示例#1
3
/**
 * @param boolean $result
 * @param EM_Booking $EM_Booking
 * @return boolean
 */
function bp_em_record_activity_booking_save($result, $EM_Booking)
{
    if ($result) {
        $rejected_statuses = array(0, 2, 3);
        //these statuses apply to rejected/cancelled bookings
        $user = $EM_Booking->person;
        $member_slug = function_exists('bp_get_members_root_slug') ? bp_get_members_root_slug() : BP_MEMBERS_SLUG;
        $member_link = trailingslashit(bp_get_root_domain()) . $member_slug . '/' . $user->user_login;
        $user_link = "<a href='" . $member_link . "/'>" . $user->display_name . "</a>";
        $event_link = $EM_Booking->get_event()->output('#_EVENTLINK');
        $status = $EM_Booking->booking_status;
        $EM_Event = $EM_Booking->get_event();
        if (empty($EM_Event->group_id)) {
            if ($status == 1 || !get_option('dbem_bookings_approval') && $status < 2) {
                $action = sprintf(__('%s is attending %s.', 'dbem'), $user_link, $event_link);
            } elseif (($EM_Booking->previous_status == 1 || !get_option('dbem_bookings_approval') && $EM_Booking->previous_status < 2) && in_array($status, $rejected_statuses)) {
                $action = sprintf(__('%s will not be attending %s anymore.', 'dbem'), $user_link, $event_link);
            }
        } else {
            $group = new BP_Groups_Group($EM_Event->group_id);
            $group_link = '<a href="' . bp_get_group_permalink($group) . '">' . bp_get_group_name($group) . '</a>';
            if ($status == 1 || !get_option('dbem_bookings_approval') && $status < 2) {
                $action = sprintf(__('%s is attending %s of the group %s.', 'dbem'), $user_link, $event_link, $group_link);
            } elseif (($EM_Booking->previous_status == 1 || !get_option('dbem_bookings_approval') && $EM_Booking->previous_status < 2) && in_array($status, $rejected_statuses)) {
                $action = sprintf(__('%s will not be attending %s of group %s anymore.', 'dbem'), $user_link, $event_link, $group_link);
            }
        }
        if (!empty($action)) {
            bp_em_record_activity(array('user_id' => $EM_Booking->person->ID, 'action' => $action, 'primary_link' => $EM_Event->output('#_EVENTURL'), 'type' => 'new_booking', 'item_id' => $EM_Event->event_id, 'secondary_item_id' => $EM_Booking->booking_id, 'hide_sitewide' => $EM_Event->event_private));
            //group activity
            if (!empty($EM_Event->group_id)) {
                //tis a group event
                bp_em_record_activity(array('component' => 'groups', 'item_id' => $EM_Event->group_id, 'user_id' => $EM_Booking->person->ID, 'action' => $action, 'primary_link' => $EM_Event->output('#_EVENTURL'), 'type' => 'new_booking', 'secondary_item_id' => $EM_Booking->booking_id, 'hide_sitewide' => $EM_Event->event_private));
            }
        }
    }
    return $result;
}
示例#2
0
/**
 * @param boolean $result
 * @param EM_Booking $EM_Booking
 * @return boolean
 */
function bp_em_record_activity_booking_save($result, $EM_Booking)
{
    if ($result) {
        $user = $EM_Booking->person;
        $user_link = "<a href='" . get_bloginfo('wpurl') . '/' . BP_MEMBERS_SLUG . '/' . $user->user_login . "/'>" . $user->display_name . "</a>";
        $event_link = $EM_Booking->get_event()->output('#_EVENTLINK');
        $status = $EM_Booking->status;
        if ($status == 1 || !get_option('dbem_bookings_approval') && $status < 2) {
            $action = sprintf(__('%s is attending %s.', 'dbem'), $user_link, $event_link);
        } elseif (($EM_Booking->previous_status == 1 || !get_option('dbem_bookings_approval') && $EM_Booking->previous_status < 2) && ($status > 1 || empty($status) || !get_option('dbem_bookings_approval') && $status != 1)) {
            $action = sprintf(__('%s will not be attending %s anymore.', 'dbem'), $user_link, $event_link);
        }
        $EM_Event = $EM_Booking->get_event();
        if (!empty($EM_Event->group_id)) {
            $group = new BP_Groups_Group($EM_Event->group_id);
            $group_link = '<a href="' . bp_get_group_permalink($group) . '">' . bp_get_group_name($group) . '</a>';
            if ($status == 1 || !get_option('dbem_bookings_approval') && $status < 2) {
                $action = sprintf(__('%s is attending %s of the group %s.', 'dbem'), $user_link, $event_link, $group_link);
            } elseif (($EM_Booking->previous_status == 1 || !get_option('dbem_bookings_approval') && $EM_Booking->previous_status < 2) && ($status > 1 || empty($status) || !get_option('dbem_bookings_approval') && $status != 1)) {
                $action = sprintf(__('%s will not be attending %s of group %s anymore.', 'dbem'), $user_link, $event_link, $group_link);
            }
        }
        if (!empty($action)) {
            bp_em_record_activity(array('user_id' => $EM_Booking->person->ID, 'action' => $action, 'primary_link' => $EM_Event->output('#_EVENTURL'), 'type' => 'new_booking', 'item_id' => $EM_Event->id, 'secondary_item_id' => $EM_Booking->id));
            //group activity
            if (!empty($EM_Event->group_id)) {
                //tis a group event
                bp_em_record_activity(array('component' => 'groups', 'item_id' => $EM_Event->group_id, 'user_id' => $EM_Booking->person->ID, 'action' => $action, 'primary_link' => $EM_Event->output('#_EVENTURL'), 'type' => 'new_booking', 'secondary_item_id' => $EM_Booking->id));
            }
        }
    }
    return $result;
}
/**
 * bp_course_nav_menu()
 * Navigation menu for BuddyPress course
 */
