function setup_nav() { global $blog_id; //check multisite or normal mode for correct permission checking if (is_multisite() && $blog_id != BP_ROOT_BLOG) { //FIXME MS mode doesn't seem to recognize cross subsite caps, using the proper functions, for now we use switch_blog. $current_blog = $blog_id; switch_to_blog(BP_ROOT_BLOG); $can_manage_events = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_events'); $can_manage_locations = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_locations'); $can_manage_bookings = current_user_can_for_blog(BP_ROOT_BLOG, 'manage_bookings'); switch_to_blog($current_blog); } else { $can_manage_events = current_user_can('edit_events'); $can_manage_locations = current_user_can('edit_locations'); $can_manage_bookings = current_user_can('manage_bookings'); } /* Add 'Events' to the main user profile navigation */ $main_nav = array('name' => __('Events', 'dbem'), 'slug' => em_bp_get_slug(), 'position' => 80, 'screen_function' => 'bp_em_events', 'default_subnav_slug' => 'profile'); $em_link = trailingslashit(bp_loggedin_user_domain() . em_bp_get_slug()); /* Create SubNav Items */ $sub_nav[] = array('name' => __('My Profile', 'dbem'), 'slug' => 'profile', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_events', 'position' => 10); $sub_nav[] = array('name' => __('Events I\'m Attending', 'dbem'), 'slug' => 'attending', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_attending', 'position' => 20, 'user_has_access' => bp_is_my_profile()); if ($can_manage_events) { $sub_nav[] = array('name' => __('My Events', 'dbem'), 'slug' => 'my-events', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_events', 'position' => 30, 'user_has_access' => bp_is_my_profile()); } if ($can_manage_locations && get_option('dbem_locations_enabled')) { $sub_nav[] = array('name' => __('My Locations', 'dbem'), 'slug' => 'my-locations', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_locations', 'position' => 40, 'user_has_access' => bp_is_my_profile()); } if ($can_manage_bookings && get_option('dbem_rsvp_enabled')) { $sub_nav[] = array('name' => __('My Event Bookings', 'dbem'), 'slug' => 'my-bookings', 'parent_slug' => em_bp_get_slug(), 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_bookings', 'position' => 50, 'user_has_access' => bp_is_my_profile()); } if (bp_is_active('groups')) { /* Create Profile Group Sub-Nav */ $sub_nav[] = array('name' => __('Events', 'dbem'), 'slug' => 'group-events', 'parent_slug' => bp_get_groups_slug(), 'parent_url' => trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()), 'screen_function' => 'bp_em_my_group_events', 'position' => 60, 'user_has_access' => bp_is_my_profile()); } parent::setup_nav($main_nav, $sub_nav); add_action('bp_init', array(&$this, 'setup_group_nav')); }
/** * Expands some basic supported BuddyPress macros. */ function wdfb_expand_buddypress_macros($str) { if (!defined('BP_VERSION')) { return $str; } if (function_exists('bp_get_activity_root_slug')) { $str = preg_replace('/\\bBP_ACTIVITY_SLUG\\b/', bp_get_activity_root_slug(), $str); } if (function_exists('bp_get_groups_slug')) { $str = preg_replace('/\\bBP_GROUPS_SLUG\\b/', bp_get_groups_slug(), $str); } if (function_exists('bp_get_members_slug')) { $str = preg_replace('/\\bBP_MEMBERS_SLUG\\b/', bp_get_members_slug(), $str); } return $str; }
function bp_dtheme_ajax_invite_user() { global $bp; check_ajax_referer('groups_invite_uninvite_user'); if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) { return false; } if (!bp_groups_user_can_send_invites($_POST['group_id']) || !friends_check_friendship($bp->loggedin_user->id, $_POST['friend_id'])) { return false; } if ('invite' == $_POST['friend_action']) { if (!groups_invite_user(array('user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id']))) { return false; } $user = new BP_Core_User($_POST['friend_id']); echo '<li id="uid-' . $user->id . '">'; echo $user->avatar_thumb; echo '<h4>' . $user->user_link . '</h4>'; echo '<span class="activity">' . esc_attr($user->last_active) . '</span>'; echo '<div class="action"> <a class="button remove" href="' . wp_nonce_url($bp->loggedin_user->domain . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a> </div>'; echo '</li>'; } else { if ('uninvite' == $_POST['friend_action']) { return (bool) groups_uninvite_user($_POST['friend_id'], $_POST['group_id']); } else { return false; } } }
?> <?php do_action('bp_before_activity_type_tab_groups'); ?> <?php if (bp_is_active('groups')) { ?> <?php if (bp_get_total_group_count_for_user(bp_loggedin_user_id())) { ?> <li id="activity-groups"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/'; ?> " title="<?php _e('The activity of groups I am a member of.', 'buddypress'); ?> "><?php printf(__('My Groups <span>%s</span>', 'buddypress'), bp_get_total_group_count_for_user(bp_loggedin_user_id())); ?> </a></li> <?php } ?> <?php }
function bp_get_group_invite_user_remove_invite_url() { global $invites_template; return wp_nonce_url(site_url(bp_get_groups_slug() . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id), 'groups_invite_uninvite_user'); }
/** * Handle the display of the Delete Group page. */ function groups_screen_group_admin_delete_group() { if ('delete-group' != bp_get_group_current_admin_tab()) { return false; } if (!bp_is_item_admin() && !bp_current_user_can('bp_moderate')) { return false; } $bp = buddypress(); if (isset($_REQUEST['delete-group-button']) && isset($_REQUEST['delete-group-understand'])) { // Check the nonce first. if (!check_admin_referer('groups_delete_group')) { return false; } /** * Fires before the deletion of a group from the Delete Group page. * * @since 1.5.0 * * @param int $id ID of the group being deleted. */ do_action('groups_before_group_deleted', $bp->groups->current_group->id); // Group admin has deleted the group, now do it. if (!groups_delete_group($bp->groups->current_group->id)) { bp_core_add_message(__('There was an error deleting the group. Please try again.', 'buddypress'), 'error'); } else { bp_core_add_message(__('The group was deleted successfully.', 'buddypress')); /** * Fires after the deletion of a group from the Delete Group page. * * @since 1.0.0 * * @param int $id ID of the group being deleted. */ do_action('groups_group_deleted', $bp->groups->current_group->id); bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug())); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug())); } /** * Fires before the loading of the Delete Group page template. * * @since 1.0.0 * * @param int $id ID of the group that is being displayed. */ do_action('groups_screen_group_admin_delete_group', $bp->groups->current_group->id); /** * Filters the template to load for the Delete Group page. * * @since 1.0.0 * * @param string $value Path to the Delete Group template. */ bp_core_load_template(apply_filters('groups_template_group_admin_delete_group', 'groups/single/home')); }
function setup_admin_bar() { global $bp, $blog_id; // Prevent debug notices $wp_admin_nav = array(); // Menus for logged in user if (is_user_logged_in()) { //check multisite or normal mode for correct permission checking if (is_multisite() && $blog_id != BP_ROOT_BLOG) { //FIXME MS mode doesn't seem to recognize cross subsite caps, using the proper functions, for now we use switch_blog. $current_blog = $blog_id; switch_to_blog(BP_ROOT_BLOG); $can_manage_events = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_events'); $can_manage_locations = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_locations'); $can_manage_bookings = current_user_can_for_blog(BP_ROOT_BLOG, 'manage_bookings'); switch_to_blog($current_blog); } else { $can_manage_events = current_user_can('edit_events'); $can_manage_locations = current_user_can('edit_locations'); $can_manage_bookings = current_user_can('manage_bookings'); } $em_link = trailingslashit(bp_loggedin_user_domain() . em_bp_get_slug()); /* Add 'Events' to the main user profile navigation */ $wp_admin_nav[] = array('parent' => $bp->my_account_menu_id, 'id' => 'my-em-' . $this->id, 'title' => __('Events', 'dbem'), 'href' => $em_link); /* Create SubNav Items */ $wp_admin_nav[] = array('parent' => 'my-em-' . $this->id, 'id' => 'my-em-' . $this->id . '-profile', 'title' => __('My Profile', 'dbem'), 'href' => $em_link . 'profile/'); $wp_admin_nav[] = array('parent' => 'my-em-' . $this->id, 'id' => 'my-em-' . $this->id . '-attending', 'title' => __('Events I\'m Attending', 'dbem'), 'href' => $em_link . 'attending/'); if ($can_manage_events) { $wp_admin_nav[] = array('parent' => 'my-em-' . $this->id, 'id' => 'my-em-' . $this->id . '-my-events', 'title' => __('My Events', 'dbem'), 'href' => $em_link . 'my-events/'); } if ($can_manage_locations && get_option('dbem_locations_enabled')) { $wp_admin_nav[] = array('parent' => 'my-em-' . $this->id, 'id' => 'my-em-' . $this->id . '-my-locations', 'title' => __('My Locations', 'dbem'), 'href' => $em_link . 'my-locations/'); } if ($can_manage_bookings && get_option('dbem_rsvp_enabled')) { $wp_admin_nav[] = array('parent' => 'my-em-' . $this->id, 'id' => 'my-em-' . $this->id . '-my-bookings', 'title' => __('My Event Bookings', 'dbem'), 'href' => $em_link . 'my-bookings/'); } if (bp_is_active('groups')) { /* Create Profile Group Sub-Nav */ $wp_admin_nav[] = array('parent' => 'my-account-groups', 'id' => 'my-account-groups-' . $this->id, 'title' => __('Events', 'dbem'), 'href' => trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . 'group-events/'); } } parent::setup_admin_bar($wp_admin_nav); }
/** * Is the current page a user's Groups activity stream? * * Eg http://example.com/members/joe/groups/ * * @since 1.5.0 * * @return bool True if the current page is a user's Groups activity stream. */ function bp_is_user_groups_activity() { if (!bp_is_active('groups')) { return false; } $slug = bp_get_groups_slug() ? bp_get_groups_slug() : 'groups'; if (bp_is_user_activity() && bp_is_current_action($slug)) { return true; } return false; }
function groups_notification_group_invites(&$group, &$member, $inviter_user_id) { global $bp; $inviter_ud = bp_core_get_core_userdata($inviter_user_id); $inviter_name = bp_core_get_userlink($inviter_user_id, true, false, true); $inviter_link = bp_core_get_user_domain($inviter_user_id); $group_link = bp_get_group_permalink($group); if (!$member->invite_sent) { $invited_user_id = $member->user_id; // Post a screen notification first. bp_core_add_notification($group->id, $invited_user_id, 'groups', 'group_invite'); if ('no' == bp_get_user_meta($invited_user_id, 'notification_groups_invite', true)) { return false; } $invited_ud = bp_core_get_core_userdata($invited_user_id); $settings_link = bp_core_get_user_domain($invited_user_id) . bp_get_settings_slug() . '/notifications/'; $invited_link = bp_core_get_user_domain($invited_user_id); $invites_link = $invited_link . bp_get_groups_slug() . '/invites'; // Set up and send the message $to = $invited_ud->user_email; $sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES); $subject = '[' . $sitename . '] ' . sprintf(__('You have an invitation to the group: "%s"', 'buddypress'), $group->name); $message = sprintf(__('One of your friends %1$s has invited you to the group: "%2$s". To view your group invites visit: %3$s To view the group visit: %4$s To view %5$s\'s profile visit: %6$s --------------------- ', 'buddypress'), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link); $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link); /* Send the message */ $to = apply_filters('groups_notification_group_invites_to', $to); $subject = apply_filters_ref_array('groups_notification_group_invites_subject', array($subject, &$group)); $message = apply_filters_ref_array('groups_notification_group_invites_message', array($message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link, $settings_link)); wp_mail($to, $subject, $message); do_action('bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group); } }
/** * Returns the member activity feed link * * @since 1.2.0 * * @uses bp_is_profile_component() * @uses bp_is_current_action() * @uses bp_displayed_user_domain() * @uses bp_get_activity_slug() * @uses bp_is_active() * @uses bp_get_friends_slug() * @uses bp_get_groups_slug() * @uses apply_filters() To call the 'bp_get_activities_member_rss_link' hook * * @return string $link The member activity feed link */ function bp_get_member_activity_feed_link() { global $bp; if (bp_is_profile_component() || bp_is_current_action('just-me')) { $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/'; } elseif (bp_is_active('friends') && bp_is_current_action(bp_get_friends_slug())) { $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/'; } elseif (bp_is_active('groups') && bp_is_current_action(bp_get_groups_slug())) { $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/'; } elseif ('favorites' == $bp->current_action) { $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/'; } elseif ('mentions' == $bp->current_action) { $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/'; } else { $link = ''; } return apply_filters('bp_get_activities_member_rss_link', $link); }
/** * Get available filters depending on the scope. * * @since BuddyPress (2.1.0) * * @param string $context The current context. 'activity', 'member', * 'member_groups', 'group' * @return string HTML for <option> values. */ function bp_get_activity_show_filters($context = '') { // Set default context based on current page if (empty($context)) { // On member pages, default to 'member', unless this // is a user's Groups activity if (bp_is_user()) { if (bp_is_active('groups') && bp_is_current_action(bp_get_groups_slug())) { $context = 'member_groups'; } else { $context = 'member'; } // On individual group pages, default to 'group' } elseif (bp_is_active('groups') && bp_is_group()) { $context = 'group'; // 'activity' everywhere else } else { $context = 'activity'; } } $filters = array(); // Walk through the registered actions, and prepare an the // select box options. foreach (bp_activity_get_actions() as $actions) { foreach ($actions as $action) { if (!in_array($context, (array) $action['context'])) { continue; } // Friends activity collapses two filters into one if (in_array($action['key'], array('friendship_accepted', 'friendship_created'))) { $action['key'] = 'friendship_accepted,friendship_created'; } $filters[$action['key']] = $action['label']; } } /** * Filters the options available in the activity filter dropdown. * * @since BuddyPress (2.2.0) * * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name. * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'. */ $filters = apply_filters('bp_get_activity_show_filters_options', $filters, $context); // Build the options output $output = ''; if (!empty($filters)) { foreach ($filters as $value => $filter) { $output .= '<option value="' . esc_attr($value) . '">' . esc_html($filter) . '</option>' . "\n"; } } /** * Filters the HTML markup result for the activity filter dropdown. * * @since BuddyPress (2.1.0) * * @param string $output HTML output for the activity filter dropdown. * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name. * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'. */ return apply_filters('bp_get_activity_show_filters', $output, $filters, $context); }
function test_member_groups_invitations() { $this->go_to(bp_core_get_user_domain(bp_loggedin_user_id()) . bp_get_groups_slug() . '/invites'); $this->assertTrue(bp_is_user_groups() && bp_is_current_action('invites')); }
/** * Load a user's my groups feed. * * @since BuddyPress (1.2) * * @global object $wp_query * @uses bp_is_active() * @uses bp_is_user_activity() * @uses bp_is_current_action() * @uses bp_get_groups_slug() * @uses bp_is_action_variable() * @uses status_header() * * @return bool False on failure */ function bp_activity_action_my_groups_feed() { global $wp_query; if (!bp_is_active('groups') || !bp_is_user_activity() || !bp_is_current_action(bp_get_groups_slug()) || !bp_is_action_variable('feed', 0)) { return false; } $wp_query->is_404 = false; status_header(200); include_once 'feeds/bp-activity-mygroups-feed.php'; die; }
private function _expand_macro($macro) { $value = false; $user = wp_get_current_user(); switch ($macro) { case 'BP_ACTIVITY_SLUG': if (function_exists('bp_get_activity_root_slug')) { $value = bp_get_activity_root_slug(); } break; case 'BP_GROUPS_SLUG': if (function_exists('bp_get_groups_slug')) { $value = bp_get_groups_slug(); } break; case 'BP_MEMBERS_SLUG': if (function_exists('bp_get_members_slug')) { $value = bp_get_members_slug(); } break; } return apply_filters('logout_redirect-macro_value', $value, $macro); }
/** * Invites a friend to join a group via a POST request. * * @since BuddyPress (1.2) * @todo Audit return types */ function bp_dtheme_ajax_invite_user() { // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } check_ajax_referer('groups_invite_uninvite_user'); if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) { return; } if (!bp_groups_user_can_send_invites($_POST['group_id'])) { return; } if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) { return; } $group_id = (int) $_POST['group_id']; $friend_id = (int) $_POST['friend_id']; if ('invite' == $_POST['friend_action']) { $group = groups_get_group($group_id); // Users who have previously requested membership do not need // another invitation created for them if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) { $user_status = 'is_pending'; // Create the user invitation } else { if (groups_invite_user(array('user_id' => $friend_id, 'group_id' => $group_id))) { $user_status = 'is_invited'; // Miscellaneous failure } else { return; } } $user = new BP_Core_User($_POST['friend_id']); echo '<li id="uid-' . $user->id . '">'; echo $user->avatar_thumb; echo '<h4>' . $user->user_link . '</h4>'; echo '<span class="activity">' . esc_attr($user->last_active) . '</span>'; echo '<div class="action"> <a class="button remove" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'vibe') . '</a> </div>'; if ('is_pending' == $user_status) { echo '<p class="description">' . sprintf(__('%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'vibe'), $user->user_link) . '</p>'; } echo '</li>'; exit; } elseif ('uninvite' == $_POST['friend_action']) { // Users who have previously requested membership should not // have their requests deleted on the "uninvite" action if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) { return; } // Remove the unsent invitation if (!groups_uninvite_user($friend_id, $group_id)) { return; } exit; } else { return; } }
/** * @group groups */ function test_member_activity_groups() { $this->go_to(bp_core_get_user_domain(bp_loggedin_user_id()) . bp_get_activity_slug() . '/' . bp_get_groups_slug()); $this->assertTrue(bp_is_user_groups_activity()); }
/** * Handle the display of the Delete Group page. */ function groups_screen_group_admin_delete_group() { global $bp; if ('delete-group' != bp_get_group_current_admin_tab()) { return false; } if (!bp_is_item_admin() && !bp_current_user_can('bp_moderate')) { return false; } if (isset($_REQUEST['delete-group-button']) && isset($_REQUEST['delete-group-understand'])) { // Check the nonce first. if (!check_admin_referer('groups_delete_group')) { return false; } do_action('groups_before_group_deleted', $bp->groups->current_group->id); // Group admin has deleted the group, now do it. if (!groups_delete_group($bp->groups->current_group->id)) { bp_core_add_message(__('There was an error deleting the group. Please try again.', 'buddypress'), 'error'); } else { bp_core_add_message(__('The group was deleted successfully', 'buddypress')); do_action('groups_group_deleted', $bp->groups->current_group->id); bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug())); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug())); } do_action('groups_screen_group_admin_delete_group', $bp->groups->current_group->id); bp_core_load_template(apply_filters('groups_template_group_admin_delete_group', 'groups/single/home')); }
<div id="group-links" class="item-list-tabs" role="navigation"> <ul> <li class="selected" id="groups-all"><a href="<?php bp_groups_directory_permalink(); ?> "><?php printf(__('All Groups <span>%s</span>', 'buddypress'), bp_get_total_group_count()); ?> </a></li> <?php if (is_user_logged_in() && bp_get_total_group_count_for_user(bp_loggedin_user_id())) { ?> <li id="groups-personal"><a href="<?php echo bp_loggedin_user_domain() . bp_get_groups_slug() . '/my-groups/'; ?> "><?php printf(__('My Groups <span>%s</span>', 'buddypress'), bp_get_total_group_count_for_user(bp_loggedin_user_id())); ?> </a></li> <?php } ?> <?php do_action('bp_groups_directory_group_filter'); ?> </ul> </div><!-- .item-list-tabs -->
/** * Set up the component entries in the WordPress Admin Bar. * * @see BP_Component::setup_nav() for a description of the $wp_admin_nav * parameter array. * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a description. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user. if (is_user_logged_in()) { // Setup the logged in user variables. $groups_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()); // Pending group invites. $count = groups_get_invite_count_for_user(); $title = _x('Groups', 'My Account Groups', 'buddypress'); $pending = _x('No Pending Invites', 'My Account Groups sub nav', 'buddypress'); if (!empty($count['total'])) { $title = sprintf(_x('Groups <span class="count">%s</span>', 'My Account Groups nav', 'buddypress'), bp_core_number_format($count)); $pending = sprintf(_x('Pending Invites <span class="count">%s</span>', 'My Account Groups sub nav', 'buddypress'), bp_core_number_format($count)); } // Add the "My Account" sub menus. $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $groups_link); // My Groups. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-memberships', 'title' => _x('Memberships', 'My Account Groups sub nav', 'buddypress'), 'href' => $groups_link); // Invitations. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-invites', 'title' => $pending, 'href' => trailingslashit($groups_link . 'invites')); // Create a Group. if (bp_user_can_create_groups()) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-create', 'title' => _x('Create a Group', 'My Account Groups sub nav', 'buddypress'), 'href' => trailingslashit(bp_get_groups_directory_permalink() . 'create')); } } parent::setup_admin_bar($wp_admin_nav); }
/** * Load the activity feed for a user's groups. * * @since 1.2.0 * * @uses bp_is_active() * @uses bp_is_user_activity() * @uses bp_is_current_action() * @uses bp_get_groups_slug() * @uses bp_is_action_variable() * @uses status_header() * * @return bool False on failure. */ function bp_activity_action_my_groups_feed() { if (!bp_is_active('groups') || !bp_is_user_activity() || !bp_is_current_action(bp_get_groups_slug()) || !bp_is_action_variable('feed', 0)) { return false; } // Get displayed user's group IDs. $groups = groups_get_user_groups(); $group_ids = implode(',', $groups['groups']); // Setup the feed. buddypress()->activity->feed = new BP_Activity_Feed(array('id' => 'mygroups', 'title' => sprintf(__('%1$s | %2$s | Group Activity', 'buddypress'), bp_get_site_name(), bp_get_displayed_user_fullname()), 'link' => trailingslashit(bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug()), 'description' => sprintf(__("Public group activity feed of which %s is a member.", 'buddypress'), bp_get_displayed_user_fullname()), 'activity_args' => array('object' => buddypress()->groups->id, 'primary_id' => $group_ids, 'display_comments' => 'threaded'))); }
/** * Invites a friend to join a group via a POST request. * * @return unknown * @since BuddyPress (1.2) * @todo Audit return types */ function bp_dtheme_ajax_invite_user() { // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } check_ajax_referer('groups_invite_uninvite_user'); if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) { return; } if (!bp_groups_user_can_send_invites($_POST['group_id'])) { return; } if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) { return; } if ('invite' == $_POST['friend_action']) { if (!groups_invite_user(array('user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id']))) { return; } $user = new BP_Core_User($_POST['friend_id']); echo '<li id="uid-' . $user->id . '">'; echo $user->avatar_thumb; echo '<h4>' . $user->user_link . '</h4>'; echo '<span class="activity">' . esc_attr($user->last_active) . '</span>'; echo '<div class="action"> <a class="button remove" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'logicalboneshug') . '</a> </div>'; echo '</li>'; exit; } elseif ('uninvite' == $_POST['friend_action']) { if (!groups_uninvite_user($_POST['friend_id'], $_POST['group_id'])) { return; } exit; } else { return; } }
/** * Catch and process "Leave Group" button clicks. * * When a group member clicks on the "Leave Group" button from a group's page, * this function is run. * * Note: When leaving a group from the group directory, AJAX is used and * another function handles this. See {@link bp_legacy_theme_ajax_joinleave_group()}. * * @since BuddyPress (1.2.4) */ function groups_action_leave_group() { if (!bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action('leave-group')) { return false; } // Nonce check if (!check_admin_referer('groups_leave_group')) { return false; } // User wants to leave any group if (groups_is_user_member(bp_loggedin_user_id(), bp_get_current_group_id())) { $bp = buddypress(); // Stop sole admins from abandoning their group $group_admins = groups_get_group_admins(bp_get_current_group_id()); if (1 == count($group_admins) && $group_admins[0]->user_id == bp_loggedin_user_id()) { bp_core_add_message(__('This group must have at least one admin', 'buddypress'), 'error'); } elseif (!groups_leave_group($bp->groups->current_group->id)) { bp_core_add_message(__('There was an error leaving the group.', 'buddypress'), 'error'); } else { bp_core_add_message(__('You successfully left the group.', 'buddypress')); } $redirect = bp_get_group_permalink(groups_get_current_group()); if ('hidden' == $bp->groups->current_group->status) { $redirect = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()); } bp_core_redirect($redirect); } bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home')); }
/** * Format notifications for the Groups component. * * @since 1.0.0 * * @param string $action The kind of notification being rendered. * @param int $item_id The primary item ID. * @param int $secondary_item_id The secondary item ID. * @param int $total_items The total number of messaging-related notifications * waiting for the user. * @param string $format 'string' for BuddyBar-compatible notifications; 'array' * for WP Toolbar. Default: 'string'. * @return string */ function groups_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string') { switch ($action) { case 'new_membership_request': $group_id = $item_id; $requesting_user_id = $secondary_item_id; $group = groups_get_group($group_id); $group_link = bp_get_group_permalink($group); $amount = 'single'; // Set up the string and the filter // because different values are passed to the filters, // we'll return values inline. if ((int) $total_items > 1) { $text = sprintf(__('%1$d new membership requests for the group "%2$s"', 'buddypress'), (int) $total_items, $group->name); $amount = 'multiple'; $notification_link = $group_link . 'admin/membership-requests/?n=1'; if ('string' == $format) { /** * Filters groups multiple new membership request notification for string format. * * This is a dynamic filter that is dependent on item count and action. * Complete filter - bp_groups_multiple_new_membership_requests_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for request. * @param string $group_link The permalink for the group. * @param int $total_items Total number of membership requests. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . 's_notification', '<a href="' . $notification_link . '" title="' . __('Group Membership Requests', 'buddypress') . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link); } else { /** * Filters groups multiple new membership request notification for any non-string format. * * This is a dynamic filter that is dependent on item count and action. * Complete filter - bp_groups_multiple_new_membership_requests_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param string $group_link The permalink for the group. * @param int $total_items Total number of membership requests. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . 's_notification', array('link' => $notification_link, 'text' => $text), $group_link, $total_items, $group->name, $text, $notification_link); } } else { $user_fullname = bp_core_get_user_displayname($requesting_user_id); $text = sprintf(__('%s requests group membership', 'buddypress'), $user_fullname); $notification_link = $group_link . 'admin/membership-requests/?n=1'; if ('string' == $format) { /** * Filters groups single new membership request notification for string format. * * This is a dynamic filter that is dependent on item count and action. * Complete filter - bp_groups_single_new_membership_request_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for request. * @param string $group_link The permalink for the group. * @param string $user_fullname Full name of requesting user. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . sprintf(__('%s requests group membership', 'buddypress'), $user_fullname) . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link); } else { /** * Filters groups single new membership request notification for any non-string format. * * This is a dynamic filter that is dependent on item count and action. * Complete filter - bp_groups_single_new_membership_request_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param string $group_link The permalink for the group. * @param string $user_fullname Full name of requesting user. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $group_link, $user_fullname, $group->name, $text, $notification_link); } } break; case 'membership_request_accepted': $group_id = $item_id; $group = groups_get_group($group_id); $group_link = bp_get_group_permalink($group); $amount = 'single'; if ((int) $total_items > 1) { $text = sprintf(__('%d accepted group membership requests', 'buddypress'), (int) $total_items, $group->name); $amount = 'multiple'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { /** * Filters multiple accepted group membership requests notification for string format. * Complete filter - bp_groups_multiple_membership_request_accepted_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $total_items Total number of accepted requests. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link); } else { /** * Filters multiple accepted group membership requests notification for non-string format. * Complete filter - bp_groups_multiple_membership_request_accepted_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification * @param int $total_items Total number of accepted requests. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $total_items, $group->name, $text, $notification_link); } } else { $text = sprintf(__('Membership for group "%s" accepted', 'buddypress'), $group->name); $filter = 'bp_groups_single_membership_request_accepted_notification'; $notification_link = $group_link . '?n=1'; if ('string' == $format) { /** * Filters single accepted group membership request notification for string format. * Complete filter - bp_groups_single_membership_request_accepted_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param string $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { /** * Filters single accepted group membership request notification for non-string format. * Complete filter - bp_groups_single_membership_request_accepted_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param string $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'membership_request_rejected': $group_id = $item_id; $group = groups_get_group($group_id); $group_link = bp_get_group_permalink($group); $amount = 'single'; if ((int) $total_items > 1) { $text = sprintf(__('%d rejected group membership requests', 'buddypress'), (int) $total_items, $group->name); $amount = 'multiple'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { /** * Filters multiple rejected group membership requests notification for string format. * Complete filter - bp_groups_multiple_membership_request_rejected_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $total_items Total number of rejected requests. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $group->name); } else { /** * Filters multiple rejected group membership requests notification for non-string format. * Complete filter - bp_groups_multiple_membership_request_rejected_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $total_items Total number of rejected requests. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $total_items, $group->name, $text, $notification_link); } } else { $text = sprintf(__('Membership for group "%s" rejected', 'buddypress'), $group->name); $notification_link = $group_link . '?n=1'; if ('string' == $format) { /** * Filters single rejected group membership requests notification for string format. * Complete filter - bp_groups_single_membership_request_rejected_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { /** * Filters single rejected group membership requests notification for non-string format. * Complete filter - bp_groups_single_membership_request_rejected_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'member_promoted_to_admin': $group_id = $item_id; $group = groups_get_group($group_id); $group_link = bp_get_group_permalink($group); $amount = 'single'; if ((int) $total_items > 1) { $text = sprintf(__('You were promoted to an admin in %d groups', 'buddypress'), (int) $total_items); $amount = 'multiple'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { /** * Filters multiple promoted to group admin notification for string format. * Complete filter - bp_groups_multiple_member_promoted_to_admin_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $total_items Total number of rejected requests. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $text, $notification_link); } else { /** * Filters multiple promoted to group admin notification for non-string format. * Complete filter - bp_groups_multiple_member_promoted_to_admin_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $total_items Total number of rejected requests. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $total_items, $text, $notification_link); } } else { $text = sprintf(__('You were promoted to an admin in the group "%s"', 'buddypress'), $group->name); $notification_link = $group_link . '?n=1'; if ('string' == $format) { /** * Filters single promoted to group admin notification for non-string format. * Complete filter - bp_groups_single_member_promoted_to_admin_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { /** * Filters single promoted to group admin notification for non-string format. * Complete filter - bp_groups_single_member_promoted_to_admin_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'member_promoted_to_mod': $group_id = $item_id; $group = groups_get_group($group_id); $group_link = bp_get_group_permalink($group); $amount = 'single'; if ((int) $total_items > 1) { $text = sprintf(__('You were promoted to a mod in %d groups', 'buddypress'), (int) $total_items); $amount = 'multiple'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { /** * Filters multiple promoted to group mod notification for string format. * Complete filter - bp_groups_multiple_member_promoted_to_mod_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $total_items Total number of rejected requests. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $text, $notification_link); } else { /** * Filters multiple promoted to group mod notification for non-string format. * Complete filter - bp_groups_multiple_member_promoted_to_mod_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $total_items Total number of rejected requests. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $total_items, $text, $notification_link); } } else { $text = sprintf(__('You were promoted to a mod in the group "%s"', 'buddypress'), $group->name); $notification_link = $group_link . '?n=1'; if ('string' == $format) { /** * Filters single promoted to group mod notification for string format. * Complete filter - bp_groups_single_member_promoted_to_mod_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { /** * Filters single promoted to group admin notification for non-string format. * Complete filter - bp_groups_single_member_promoted_to_mod_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'group_invite': $group_id = $item_id; $group = groups_get_group($group_id); $group_link = bp_get_group_permalink($group); $amount = 'single'; $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/?n=1'; if ((int) $total_items > 1) { $text = sprintf(__('You have %d new group invitations', 'buddypress'), (int) $total_items); $amount = 'multiple'; if ('string' == $format) { /** * Filters multiple group invitation notification for string format. * Complete filter - bp_groups_multiple_group_invite_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $total_items Total number of rejected requests. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __('Group Invites', 'buddypress') . '">' . $text . '</a>', $total_items, $text, $notification_link); } else { /** * Filters multiple group invitation notification for non-string format. * Complete filter - bp_groups_multiple_group_invite_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $total_items Total number of rejected requests. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $total_items, $text, $notification_link); } } else { $text = sprintf(__('You have an invitation to the group: %s', 'buddypress'), $group->name); $filter = 'bp_groups_single_group_invite_notification'; if ('string' == $format) { /** * Filters single group invitation notification for string format. * Complete filter - bp_groups_single_group_invite_notification. * * @since 1.0.0 * * @param string $string HTML anchor tag for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { /** * Filters single group invitation notification for non-string format. * Complete filter - bp_groups_single_group_invite_notification. * * @since 1.0.0 * * @param array $array Array holding permalink and content for notification. * @param int $group_link The permalink for the group. * @param string $group->name Name of the group. * @param string $text Notification content. * @param string $notification_link The permalink for notification. */ return apply_filters('bp_groups_' . $amount . '_' . $action . '_notification', array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; default: /** * Filters plugin-added group-related custom component_actions. * * @since 2.4.0 * * @param string $notification Null value. * @param int $item_id The primary item ID. * @param int $secondary_item_id The secondary item ID. * @param int $total_items The total number of messaging-related notifications * waiting for the user. * @param string $format 'string' for BuddyBar-compatible notifications; * 'array' for WP Toolbar. */ $custom_action_notification = apply_filters('bp_groups_' . $action . '_notification', null, $item_id, $secondary_item_id, $total_items, $format); if (!is_null($custom_action_notification)) { return $custom_action_notification; } break; } /** * Fires right before returning the formatted group notifications. * * @since 1.0.0 * * @param string $action The type of notification being rendered. * @param int $item_id The primary item ID. * @param int $secondary_item_id The secondary item ID. * @param int $total_items Total amount of items to format. */ do_action('groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items); return false; }
function groups_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string') { switch ($action) { case 'new_membership_request': $group_id = $secondary_item_id; $requesting_user_id = $item_id; $group = groups_get_group(array('group_id' => $group_id)); $group_link = bp_get_group_permalink($group); // Set up the string and the filter // Because different values are passed to the filters, we'll return the // values inline if ((int) $total_items > 1) { $text = sprintf(__('%1$d new membership requests for the group "%2$s"', 'buddypress'), (int) $total_items, $group->name); $filter = 'bp_groups_multiple_new_membership_requests_notification'; $notification_link = $group_link . 'admin/membership-requests/?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '" title="' . __('Group Membership Requests', 'buddypress') . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $total_items, $group->name, $text, $notification_link); } } else { $user_fullname = bp_core_get_user_displayname($requesting_user_id); $text = sprintf(__('%s requests group membership', 'buddypress'), $user_fullname); $filter = 'bp_groups_single_new_membership_request_notification'; $notification_link = $group_link . 'admin/membership-requests/?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '" title="' . sprintf(__('%s requests group membership', 'buddypress'), $user_fullname) . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $user_fullname, $group->name, $text, $notification_link); } } break; case 'membership_request_accepted': $group_id = $item_id; $group = groups_get_group(array('group_id' => $group_id)); $group_link = bp_get_group_permalink($group); if ((int) $total_items > 1) { $text = sprintf(__('%d accepted group membership requests', 'buddypress'), (int) $total_items, $group->name); $filter = 'bp_groups_multiple_membership_request_accepted_notification'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $total_items, $group->name, $text, $notification_link); } } else { $text = sprintf(__('Membership for group "%s" accepted', 'buddypress'), $group->name); $filter = 'bp_groups_single_membership_request_accepted_notification'; $notification_link = $group_link . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'membership_request_rejected': $group_id = $item_id; $group = groups_get_group(array('group_id' => $group_id)); $group_link = bp_get_group_permalink($group); if ((int) $total_items > 1) { $text = sprintf(__('%d rejected group membership requests', 'buddypress'), (int) $total_items, $group->name); $filter = 'bp_groups_multiple_membership_request_rejected_notification'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $group->name); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $total_items, $group->name, $text, $notification_link); } } else { $text = sprintf(__('Membership for group "%s" rejected', 'buddypress'), $group->name); $filter = 'bp_groups_single_membership_request_rejected_notification'; $notification_link = $group_link . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'member_promoted_to_admin': $group_id = $item_id; $group = groups_get_group(array('group_id' => $group_id)); $group_link = bp_get_group_permalink($group); if ((int) $total_items > 1) { $text = sprintf(__('You were promoted to an admin in %d groups', 'buddypress'), (int) $total_items); $filter = 'bp_groups_multiple_member_promoted_to_admin_notification'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $total_items, $text, $notification_link); } } else { $text = sprintf(__('You were promoted to an admin in the group "%s"', 'buddypress'), $group->name); $filter = 'bp_groups_single_member_promoted_to_admin_notification'; $notification_link = $group_link . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'member_promoted_to_mod': $group_id = $item_id; $group = groups_get_group(array('group_id' => $group_id)); $group_link = bp_get_group_permalink($group); if ((int) $total_items > 1) { $text = sprintf(__('You were promoted to a mod in %d groups', 'buddypress'), (int) $total_items); $filter = 'bp_groups_multiple_member_promoted_to_mod_notification'; $notification_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()) . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '" title="' . __('Groups', 'buddypress') . '">' . $text . '</a>', $total_items, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $total_items, $text, $notification_link); } } else { $text = sprintf(__('You were promoted to a mod in the group "%s"', 'buddypress'), $group->name); $filter = 'bp_groups_single_member_promoted_to_mod_notification'; $notification_link = $group_link . '?n=1'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; case 'group_invite': $group_id = $item_id; $group = groups_get_group(array('group_id' => $group_id)); $group_link = bp_get_group_permalink($group); $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/?n=1'; if ((int) $total_items > 1) { $text = sprintf(__('You have %d new group invitations', 'buddypress'), (int) $total_items); $filter = 'bp_groups_multiple_group_invite_notification'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '" title="' . __('Group Invites', 'buddypress') . '">' . $text . '</a>', $total_items, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $total_items, $text, $notification_link); } } else { $text = sprintf(__('You have an invitation to the group: %s', 'buddypress'), $group->name); $filter = 'bp_groups_single_group_invite_notification'; if ('string' == $format) { return apply_filters($filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link); } else { return apply_filters($filter, array('link' => $notification_link, 'text' => $text), $group_link, $group->name, $text, $notification_link); } } break; } do_action('groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items); return false; }
function groups_notification_group_invites(&$group, &$member, $inviter_user_id) { // @todo $inviter_up may be used for caching, test without it $inviter_ud = bp_core_get_core_userdata($inviter_user_id); $inviter_name = bp_core_get_userlink($inviter_user_id, true, false, true); $inviter_link = bp_core_get_user_domain($inviter_user_id); $group_link = bp_get_group_permalink($group); if (!$member->invite_sent) { $invited_user_id = $member->user_id; // Post a screen notification first. bp_core_add_notification($group->id, $invited_user_id, 'groups', 'group_invite'); if ('no' == bp_get_user_meta($invited_user_id, 'notification_groups_invite', true)) { return false; } $invited_ud = bp_core_get_core_userdata($invited_user_id); $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings'; $settings_link = bp_core_get_user_domain($invited_user_id) . $settings_slug . '/notifications/'; $invited_link = bp_core_get_user_domain($invited_user_id); $invites_link = trailingslashit($invited_link . bp_get_groups_slug() . '/invites'); // Set up and send the message $to = $invited_ud->user_email; $subject = bp_get_email_subject(array('text' => sprintf(__('You have an invitation to the group: "%s"', 'buddypress'), $group->name))); $message = sprintf(__('One of your friends %1$s has invited you to the group: "%2$s". To view your group invites visit: %3$s To view the group visit: %4$s To view %5$s\'s profile visit: %6$s --------------------- ', 'buddypress'), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link); // Only show the disable notifications line if the settings component is enabled if (bp_is_active('settings')) { $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link); } /* Send the message */ $to = apply_filters('groups_notification_group_invites_to', $to); $subject = apply_filters_ref_array('groups_notification_group_invites_subject', array($subject, &$group)); $message = apply_filters_ref_array('groups_notification_group_invites_message', array($message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link, $settings_link)); wp_mail($to, $subject, $message); do_action('bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group); } }
/** * Set up the component entries in the WordPress Admin Bar. * * @since BuddyPress (1.5) * * @see BP_Component::setup_nav() for a description of the $wp_admin_nav * parameter array. * @uses is_user_logged_in() * @uses trailingslashit() * @uses bp_get_total_mention_count_for_user() * @uses bp_loggedin_user_id() * @uses bp_is_active() * @uses bp_get_friends_slug() * @uses bp_get_groups_slug() * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a * description. */ public function setup_admin_bar($wp_admin_nav = array()) { $bp = buddypress(); // Menus for logged in user if (is_user_logged_in()) { // Setup the logged in user variables $user_domain = bp_loggedin_user_domain(); $activity_link = trailingslashit($user_domain . $this->slug); // Unread message count if (bp_activity_do_mentions()) { $count = bp_get_total_mention_count_for_user(bp_loggedin_user_id()); if (!empty($count)) { $title = sprintf(__('Mentions <span class="count">%s</span>', 'buddypress'), number_format_i18n($count)); } else { $title = __('Mentions', 'buddypress'); } } // Add the "Activity" sub menu $wp_admin_nav[] = array('parent' => $bp->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => __('Activity', 'buddypress'), 'href' => trailingslashit($activity_link)); // Personal $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-personal', 'title' => __('Personal', 'buddypress'), 'href' => trailingslashit($activity_link)); // Mentions if (bp_activity_do_mentions()) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-mentions', 'title' => $title, 'href' => trailingslashit($activity_link . 'mentions')); } // Favorites $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => __('Favorites', 'buddypress'), 'href' => trailingslashit($activity_link . 'favorites')); // Friends? if (bp_is_active('friends')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friends', 'title' => __('Friends', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_friends_slug())); } // Groups? if (bp_is_active('groups')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-groups', 'title' => __('Groups', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_groups_slug())); } } parent::setup_admin_bar($wp_admin_nav); }
/** * Displays group header tabs * * @package BuddyPress * @todo Deprecate? */ function bp_groups_header_tabs() { global $bp; ?> <li<?php if (!bp_action_variable(0) || bp_is_action_variable('recently-active', 0)) { ?> class="current"<?php } ?> ><a href="<?php echo trailingslashit(bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/recently-active'); ?> "><?php _e('Recently Active', 'buddypress'); ?> </a></li> <li<?php if (bp_is_action_variable('recently-joined', 0)) { ?> class="current"<?php } ?> ><a href="<?php echo trailingslashit(bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/recently-joined'); ?> "><?php _e('Recently Joined', 'buddypress'); ?> </a></li> <li<?php if (bp_is_action_variable('most-popular', 0)) { ?> class="current"<?php } ?> ><a href="<?php echo trailingslashit(bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/most-popular'); ?> "><?php _e('Most Popular', 'buddypress'); ?> </a></li> <li<?php if (bp_is_action_variable('admin-of', 0)) { ?> class="current"<?php } ?> ><a href="<?php echo trailingslashit(bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/admin-of'); ?> "><?php _e('Administrator Of', 'buddypress'); ?> </a></li> <li<?php if (bp_is_action_variable('mod-of', 0)) { ?> class="current"<?php } ?> ><a href="<?php echo trailingslashit(bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/mod-of'); ?> "><?php _e('Moderator Of', 'buddypress'); ?> </a></li> <li<?php if (bp_is_action_variable('alphabetically')) { ?> class="current"<?php } ?> ><a href="<?php echo trailingslashit(bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/alphabetically'); ?> "><?php _e('Alphabetically', 'buddypress'); ?> </a></li> <?php do_action('groups_header_tabs'); }
/** * Set up the component entries in the WordPress Admin Bar. * * @since 1.5.0 * * @see BP_Component::setup_nav() for a description of the $wp_admin_nav * parameter array. * @uses is_user_logged_in() * @uses trailingslashit() * @uses bp_get_total_mention_count_for_user() * @uses bp_loggedin_user_id() * @uses bp_is_active() * @uses bp_get_friends_slug() * @uses bp_get_groups_slug() * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a * description. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user. if (is_user_logged_in()) { // Setup the logged in user variables. $activity_link = trailingslashit(bp_loggedin_user_domain() . bp_get_activity_slug()); // Unread message count. if (bp_activity_do_mentions()) { $count = bp_get_total_mention_count_for_user(bp_loggedin_user_id()); if (!empty($count)) { $title = sprintf(_x('Mentions <span class="count">%s</span>', 'Toolbar Mention logged in user', 'buddypress'), bp_core_number_format($count)); } else { $title = _x('Mentions', 'Toolbar Mention logged in user', 'buddypress'); } } // Add the "Activity" sub menu. $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => _x('Activity', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link); // Personal. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-personal', 'title' => _x('Personal', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link); // Mentions. if (bp_activity_do_mentions()) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-mentions', 'title' => $title, 'href' => trailingslashit($activity_link . 'mentions')); } // Favorite activity items. if (bp_activity_can_favorite()) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => _x('Favorites', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . 'favorites')); } // Friends? if (bp_is_active('friends')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friends', 'title' => _x('Friends', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_friends_slug())); } // Groups? if (bp_is_active('groups')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-groups', 'title' => _x('Groups', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_groups_slug())); } } parent::setup_admin_bar($wp_admin_nav); }
<div class="item-list-tabs" role="navigation"> <ul> <li class="selected" id="groups-all"><a href="<?php echo trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()); ?> "><?php printf(__('All Groups <span>%s</span>', 'buddypress'), bp_get_total_group_count()); ?> </a></li> <?php if (is_user_logged_in() && bp_get_total_group_count_for_user(bp_loggedin_user_id())) { ?> <li id="groups-personal"><a href="<?php echo trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug() . '/my-groups'); ?> "><?php printf(__('My Groups <span>%s</span>', 'buddypress'), bp_get_total_group_count_for_user(bp_loggedin_user_id())); ?> </a></li> <?php } ?> <?php do_action('bp_groups_directory_group_filter'); ?> </ul>
/** * Modify the user nav before it gets rendered, so we remove redundant items */ function thatcamp_mod_user_nav() { global $bp; if (bp_is_active('xprofile')) { $bp->bp_nav['profile']['name'] = 'About'; $bp->bp_nav['profile']['position'] = 5; } if (bp_is_active('activity')) { bp_core_remove_subnav_item('activity', 'mentions'); bp_core_remove_subnav_item('activity', 'favorites'); bp_core_remove_subnav_item('activity', 'friends'); bp_core_remove_subnav_item('activity', 'camps'); } if (bp_is_active('blogs')) { bp_core_remove_nav_item('blogs'); } if (bp_is_active('groups')) { bp_core_remove_subnav_item('camps', 'invites'); } /** if ( bp_is_active( 'messages' ) ) { bp_core_remove_nav_item( 'messages' ); } **/ if (bp_is_active('settings') && is_user_logged_in()) { bp_core_remove_nav_item('settings'); } // There's a baffling bug in BuddyPress that makes this necessary // I blame the Buddybar if (is_user_logged_in()) { $activity_base = trailingslashit(bp_displayed_user_domain() . bp_get_activity_slug()); } else { $activity_base = bp_get_activity_slug() . '/'; } $bp->bp_nav['blogs'] = array('name' => 'Blog Posts', 'slug' => 'blogs', 'link' => add_query_arg('a_type', 'blog_posts', $activity_base), 'css_id' => 'blogs', 'show_for_displayed_user' => true, 'position' => 70, 'screen_function' => 'bp_activity_screen_my_activity'); $bp->bp_nav['comments'] = array('name' => 'Blog Comments', 'slug' => 'comments', 'link' => add_query_arg('a_type', 'blog_comments', $activity_base), 'css_id' => 'comments', 'show_for_displayed_user' => true, 'position' => 73, 'screen_function' => 'bp_activity_screen_my_activity'); $bp->bp_nav['forums'] = array('name' => 'Forum Posts', 'slug' => 'forums', 'link' => add_query_arg('a_type', 'forums', $activity_base), 'css_id' => 'forums', 'show_for_displayed_user' => true, 'position' => 90, 'screen_function' => 'bp_activity_screen_my_activity'); $bp->bp_nav['favorites'] = array('name' => 'Favorites', 'slug' => 'favorites', 'link' => add_query_arg('a_type', 'favorites', $activity_base), 'css_id' => 'favorites', 'show_for_displayed_user' => false, 'position' => 100, 'screen_function' => 'bp_activity_screen_my_activity'); $bp->bp_nav[bp_get_groups_slug()]['name'] = str_replace('Groups', 'Camps', $bp->bp_nav[bp_get_groups_slug()]['name']); // Cheating: Put Camps before Friends if (isset($bp->bp_nav[bp_get_groups_slug()])) { $bp->bp_nav[bp_get_groups_slug()]['position'] = 55; } // Correct the Edit My Profile link if (isset($bp->bp_options_nav['profile']['edit'])) { remove_filter('edit_profile_url', 'bp_members_edit_profile_url', 10, 3); $bp->bp_options_nav['profile']['edit']['link'] = get_edit_profile_url(get_current_user_id()); add_filter('edit_profile_url', 'bp_members_edit_profile_url', 10, 3); } }