function bp_get_groups_action_link($action = '', $query_args = '', $nonce = false)
 {
     global $bp;
     // Must be displayed user
     if (empty($bp->groups->current_group->id)) {
         return;
     }
     // Append $action to $url if there is no $type
     if (!empty($action)) {
         $url = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/' . $action;
     } else {
         $url = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug;
     }
     // Add a slash at the end of our user url
     $url = trailingslashit($url);
     // Add possible query arg
     if (!empty($query_args) && is_array($query_args)) {
         $url = add_query_arg($query_args, $url);
     }
     // To nonce, or not to nonce...
     if (true === $nonce) {
         $url = wp_nonce_url($url);
     } elseif (is_string($nonce)) {
         $url = wp_nonce_url($url, $nonce);
     }
     // Return the url, if there is one
     if (!empty($url)) {
         return $url;
     }
 }
function groups_notification_group_updated($group_id)
{
    global $bp;
    $group = new BP_Groups_Group($group_id);
    $sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
    $subject = '[' . $sitename . '] ' . __('Group Details Updated', 'buddypress');
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        if ('no' == bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message
        $to = $ud->user_email;
        $group_link = site_url(bp_get_groups_root_slug() . '/' . $group->slug);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated:

To view the group: %2$s

---------------------
', 'buddypress'), $group->name, $group_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_updated_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
Example #3
0
 /**
  * Load Custom tabs on BuddyPress
  *
  * @global object $bp global BuddyPress object
  */
 function custom_media_nav_tab()
 {
     global $bp;
     if (!function_exists("bp_core_new_nav_item")) {
         return;
     }
     if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) {
         return;
     }
     global $rtmedia;
     if (function_exists("bp_is_group") && !bp_is_group()) {
         if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) {
             $profile_counts = $this->actual_counts($bp->displayed_user->id);
         }
         $tab_position = apply_filters('rtmedia_media_tab_position', 99);
         if ($rtmedia->options["buddypress_enableOnProfile"] != 0) {
             bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position));
         }
     }
     if (bp_is_group() && $rtmedia->options["buddypress_enableOnGroup"] != 0) {
         global $bp;
         $media_enabled = true;
         //filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality
         $media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled);
         // check if current user can view this group
         $current_group = groups_get_current_group();
         $is_visible_to_current_user = $current_group->is_visible;
         if ($media_enabled && $is_visible_to_current_user) {
             $group_counts = $this->actual_counts($bp->groups->current_group->id, "group");
             $bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . RTMEDIA_MEDIA_SLUG, 'slug' => RTMEDIA_MEDIA_SLUG, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all');
         }
     }
 }
 function add_cover()
 {
     if (!is_user_logged_in()) {
         return;
     }
     $user_ID = get_current_user_id();
     $output = '';
     if (groups_is_user_mod($user_ID, $this->group_id) || groups_is_user_admin($user_ID, $this->group_id)) {
         if ($this->get_cover()) {
             $message = __("Change Cover", 'bpcp');
         } else {
             $message = __("Add Cover", 'bpcp');
         }
         $group = groups_get_group(array('group_id' => $this->group_id));
         $group_permalink = trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/');
         $output .= '<div class="profile-cover-action">';
         $output .= '<a href="' . trailingslashit($group_permalink . 'admin') . $this->slug . '" class="button">' . $message . '</a>';
         $output .= '</div>';
     }
     $default_cover = bp_get_option('bpcp-group-default');
     if ($this->get_cover() || $default_cover) {
         $output .= '<div class="profile-cover-inner"></div>';
     }
     echo $output;
 }
Example #5
0
 /**
  * Load Custom tabs on BuddyPress
  *
  * @global object $bp global BuddyPress object
  */
 function custom_media_nav_tab()
 {
     $bp = buddypress();
     if (!function_exists('bp_core_new_nav_item')) {
         return;
     }
     if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) {
         return;
     }
     global $rtmedia;
     if (function_exists('bp_is_group') && !bp_is_group()) {
         if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) {
             $profile_counts = $this->actual_counts($bp->displayed_user->id);
         }
         $tab_position = apply_filters('rtmedia_media_tab_position', 99);
         if (0 !== intval($rtmedia->options['buddypress_enableOnProfile'])) {
             bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position));
         }
     }
     if (bp_is_group() && 0 !== intval($rtmedia->options['buddypress_enableOnGroup'])) {
         $media_enabled = true;
         //filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality
         $media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled);
         // check if current user can view this group
         $current_group = groups_get_current_group();
         /**
          * remove `$current_group->is_visible` and add `bp_group_is_visible( $current_group )`
          * reason   : In Buddypress 2.7 `is_visible` return false so we can't display `media` tab on group
          * issue id	: http://git.rtcamp.com/rtmedia/rtMedia/issues/119
          */
         // $is_visible_to_current_user = $current_group->is_visible;
         $is_visible_to_current_user = bp_group_is_visible($current_group);
         if ($media_enabled && $is_visible_to_current_user) {
             $group_counts = $this->actual_counts($bp->groups->current_group->id, 'group');
             $slug = apply_filters('rtmedia_group_media_tab_slug', RTMEDIA_MEDIA_SLUG);
             if (isset($bp->version) && $bp->version > '2.5.3') {
                 /*
                  * As from BuddyPress 2.6, you can't access $bp->bp_options_nav directly.
                  * Use `bp_core_new_subnav_item` to add subnav item.
                  *
                  * Check https://buddypress.trac.wordpress.org/ticket/6534 and https://buddypress.trac.wordpress.org/changeset/10745
                  * for more details
                  */
                 bp_core_new_subnav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/'), 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all'));
             } else {
                 $bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all');
             }
         }
     }
 }