function bp_course_nav_menu()
{
    $nav = bp_course_get_nav_permalinks();
    $defaults = array('' => array('id' => 'home', 'label' => __('Home', 'vibe'), 'action' => '', 'link' => bp_get_course_permalink()), 'curriculum' => array('id' => 'curriculum', 'label' => __('Curriculum', 'vibe'), 'can_view' => 1, 'action' => empty($nav['curriculum_slug']) ? __('curriculum', 'vibe') : $nav['curriculum_slug'], 'link' => bp_get_course_permalink()), 'members' => array('id' => 'members', 'label' => __('Members', 'vibe'), 'can_view' => 1, 'action' => empty($nav['members_slug']) ? __('members', 'vibe') : $nav['members_slug'], 'link' => bp_get_course_permalink()), 'activity' => array('id' => 'activity', 'label' => __('Activity', 'vibe'), 'can_view' => 1, 'action' => empty($nav['activity_slug']) ? __('activity', 'vibe') : $nav['activity_slug'], 'link' => bp_get_course_permalink()));
    global $post;
    if ($post->post_type == 'course') {
        if (function_exists('bp_is_active') && bp_is_active('groups')) {
            $vgroup = get_post_meta(get_the_ID(), 'vibe_group', true);
            if (!empty($vgroup)) {
                $group = groups_get_group(array('group_id' => $vgroup));
                $defaults['group'] = array('id' => 'group', 'label' => __('Group', 'vibe'), 'action' => 'group', 'can_view' => 1, 'link' => bp_get_group_permalink($group), 'external' => true);
            }
        }
        if (in_array('bbpress/bbpress.php', apply_filters('active_plugins', get_option('active_plugins'))) || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('bbpress/bbpress.php')) {
            $forum = get_post_meta(get_the_ID(), 'vibe_forum', true);
            if (!empty($forum)) {
                $defaults['forum'] = array('id' => 'forum', 'label' => __('Forum', 'vibe'), 'action' => 'forum', 'can_view' => 1, 'link' => get_permalink($forum), 'external' => true);
            }
        }
    }
    $nav_menu = apply_filters('wplms_course_nav_menu', $defaults);
    global $bp;
    $action = bp_current_action();
    if (empty($action)) {
        !empty($_GET['action']) ? $action = $_GET['action'] : ($action = '');
    }
    if (is_array($nav_menu)) {
        foreach ($nav_menu as $key => $menu_item) {
            $menu_item['action'] = str_replace('/', '', $menu_item['action']);
            if ($key == $action) {
                $class = 'class="current"';
            } else {
                $class = '';
            }
            global $wp_query;
            if (!empty($nav[$menu_item['id'] . '_slug'])) {
                echo '<li id="' . $menu_item['id'] . '" ' . $class . '><a href="' . $menu_item['link'] . '' . (isset($menu_item['action']) && !isset($menu_item['external']) ? $menu_item['action'] : '') . '">' . $menu_item['label'] . '</a></li>';
            } else {
                echo '<li id="' . $menu_item['id'] . '" ' . $class . '><a href="' . $menu_item['link'] . '' . (!empty($menu_item['action']) && !isset($menu_item['external']) ? (strpos($menu_item['link'], '?') ? '&' : '?') . 'action=' . $menu_item['action'] : '') . '">' . $menu_item['label'] . '</a></li>';
            }
        }
    }
    if (is_super_admin() || is_instructor()) {
        $admin_slug = empty($nav['admin_slug']) ? _x('admin', 'course admin slug', 'vibe') : $nav['admin_slug'];
        $admin_slug = apply_filters('wplms_course_admin_slug', str_replace('/', '', $admin_slug));
        ?>
      <li id="admin" class="<?php 
        echo !empty($action) && ($action == 'admin' || $action == 'submission' || $action == 'stats') ? 'selected current' : '';
        ?>
"><a href="<?php 
        bp_course_permalink();
        echo $admin_slug;
        ?>
"><?php 
        _e('Admin', 'vibe');
        ?>
</a></li>
      <?php 
    }
}
示例#4
0
 function post_review($args = '')
 {
     global $bp;
     $defaults = array('content' => false, 'rating' => false, 'user_id' => $bp->loggedin_user->id, 'group_id' => $bp->groups->current_group->id);
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     if (empty($content) || !strlen(trim($content)) || empty($user_id) || empty($group_id)) {
         return false;
     }
     // Be sure the user is a member of the group before posting.
     if (!is_super_admin() && !groups_is_user_member($user_id, $group_id)) {
         return false;
     }
     // Record this in activity streams
     $activity_action = sprintf(__('%s reviewed %s:', 'bpgr'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_html($bp->groups->current_group->name) . '</a>');
     $rating_content = false;
     if (!empty($rating)) {
         $rating_content = '<span class="p-rating">' . bpgr_get_review_rating_html($rating) . '</span>';
     }
     $activity_content = $rating_content . $content;
     $activity_id = groups_record_activity(array('user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'type' => 'review', 'item_id' => $group_id));
     $this->add_rating(array('score' => $rating, 'activity_id' => $activity_id, 'group_id' => $group_id));
     groups_update_groupmeta($group_id, 'last_activity', gmdate("Y-m-d H:i:s"));
     do_action('bpgr_posted_review', $args, $activity_id);
     return $activity_id;
 }
/**
 * Restrict access to a group regarding its 'member type'
 *
 * If a user is not logged in, he is redirected to the login form
 * If a user ! member type, he is redirected to the groups directory
 * If a user is a super admin, he can access
 *
 * @param  bool $user_has_access
 * @param  array &$no_access_args the redirect args
 * @return bool False if member type doesn't match, true otherwise
 */
function cfbgr_enqueue_current_user_has_access($user_has_access, &$no_access_args)
{
    // If the user does not already have access bail
    if (empty($user_has_access)) {
        return $user_has_access;
    }
    // Get the member type of the group
    $restriction = groups_get_groupmeta(bp_get_current_group_id(), 'cf-buddypress-group-restrictions');
    // Don't touch to regular groups and leave Admins access
    if (empty($restriction) || bp_current_user_can('bp_moderate')) {
        return $user_has_access;
    }
    $current_group = groups_get_current_group();
    if (!is_user_logged_in()) {
        $user_has_access = false;
        $no_access_args = array('message' => __('You must log in to access the page you requested.', 'buddypress-group-restrictions'), 'root' => bp_get_group_permalink($current_group) . 'home/', 'redirect' => false);
        return $user_has_access;
        // Current user does not match the restriction
    } elseif ($restriction !== bp_get_member_type(bp_loggedin_user_id())) {
        $user_has_access = false;
        // Get infos about the member type
        $member_type_object = bp_get_member_type_object($restriction);
        $singular_name = '';
        if (!empty($member_type_object->labels['singular_name'])) {
            $singular_name = $member_type_object->labels['singular_name'];
        }
        // You need to redirect to a BuddyPress page to have
        $no_access_args = array('mode' => 3, 'message' => sprintf(__('Sorry the group you tried to enter is only viewable for %s members', 'buddypress-group-restrictions'), esc_html($singular_name)), 'root' => bp_get_groups_directory_permalink(), 'redirect' => false);
        return $user_has_access;
    }
    // By default, leave BuddyPress deal with access
    return $user_has_access;
}
 function dispatch_creation_activity_update($post_id)
 {
     if (!function_exists('bp_activity_get')) {
         return false;
     }
     // WTF
     $created = $this->_data->get_option('bp-activity_autoupdate-event_created');
     if (!$created) {
         return false;
     }
     $event = new Eab_EventModel(get_post($post_id));
     if (!$event->is_published()) {
         return false;
     }
     $user_link = bp_core_get_userlink($event->get_author());
     $update = false;
     $group_id = $this->_is_group_event($event->get_id());
     $public_announcement = $this->_is_public_announcement($event->get_id());
     if ('any' == $created) {
         $update = sprintf(__('%s created an event', Eab_EventsHub::TEXT_DOMAIN), $user_link);
     } else {
         if ('group' == $created && $group_id) {
             $group = groups_get_group(array('group_id' => $group_id));
             $group_link = bp_get_group_permalink($group);
             $group_name = bp_get_group_name($group);
             $update = sprintf(__('%s created an event in <a href="%s">%s</a>', Eab_EventsHub::TEXT_DOMAIN), $user_link, $group_link, $group_name);
         } else {
             if ('pa' == $created && $public_announcement) {
                 $update = sprintf(__('%s created a public announcement', Eab_EventsHub::TEXT_DOMAIN), $user_link);
             }
         }
     }
     if (!$update) {
         return false;
     }
     $update = sprintf("{$update}, <a href='%s'>%s</a>", get_permalink($event->get_id()), $event->get_title());
     $existing = bp_activity_get(array("filter" => array("object" => 'eab_events', "action" => 'event_created', 'primary_id' => $event->get_id())));
     if (isset($existing['activities']) && !empty($existing['activities'])) {
         return false;
     }
     $activity = array('action' => $update, 'component' => 'eab_events', 'type' => 'event_created', 'item_id' => $event->get_id(), 'user_id' => $event->get_author());
     bp_activity_add($activity);
     if ($this->_data->get_option('bp-activity_autoupdate-created_group_post') && $group_id) {
         global $bp;
         $group_activity = $activity;
         $group_activity['component'] = $bp->groups->id;
         $group_activity['item_id'] = $group_id;
         $group_activity['secondary_item_id'] = $event->get_id();
         $existing = bp_activity_get(array("filter" => array('user_id' => $user_id, "object" => $bp->groups->id, "action" => 'event_created', 'primary_id' => $group_id, 'secondary_id' => $event->get_id())));
         if (isset($existing['activities']) && !empty($existing['activities'])) {
             $old = reset($existing['activities']);
             if (is_object($old) && isset($old->id)) {
                 $group_activity['id'] = $old->id;
             }
         }
         // Add group activity update
         groups_record_activity($group_activity);
     }
 }
/**
 * Load the Forums directory.
 */
function bp_forums_directory_forums_setup()
{
    // Get BuddyPress once
    $bp = buddypress();
    if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
        if (!bp_forums_has_directory()) {
            return false;
        }
        if (!bp_forums_is_installed_correctly()) {
            bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain());
        }
        bp_update_is_directory(true, 'forums');
        do_action('bbpress_init');
        // Check to see if the user has posted a new topic from the forums page.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            check_admin_referer('bp_forums_new_topic');
            $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id']));
            if (!empty($bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group
                if (!bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id);
                }
                $error_message = '';
                $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
                if (!empty($forum_id)) {
                    if (empty($_POST['topic_title'])) {
                        $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                    } else {
                        if (empty($_POST['topic_text'])) {
                            $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                        }
                    }
                    if ($error_message) {
                        bp_core_add_message($error_message, 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                            bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                        } else {
                            bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                        }
                    }
                    bp_core_redirect($redirect);
                } else {
                    bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                    bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
                }
            } else {
                bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
            }
        }
        do_action('bp_forums_directory_forums_setup');
        bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index'));
    }
}
/**
 * Catch and route requests for single activity item permalinks.
 *
 * @since 1.2.0
 *
 * @uses bp_is_activity_component()
 * @uses bp_is_current_action()
 * @uses bp_action_variable()
 * @uses bp_activity_get_specific()
 * @uses bp_is_active()
 * @uses bp_core_get_user_domain()
 * @uses groups_get_group()
 * @uses bp_get_group_permalink()
 * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook.
 * @uses bp_core_redirect()
 * @uses bp_get_root_domain()
 *
 * @return bool False on failure.
 */
