本文整理汇总了PHP中groups_get_group函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_get_group函数的具体用法?PHP groups_get_group怎么用?PHP groups_get_group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_get_group函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate and sanitise the parameters for the suggestion service query.
*
* @since 2.1.0
*
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
*/
public function validate()
{
$this->args['group_id'] = (int) $this->args['group_id'];
/**
* Filters the arguments used to validate and sanitize suggestion service query.
*
* @since 2.1.0
*
* @param array $args Array of arguments for the suggestion service query.
* @param BP_Groups_Member_Suggestions $this Instance of the current suggestion class.
*/
$this->args = apply_filters('bp_groups_member_suggestions_args', $this->args, $this);
// Check for invalid or missing mandatory parameters.
if (!$this->args['group_id'] || !bp_is_active('groups')) {
return new WP_Error('missing_requirement');
}
// Check that the specified group_id exists, and that the current user can access it.
$the_group = groups_get_group(array('group_id' => absint($this->args['group_id']), 'populate_extras' => true));
if ($the_group->id === 0 || !$the_group->user_has_access) {
return new WP_Error('access_denied');
}
/**
* Filters the validation results for the suggestion service query.
*
* @since 2.1.0
*
* @param bool|WP_Error $value True if valid, WP_Error if not.
* @param BP_Groups_Member_Suggestions $this Instance of the current suggestion class.
*/
return apply_filters('bp_groups_member_suggestions_validate_args', parent::validate(), $this);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:38,代码来源:class-bp-groups-member-suggestions.php
示例2: getGroups
function getGroups($force = false)
{
//need a user id for this
if (empty($this->ID)) {
return false;
}
//check cache
if (isset($this->groups) && !$force) {
return $this->groups;
}
//remove the bp-site-groups filter
remove_filter('groups_get_groups', 'bpsg_groups_get_groups');
//get corresponding class ids for buddypress groups this user is a member of
$groups = array();
if (bp_has_groups(array('user_id' => $this->ID))) {
while (bp_groups()) {
bp_the_group();
$group_id = bp_get_group_id();
$groups[] = groups_get_group(array('group_id' => $group_id));
}
}
//add the bp-site-groups filter back
add_filter('groups_get_groups', 'bpsg_groups_get_groups');
$this->groups = $groups;
return $this->groups;
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:26,代码来源:class.SPStudent.php
示例3: __construct
/**
* Construct the class
* @version 2.0
*/
function __construct()
{
// Get the Entropy Rising group from BuddyPress
$this->group = groups_get_group(array('group_id' => $this->group_id, 'populate_extras' => true));
// Remap membership flag
$this->is_member = $this->group->is_member;
}
开发者ID:tamriel-foundry,项目名称:apoc2,代码行数:11,代码来源:entropy-rising.php
示例4: bp_em_group_event_save
/**
* @param EM_Event $EM_Event
*/
function bp_em_group_event_save($result, $EM_Event)
{
if (is_object($EM_Event) && !empty($EM_Event->event_id)) {
if (!empty($_REQUEST['group_id']) && is_numeric($_REQUEST['group_id']) && bp_is_active('groups')) {
//we have been requested an event creation tied to a group, so does this group exist, and does this person have admin rights to it?
if (groups_is_user_admin(get_current_user_id(), $_REQUEST['group_id'])) {
$EM_Event->group_id = $_REQUEST['group_id'];
}
if (!empty($EM_Event->group_id)) {
//if group is private, make it private
$group = groups_get_group(array('group_id' => $EM_Event->group_id));
$is_member = groups_is_user_member(get_current_user_id(), $EM_Event->group_id) || groups_is_user_admin(get_current_user_id(), $EM_Event->group_id) || groups_is_user_mod(get_current_user_id(), $EM_Event->group_id);
if ($group->status != 'public' && $is_member) {
//Make sure event status is private and set post status to private
global $wpdb;
$EM_Event->event_private = 1;
$wpdb->update($wpdb->posts, array('post_status' => 'private'), array('ID' => $EM_Event->post_id));
$wpdb->update(EM_EVENTS_TABLE, array('event_private' => 1), array('event_id' => $EM_Event->event_id));
}
}
} else {
$EM_Event->group_id = null;
}
}
return $result;
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:29,代码来源:bp-em-groups.php
示例5: bp_course_nav_menu
/**
* 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
}
}
开发者ID:nikitansk,项目名称:devschool,代码行数:64,代码来源:bp-course-functions.php
示例6: admin_notices
public static function admin_notices()
{
//When editing
global $post, $EM_Event, $pagenow;
if ($pagenow == 'post.php' && ($post->post_type == EM_POST_TYPE_EVENT || $post->post_type == 'event-recurring')) {
if ($EM_Event->is_recurring()) {
$warning = "<p><strong>" . __('WARNING: This is a recurring event.', 'dbem') . "</strong></p>";
$warning .= "<p>" . __('Modifications to this event will cause all recurrences of this event to be deleted and recreated and previous bookings will be deleted! You can edit individual recurrences and disassociate them with this recurring event.', 'dbem');
?>
<div class="updated"><?php
echo $warning;
?>
</div><?php
} elseif ($EM_Event->is_recurrence()) {
$warning = "<p><strong>" . __('WARNING: This is a recurrence in a set of recurring events.', 'dbem') . "</strong></p>";
$warning .= "<p>" . sprintf(__('If you update this event data and save, it could get overwritten if you edit the recurring event template. To make it an independent, <a href="%s">detach it</a>.', 'dbem'), $EM_Event->get_detach_url()) . "</p>";
$warning .= "<p>" . sprintf(__('To manage the whole set, <a href="%s">edit the recurring event template</a>.', 'dbem'), admin_url('post.php?action=edit&post=' . $EM_Event->get_event_recurrence()->post_id)) . "</p>";
?>
<div class="updated"><?php
echo $warning;
?>
</div><?php
}
if (!empty($EM_Event->group_id) && function_exists('groups_get_group')) {
$group = groups_get_group(array('group_id' => $EM_Event->group_id));
$warning = sprintf(__('WARNING: This is a event belonging to the group "%s". Other group admins can also modify this event.', 'dbem'), $group->name);
?>
<div class="updated"><p><?php
echo $warning;
?>
</p></div><?php
}
}
}
开发者ID:batruji,项目名称:metareading,代码行数:34,代码来源:em-event-post-admin.php
示例7: add_cover
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;
}
开发者ID:EfncoPlugins,项目名称:buddypress-cover-photo,代码行数:25,代码来源:group-cover.php
示例8: dispatch_creation_activity_update
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);
}
}
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:59,代码来源:eab-buddypres-activity.php
示例9: bp_forums_directory_forums_setup
/**
* 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'));
}
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:62,代码来源:bp-forums-screens.php
示例10: set_up_group
/**
* Create a group, set up nav item, and go to the group.
*/
protected function set_up_group()
{
$g = $this->factory->group->create(array('slug' => 'testgroup'));
$group = groups_get_group($g);
$group_permalink = bp_get_group_permalink($group);
$this->go_to($group_permalink);
bp_core_new_subnav_item(array('name' => 'Foo', 'slug' => 'foo', 'parent_url' => $group_permalink, 'parent_slug' => 'testgroup', 'screen_function' => 'foo_screen_function', 'position' => 10), 'groups');
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:11,代码来源:backCompat.php
示例11: bp_activity_action_permalink_router
/**
* 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);
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:75,代码来源:bp-activity-actions.php
示例12: groups_screen_group_invites
/**
* Handle the loading of a user's Groups > Invites page.
*/
function groups_screen_group_invites()
{
$group_id = (int) bp_action_variable(1);
if (bp_is_action_variable('accept') && is_numeric($group_id)) {
// Check the nonce.
if (!check_admin_referer('groups_accept_invite')) {
return false;
}
if (!groups_accept_invite(bp_loggedin_user_id(), $group_id)) {
bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group invite accepted', 'buddypress'));
// Record this in activity streams.
$group = groups_get_group(array('group_id' => $group_id));
groups_record_activity(array('type' => 'joined_group', 'item_id' => $group->id));
}
if (isset($_GET['redirect_to'])) {
$redirect_to = urldecode($_GET['redirect_to']);
} else {
$redirect_to = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action());
}
bp_core_redirect($redirect_to);
} elseif (bp_is_action_variable('reject') && is_numeric($group_id)) {
// Check the nonce.
if (!check_admin_referer('groups_reject_invite')) {
return false;
}
if (!groups_reject_invite(bp_loggedin_user_id(), $group_id)) {
bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group invite rejected', 'buddypress'));
}
if (isset($_GET['redirect_to'])) {
$redirect_to = urldecode($_GET['redirect_to']);
} else {
$redirect_to = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action());
}
bp_core_redirect($redirect_to);
}
/**
* Fires before the loading of a users Groups > Invites template.
*
* @since 1.0.0
*
* @param int $group_id ID of the group being displayed
*/
do_action('groups_screen_group_invites', $group_id);
/**
* Filters the template to load for a users Groups > Invites page.
*
* @since 1.0.0
*
* @param string $value Path to a users Groups > Invites page template.
*/
bp_core_load_template(apply_filters('groups_template_group_invites', 'members/single/home'));
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:59,代码来源:bp-groups-screens.php
示例13: test_bp_groups_format_activity_action_joined_group
/**
* @group activity_action
* @group bp_groups_format_activity_action_joined_group
*/
public function test_bp_groups_format_activity_action_joined_group()
{
$u = $this->factory->user->create();
$g = $this->factory->group->create();
$a = $this->factory->activity->create(array('component' => buddypress()->groups->id, 'type' => 'joined_group', 'user_id' => $u, 'item_id' => $g));
$a_obj = new BP_Activity_Activity($a);
$g_obj = groups_get_group($g);
$expected = sprintf(__('%s joined the group %s', 'buddypress'), bp_core_get_userlink($u), '<a href="' . bp_get_group_permalink($g_obj) . '">' . $g_obj->name . '</a>');
$this->assertSame($expected, $a_obj->action);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:14,代码来源:activity.php
示例14: cacsp_format_activity_action
/**
* 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);
}
开发者ID:sheesh,项目名称:social-paper,代码行数:62,代码来源:hooks-buddypress-activity.php
示例15: bp_activity_action_permalink_router
/**
* 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);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:71,代码来源:bp-activity-actions.php
示例16: bp_reshare_prepare_reshare
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);
}
开发者ID:KristianI,项目名称:bp-reshare,代码行数:51,代码来源:bp-reshare-functions.php
示例17: test_group_nav
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);
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:14,代码来源:bpCoreNewNavItem.php
示例18: groups_update_group_forum
/**
* Update group forum metadata (title, description, slug) when the group's details are edited.
*
* @since BuddyPress (1.1.0)
*
* @param int $group_id Group id, passed from groups_details_updated.
*/
function groups_update_group_forum($group_id)
{
$group = groups_get_group(array('group_id' => $group_id));
/**
* Bail in the following three situations:
* 1. Forums are not enabled for this group
* 2. The BP Forum component is not enabled
* 3. The built-in bbPress forums are not correctly installed (usually means they've been
* uninstalled)
*/
if (empty($group->enable_forum) || !bp_is_active('forums') || function_exists('bp_forums_is_installed_correctly') && !bp_forums_is_installed_correctly()) {
return false;
}
bp_forums_update_forum(apply_filters('groups_update_group_forum', array('forum_id' => groups_get_groupmeta($group_id, 'forum_id'), 'forum_name' => $group->name, 'forum_desc' => $group->description, 'forum_slug' => $group->slug)));
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:22,代码来源:bp-groups-forums.php
|
请发表评论