Example #6
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);
}
 /**
  * figure out the current used buddypress group_id
  *
  * @since   0.1
  * @access public
  * @returns int  $group_id
  */
 public function bd_docs_get_current_group_id()
 {
     $group_id = false;
     if (bp_docs_is_bp_docs_page() && NULL !== bp_docs_get_current_doc()) {
         $group_id = bp_docs_get_associated_group_id(get_the_ID());
     } else {
         $path = $_SERVER['REQUEST_URI'];
         $p_arr = explode('/', $path);
         if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) {
             $slug = $p_arr[2];
             $group_id = BP_Groups_Group::get_id_from_slug($slug);
         } else {
             $u = parse_url(wp_get_referer());
             $path = $u['path'];
             $p_arr = explode('/', $path);
             if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) {
                 $slug = $p_arr[2];
                 $group_id = BP_Groups_Group::get_id_from_slug($slug);
             }
         }
     }
     return $group_id;
 }
Example #8
0
if ($cb_bp_current_component == 'groups' && ($cb_bp_current_action == 'my-groups' || $cb_bp_current_action == 'invites')) {
    $cb_title_prefix = NULL;
    $cb_title = __('Groups', 'cubell');
}
if ($cb_bp_current_component == 'settings') {
    $cb_title_prefix = '<span>' . __('Settings', 'cubell') . ' <i class="icon-long-arrow-right"></i></span> ';
}
if ($cb_bp_current_component == 'forums') {
    $cb_title_prefix = '<span>' . __('Forums', 'cubell') . ' <i class="icon-long-arrow-right"></i></span> ';
}
if ($cb_bp_current_component == 'activity' && $cb_bp_current_action == NULL) {
    $cb_title = __('Latest Activity', 'cubell');
    $cb_breadcrumbs_override = true;
}
if ($cb_bp_current_component == 'groups' && $cb_bp_current_action == NULL) {
    $cb_title = '<span>' . __('Groups', 'cubell') . ' ' . '<a class="cb-group-create cb-tip-bot" title="' . __('Create a Group', 'buddypress') . '" href="' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create') . '"><i class="icon-plus"></i></a>';
    $cb_group_creator = NULL;
}
if ($cb_bp_current_component == 'groups' && $cb_bp_current_action == 'create') {
    $cb_title_prefix = '<span>' . __('Groups', 'cubell') . ' <i class="icon-long-arrow-right"></i></span> ';
    $cb_title = __('Create a Group', 'buddypress');
}
if ((string) (int) $cb_bp_current_action == $cb_bp_current_action && $cb_bp_current_component == 'activity') {
    $cb_bp_class = 'cb-activity-stream ';
    $cb_title_prefix = NULL;
    $cb_title = __('Activity', 'cubell');
}
$cb_title = '<h1 id="cb-cat-title">' . $cb_title_prefix . $cb_title . '</h1>';
$cb_user_page = 'cb-author-page ';
$cb_sidebar_position = NULL;
if ($cb_buddypress_sidebar == 'sidebar_left') {
/**
 * A javascript-free implementation of the search functions in BuddyPress.
 *
 * @param string $slug The slug to redirect to for searching.
 */
function bp_core_action_search_site($slug = '')
{
    if (!bp_is_current_component(bp_get_search_slug())) {
        return;
    }
    if (empty($_POST['search-terms'])) {
        bp_core_redirect(bp_get_root_domain());
        return;
    }
    $search_terms = stripslashes($_POST['search-terms']);
    $search_which = !empty($_POST['search-which']) ? $_POST['search-which'] : '';
    $query_string = '/?s=';
    if (empty($slug)) {
        switch ($search_which) {
            case 'posts':
                $slug = '';
                $var = '/?s=';
                // If posts aren't displayed on the front page, find the post page's slug.
                if ('page' == get_option('show_on_front')) {
                    $page = get_post(get_option('page_for_posts'));
                    if (!is_wp_error($page) && !empty($page->post_name)) {
                        $slug = $page->post_name;
                        $var = '?s=';
                    }
                }
                break;
            case 'blogs':
                $slug = bp_is_active('blogs') ? bp_get_blogs_root_slug() : '';
                break;
            case 'forums':
                $slug = bp_is_active('forums') ? bp_get_forums_root_slug() : '';
                $query_string = '/?fs=';
                break;
            case 'groups':
                $slug = bp_is_active('groups') ? bp_get_groups_root_slug() : '';
                break;
            case 'members':
            default:
                $slug = bp_get_members_root_slug();
                break;
        }
        if (empty($slug) && 'posts' != $search_which) {
            bp_core_redirect(bp_get_root_domain());
            return;
        }
    }
    bp_core_redirect(apply_filters('bp_core_search_site', home_url($slug . $query_string . urlencode($search_terms)), $search_terms));
}
 function migrate_single_media($result, $album = false)
 {
     $blog_id = get_current_blog_id();
     $old = $result;
     if (function_exists('bp_core_get_table_prefix')) {
         $bp_prefix = bp_core_get_table_prefix();
     } else {
         $bp_prefix = '';
     }
     global $wpdb;
     if (false !== $album && !is_object($result)) {
         $id = $wpdb->get_var($wpdb->prepare("select ID from {$this->bmp_table} where media_id = %d", $result));
         if (null == $id) {
             $sql = "select\n                        a.post_id as 'post_id',\n                        a.meta_value as 'privacy',\n                        b.meta_value as 'context_id',\n                        c.meta_value as 'activity_id',\n                        p.post_type,\n                        p.post_mime_type,\n                        p.post_author as 'media_author',\n                        p.post_title as 'media_title',\n                        p.post_parent as 'parent'\n                    from\n                        {$wpdb->postmeta} a\n                            left join\n                        {$wpdb->postmeta} b ON ((a.post_id = b.post_id)\n                            and (b.meta_key = 'bp-media-key'))\n                            left join\n                        {$wpdb->postmeta} c ON (a.post_id = c.post_id)\n                            and (c.meta_key = 'bp_media_child_activity')\n                            left join\n                        {$wpdb->posts} p ON (a.post_id = p.ID)\n                    where\n                        a.post_id = %d and (NOT p.ID IS NULL)\n                            and a.meta_key = 'bp_media_privacy'";
             $result = $wpdb->get_row($wpdb->prepare($sql, $result));
         } else {
             return $id;
         }
     }
     if (!isset($result) || !isset($result->post_id)) {
         return $old;
     }
     $media_id = $result->post_id;
     if (intval($result->context_id) > 0) {
         $media_context = 'profile';
         $prefix = 'users/' . abs(intval($result->context_id));
     } else {
         $media_context = 'group';
         $prefix = bp_get_groups_root_slug() . abs(intval($result->context_id));
     }
     $old_type = '';
     if ('attachment' != $result->post_type) {
         $media_type = 'album';
     } else {
         $mime_type = strtolower($result->post_mime_type);
         $old_type = '';
         if (0 === strpos($mime_type, 'image')) {
             $media_type = 'photo';
             $old_type = 'photos';
         } else {
             if (0 === strpos($mime_type, 'audio')) {
                 $media_type = 'music';
                 $old_type = 'music';
             } else {
                 if (0 === strpos($mime_type, 'video')) {
                     $media_type = 'video';
                     $old_type = 'videos';
                 } else {
                     $media_type = 'other';
                 }
             }
         }
     }
     $activity_data = $wpdb->get_row($wpdb->prepare("select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id));
     if ('album' != $media_type) {
         $this->importmedia($media_id, $prefix);
     }
     if ($this->table_exists($bp_prefix . 'bp_activity') && class_exists('BP_Activity_Activity')) {
         $bp_activity = new BP_Activity_Activity();
         $activity_sql = $wpdb->prepare("SELECT\n                            *\n                        FROM\n                            {$bp_prefix}bp_activity\n                        where\n                                        id in (select distinct\n                                    a.meta_value\n                                from\n                                    {$wpdb->postmeta} a\n                                        left join\n                                    {$wpdb->posts} p ON (a.post_id = p.ID)\n                                where\n                                    (NOT p.ID IS NULL) and p.ID = %d\n                and a.meta_key = 'bp_media_child_activity')", $media_id);
         $all_activity = $wpdb->get_results($activity_sql);
         remove_all_actions('wp_insert_comment');
         foreach ($all_activity as $activity) {
             $comments = $bp_activity->get_activity_comments($activity->id, $activity->mptt_left, $activity->mptt_right);
             $exclude = get_post_meta($media_id, 'rtmedia_imported_activity', true);
             if (!is_array($exclude)) {
                 $exclude = array();
             }
             if ($comments) {
                 $this->insert_comment($media_id, $comments, $exclude);
             }
         }
     }
     if (0 !== intval($result->parent)) {
         $album_id = $this->migrate_single_media($result->parent, true);
     } else {
         $album_id = 0;
     }
     if (function_exists('bp_activity_get_meta')) {
         $likes = bp_activity_get_meta($result->activity_id, 'favorite_count');
     } else {
         $likes = 0;
     }
     $wpdb->insert($this->bmp_table, array('blog_id' => $blog_id, 'media_id' => $media_id, 'media_type' => $media_type, 'context' => $media_context, 'context_id' => abs(intval($result->context_id)), 'activity_id' => $result->activity_id, 'privacy' => intval($result->privacy) * 10, 'media_author' => $result->media_author, 'media_title' => $result->media_title, 'album_id' => $album_id, 'likes' => $likes), array('%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d'));
     $last_id = $wpdb->insert_id;
     // Photo tag meta migration
     //$photo_tag_meta = get_post_meta($media_id, "bp-media-user-tags", true);
     //        if($photo_tag_meta && !empty($photo_tag_meta)){
     //            $wpdb->insert(
     //                $wpdb->prefix . "rt_rtm_media_meta", array(
     //                    'media_id' => $media_id,
     //                    'meta_key' => "user-tags",
     //                    "meta_value" =>  maybe_serialize($photo_tag_meta)), array('%d', '%s', '%s'));
     //        }
     if ('album' != $media_type && function_exists('bp_core_get_user_domain') && $activity_data) {
         if (function_exists('bp_core_get_table_prefix')) {
             $bp_prefix = bp_core_get_table_prefix();
         } else {
             $bp_prefix = '';
         }
         $activity_data->old_primary_link = $activity_data->primary_link;
         $parent_link = get_rtmedia_user_link($activity_data->user_id);
         $activity_data->primary_link = $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id;
         $this->search_and_replace($activity_data->old_primary_link, $activity_data->primary_link);
         $activity_data->action = str_replace($activity_data->old_primary_link, $activity_data->primary_link, $activity_data->action);
         $activity_data->content = str_replace($activity_data->old_primary_link, $activity_data->primary_link, $activity_data->content);
         global $last_baseurl, $last_newurl;
         $replace_img = $last_newurl;
         //$last_baseurl . "rtMedia/$prefix/";
         if (false === strpos($activity_data->content, $replace_img)) {
             $activity_data->content = str_replace($last_baseurl, $replace_img, $activity_data->content);
         }
         global $wpdb;
         $wpdb->update($bp_prefix . 'bp_activity', array('primary_link' => $activity_data->primary_link, 'action' => $activity_data->action, 'content' => $activity_data->content), array('id' => $activity_data->id));
     } else {
         if ('group' == $media_context) {
             $activity_data->old_primary_link = $activity_data->primary_link;
             $parent_link = get_rtmedia_group_link(abs(intval($result->context_id)));
             $parent_link = trailingslashit($parent_link);
             $activity_data->primary_link = trailingslashit($parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id);
             $this->search_and_replace($activity_data->old_primary_link, $activity_data->primary_link);
         } else {
             $activity_data->old_primary_link = $activity_data->primary_link;
             $parent_link = get_rtmedia_user_link($activity_data->user_id);
             $parent_link = trailingslashit($parent_link);
             $activity_data->primary_link = trailingslashit($parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id);
             $this->search_and_replace($activity_data->old_primary_link, $activity_data->primary_link);
         }
     }
     if ('' != $old_type) {
         if ('group' == $media_context) {
             $parent_link = get_rtmedia_group_link(abs(intval($result->context_id)));
             $parent_link = trailingslashit($parent_link);
             $this->search_and_replace(trailingslashit($parent_link . $old_type . '/' . $media_id), trailingslashit($parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id));
         } else {
             $parent_link = get_rtmedia_user_link($activity_data->user_id);
             $parent_link = trailingslashit($parent_link);
             $this->search_and_replace(trailingslashit($parent_link . $old_type . '/' . $media_id), trailingslashit($parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id));
         }
     }
     return $last_id;
 }
function rtmedia_pagination_page_link($page_no)
{
    global $rtmedia_media, $rtmedia_interaction, $rtmedia_query;
    $page_url = 'pg/' . $page_no;
    $site_url = is_multisite() ? trailingslashit(get_site_url(get_current_blog_id())) : trailingslashit(get_site_url());
    $author_name = get_query_var('author_name');
    $link = '';
    if ($rtmedia_interaction && isset($rtmedia_interaction->context) && $rtmedia_interaction->context->type == "profile") {
        if (function_exists("bp_core_get_user_domain")) {
            $link .= trailingslashit(bp_core_get_user_domain($rtmedia_query->media_query['media_author']));
        } else {
            $link .= $site_url . 'author/' . $author_name . '/';
        }
    } else {
        if ($rtmedia_interaction && isset($rtmedia_interaction->context) && $rtmedia_interaction->context->type == 'group') {
            if (function_exists("bp_get_current_group_slug")) {
                $link .= $site_url . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/';
            }
        } else {
            //$post = get_post ( $rtmedia_media->post_parent );
            $post = get_post(get_post_field("post_parent", $rtmedia_query->media->media_id));
            $link .= $site_url . $post->post_name . '/';
        }
    }
    $link .= RTMEDIA_MEDIA_SLUG . '/';
    if (isset($rtmedia_query->media_query["album_id"]) && intval($rtmedia_query->media_query["album_id"]) > 0) {
        $link .= $rtmedia_query->media_query["album_id"] . "/";
    }
    if (isset($rtmedia_query->action_query->media_type)) {
        if (in_array($rtmedia_query->action_query->media_type, array("photo", "music", "video", "album", "playlist"))) {
            $link .= $rtmedia_query->action_query->media_type . '/';
        }
    }
    return apply_filters('rtmedia_pagination_page_link', $link . $page_url, $link, $page_url);
}
Example #12
0
    function widget($args, $instance)
    {
        $user_id = apply_filters('bp_group_widget_user_id', '0');
        extract($args);
        if (empty($instance['group_default'])) {
            $instance['group_default'] = 'popular';
        }
        if (empty($instance['title'])) {
            $instance['title'] = __('Groups', 'buddypress');
        }
        echo $before_widget;
        $title = !empty($instance['link_title']) ? '<a href="' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()) . '">' . $instance['title'] . '</a>' : $instance['title'];
        echo $before_title . $title . $after_title;
        ?>

		<?php 
        if (bp_has_groups('user_id=' . $user_id . '&type=' . $instance['group_default'] . '&max=' . $instance['max_groups'] . '&per_page=' . $instance['max_groups'])) {
            ?>
			<div class="item-options" id="groups-list-options">
				<a href="<?php 
            echo site_url(bp_get_groups_root_slug());
            ?>
" id="newest-groups"<?php 
            if ($instance['group_default'] == 'newest') {
                ?>
 class="selected"<?php 
            }
            ?>
><?php 
            _e("Newest", 'buddypress');
            ?>
</a> |
				<a href="<?php 
            echo site_url(bp_get_groups_root_slug());
            ?>
" id="recently-active-groups"<?php 
            if ($instance['group_default'] == 'active') {
                ?>
 class="selected"<?php 
            }
            ?>
><?php 
            _e("Active", 'buddypress');
            ?>
</a> |
				<a href="<?php 
            echo site_url(bp_get_groups_root_slug());
            ?>
" id="popular-groups" <?php 
            if ($instance['group_default'] == 'popular') {
                ?>
 class="selected"<?php 
            }
            ?>
><?php 
            _e("Popular", 'buddypress');
            ?>
</a>
			</div>

			<ul id="groups-list" class="item-list">
				<?php 
            while (bp_groups()) {
                bp_the_group();
                ?>
					<li>
						<div class="item-avatar">
							<a href="<?php 
                bp_group_permalink();
                ?>
" title="<?php 
                bp_group_name();
                ?>
"><?php 
                bp_group_avatar_thumb();
                ?>
</a>
						</div>

						<div class="item">
							<div class="item-title"><a href="<?php 
                bp_group_permalink();
                ?>
" title="<?php 
                bp_group_name();
                ?>
"><?php 
                bp_group_name();
                ?>
</a></div>
							<div class="item-meta">
								<span class="activity">
								<?php 
                if ('newest' == $instance['group_default']) {
                    printf(__('created %s', 'buddypress'), bp_get_group_date_created());
                }
                if ('active' == $instance['group_default']) {
                    printf(__('active %s', 'buddypress'), bp_get_group_last_active());
                } else {
                    if ('popular' == $instance['group_default']) {
                        bp_group_member_count();
                    }
                }
                ?>
								</span>
							</div>
						</div>
					</li>

				<?php 
            }
            ?>
			</ul>
			<?php 
            wp_nonce_field('groups_widget_groups_list', '_wpnonce-groups');
            ?>
			<input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php 
            echo esc_attr($instance['max_groups']);
            ?>
" />

		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            _e('There are no groups to display.', 'buddypress');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $after_widget;
        ?>
	<?php 
    }
/**
 * Prints the group assignment of a post on the theme on the single.php template file
 * 
 * @param text $text Text for the link. Use %s as placeholder for the link, e.g 'Dieser Beitrag ist mit der Gruppe %s verknüpft.' (default) 
 * @param obj $obj Optionally a specicific post object, if not set the current post in the loop
 * @param bool $linkbuddypressgroup True for linking to the real Buddypress group page, false for the group taxonomy.
 */
function printBuddypressGroupAssignment($text = 'Dieser Beitrag ist mit der Gruppe %s verknüpft.', $obj = NULL, $linkbuddypressgroup = true)
{
    global $post;
    if (!is_null($obj)) {
        $obj = $post;
    }
    $groups = wp_get_object_terms(array($post->ID), array('buddypress_groups'));
    if ($groups) {
        $group_name = $groups[0]->name;
        $group_slug = $groups[0]->slug;
        if ($group_slug != 'keine') {
            if ($linkbuddypressgroup && function_exists('bp_get_groups_root_slug')) {
                $group_link = get_bloginfo('url') . '/' . bp_get_groups_root_slug() . '/' . $group_slug;
            } else {
                $group_link = get_term_link($groups[0]);
            }
            $link = '<a href="' . esc_url($group_link) . '" title="' . esc_attr($group_name) . '">' . esc_html($group_name) . '</a>';
            if (is_null($text)) {
                $text = 'Gruppe: %s';
            }
            ?>
			<p><?php 
            printf($text, $link);
            ?>
</p>
			<?php 
        }
    }
}
							</div>

							<?php 
        wp_nonce_field('bp_forums_new_topic');
        ?>

						</form><!-- #forum-topic-form -->

					<?php 
    } elseif (bp_is_active('groups')) {
        ?>

						<div id="message" class="info">

							<p><?php 
        printf(__("You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress'), site_url(bp_get_groups_root_slug() . '/create/'));
        ?>
</p>

						</div>

					<?php 
    }
    ?>

				<?php 
}
?>
			</div><!-- #new-topic-post -->

			<?php 
 function _register()
 {
     global $bp;
     // If admin/create names and slugs are not provided, they fall back on the main
     // name and slug for the extension
     if (!$this->admin_name) {
         $this->admin_name = $this->name;
     }
     if (!$this->admin_slug) {
         $this->admin_slug = $this->slug;
     }
     if (!$this->create_name) {
         $this->create_name = $this->name;
     }
     if (!$this->create_slug) {
         $this->create_slug = $this->slug;
     }
     if (!empty($this->enable_create_step)) {
         // Insert the group creation step for the new group extension
         $bp->groups->group_creation_steps[$this->create_slug] = array('name' => $this->create_name, 'slug' => $this->create_slug, 'position' => $this->create_step_position);
         // Attach the group creation step display content action
         add_action('groups_custom_create_steps', array(&$this, 'create_screen'));
         // Attach the group creation step save content action
         add_action('groups_create_group_step_save_' . $this->create_slug, array(&$this, 'create_screen_save'));
     }
     // When we are viewing a single group, add the group extension nav item
     if (bp_is_group()) {
         if ($this->visibility == 'public' || $this->visibility != 'public' && $bp->groups->current_group->user_has_access) {
             if ($this->enable_nav_item) {
                 bp_core_new_subnav_item(array('name' => !$this->nav_item_name ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => $bp->groups->current_group->slug, 'parent_url' => bp_get_group_permalink($bp->groups->current_group), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array(&$this, '_display_hook'), 'user_has_access' => $this->enable_nav_item));
                 // When we are viewing the extension display page, set the title and options title
                 if (bp_is_current_action($this->slug)) {
                     add_action('bp_template_content_header', create_function('', 'echo "' . esc_attr($this->name) . '";'));
                     add_action('bp_template_title', create_function('', 'echo "' . esc_attr($this->name) . '";'));
                 }
             }
             // Hook the group home widget
             if (!bp_current_action() && bp_is_current_action('home')) {
                 add_action($this->display_hook, array(&$this, 'widget_display'));
             }
         }
     }
     // Construct the admin edit tab for the new group extension
     if (!empty($this->enable_edit_item) && bp_is_item_admin()) {
         add_action('groups_admin_tabs', create_function('$current, $group_slug', '$selected = ""; if ( "' . esc_attr($this->admin_slug) . '" == $current ) $selected = " class=\\"current\\""; echo "<li{$selected}><a href=\\"' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/{$group_slug}/admin/' . esc_attr($this->admin_slug)) . '\\">' . esc_attr($this->admin_name) . '</a></li>";'), 10, 2);
         // Catch the edit screen and forward it to the plugin template
         if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable($this->admin_slug, 0)) {
             // Check whether the user is saving changes
             $this->edit_screen_save();
             add_action('groups_custom_edit_steps', array(&$this, 'edit_screen'));
             if ('' != locate_template(array('groups/single/home.php'), false)) {
                 bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home'));
             } else {
                 add_action('bp_template_content_header', create_function('', 'echo "<ul class=\\"content-header-nav\\">"; bp_group_admin_tabs(); echo "</ul>";'));
                 add_action('bp_template_content', array(&$this, 'edit_screen'));
                 bp_core_load_template(apply_filters('bp_core_template_plugin', '/groups/single/plugins'));
             }
         }
     }
 }
/**
 * Return the permalink to a given forum.
 *
 * @param int $forum_id Optional. Defaults to the current forum, if
 *        there is one.
 * @return string|bool False on failure, a URL on success.
 */
function bp_get_forum_permalink($forum_id = 0)
{
    global $bp;
    if (bp_is_groups_component()) {
        $permalink = trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_current_item() . '/forum');
    } else {
        if (empty($forum_id)) {
            global $topic_template;
            if (isset($topic_template->forum_id)) {
                $forum_id = $topic_template->forum_id;
            }
        }
        if ($forum = bp_forums_get_forum($forum_id)) {
            $permalink = trailingslashit(bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/forum/' . $forum->forum_slug);
        } else {
            return false;
        }
    }
    return apply_filters('bp_get_forum_permalink', trailingslashit($permalink));
}
function invite_anyone_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 ('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']);
        $group_slug = isset($bp->groups->root_slug) ? $bp->groups->root_slug : $bp->groups->slug;
        if (bp_is_current_action('create')) {
            $uninvite_url = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-invites/?user_id=' . $user->id;
        } else {
            $uninvite_url = bp_get_group_permalink(groups_get_current_group()) . 'send-invites/remove/' . $user->id;
        }
        echo '<li id="uid-' . $user->id . '">';
        echo bp_core_fetch_avatar(array('item_id' => $user->id));
        echo '<h4>' . bp_core_get_userlink($user->id) . '</h4>';
        echo '<span class="activity">' . esc_html($user->last_active) . '</span>';
        echo '<div class="action">
				<a class="remove" href="' . wp_nonce_url($uninvite_url) . '" id="uid-' . esc_html($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a>
			  </div>';
        echo '</li>';
    } else {
        if ('uninvite' == $_POST['friend_action']) {
            groups_uninvite_user($_POST['friend_id'], $_POST['group_id']);
        }
    }
    die;
}
	/**
	 * Return the permalink to a given forum.
	 *
	 * @param int $forum_id Optional. Defaults to the current forum, if
	 *        there is one.
	 * @return string|bool False on failure, a URL on success.
	 */
	function bp_get_forum_permalink( $forum_id = 0 ) {
		global $bp;

		if ( bp_is_groups_component() ) {
			$permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_current_item() . '/forum' );
		} else {
			if ( empty( $forum_id ) ) {
				global $topic_template;
				if ( isset( $topic_template->forum_id ) )
					$forum_id = $topic_template->forum_id;
			}

			if ( $forum = bp_forums_get_forum( $forum_id ) )
				$permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/forum/' . $forum->forum_slug );
			else
				return false;
		}

		/**
		 * Filters the permalink to a given forum.
		 *
		 * @since BuddyPress (1.0.0)
		 *
		 * @param string $value Peramlink to the given forum.
		 */
		return apply_filters( 'bp_get_forum_permalink', trailingslashit( $permalink ) );
	}