function bp_activity_action_permalink_router()
{
    // Not viewing activity.
    if (!bp_is_activity_component() || !bp_is_current_action('p')) {
        return false;
    }
    // No activity to display.
    if (!bp_action_variable(0) || !is_numeric(bp_action_variable(0))) {
        return false;
    }
    // Get the activity details.
    $activity = bp_activity_get_specific(array('activity_ids' => bp_action_variable(0), 'show_hidden' => true));
    // 404 if activity does not exist
    if (empty($activity['activities'][0])) {
        bp_do_404();
        return;
    } else {
        $activity = $activity['activities'][0];
    }
    // Do not redirect at default.
    $redirect = false;
    // Redirect based on the type of activity.
    if (bp_is_active('groups') && $activity->component == buddypress()->groups->id) {
        // Activity is a user update.
        if (!empty($activity->user_id)) {
            $redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
            // Activity is something else.
        } else {
            // Set redirect to group activity stream.
            if ($group = groups_get_group(array('group_id' => $activity->item_id))) {
                $redirect = bp_get_group_permalink($group) . bp_get_activity_slug() . '/' . $activity->id . '/';
            }
        }
        // Set redirect to users' activity stream.
    } elseif (!empty($activity->user_id)) {
        $redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
    }
    // If set, add the original query string back onto the redirect URL.
    if (!empty($_SERVER['QUERY_STRING'])) {
        $query_frags = array();
        wp_parse_str($_SERVER['QUERY_STRING'], $query_frags);
        $redirect = add_query_arg(urlencode_deep($query_frags), $redirect);
    }
    /**
     * Filter the intended redirect url before the redirect occurs for the single activity item.
     *
     * @since 1.2.2
     *
     * @param array $value Array with url to redirect to and activity related to the redirect.
     */
    if (!($redirect = apply_filters_ref_array('bp_activity_permalink_redirect_url', array($redirect, &$activity)))) {
        bp_core_redirect(bp_get_root_domain());
    }
    // Redirect to the actual activity permalink page.
    bp_core_redirect($redirect);
}
/**
 * Format activity actions.
 *
 * @param string $action   Activity action as determined by BuddyPress.
 * @param obj    $activity Activity item.
 * @return string
 */
