function messages_ajax_send_reply()
{
    global $bp;
    check_ajax_referer('messages_send_message');
    $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
    if ($result['status']) {
        ?>
			<div class="avatar-box">
				<?php 
        if (function_exists('bp_core_get_avatar')) {
            echo bp_core_get_avatar($result['reply']->sender_id, 1);
        }
        ?>
	
				<h3><?php 
        echo bp_core_get_userlink($result['reply']->sender_id);
        ?>
</h3>
				<small><?php 
        echo bp_format_time($result['reply']->date_sent);
        ?>
</small>
			</div>
			<?php 
        echo stripslashes(apply_filters('bp_get_message_content', $result['reply']->message));
        ?>
			<div class="clear"></div>
		<?php 
    } else {
        $result['message'] = '<img src="' . $bp->messages->image_base . '/warning.gif" alt="Warning" /> &nbsp;' . $result['message'];
        echo "-1[[split]]" . $result['message'];
    }
}
 /**
  * populate()
  *
  * Populate the instantiated class with data based on the User ID provided.
  * 
  * @package BuddyPress Core
  * @global $userdata WordPress user data for the current logged in user.
  * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
  * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
  * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
  * @uses get_usermeta() WordPress function returns the value of passed usermeta name from usermeta table
  * @uses bp_core_get_avatar() Returns HTML formatted avatar for a user
  * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
  */
 function populate()
 {
     $this->user_url = bp_core_get_userurl($this->id);
     $this->user_link = bp_core_get_userlink($this->id);
     $this->fullname = bp_fetch_user_fullname($this->id, false);
     $this->email = bp_core_get_user_email($this->id);
     $this->last_active = bp_core_get_last_activity(get_usermeta($this->id, 'last_activity'), __('active %s ago', 'buddypress'));
     $this->avatar = bp_core_get_avatar($this->id, 2);
     $this->avatar_thumb = bp_core_get_avatar($this->id, 1);
     $this->avatar_mini = bp_core_get_avatar($this->id, 1, 25, 25, false);
 }