/**
 * Display the Groups admin index screen.
 *
 * This screen contains a list of all BuddyPress groups.
 *
 * @since BuddyPress (1.7.0)
 *
 * @global BP_Group_List_Table $bp_groups_list_table Group screen list table.
 * @global string $plugin_page Currently viewed plugin page.
 */
function bp_groups_admin_index()
{
    global $bp_groups_list_table, $plugin_page;
    $messages = array();
    // If the user has just made a change to a group, build status messages
    if (!empty($_REQUEST['deleted'])) {
        $deleted = !empty($_REQUEST['deleted']) ? (int) $_REQUEST['deleted'] : 0;
        if ($deleted > 0) {
            $messages[] = sprintf(_n('%s group has been permanently deleted.', '%s groups have been permanently deleted.', $deleted, 'buddypress'), number_format_i18n($deleted));
        }
    }
    // Prepare the group items for display
    $bp_groups_list_table->prepare_items();
    // Call an action for plugins to modify the messages before we display the edit form
    do_action('bp_groups_admin_index', $messages);
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress-groups');
    ?>
		<h2>
			<?php 
    _e('Groups', 'buddypress');
    ?>

			<?php 
    if (is_user_logged_in() && bp_user_can_create_groups()) {
        ?>
				<a class="add-new-h2" href="<?php 
        echo trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create');
        ?>
"><?php 
        _e('Add New', 'buddypress');
        ?>
</a>
			<?php 
    }
    ?>

			<?php 
    if (!empty($_REQUEST['s'])) {
        ?>
				<span class="subtitle"><?php 
        printf(__('Search results for &#8220;%s&#8221;', 'buddypress'), wp_html_excerpt(esc_html(stripslashes($_REQUEST['s'])), 50));
        ?>
</span>
			<?php 
    }
    ?>
		</h2>

		<?php 
    // If the user has just made a change to an group, display the status messages
    ?>
		<?php 
    if (!empty($messages)) {
        ?>
			<div id="moderated" class="<?php 
        echo !empty($_REQUEST['error']) ? 'error' : 'updated';
        ?>
"><p><?php 
        echo implode("<br/>\n", $messages);
        ?>
</p></div>
		<?php 
    }
    ?>

		<?php 
    // Display each group on its own row
    ?>
		<?php 
    $bp_groups_list_table->views();
    ?>

		<form id="bp-groups-form" action="" method="get">
			<?php 
    $bp_groups_list_table->search_box(__('Search all Groups', 'buddypress'), 'bp-groups');
    ?>
			<input type="hidden" name="page" value="<?php 
    echo esc_attr($plugin_page);
    ?>
" />
			<?php 
    $bp_groups_list_table->display();
    ?>
		</form>

	</div>

<?php 
}
    /**
     * Hook this extension's Edit panel into BuddyPress, if necessary
     *
     * @since BuddyPress (1.8)
     */
    protected function setup_edit_hooks()
    {
        // Bail if not an edit screen
        if (!$this->is_screen_enabled('edit') || !bp_is_item_admin()) {
            return;
        }
        $screen = $this->screens['edit'];
        $position = isset($screen['position']) ? (int) $screen['position'] : 10;
        // Add the tab
        // @todo BP should be using bp_core_new_subnav_item()
        add_action('groups_admin_tabs', create_function('$current, $group_slug', '$selected = "";
			if ( "' . esc_attr($screen['slug']) . '" == $current )
				$selected = " class=\\"current\\"";
			echo "<li{$selected}><a href=\\"' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/{$group_slug}/admin/' . esc_attr($screen['slug'])) . '\\">' . esc_attr($screen['name']) . '</a></li>";'), $position, 2);
        // Catch the edit screen and forward it to the plugin template
        if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable($screen['slug'], 0)) {
            $this->call_edit_screen_save($this->group_id);
            add_action('groups_custom_edit_steps', array(&$this, 'call_edit_screen'));
            // Determine the proper template and save for later
            // loading
            if ('' !== bp_locate_template(array('groups/single/home.php'), false)) {
                $this->edit_screen_template = '/groups/single/home';
            } else {
                add_action('bp_template_content_header', create_function('', 'echo "<ul class=\\"content-header-nav\\">"; bp_group_admin_tabs(); echo "</ul>";'));
                add_action('bp_template_content', array(&$this, 'call_edit_screen'));
                $this->edit_screen_template = '/groups/single/plugins';
            }
            // We load the template at bp_screens, to give all
            // extensions a chance to load
            add_action('bp_screens', array($this, 'call_edit_screen_template_loader'));
        }
    }