function cacsp_format_activity_action($action, $activity)
{
    $paper = new CACSP_Paper($activity->secondary_item_id);
    $paper_id = $paper->ID;
    if (!$paper_id) {
        return $action;
    }
    $paper_title = $paper->post_title;
    $paper_link = get_permalink($paper->ID);
    $user_link = bp_core_get_userlink($activity->user_id);
    switch ($activity->type) {
        case 'new_cacsp_paper':
            $action = sprintf(__('%1$s created a new paper %2$s', 'social-paper'), $user_link, sprintf('<a href="%s">%s</a>', esc_url($paper_link), esc_html($paper_title)));
            break;
        case 'new_cacsp_comment':
            $comment = get_comment($activity->item_id);
            if (!$comment) {
                return $action;
            }
            if ($comment->user_id) {
                $commenter_link = bp_core_get_userlink($comment->user_id);
            } elseif ($comment->comment_author_url) {
                $commenter_link = sprintf('<a href="%s">%s</a>', esc_url($comment->comment_author_url), esc_html($comment->comment_author));
            } else {
                $commenter_link = esc_html($comment->comment_author);
            }
            $action = sprintf(__('%1$s commented on the paper %2$s', 'social-paper'), $commenter_link, sprintf('<a href="%s">%s</a>', esc_url($paper_link), esc_html($paper_title)));
            break;
        case 'new_cacsp_edit':
            $action = sprintf(__('%1$s edited the paper %2$s', 'social-paper'), $user_link, sprintf('<a href="%s">%s</a>', esc_url($paper_link), esc_html($paper_title)));
            break;
        case 'cacsp_paper_added_to_group':
            if (!bp_is_active('groups')) {
                return $action;
            }
            $group = groups_get_group(array('group_id' => $activity->item_id));
            $action = sprintf(__('%1$s added the paper %2$s to the group %3$s', 'social-paper'), $user_link, sprintf('<a href="%s">%s</a>', esc_url($paper_link), esc_html($paper_title)), sprintf('<a href="%s">%s</a>', esc_url(bp_get_group_permalink($group)), esc_html(stripslashes($group->name))));
            break;
        default:
            return $action;
    }
    /**
     * Filters the formatted action for paper activities.
     *
     * Used by hooks-buddypress-groups.php to add group information.
     *
     * @param string      $action      Formatted action string.
     * @param obj         $activity    Activity item.
     * @param CACSP_Paper $paper       Paper object.
     * @param string      $paper_title Paper title.
     * @param string      $paper_link  Paper URL.
     * @param string      $user_link   User link.
     */
    return apply_filters('cacsp_format_activity_action', $action, $activity, $paper, $paper_title, $paper_link, $user_link);
}
示例#10
0
function bp_gmt_get_form_action($page = false, $group = false)
{
    global $bp, $groups_template;
    if (!$group) {
        $group =& $groups_template->group;
    }
    if (!$page) {
        $page = $bp->action_variables[0];
    }
    return apply_filters('bp_gtm_form_action', bp_get_group_permalink($group) . $bp->gtm->slug . '/' . $page);
}
示例#11
0
 /**
  * set_nav()
  *
  * Sets up the component navigation
  */
 function set_nav()
 {
     global $bp;
     if (!$bp->groups->current_group || !$this->courseware_status($bp->groups->current_group->id)) {
         return;
     }
     $group_permalink = bp_get_group_permalink($bp->groups->current_group);
     bp_core_new_subnav_item(array('name' => __('Courseware', 'bpsp'), 'slug' => $bp->courseware->slug, 'parent_url' => $group_permalink, 'parent_slug' => $bp->groups->current_group->slug, 'screen_function' => array(&$this, 'screen_handler'), 'position' => 35, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'courseware-group'));
     $this->nav_options[__('Home', 'bpsp')] = $group_permalink . $bp->courseware->slug;
     do_action('courseware_group_set_nav');
 }
/**
 * Allow core components and dependent plugins to register activity actions
 *
 * @since BuddyPress (1.2)
 *
 * @global object $bp BuddyPress global settings
 * @uses bp_is_activity_component()
 * @uses bp_is_current_action()
 * @uses bp_action_variable()
 * @uses bp_activity_get_specific()
 * @uses bp_is_active()
 * @uses bp_core_get_user_domain()
 * @uses groups_get_group()
 * @uses bp_get_group_permalink()
 * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook
 * @uses bp_core_redirect()
 * @uses bp_get_root_domain()
 *
 * @return bool False on failure
 */