Example #3
0
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;
        }
    }
}
Example #4
0
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;
        }
    }
}
function bp_zoneideas_screen_one_content()
{
    global $bp;
    $high_fives = bp_zoneideas_get_highfives_for_user($bp->displayed_user->id);
    /**
     * For security reasons, we want to use the wp_nonce_url() function on any actions.
     * This will stop naughty people from tricking users into performing actions without their
     * knowledge or intent.
     */
    $send_link = wp_nonce_url($bp->displayed_user->domain . $bp->current_component . '/screen-one/send-h5', 'bp_zoneideas_send_high_five');
    ?>
      <?php 
    do_action('template_notices');
    ?>
      
      <h3><?php 
    _e('Welcome to Screen One', 'bp-zoneideas');
    ?>
</h3>
      <p><?php 
    printf(__('Send %s a <a href="%s" title="Send high-five!">high-five!</a>', 'bp-zoneideas'), $bp->displayed_user->fullname, $send_link);
    ?>
</p>
      
      <?php 
    if ($high_fives) {
        ?>
         <h3><?php 
        _e('Received High Fives!', 'bp-zoneideas');
        ?>
</h3>
      
         <table id="high-fives">
            <?php 
        foreach ($high_fives as $user_id) {
            ?>
            <tr>
               <td><?php 
            echo bp_core_get_avatar($user_id, 1, 25, 25);
            ?>
</td>
               <td>&nbsp; <?php 
            echo bp_core_get_userlink($user_id);
            ?>
</td>
            </tr>
            <?php 
        }
        ?>
         </table>
      <?php 
    }
    ?>
   <?php 
}
Example #6
0
function bp_core_ajax_widget_members()
{
    global $bp;
    check_ajax_referer('bp_core_widget_members');
    switch ($_POST['filter']) {
        case 'newest-members':
            if (!($users = wp_cache_get('newest_users', 'bp'))) {
                $users = BP_Core_User::get_newest_users($_POST['max-members'], 1);
                wp_cache_set('newest_users', $users, 'bp');
            }
            break;
        case 'recently-active-members':
            if (!($users = wp_cache_get('active_users', 'bp'))) {
                $users = BP_Core_User::get_active_users($_POST['max-members'], 1);
                wp_cache_set('active_users', $users, 'bp');
            }
            break;
        case 'popular-members':
            if (!($users = wp_cache_get('popular_users', 'bp'))) {
                $users = BP_Core_User::get_popular_users($_POST['max-members'], 1);
                wp_cache_set('popular_users', $users, 'bp');
            }
            break;
    }
    if ($users['users']) {
        echo '0[[SPLIT]]';
        // return valid result.
        foreach ((array) $users['users'] as $user) {
            ?>
			<li class="vcard">
				<div class="item-avatar">
					<a href="<?php 
            echo bp_core_get_userlink($user->user_id, false, true);
            ?>
"><?php 
            echo bp_core_get_avatar($user->user_id, 1);
            ?>
</a>
				</div>

				<div class="item">
					<div class="item-title"><?php 
            echo bp_core_get_userlink($user->user_id);
            ?>
</div>
					<div class="item-meta">
						<span class="activity">
							<?php 
            if ('newest-members' == $_POST['filter']) {
                echo bp_core_get_last_activity($user->user_registered, __('registered %s ago', 'buddypress'));
            } else {
                if ('recently-active-members' == $_POST['filter']) {
                    echo bp_core_get_last_activity(get_usermeta($user->user_id, 'last_activity'), __('active %s ago', 'buddypress'));
                } else {
                    if ('popular-members' == $_POST['filter']) {
                        if (1 == get_usermeta($user->user_id, 'total_friend_count')) {
                            echo get_usermeta($user->user_id, 'total_friend_count') . __(' friend', 'buddypress');
                        } else {
                            echo get_usermeta($user->user_id, 'total_friend_count') . __(' friends', 'buddypress');
                        }
                    }
                }
            }
            ?>
						</span>
					</div>
				</div>
			</li>
			<?php 
        }
    } else {
        echo "-1[[SPLIT]]<li>" . __("No members matched the current filter.", 'buddypress');
    }
}
function bp_core_widget_whos_online($args)
{
    global $current_blog;
    extract($args);
    $options = get_blog_option($current_blog->blog_id, 'bp_core_widget_whos_online');
    ?>
	<?php 
    echo $before_widget;
    ?>
	<?php 
    echo $before_title . $widget_name . $after_title;
    ?>

	<?php 
    if (!($users = wp_cache_get('online_users', 'bp'))) {
        $users = BP_Core_User::get_online_users($options['max_members']);
        wp_cache_set('online_users', $users, 'bp');
    }
    ?>

	<?php 
    $users = BP_Core_User::get_online_users($options['max_members']);
    ?>

	<?php 
    if ($users['users']) {
        ?>
		<div class="avatar-block">
		<?php 
        foreach ((array) $users['users'] as $user) {
            ?>
			<div class="item-avatar">
				<a href="<?php 
            echo bp_core_get_userurl($user->user_id);
            ?>
" title="<?php 
            bp_fetch_user_fullname($user->user_id, true);
            ?>
"><?php 
            echo bp_core_get_avatar($user->user_id, 1);
            ?>
</a>
			</div>
		<?php 
        }
        ?>
		</div>
			
		<?php 
        if (function_exists('wp_nonce_field')) {
            wp_nonce_field('bp_core_widget_members', '_wpnonce-members');
        }
        ?>

		<input type="hidden" name="bp_core_widget_members_max" id="bp_core_widget_members_max" value="<?php 
        echo attribute_escape($options['max_members']);
        ?>
" />

	<?php 
    } else {
        ?>
		<div class="widget-error">
			<?php 
        _e('There are no users currently online.', 'buddypress');
        ?>
		</div>
	<?php 
    }
    ?>

	<?php 
    echo $after_widget;
    ?>
	
	<div class="clear" style="margin-bottom: 25px"></div>
	
<?php 
}
function bp_core_avatar_admin($message = null, $action, $delete_action)
{
    global $wp_upload_error;
    ?>
	
	<?php 
    if (!isset($_POST['slick_avatars_action']) && !isset($_GET['slick_avatars_action'])) {
        ?>
		
		<?php 
        if ($message) {
            ?>
			<br />
			<div id="message" class="updated fade">
				<p><?php 
            echo $message;
            ?>
</p>
			</div>
		<?php 
        }
        ?>

		<p><?php 
        _e('Your avatar will be used on your profile and throughout the site.', 'buddypress');
        ?>
</p>
		<p><?php 
        _e('Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Photo\' to proceed.', 'buddypress');
        ?>
</p>
		
		<?php 
        bp_core_render_avatar_upload_form($action);
        $str = bp_core_get_avatar(get_current_user_id(), 1);
        if (strlen($str)) {
            echo '<h3>' . __('This is your current avatar', 'buddypress') . '</h3>';
            echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 1) . '</span>';
            echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 2) . '</span>';
            echo '<a href="' . wp_nonce_url($delete_action, 'bp_delete_avatar_link') . '">' . __('Delete', 'buddypress') . '</a>';
        }
    } else {
        if (isset($_POST['slick_avatars_action']) && 'upload' == $_POST['slick_avatars_action']) {
            // Confirm that the nonce is valid
            if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars')) {
                bp_core_ap_die('Security error.');
            }
            // Set friendly error feedback.
            $uploadErrors = array(0 => __("There is no error, the file uploaded with success", 'buddypress'), 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(CORE_MAX_FILE_SIZE), 2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(CORE_MAX_FILE_SIZE), 3 => __("The uploaded file was only partially uploaded", 'buddypress'), 4 => __("No file was uploaded", 'buddypress'), 6 => __("Missing a temporary folder", 'buddypress'));
            if (!bp_core_check_avatar_upload($_FILES)) {
                bp_core_ap_die(sprintf(__('Your upload failed, please try again. Error was: %s', 'buddypress'), $uploadErrors[$_FILES['file']['error']]));
            }
            if (!bp_core_check_avatar_size($_FILES)) {
                bp_core_ap_die(sprintf(__('The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(CORE_MAX_FILE_SIZE)));
            }
            if (!bp_core_check_avatar_type($_FILES)) {
                bp_core_ap_die(__('Please upload only JPG, GIF or PNG photos.', 'buddypress'));
            }
            // "Handle" upload into temporary location
            if (!($original = bp_core_handle_avatar_upload($_FILES))) {
                bp_core_ap_die(sprintf(__('Upload Failed! Error was: %s', 'buddypress'), $wp_upload_error));
            }
            // Resize down to something we can display on the page or use original if its small enough already.
            if (!($canvas = bp_core_resize_avatar($original))) {
                $canvas = $original;
            }
            // Render the cropper UI
            bp_core_render_avatar_cropper($original, $canvas, $action);
        } else {
            if (isset($_POST['slick_avatars_action']) && 'crop' == $_POST['slick_avatars_action']) {
                // Crop, save, store
                // Confirm that the nonce is valid
                if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars')) {
                    bp_core_ap_die(__('Security error.', 'buddypress'));
                }
                if (!bp_core_check_crop($_POST['orig'], $_POST['canvas'])) {
                    bp_core_ap_die(__('Error when cropping, please go back and try again', 'buddypress'));
                }
                if (!($result = bp_core_avatar_cropstore(stripslashes($_POST['orig']), $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h']))) {
                    bp_core_ap_die(__('Error when saving avatars, please go back and try again.', 'buddypress'));
                }
                // Store details to the DB and we're done
                echo '<p>' . __('Your new avatar was successfully created!', 'buddypress') . '</p>';
                bp_core_avatar_save($result);
                echo '<span class="crop-img">' . bp_core_get_avatar(get_current_user_id(), 1) . '</span>';
                if (CORE_AVATAR_V2_W && CORE_AVATAR_V2_H) {
                    echo '<span class="crop-img">' . bp_core_get_avatar(get_current_user_id(), 2) . '</span>';
                }
            } else {
                if (isset($_GET['slick_avatars_action']) && 'delete' == $_GET['slick_avatars_action']) {
                    // Delete an avatar
                    bp_core_delete_avatar();
                    unset($_GET['slick_avatars_action']);
                    $message = __('Avatar successfully removed.', 'buddypress');
                    bp_core_avatar_admin($message);
                }
            }
        }
    }
    ?>
	<?php 
}
function messages_view_thread($thread_id)
{
    global $bp;
    $thread = new BP_Messages_Thread($thread_id, true);
    if (!$thread->has_access) {
        unset($_GET['mode']);
        ?>
		<div id="message" class="error">
			<p><?php 
        _e('There was an error when viewing that message', 'buddypress');
        ?>
</p>
		</div>
	<?php 
    } else {
        if ($thread->messages) {
            ?>
			<?php 
            $thread->mark_read();
            ?>
				
			<div class="wrap">
				<h2 id="message-subject"><?php 
            echo $thread->subject;
            ?>
</h2>
				<table class="form-table">
					<tbody>
						<tr>
							<td>
								<img src="<?php 
            echo $bp->messages->image_base;
            ?>
/email_open.gif" alt="Message" style="vertical-align: top;" /> &nbsp;
								<?php 
            _e('Sent between ', 'buddypress');
            ?>
 <?php 
            echo BP_Messages_Thread::get_recipient_links($thread->recipients);
            ?>
 
								<?php 
            _e('and', 'buddypress');
            ?>
 <?php 
            echo bp_core_get_userlink($bp->loggedin_user->id);
            ?>
. 
							</td>
						</tr>
					</tbody>
				</table>
				
		<?php 
            $counter = 0;
            foreach ($thread->messages as $message) {
                $alt = $counter % 2 == 1 ? ' alt' : '';
                ?>
					<a name="<?php 
                echo 'm-' . $message->id;
                ?>
"></a>
					<div class="message-box<?php 
                echo $alt;
                ?>
">
						<div class="avatar-box">
							<?php 
                echo apply_filters('bp_get_message_sender_avatar', bp_core_get_avatar($message->sender_id, 1));
                ?>
							<h3><?php 
                echo apply_filters('bp_get_message_sender_id', bp_core_get_userlink($message->sender_id));
                ?>
</h3>
							<small><?php 
                echo apply_filters('bp_get_message_date_sent', bp_format_time(strtotime($message->date_sent)));
                ?>
</small>
						</div>
						
						<?php 
                do_action('messages_custom_fields_output_before');
                ?>
						
						<?php 
                echo apply_filters('bp_get_message_content', stripslashes($message->message));
                ?>
						
						<?php 
                do_action('messages_custom_fields_output_after');
                ?>
		
						<div class="clear"></div>
					</div>
				<?php 
                $counter++;
            }
            ?>
				<form id="send-reply" action="<?php 
            bp_messages_form_action();
            ?>
" method="post">
					<div class="message-box">
							<div id="messagediv">
								<div class="avatar-box">
									<?php 
            if (function_exists('bp_core_get_avatar')) {
                echo bp_core_get_avatar($bp->loggedin_user->id, 1);
            }
            ?>
					
									<h3><?php 
            _e("Reply: ", 'buddypress');
            ?>
</h3>
								</div>
								<label for="reply"></label>
								<div>
									<textarea name="content" id="message_content" rows="15" cols="40"><?php 
            echo htmlspecialchars(wp_filter_kses($content));
            ?>
</textarea>
								</div>
							</div>
							<p class="submit">
								<input type="submit" name="send" value="<?php 
            _e('Send Reply', 'buddypress');
            ?>
 &rarr;" id="send_reply_button"/>
							</p>
							<input type="hidden" id="thread_id" name="thread_id" value="<?php 
            echo attribute_escape($thread->thread_id);
            ?>
" />
							<input type="hidden" name="subject" id="subject" value="<?php 
            _e('Re: ', 'buddypress');
            echo str_replace('Re: ', '', $thread->last_message_subject);
            ?>
" />
					</div>
					
					<?php 
            wp_nonce_field('messages_send_message', '_wpnonce_send_message');
            ?>
				</form>
			</div>
			<?php 
        }
    }
}
Example #10
0
/**
 * bp_core_setup_nav()
 *
 * Sets up the profile navigation item if the Xprofile component is not installed.
 * 
 * @package BuddyPress Core
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @uses bp_core_add_nav_item() Adds a navigation item to the top level buddypress navigation
 * @uses bp_core_add_nav_default() Sets which sub navigation item is selected by default
 * @uses bp_core_add_subnav_item() Adds a sub navigation item to a nav item
 * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user
 * @uses bp_core_get_avatar() Returns the either the thumb (1) or full (2) avatar URL for the user_id passed
 */
function bp_core_setup_nav()
{
    global $bp;
    if (!function_exists('xprofile_install')) {
        /* Add 'Profile' to the main navigation */
        bp_core_add_nav_item(__('Perfil', 'buddypress'), 'profile');
        bp_core_add_nav_default('profile', 'bp_core_catch_profile_uri', 'public');
        $profile_link = $bp->loggedin_user->domain . '/profile/';
        /* Add the subnav items to the profile */
        bp_core_add_subnav_item('profile', 'public', __('Public', 'buddypress'), $profile_link, 'xprofile_screen_display_profile');
        if ('profile' == $bp->current_component) {
            if (bp_is_home()) {
                $bp->bp_options_title = __('Mi Perfil', 'buddypress');
            } else {
                $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1);
                $bp->bp_options_title = $bp->displayed_user->fullname;
            }
        }
    }
}
<?php

/* Load the WP environment */
require_once preg_replace('%(.*)[/\\\\]wp-content[/\\\\].*%', '\\1', dirname(__FILE__)) . '/wp-load.php';
require_once BP_PLUGIN_DIR . '/bp-core.php';
require_once BP_PLUGIN_DIR . '/bp-friends.php';
// Setup the $bp global array as it's not auto set outside of the normal WP enviro.
bp_core_setup_globals();
friends_setup_globals();
// Get the friend ids based on the search terms
$friends = friends_search_friends($_GET['q'], $bp->loggedin_user->id, $_GET['limit'], 1);
if ($friends['friends']) {
    foreach ($friends['friends'] as $user_id) {
        $ud = get_userdata($user_id);
        $username = $ud->user_login;
        echo bp_core_get_avatar($user_id, 1, 15, 15) . ' ' . bp_fetch_user_fullname($user_id, false) . ' (' . $username . ')
		';
    }
}
function bp_friends_random_members($total_members = 5)
{
    global $bp;
    if (!($user_ids = wp_cache_get('friends_random_users', 'bp'))) {
        $user_ids = BP_Core_User::get_random_users($total_members);
        wp_cache_set('friends_random_users', $user_ids, 'bp');
    }
    ?>
	
	<?php 
    if ($user_ids['users']) {
        ?>
		<ul class="item-list" id="random-members-list">
		<?php 
        for ($i = 0; $i < count($user_ids['users']); $i++) {
            ?>
			<li>
				<a href="<?php 
            echo bp_core_get_userurl($user_ids['users'][$i]->user_id);
            ?>
"><?php 
            echo bp_core_get_avatar($user_ids['users'][$i]->user_id, 1);
            ?>
</a>
				<h5><?php 
            echo bp_core_get_userlink($user_ids['users'][$i]->user_id);
            ?>
</h5>
				<?php 
            if (function_exists('xprofile_get_random_profile_data')) {
                ?>
					<?php 
                $random_data = xprofile_get_random_profile_data($user_ids['users'][$i]->user_id, true);
                ?>
					<div class="profile-data">
						<p class="field-name"><?php 
                echo $random_data[0]->name;
                ?>
</p>
						<?php 
                echo $random_data[0]->value;
                ?>
					</div>
				<?php 
            }
            ?>
				
				<div class="action">
					<?php 
            if (function_exists('bp_add_friend_button')) {
                ?>
						<?php 
                bp_add_friend_button($user_ids['users'][$i]->user_id);
                ?>
					<?php 
            }
            ?>
				</div>
			</li>
		<?php 
        }
        ?>
		</ul>
	<?php 
    } else {
        ?>
		<div id="message" class="info">
			<p><?php 
        _e("There aren't enough site members to show a random sample just yet.", 'buddypress');
        ?>
</p>
		</div>		
	<?php 
    }
}
function bp_group_request_user_avatar_thumb()
{
    global $requests_template;
    echo apply_filters('bp_group_request_user_avatar_thumb', bp_core_get_avatar($requests_template->request->user_id, 1));
}
Example #14
0
/**
 * 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;
        }
    }
}
Example #15
0
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;
        }
    }
}
Example #16
0
/**
 * xprofile_setup_nav()
 *
 * Sets up the navigation items for the xprofile component
 * 
 * @package BuddyPress XProfile
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @uses bp_core_add_nav_item() Adds a navigation item to the top level buddypress navigation
 * @uses bp_core_add_nav_default() Sets which sub navigation item is selected by default
 * @uses bp_core_add_subnav_item() Adds a sub navigation item to a nav item
 * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user
 * @uses bp_core_get_avatar() Returns the either the thumb (1) or full (2) avatar URL for the user_id passed
 */
function xprofile_setup_nav()
{
    global $bp;
    /* Add 'Profile' to the main navigation */
    bp_core_add_nav_item(__('Profile', 'buddypress'), $bp->profile->slug);
    bp_core_add_nav_default($bp->profile->slug, 'xprofile_screen_display_profile', 'public');
    $profile_link = $bp->loggedin_user->domain . $bp->profile->slug . '/';
    /* Add the subnav items to the profile */
    bp_core_add_subnav_item($bp->profile->slug, 'public', __('Public', 'buddypress'), $profile_link, 'xprofile_screen_display_profile');
    bp_core_add_subnav_item($bp->profile->slug, 'edit', __('Edit Profile', 'buddypress'), $profile_link, 'xprofile_screen_edit_profile');
    bp_core_add_subnav_item($bp->profile->slug, 'change-avatar', __('Change Avatar', 'buddypress'), $profile_link, 'xprofile_screen_change_avatar');
    if ($bp->current_component == $bp->profile->slug) {
        if (bp_is_home()) {
            $bp->bp_options_title = __('My Profile', 'buddypress');
        } else {
            $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1);
            $bp->bp_options_title = $bp->displayed_user->fullname;
        }
    }
}
Example #17
0
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 = '&nbsp; <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;
        }
    }
}
Example #18
0
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);
                    }
                }
            }
        }
    }
}
function bp_the_avatar_thumbnail()
{
    global $bp;
    echo apply_filters('bp_the_avatar_thumbnail', bp_core_get_avatar($bp->displayed_user->id, 1));
}
function bp_get_the_topic_post_poster_avatar()
{
    global $topic_template;
    return apply_filters('bp_get_the_topic_post_poster_avatar', bp_core_get_avatar($topic_template->post->poster_id, 1, 20, 20));
}
function bp_get_wire_poster_avatar()
{
    global $bp;
    return apply_filters('bp_get_wire_poster_avatar', bp_core_get_avatar($bp->loggedin_user->id, 1));
}
function bp_blogs_widget_recent_posts($args)
{
    global $current_blog;
    extract($args);
    $options = get_blog_option($current_blog->blog_id, 'bp_blogs_widget_recent_posts');
    ?>
	<?php 
    echo $before_widget;
    ?>
	<?php 
    echo $before_title . $widget_name . $after_title;
    ?>

		<?php 
    $posts = bp_blogs_get_latest_posts(null, $options['max_posts']);
    ?>
		<?php 
    $counter = 0;
    ?>
		
	<?php 
    if ($posts) {
        ?>
		<div class="item-options" id="recent-posts-options">
			<?php 
        _e("Site Wide", 'buddypress');
        ?>
		</div>
		<ul id="recent-posts" class="item-list">
			<?php 
        foreach ($posts as $post) {
            ?>
				<li>
					<div class="item-avatar">
						<a href="<?php 
            echo bp_post_get_permalink($post, $post->blog_id);
            ?>
" title="<?php 
            echo apply_filters('the_title', $post->post_title);
            ?>
"><?php 
            echo bp_core_get_avatar($post->post_author, 1);
            ?>
</a>
					</div>

					<div class="item">
						<h4 class="item-title"><a href="<?php 
            echo bp_post_get_permalink($post, $post->blog_id);
            ?>
" title="<?php 
            echo apply_filters('the_title', $post->post_title);
            ?>
"><?php 
            echo apply_filters('the_title', $post->post_title);
            ?>
</a></h4>
						<?php 
            if (!$counter) {
                ?>
							<div class="item-content"><?php 
                echo bp_create_excerpt($post->post_content);
                ?>
</div>
						<?php 
            }
            ?>
						<div class="item-meta"><em><?php 
            printf(__('by %s from the blog <a href="%s">%s</a>', 'buddypress'), bp_core_get_userlink($post->post_author), get_blog_option($post->blog_id, 'siteurl'), get_blog_option($post->blog_id, 'blogname'));
            ?>
</em></div>
					</div>
				</li>
				<?php 
            $counter++;
            ?>
	
			<?php 
        }
        ?>
		</ul>
	<?php 
    } else {
        ?>
		<div class="widget-error">
			<?php 
        _e('There are no recent blog posts, why not write one?', 'buddypress');
        ?>
		</div>
	<?php 
    }
    ?>

	<?php 
    echo $after_widget;
}