/**
 * Return group directory permalink.
 *
 * @since 1.5.0
 *
 * @return string
 */
function bp_get_groups_directory_permalink()
{
    /**
     * Filters the group directory permalink.
     *
     * @since 1.5.0
     *
     * @param string $value Permalink for the group directory.
     */
    return apply_filters('bp_get_groups_directory_permalink', trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()));
}
/**
 * Displays the introduction for the group and loops through each item
 *
 * I've chosen to cache on an individual-activity basis, instead of a group-by-group basis. This
 * requires just a touch more overhead (in terms of looping through individual activity_ids), and
 * doesn't really have any added effect at the moment (since an activity item can only be associated
 * with a single group). But it provides the greatest amount of flexibility going forward, both in
 * terms of the possibility that activity items could be associated with more than one group, and
 * the possibility that users within a single group would want more highly-filtered digests.
 */
function ass_digest_format_item_group($group_id, $activity_ids, $type, $group_name, $group_slug, $user_id)
{
    global $bp, $ass_email_css;
    $group_permalink = apply_filters('bp_get_group_permalink', bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group_slug . '/');
    $group_name_link = '<a href="' . $group_permalink . '" name="' . $group_slug . '">' . $group_name . '</a>';
    $userdomain = ass_digest_get_user_domain($user_id);
    $unsubscribe_link = "{$userdomain}?bpass-action=unsubscribe&group={$group_id}&access_key=" . md5("{$group_id}{$user_id}unsubscribe" . wp_salt());
    $gnotifications_link = ass_get_login_redirect_url($group_permalink . 'notifications/');
    // add the group title bar
    if ($type == 'dig') {
        $group_message = "\n<div {$ass_email_css['group_title']}>" . sprintf(__('Group: %s', 'bp-ass'), $group_name_link) . "</div>\n\n";
    } elseif ($type == 'sum') {
        $group_message = "\n<div {$ass_email_css['group_title']}>" . sprintf(__('Group: %s weekly summary', 'bp-ass'), $group_name_link) . "</div>\n";
    }
    // add change email settings link
    $group_message .= "\n<div {$ass_email_css['change_email']}>";
    $group_message .= __('To disable these notifications for this group click ', 'bp-ass') . " <a href=\"{$unsubscribe_link}\">" . __('unsubscribe', 'bp-ass') . '</a> - ';
    $group_message .= __('change ', 'bp-ass') . '<a href="' . $gnotifications_link . '">' . __('email options', 'bp-ass') . '</a>';
    $group_message .= "</div>\n\n";
    $group_message = apply_filters('ass_digest_group_message_title', $group_message, $group_id, $type);
    // Finally, add the markup to the digest
    foreach ($activity_ids as $activity_id) {
        // Cache is set earlier in ass_digest_fire()
        $activity_item = !empty($bp->ass->items[$activity_id]) ? $bp->ass->items[$activity_id] : false;
        if (!empty($activity_item)) {
            $group_message .= ass_digest_format_item($activity_item, $type);
        }
        //$group_message .= '<pre>'. $item->id .'</pre>';
    }
    return apply_filters('ass_digest_format_item_group', $group_message, $group_id, $type);
}
Example #23
0
<?php 
if (!substr_count($_SERVER['REQUEST_URI'], '/' . bp_get_members_root_slug()) && !substr_count($_SERVER['REQUEST_URI'], '/' . bp_get_groups_root_slug()) && !in_array('bp-profile', apply_filters('body_class', 'a-class')) && !in_array('bp-plugin', apply_filters('body_class', 'a-class'))) {
    ?>

		<div id="sidebar-page">

			<?php 
    dynamic_sidebar('sidebar-page');
    ?>

		</div><!-- #sidebar-page -->

	<?php 
}
/**
 * Invites a friend to join a group via a POST request.
 *
 * @since BuddyPress (1.2)
 * @todo Audit return types
 */