function bp_activity_action_permalink_router()
{
    global $bp;
    // Not viewing activity
    if (!bp_is_activity_component() || !bp_is_current_action('p')) {
        return false;
    }
    // No activity to display
    if (!bp_action_variable(0) || !is_numeric(bp_action_variable(0))) {
        return false;
    }
    // Get the activity details
    $activity = bp_activity_get_specific(array('activity_ids' => bp_action_variable(0), 'show_hidden' => true));
    // 404 if activity does not exist
    if (empty($activity['activities'][0])) {
        bp_do_404();
        return;
    } else {
        $activity = $activity['activities'][0];
    }
    // Do not redirect at default
    $redirect = false;
    // Redirect based on the type of activity
    if (bp_is_active('groups') && $activity->component == $bp->groups->id) {
        // Activity is a user update
        if (!empty($activity->user_id)) {
            $redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
            // Activity is something else
        } else {
            // Set redirect to group activity stream
            if ($group = groups_get_group(array('group_id' => $activity->item_id))) {
                $redirect = bp_get_group_permalink($group) . bp_get_activity_slug() . '/' . $activity->id . '/';
            }
        }
        // Set redirect to users' activity stream
    } else {
        $redirect = bp_core_get_user_domain($activity->user_id, $activity->user_nicename, $activity->user_login) . bp_get_activity_slug() . '/' . $activity->id . '/';
    }
    // If set, add the original query string back onto the redirect URL
    if (!empty($_SERVER['QUERY_STRING'])) {
        $query_frags = array();
        wp_parse_str($_SERVER['QUERY_STRING'], $query_frags);
        $redirect = add_query_arg(urlencode_deep($query_frags), $redirect);
    }
    // Allow redirect to be filtered
    if (!($redirect = apply_filters_ref_array('bp_activity_permalink_redirect_url', array($redirect, &$activity)))) {
        bp_core_redirect(bp_get_root_domain());
    }
    // Redirect to the actual activity permalink page
    bp_core_redirect($redirect);
}
function bp_reshare_prepare_reshare($activity_id)
{
    global $bp;
    $activity_to_reshare = bp_activity_get_specific('activity_ids=' . $activity_id);
    $activity = $activity_to_reshare['activities'][0];
    /* get and increment reshared count */
    $rs_count = bp_activity_get_meta($activity_id, 'reshared_count');
    $rs_count = !empty($rs_count) ? (int) $rs_count + 1 : 1;
    bp_activity_update_meta($activity_id, 'reshared_count', $rs_count);
    /* get an array of users that reshared the activity */
    $reshared_by = bp_activity_get_meta($activity_id, 'reshared_by');
    if (is_array($reshared_by) && !in_array($bp->loggedin_user->id, $reshared_by)) {
        $reshared_by[] = $bp->loggedin_user->id;
    } else {
        $reshared_by[] = $bp->loggedin_user->id;
    }
    bp_activity_update_meta($activity_id, 'reshared_by', $reshared_by);
    $secondary_avatar = bp_core_fetch_avatar(array('item_id' => $activity->user_id, 'object' => 'user', 'type' => 'thumb', 'alt' => $alt, 'class' => 'avatar', 'width' => 20, 'height' => 20));
    $component = $activity->component;
    $item_id = $activity->item_id;
    if ($component != 'activity') {
        if ($activity->type == 'new_blog_post') {
            $action = sprintf(__('%s reshared a <a href="%s">blog post</a> originally posted by %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id));
        } else {
            if ($activity->type == 'new_blog_comment') {
                $action = sprintf(__('%s reshared a <a href="%s">comment</a> originally posted by %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id));
            } else {
                if ($component == 'groups') {
                    $group = groups_get_group(array('group_id' => $item_id));
                    $group_link = '<a href="' . bp_get_group_permalink($group) . '">' . $group->name . '</a>';
                    if ($activity->type == 'new_forum_topic') {
                        $action = sprintf(__('%s reshared a <a href="%s">forum topic</a> originally posted by %s in the group %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id), $group_link);
                    } else {
                        if ($activity->type == 'new_forum_post') {
                            $action = sprintf(__('%s reshared a <a href="%s">forum reply</a> originally posted by %s in the group %s', 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $activity->primary_link, $secondary_avatar . bp_core_get_userlink($activity->user_id), $group_link);
                        } else {
                            $action = sprintf(__("%s reshared an activity originally shared by %s in the group %s", 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $secondary_avatar . bp_core_get_userlink($activity->user_id), $group_link);
                        }
                    }
                }
            }
        }
    } else {
        $action = sprintf(__("%s reshared an activity originally shared by %s", 'bp-reshare'), bp_core_get_userlink($bp->loggedin_user->id), $secondary_avatar . bp_core_get_userlink($activity->user_id));
    }
    $reshared_args = array('action' => apply_filters('bp_reshare_action_parent_activity', $action, $activity->type), 'content' => $activity->content, 'component' => $component, 'type' => 'reshare_update', 'user_id' => $bp->loggedin_user->id, 'secondary_item_id' => $activity_id, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => $activity->hide_sitewide);
    if (!empty($item_id)) {
        $reshared_args['item_id'] = $item_id;
    }
    return apply_filters('bp_reshare_prepare_reshare', $reshared_args, $activity_id);
}
/**
 * Get the base url for the component gallery home page
 * e.g http://site.com/members/user-name/gallery //without any trailing slash
 * 
 * @param type $component
 * @return type
 * 
 * @todo In future, avoid dependecy on BuddyPress
 * 
 */
function mpp_get_gallery_base_url($component, $component_id)
{
    $base_url = '';
    if ($component == 'members') {
        $base_url = mpp_get_user_url($component_id) . MPP_GALLERY_SLUG;
    } elseif ($component == 'groups' && function_exists('bp_get_group_permalink')) {
        $base_url = bp_get_group_permalink(new BP_Groups_Group($component_id)) . MPP_GALLERY_SLUG;
    }
    //for admin new/edit gallery, specially new gallery
    if (!$base_url && (empty($component) || empty($component_id))) {
        $base_url = mpp_get_user_url(get_current_user_id()) . MPP_GALLERY_SLUG;
    }
    return apply_filters('mpp_get_gallery_base_url', untrailingslashit($base_url), $component, $component_id);
}
 public function setup_nav($current_user_access)
 {
     $bp = buddypress();
     if (!bp_is_group()) {
         return;
     }
     $group_id = bp_get_current_group_id();
     if (bcg_is_disabled($group_id)) {
         return;
     }
     $current_group = groups_get_current_group();
     $group_link = bp_get_group_permalink($current_group);
     bp_core_new_subnav_item(array('name' => __('Blog', 'blog-categories-for-groups'), 'slug' => BCG_SLUG, 'parent_url' => $group_link, 'parent_slug' => $current_group->slug, 'screen_function' => array($this, 'display'), 'position' => 10, 'user_has_access' => $current_user_access, 'item_css_id' => 'blog'));
 }
 public function test_group_nav()
 {
     $bp_nav = buddypress()->bp_nav;
     $u = $this->factory->user->create();
     $g = $this->factory->group->create();
     $old_current_user = get_current_user_id();
     $this->set_current_user($u);
     $group = groups_get_group(array('group_id' => $g));
     $this->go_to(bp_get_group_permalink($group));
     $this->assertTrue(buddypress()->bp_nav[$group->slug]['position'] === -1);
     // Clean up
     buddypress()->bp_nav = $bp_nav;
     $this->set_current_user($old_current_user);
 }
/**
 * Builds the BuddyDrive Group url
 *
 * @param integer $group_id the group id
 * @uses groups_get_group to get group datas
 * @uses groups_get_current_group() if no id was given to get current group datas
 * @uses bp_get_group_permalink() to build the group permalink
 * @uses buddydrive_get_slug() to get the BuddyDrive slug to end to the group url
 * @return string $buddydrive_link the link to user's BuddyDrive
 */
function buddydrive_get_group_buddydrive_url($group_id = 0)
{
    $buddydrive_link = false;
    if (!empty($group_id)) {
        $group = groups_get_group(array('group_id' => $group_id));
    } else {
        $group = groups_get_current_group();
    }
    if (!empty($group)) {
        $group_link = bp_get_group_permalink($group);
        $buddydrive_link = trailingslashit($group_link . buddydrive_get_slug());
    }
    return $buddydrive_link;
}
示例#18
0
/**
 * bp_group_documents_record_activity()
 *
 * If the activity stream component is installed, this function will record upload
 * and edit activity items.
 */
function bp_group_documents_record_activity($args = '')
{
    global $bp;
    if (!function_exists('bp_activity_add')) {
        return false;
    }
    $defaults = array('primary_link' => bp_get_group_permalink($bp->groups->current_group), 'component_name' => 'groups', 'component_action' => false, 'hide_sitewide' => false, 'user_id' => $bp->loggedin_user->id, 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => false, 'content' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // If the group is not public, don't broadcast updates.
    if ('public' != $bp->groups->current_group->status) {
        $hide_sitewide = 1;
    }
    return bp_activity_add(array('content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'hide_sitewide' => $hide_sitewide, 'action' => $action));
}
示例#19
0
function mpp_group_form_uploaded_activity_action($action, $activity, $media_id, $media_ids, $gallery)
{
    if ($gallery->component != 'groups') {
        return $action;
    }
    $media_count = count($media_ids);
    $type = $gallery->type;
    //we need the type plural in case of mult
    $type = _n($type, $type . 's', $media_count);
    //photo vs photos etc
    $group_id = $activity->item_id;
    $group = new BP_Groups_Group($group_id);
    $group_link = sprintf("<a href='%s'>%s</a>", bp_get_group_permalink($group), bp_get_group_name($group));
    $action = sprintf(__('%s uploaded %d new %s to %s', 'mediapress'), mpp_get_user_link($activity->user_id), $media_count, $type, $group_link);
    return $action;
}
 public function edit_screen_save($group_id = null)
 {
     $bp = buddypress();
     if (!isset($_POST['save'])) {
         return false;
     }
     check_admin_referer('groups_edit_save_' . $this->slug);
     $group_id = $bp->groups->current_group->id;
     $cats = $_POST['blog_cats'];
     if (!bcg_update_categories($group_id, $cats)) {
         bp_core_add_message(__('There was an error updating Group Blog Categories settings, please try again.', 'bcg'), 'error');
     } else {
         bp_core_add_message(__('Group Blog Categories settings were successfully updated.', 'bcg'));
     }
     bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . '/admin/' . $this->slug);
 }
/**
 * Adds the Group Admin top-level menu to group pages
 *
 * @package BuddyPress
 * @since 1.5
 *
 * @todo Add dynamic menu items for group extensions
 */
function bp_groups_group_admin_menu()
{
    global $nxt_admin_bar, $bp;
    // Only show if viewing a group
    if (!bp_is_group()) {
        return false;
    }
    // Only show this menu to group admins and super admins
    if (!is_super_admin() && !bp_group_is_admin()) {
        return false;
    }
    if ('3.2' == bp_get_major_nxt_version()) {
        // Group avatar
        $avatar = bp_core_fetch_avatar(array('object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'width' => 16, 'height' => 16));
        // Unique ID for the 'My Account' menu
        $bp->group_admin_menu_id = !empty($avatar) ? 'group-admin-with-avatar' : 'group-admin';
        // Add the top-level Group Admin button
        $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => $avatar . bp_get_current_group_name(), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    } elseif ('3.3' == bp_get_major_nxt_version()) {
        // Unique ID for the 'My Account' menu
        $bp->group_admin_menu_id = 'group-admin';
        // Add the top-level Group Admin button
        $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    }
    // Group Admin > Edit details
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'edit-details', 'title' => __('Edit Details', 'buddypress'), 'href' => bp_get_groups_action_link('admin/edit-details')));
    // Group Admin > Group settings
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-settings', 'title' => __('Edit Settings', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-settings')));
    // Group Admin > Group avatar
    if (!(int) bp_get_option('bp-disable-avatar-uploads')) {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-avatar', 'title' => __('Edit Avatar', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-avatar')));
    }
    // Group Admin > Manage invitations
    if (bp_is_active('friends')) {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-invitations', 'title' => __('Manage Invitations', 'buddypress'), 'href' => bp_get_groups_action_link('send-invites')));
    }
    // Group Admin > Manage members
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-members', 'title' => __('Manage Members', 'buddypress'), 'href' => bp_get_groups_action_link('admin/manage-members')));
    // Group Admin > Membership Requests
    if (bp_get_group_status($bp->groups->current_group) == 'private') {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'membership-requests', 'title' => __('Membership Requests', 'buddypress'), 'href' => bp_get_groups_action_link('admin/membership-requests')));
    }
    // Delete Group
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'delete-group', 'title' => __('Delete Group', 'buddypress'), 'href' => bp_get_groups_action_link('admin/delete-group')));
}
 public function test_backcompat_remove_group_nav_items()
 {
     $g1 = $this->factory->group->create();
     // In group context
     $g_obj = groups_get_group($g1);
     $this->go_to(bp_get_group_permalink($g_obj));
     bp_core_new_subnav_item(array('name' => 'Clam', 'slug' => 'clam', 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => bp_get_group_permalink($g_obj), 'screen_function' => 'clam_subnav'));
     bp_core_remove_subnav_item($g_obj->slug, 'clam');
     $nav = bp_get_nav_menu_items('groups');
     $found = false;
     foreach ($nav as $_nav) {
         if ('clam' === $_nav->css_id) {
             $found = true;
             break;
         }
     }
     $this->assertFalse($found);
 }
示例#23
0
/**
 * Get the base url for the component gallery home page
 * e.g http://site.com/members/user-name/gallery //without any trailing slash
 * 
 * @param type $component
 * @return type
 * 
 * @todo In future, avoid dependecy on BuddyPress
 * 
 */
function mpp_get_gallery_base_url($component, $component_id)
{
    $base_url = '';
    if ($component == 'members') {
        if (function_exists('bp_core_get_user_domain')) {
            $base_url = bp_core_get_user_domain($component_id) . MPP_GALLERY_SLUG;
        } else {
            $base_url = get_author_posts_url($component_id);
        }
    } elseif ($component == 'groups' && function_exists('bp_get_group_permalink')) {
        $base_url = bp_get_group_permalink(new BP_Groups_Group($component_id)) . MPP_GALLERY_SLUG;
    }
    //for admin new/edit gallery, specially new gallery
    if (!$base_url && (empty($component) || empty($component_id))) {
        $base_url = bp_core_get_user_domain(get_current_user_id()) . MPP_GALLERY_SLUG;
    }
    return apply_filters('mpp_get_gallery_base_url', $base_url, $component, $component_id);
}
示例#24
0
function bp_forums_directory_forums_setup() {
	global $bp;

	if ( $bp->current_component == $bp->forums->slug ) {
		if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) )
			return false;

		if ( !bp_forums_is_installed_correctly() ) {
			bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
			bp_core_redirect( $bp->root_domain );
		}

		$bp->is_directory = true;

		do_action( 'bbpress_init' );

		/* Check to see if the user has posted a new topic from the forums page. */
		if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
			/* Check the nonce */
			check_admin_referer( 'bp_forums_new_topic' );

			if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
				/* Auto join this user if they are not yet a member of this group */
				if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
					groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );

				if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
					if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) )
						bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
					else
						bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );

					bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
				} else {
					bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
				}
			}
		}

		do_action( 'bp_forums_directory_forums_setup' );

		bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
	}
}
示例#25
0
/**
 * Format 'new_group_deposit' activity action.
 *
 * @param object $activity Activity data.
 * @return string $action Formatted activity action.
 */