function bp_legacy_theme_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($friend_id);
        $uninvite_url = bp_is_current_action('create') ? bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-invites/?user_id=' . $friend_id : bp_get_group_permalink($group) . 'send-invites/remove/' . $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($uninvite_url, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</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.', 'buddypress'), $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;
    }
}
function bp_get_group_invite_user_remove_invite_url()
{
    global $invites_template;
    $user_id = intval($invites_template->invite->user->id);
    if (bp_is_current_action('create')) {
        $uninvite_url = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-invites/?user_id=' . $user_id;
    } else {
        $uninvite_url = bp_get_group_permalink(groups_get_current_group()) . 'send-invites/remove/' . $user_id;
    }
    return wp_nonce_url($uninvite_url, 'groups_invite_uninvite_user');
}
Example #26
0
 function setup_group_nav()
 {
     global $bp;
     /* Add some group subnav items */
     $user_access = false;
     $group_link = '';
     if (bp_is_active('groups') && !empty($bp->groups->current_group)) {
         $group_link = $bp->root_domain . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/';
         $user_access = $bp->groups->current_group->user_has_access;
         if (!empty($bp->current_component) && $bp->current_component == 'groups') {
             $count = EM_Events::count(array('group' => $bp->groups->current_group->id));
             if (empty($count)) {
                 $count = 0;
             }
         }
         bp_core_new_subnav_item(array('name' => __('Events', 'dbem') . " <span>{$count}</span>", 'slug' => 'events', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->current_group->slug, 'screen_function' => 'bp_em_group_events', 'position' => 50, 'user_has_access' => $user_access, 'item_css_id' => 'forums'));
     }
 }