function humcore_format_activity_action_new_group_deposit($action, $activity)
{
    $item_post = get_post($activity->secondary_item_id);
    $item_link = sprintf('<a href="%1$s">%2$s</a>', esc_url($activity->primary_link), esc_html($item_post->post_title));
    $post_metadata = json_decode(get_post_meta($activity->secondary_item_id, '_deposit_metadata', true), true);
    if (!empty($post_metadata['committee_id'])) {
        $committee = groups_get_group(array('group_id' => $post_metadata['committee_id']));
        $initiator_url = trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $committee->slug . '/');
        $initiator_name = $committee->name;
        $initiator_link = sprintf('<a href="%1$sdeposits/">%2$s</a>', esc_url($initiator_url), esc_html($initiator_name));
    } else {
        $initiator_url = bp_core_get_userlink($activity->user_id, false, true);
        $initiator_name = bp_core_get_userlink($activity->user_id, true, false);
        $initiator_link = sprintf('<a href="%1$sdeposits/">%2$s</a>', esc_url($initiator_url), esc_html($initiator_name));
    }
    $group = groups_get_group(array('group_id' => $activity->item_id));
    $group_link = sprintf('<a href="%1$sdeposits/">%2$s</a>', esc_url(bp_get_group_permalink($group)), esc_html($group->name));
    $action = sprintf(__('%1$s deposited %2$s in the group %3$s', 'humcore_domain'), $initiator_link, $item_link, $group_link);
    return apply_filters('humcore_format_activity_action_new_group_deposit', $action, $activity);
}
 /**
  * Appends course information to group header
  */
 function course_group_header()
 {
     global $bp;
     if (!$this->has_course_caps($bp->loggedin_user->id) || !BPSP_Roles::can_teach($bp->loggedin_user->id)) {
         return;
     }
     $c = $this->has_courses();
     if (!empty($c[0])) {
         $this->current_course = $c[0]->ID;
         $vars['name'] = '_course_group_header';
         $vars['echo'] = false;
         $vars['course'] = $c[0];
     } else {
         $vars['name'] = '_no_course_group_header';
         $vars['echo'] = false;
         $this->current_uri = bp_get_group_permalink($bp->groups->current_group) . $bp->courseware->slug;
         $vars['init_course_link'] = $this->current_uri . '/course/edit';
     }
     echo BPSP_Groups::load_template($vars);
 }
/**
 * Add the Group Admin top-level menu when viewing group pages.
 *
 * @since 1.5.0
 *
 * @todo Add dynamic menu items for group extensions.
 *
 * @return false|null False if not on a group page, or if user does not have
 *                    access to group admin options.
 */
function bp_groups_group_admin_menu()
{
    global $wp_admin_bar;
    $bp = buddypress();
    // Only show if viewing a group.
    if (!bp_is_group() || bp_is_group_create()) {
        return false;
    }
    // Only show this menu to group admins and super admins.
    if (!bp_current_user_can('bp_moderate') && !bp_group_is_admin()) {
        return false;
    }
    // Unique ID for the 'Edit Group' menu.
    $bp->group_admin_menu_id = 'group-admin';
    // Add the top-level Group Admin button.
    $wp_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    // Index of the Manage tabs parent slug.
    $nav_index = $bp->groups->current_group->slug . '_manage';
    // Check if current group has Manage tabs.
    if (empty($bp->bp_options_nav[$nav_index])) {
        return;
    }
    // Build the Group Admin menus.
    foreach ($bp->bp_options_nav[$nav_index] as $menu) {
        /**
         * Should we add the current manage link in the Group's "Edit" Admin Bar menu ?
         *
         * All core items will be added, plugins can use a new parameter in the BP Group Extension API
         * to also add the link to the "edit screen" of their group component. To do so, set the
         * the 'show_in_admin_bar' argument of your edit screen to true
         */
        if ($menu['show_in_admin_bar']) {
            $title = sprintf(_x('Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress'), $menu['name']);
            // Title is specific for delete.
            if ('delete-group' == $menu['slug']) {
                $title = sprintf(_x('%s Group', 'Group WP Admin Bar delete link', 'buddypress'), $menu['name']);
            }
            $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => $menu['slug'], 'title' => $title, 'href' => bp_get_groups_action_link('admin/' . $menu['slug'])));
        }
    }
}
示例#28
0
 /**
  * Gets user data for a forum reply or article comment
  */
 function get_data($group_id)
 {
     // Get the meta from cache
     $allmeta = wp_cache_get('bp_groups_allmeta_' . $group_id, 'bp');
     // Otherwise query the groupmeta table
     if (false === $allmeta) {
         global $bp, $wpdb;
         $allmeta = array();
         $rawmeta = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id));
         foreach ($rawmeta as $meta) {
             $allmeta[$meta->meta_key] = $meta->meta_value;
         }
         wp_cache_set('bp_groups_allmeta_' . $group_id, $allmeta, 'bp');
     }
     // Add data to the class object
     $this->id = $group_id;
     $this->fullname = bp_get_group_name();
     $this->domain = bp_get_group_permalink();
     $this->slug = bp_get_group_slug();
     $this->guild = isset($allmeta['is_guild']) ? $allmeta['is_guild'] : 0;
     $this->members = bp_get_group_member_count();
     $this->alliance = isset($allmeta['group_faction']) ? $allmeta['group_faction'] : 'neutral';
     $this->server = isset($allmeta['group_server']) ? $allmeta['group_server'] : NULL;
     $this->style = isset($allmeta['group_style']) ? $allmeta['group_style'] : NULL;
     $this->interests = isset($allmeta['group_interests']) ? unserialize($allmeta['group_interests']) : array();
     $this->website = isset($allmeta['group_website']) ? $allmeta['group_website'] : NULL;
     // Get some derived data
     $this->type = $this->type();
     $this->faction = $this->allegiance();
     $this->servname = $this->server_name($this->server);
     $this->tooltip = $this->tooltip();
     // Get some extra stuff on user profiles
     if ($this->context == 'profile') {
         $this->byline = $this->byline();
         $this->admins = $this->admins();
         $this->mods = $this->mods();
     }
 }
示例#29
0
function bp_gtm_filter_short_links($content)
{
    global $bp;
    $gtm_link = bp_get_group_permalink() . $bp->gtm->slug . '/';
    $i = $j = 0;
    if (preg_match_all('~([#]+([TP])(\\d+))~', $content, $data, PREG_SET_ORDER)) {
        $content = strip_tags($content, '<p>');
        // prevent duplicate <a> tags in comments
        $content = nl2br($content);
        //print_var($data);
        foreach ((array) $data as $match) {
            if ($match[2] == 'T') {
                $name = bp_gtm_get_el_name_by_id($match[3], 'task');
                if (!$name) {
                    $name = __('doesn\'t exist', 'bp_gtm');
                    $color = 'color-red';
                }
                if (!$i) {
                    /// prevent duplicate <a> tags in comments
                    $content = str_replace($match[1], '<a class="' . $color . '" href="' . $gtm_link . 'tasks/view/' . $match[3] . '" title="' . __('Task:', 'bp_gtm') . ' ' . $name . '">' . $match[1] . '</a>', $content);
                }
                $i++;
            } elseif ($match[2] == 'P') {
                $name = bp_gtm_get_el_name_by_id($match[3], 'project');
                if (!$name) {
                    $name = __('doesn\'t exist', 'bp_gtm');
                    $color = 'color-red';
                }
                if (!$j) {
                    /// prevent duplicate <a> tags in comments
                    $content = str_replace($match[1], '<a class="' . $color . '" href="' . $gtm_link . 'projects/view/' . $match[3] . '" title="' . __('Project:', 'bp_gtm') . ' ' . $name . '">' . $match[1] . '</a>', $content);
                }
                $j++;
            }
        }
    }
    return $content;
}
/**
 * Add the Group Admin top-level menu when viewing group pages.
 *
 * @since BuddyPress (1.5.0)
 *
 * @todo Add dynamic menu items for group extensions.
 */
function bp_groups_group_admin_menu()
{
    global $wp_admin_bar, $bp;
    // Only show if viewing a group
    if (!bp_is_group()) {
        return false;
    }
    // Only show this menu to group admins and super admins
    if (!bp_current_user_can('bp_moderate') && !bp_group_is_admin()) {
        return false;
    }
    // Unique ID for the 'Edit Group' menu
    $bp->group_admin_menu_id = 'group-admin';
    // Add the top-level Group Admin button
    $wp_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    // Group Admin > Edit details
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'edit-details', 'title' => __('Edit Details', 'buddypress'), 'href' => bp_get_groups_action_link('admin/edit-details')));
    // Group Admin > Group settings
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-settings', 'title' => __('Edit Settings', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-settings')));
    // Group Admin > Group avatar
    if (!(int) bp_get_option('bp-disable-avatar-uploads')) {
        $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-avatar', 'title' => __('Edit Avatar', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-avatar')));
    }
    // Group Admin > Manage invitations
    if (bp_is_active('friends')) {
        $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-invitations', 'title' => __('Manage Invitations', 'buddypress'), 'href' => bp_get_groups_action_link('send-invites')));
    }
    // Group Admin > Manage members
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-members', 'title' => __('Manage Members', 'buddypress'), 'href' => bp_get_groups_action_link('admin/manage-members')));
    // Group Admin > Membership Requests
    if (bp_get_group_status($bp->groups->current_group) == 'private') {
        $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'membership-requests', 'title' => __('Membership Requests', 'buddypress'), 'href' => bp_get_groups_action_link('admin/membership-requests')));
    }
    // Delete Group
    $wp_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'delete-group', 'title' => __('Delete Group', 'buddypress'), 'href' => bp_get_groups_action_link('admin/delete-group')));
}