Example #27
0
			<div id="group-dir-search" class="dir-search" role="search">

				<?php 
bp_directory_groups_search_form();
?>

			</div><!-- #group-dir-search -->

			<?php 
do_action('template_notices');
?>

			<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()));
function bp_adminbar_random_menu()
{
    global $bp;
    ?>

	<li class="align-right" id="bp-adminbar-visitrandom-menu">
		<a href="#"><?php 
    _e('Visit', 'buddypress');
    ?>
</a>
		<ul class="random-list">
			<li><a href="<?php 
    echo trailingslashit(bp_get_root_domain() . '/' . bp_get_members_root_slug()) . '?random-member';
    ?>
" rel="nofollow"><?php 
    _e('Random Member', 'buddypress');
    ?>
</a></li>

			<?php 
    if (bp_is_active('groups')) {
        ?>

				<li class="alt"><a href="<?php 
        echo trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()) . '?random-group';
        ?>
"  rel="nofollow"><?php 
        _e('Random Group', 'buddypress');
        ?>
</a></li>

			<?php 
    }
    ?>

			<?php 
    if (is_multisite() && bp_is_active('blogs')) {
        ?>

				<li><a href="<?php 
        echo trailingslashit(bp_get_root_domain() . '/' . bp_get_blogs_root_slug()) . '?random-blog';
        ?>
"  rel="nofollow"><?php 
        _e('Random Site', 'buddypress');
        ?>
</a></li>

			<?php 
    }
    ?>

			<?php 
    do_action('bp_adminbar_random_menu');
    ?>

		</ul>
	</li>

	<?php 
}
 /**
  * @author
  * @since
  */
 private function do_paging_logic()
 {
     global $bp;
     do_action('bp_group_documents_template_do_paging_logic');
     $this->items_per_page = get_option('bp_group_documents_items_per_page');
     $this->total_records = BP_Group_Documents::get_total($bp->groups->current_group->id, $this->category);
     $this->total_pages = ceil($this->total_records / $this->items_per_page);
     if (isset($_GET['page']) && ctype_digit($_GET['page'])) {
         $this->page = $_GET['page'];
         $this->start_record = ($this->page - 1) * $this->items_per_page + 1;
     }
     $last_possible = $this->items_per_page * $this->page;
     $this->end_record = $this->total_records < $last_possible ? $this->total_records : $last_possible;
     $this->action_link = get_bloginfo('url') . '/' . bp_get_groups_root_slug() . '/' . $bp->current_item . '/' . $bp->current_action . '/';
 }
function bp_get_group_creation_previous_link()
{
    global $bp;
    foreach ((array) $bp->groups->group_creation_steps as $slug => $name) {
        if (bp_is_action_variable($slug)) {
            break;
        }
        $previous_steps[] = $slug;
    }
    return apply_filters('bp_get_group_creation_previous_link', trailingslashit(bp_get_root_domain()) . bp_get_groups_root_slug() . '/create/step/' . array_pop($previous_steps));
}