Beispiel #1
0
function bp_gtm_email_notify()
{
    global $bp;
    // Get user data
    $reciever_name = bp_core_get_user_displayname($_GET['resp_id'], false);
    $reciever_ud = get_userdata($_GET['resp_id']);
    $sender_name = bp_core_get_user_displayname($bp->loggedin_user->id, false);
    $sender_link = bp_core_get_userlink($bp->loggedin_user->id, false, true);
    // Lunks to use in email
    $reciever_personal_tasks_link = site_url(BP_MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/' . $bp->gtm->slug . '/tasks');
    $reciever_personal_projects_link = site_url(BP_MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/' . $bp->gtm->slug . '/projects');
    /* Set up and send the message */
    $to = $reciever_ud->user_email;
    $subject = get_blog_option(1, 'blogname') . ': ' . __('Assignments');
    $message = sprintf(__('Hello there %s,

%s (%s) reminds you, that pending tasks and projects you are responsible for need to be done.

To see your personal tasks click here: %s

To see your personal projects click here: %s

---------------------
%s. %s
', 'bp_gtm'), $reciever_name, $sender_name, $sender_link, $reciever_personal_tasks_link, $reciever_personal_projects_link, get_blog_option(1, 'blogname'), get_blog_option(1, 'blogdescription'));
    // Send it!
    wp_mail($to, $subject, $message);
    echo 'sent!';
}
 function block_message($message_info)
 {
     global $bp;
     $recipients = $message_info->recipients;
     foreach ($recipients as $key => $recipient) {
         // if site admin, skip check
         if ($bp->loggedin_user->is_site_admin == 1) {
             continue;
         }
         // make sure sender is not trying to send to themselves
         if ($recipient->user_id == $bp->loggedin_user->id) {
             unset($message_info->recipients[$key]);
             continue;
         }
         // check if the attempted recipient is block user
         // if we get a match, remove person from recipient list
         if ($this->check_blocking($bp->loggedin_user->id, $recipient->user_id)) {
             if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                 //if ajax - just unset
                 unset($message_info->recipients[$key]);
             } else {
                 wp_redirect(bp_core_get_userlink($recipient->user_id, false, true));
                 exit;
             }
         }
     }
 }
Beispiel #3
0
function bp_group_documents_record_delete($document)
{
    global $bp;
    $params = array('action' => sprintf(__('%s deleted the file: %s from %s', 'bp-group-documents'), bp_core_get_userlink($bp->loggedin_user->id), $document->name, '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_attr($bp->groups->current_group->name) . '</a>'), 'component_action' => 'deleted_group_document', 'secondary_item_id' => $document->id);
    bp_group_documents_record_activity($params);
    do_action('bp_group_documents_record_delete', $document);
}
Beispiel #4
0
	/**
	 * populate()
	 *
	 * Populate the instantiated class with data based on the User ID provided.
	 *
	 * @package BuddyPress Core
 	 * @global $userdata WordPress user data for the current logged in user.
	 * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
	 * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
	 * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
	 * @uses get_user_meta() WordPress function returns the value of passed usermeta name from usermeta table
	 * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
	 * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
	 */
	function populate() {
		if ( function_exists( 'xprofile_install' ) )
			$this->profile_data = $this->get_profile_data();

		if ( $this->profile_data ) {
			$this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
			$this->fullname = esc_attr( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
			$this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
			$this->email = esc_attr( $this->profile_data['user_email'] );
		} else {
			$this->user_url = bp_core_get_user_domain( $this->id );
			$this->user_link = bp_core_get_userlink( $this->id );
			$this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
			$this->email = esc_attr( bp_core_get_user_email( $this->id ) );
		}

		/* Cache a few things that are fetched often */
		wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
		wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
		wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );

		$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) );
		$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
		$this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );

		$this->last_active = bp_core_get_last_activity( get_user_meta( $this->id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) );
	}
/**
 * bp_like_post_to_stream()
 * 
 * Posts to stream, depending on settings
 * 
 * TODO, Should we be posted that people like comments to the feed? This can get messy..
 * Also no point having 20 posts saying people liked the same status..
 * 
 */
function bp_like_post_to_stream($item_id, $user_id)
{
    if (bp_like_get_settings('post_to_activity_stream') == 1) {
        $activity = bp_activity_get_specific(array('activity_ids' => $item_id, 'component' => 'buddypress-like'));
        $author_id = $activity['activities'][0]->user_id;
        if ($user_id == $author_id) {
            $action = bp_like_get_text('record_activity_likes_own');
        } elseif ($user_id == 0) {
            $action = bp_like_get_text('record_activity_likes_an');
        } else {
            $action = bp_like_get_text('record_activity_likes_users');
        }
        $liker = bp_core_get_userlink($user_id);
        $author = bp_core_get_userlink($author_id);
        $activity_url = bp_activity_get_permalink($item_id);
        $content = '';
        //content must be defined...
        /* Grab the content and make it into an excerpt of 140 chars if we're allowed */
        if (bp_like_get_settings('show_excerpt') == 1) {
            $content = $activity['activities'][0]->content;
            if (strlen($content) > bp_like_get_settings('excerpt_length')) {
                $content = substr($content, 0, bp_like_get_settings('excerpt_length'));
                $content = strip_tags($content);
                $content = $content . '...';
            }
        }
        /* Filter out the placeholders */
        $action = str_replace('%user%', $liker, $action);
        $action = str_replace('%permalink%', $activity_url, $action);
        $action = str_replace('%author%', $author, $action);
        bp_activity_add(array('action' => $action, 'content' => $content, 'primary_link' => $activity_url, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id, 'item_id' => $item_id));
    }
}
function messages_ajax_send_reply()
{
    global $bp;
    check_ajax_referer('messages_send_message');
    $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
    if ($result['status']) {
        ?>
			<div class="avatar-box">
				<?php 
        if (function_exists('bp_core_get_avatar')) {
            echo bp_core_get_avatar($result['reply']->sender_id, 1);
        }
        ?>
	
				<h3><?php 
        echo bp_core_get_userlink($result['reply']->sender_id);
        ?>
</h3>
				<small><?php 
        echo bp_format_time($result['reply']->date_sent);
        ?>
</small>
			</div>
			<?php 
        echo stripslashes(apply_filters('bp_get_message_content', $result['reply']->message));
        ?>
			<div class="clear"></div>
		<?php 
    } else {
        $result['message'] = '<img src="' . $bp->messages->image_base . '/warning.gif" alt="Warning" /> &nbsp;' . $result['message'];
        echo "-1[[split]]" . $result['message'];
    }
}
/**
 * Save the new item and records an activity item for it
 */
function bp_portfolio_save_item($args = array())
{
    global $bp;
    $defaults = array('id' => null, 'author_id' => $bp->loggedin_user->id, 'title' => null, 'description' => null, 'url' => null, 'screenshot' => null);
    $db_args = wp_parse_args($args, $defaults);
    extract($db_args, EXTR_SKIP);
    $portfolio = new BP_Portfolio_Item($db_args);
    // Records an activity
    if ($result = $portfolio->save()) {
        /* Now record the activity item */
        $user_link = bp_core_get_userlink($bp->loggedin_user->id);
        $project = new BP_Portfolio_Item(array('id' => $result));
        $project->get();
        $title = $project->query->post->post_title;
        $user_portfolio_link = '<a href="' . bp_core_get_user_domain($bp->loggedin_user->id) . BP_PORTFOLIO_SLUG . '">portfolio</a>';
        if ($id) {
            // Edit an existing item
            bp_portfolio_record_activity(array('type' => 'edit_project', 'action' => apply_filters('bp_edit_portfolio_activity_action', sprintf(__('%s edited the <strong>%s</strong> project in his %s', 'bp-portfolio'), $user_link, $title, $user_portfolio_link), $user_link, $title, $user_portfolio_link), 'item_id' => $bp->loggedin_user->id));
        } else {
            // New item, so new activity
            $description = $project->query->post->post_content;
            $url = get_post_meta($result, 'bp_portfolio_url', true);
            $attachment = wp_get_attachment_image_src($project->query->post->post_parent, 'portfolio-thumb');
            if ($attachment != 0) {
                $thumbnail = apply_filters('bp_portfolio_get_item_thumbnail', $attachment[0]);
            } else {
                $thumbnail = apply_filters('bp_portfolio_get_item_thumbnail', BP_PORTFOLIO_PLUGIN_URL . '/templates/' . BP_PORTFOLIO_TEMPLATE . '/img/default.png');
            }
            $activity_content = sprintf(__('<div class="item-project"><div class="item-project-pictures"><img width="250px" height="170px" src="%s"></div><div class="item-project-content"><div class="item-project-title">%s</div><div class="item-project-url"><a href="%s">%s</a></div><div class="item-project-desc">%s</div></div></div></div>', 'bp-portfolio'), $thumbnail, $title, $url, $url, $description);
            bp_portfolio_record_activity(array('type' => 'new_project', 'action' => apply_filters('bp_new_portfolio_activity_action', sprintf(__('%s created a new project in his %s', 'bp-portfolio'), $user_link, $user_portfolio_link), $user_link, $user_portfolio_link), 'content' => $activity_content, 'item_id' => $bp->loggedin_user->id));
        }
        return true;
    }
    return false;
}
 public function display_cols($col, $post_id)
 {
     $allowed = array('type', 'status', 'component', 'user_id', 'media_count');
     if (!in_array($col, $allowed)) {
         return $col;
     }
     $gallery = mpp_get_gallery(get_post($post_id));
     switch ($col) {
         case 'type':
             echo $gallery->type;
             break;
         case 'status':
             echo $gallery->status;
             break;
         case 'component':
             echo $gallery->component;
             break;
         case 'media_count':
             echo $gallery->media_count;
             break;
         case 'user_id':
             echo bp_core_get_userlink($gallery->user_id);
             break;
     }
 }
Beispiel #9
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;
 }
Beispiel #10
0
 /**
  * @group activity_action
  * @group bp_core_format_activity_action_new_member
  */
 public function test_bp_members_format_activity_action_new_member()
 {
     $u = $this->factory->user->create();
     $a = $this->factory->activity->create(array('component' => buddypress()->members->id, 'type' => 'new_member', 'user_id' => $u));
     $expected = sprintf(__('%s became a registered member', 'buddypress'), bp_core_get_userlink($u));
     $a_obj = new BP_Activity_Activity($a);
     $this->assertSame($expected, $a_obj->action);
 }
 /**
  * Modify the default buddypress_profile action's HTML to include a link to the profile.
  *
  * @author potanin@UD
  */
 function wp_crm_user_action($action)
 {
     if ($action['action'] != 'buddypress_profile') {
         return $action;
     }
     $action['html'] = sprintf(__('<a href="%1s">BuddyPress Profile</a>', 'wp_crm'), bp_core_get_userlink($action['user_id'], false, true));
     return $action;
 }
/**
 * Not yet used fully - formats event-related actions
 * @param string $action
 * @param object $activity
 * @return string
 */
function em_bp_events_format_activity_action_events($action, $activity)
{
    return '';
    $member_link = bp_core_get_userlink($activity->user_id);
    $EM_Event = em_get_event($activity->item_id);
    $action = sprintf(__('%s added the event %s', 'dbem'), $member_link, $EM_Event->output('#_EVENTLINK'));
    return apply_filters('bp_events_format_activity_action_events', $action, $activity);
}
/**
 * Adds an activity stream item when a user has uploaded a new avatar.
 *
 * @package BuddyPress XProfile
 * @global BuddyPress $bp The one true BuddyPress instance
 * @uses bp_activity_add() Adds an entry to the activity component tables for a specific activity
 */
function bp_xprofile_new_avatar_activity()
{
    if (!bp_is_active('activity')) {
        return false;
    }
    $user_id = apply_filters('bp_xprofile_new_avatar_user_id', bp_displayed_user_id());
    $userlink = bp_core_get_userlink($user_id);
    bp_activity_add(array('user_id' => $user_id, 'action' => apply_filters('bp_xprofile_new_avatar_action', sprintf(__('%s changed their profile picture', 'buddypress'), $userlink), $user_id), 'component' => 'profile', 'type' => 'new_avatar'));
}
 /**
  * @group activity_action
  * @group bp_friends_format_activity_action_friendship_created
  */
 public function test_bp_friends_format_activity_action_friendship_created()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $a = $this->factory->activity->create(array('component' => buddypress()->friends->id, 'type' => 'friendship_created', 'user_id' => $u1, 'secondary_item_id' => $u2));
     $expected = sprintf(__('%1$s and %2$s are now friends', 'buddypress'), bp_core_get_userlink($u1), bp_core_get_userlink($u2));
     $a_obj = new BP_Activity_Activity($a);
     $this->assertSame($expected, $a_obj->action);
 }
Beispiel #15
0
/**
 * Format 'new_member' activity actions.
 *
 * @since BuddyPress (2.0.0)
 *
 * @param string $action Static activity action.
 * @param object $activity Activity object.
 * @return string
 */
function bp_xprofile_format_activity_action_new_member($action, $activity)
{
    $userlink = bp_core_get_userlink($activity->user_id);
    $action = sprintf(__('%s became a registered member', 'buddypress'), $userlink);
    // Legacy filter - pass $user_id instead of $activity
    if (has_filter('bp_core_activity_registered_member_action')) {
        $action = apply_filters('bp_core_activity_registered_member_action', $action, $activity->user_id);
    }
    return apply_filters('bp_xprofile_format_activity_action_new_member', $action, $activity);
}
/**
 * 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);
}
 /**
  * populate()
  *
  * Populate the instantiated class with data based on the User ID provided.
  * 
  * @package BuddyPress Core
  * @global $userdata WordPress user data for the current logged in user.
  * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
  * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
  * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
  * @uses get_usermeta() WordPress function returns the value of passed usermeta name from usermeta table
  * @uses bp_core_get_avatar() Returns HTML formatted avatar for a user
  * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
  */
 function populate()
 {
     $this->user_url = bp_core_get_userurl($this->id);
     $this->user_link = bp_core_get_userlink($this->id);
     $this->fullname = bp_fetch_user_fullname($this->id, false);
     $this->email = bp_core_get_user_email($this->id);
     $this->last_active = bp_core_get_last_activity(get_usermeta($this->id, 'last_activity'), __('active %s ago', 'buddypress'));
     $this->avatar = bp_core_get_avatar($this->id, 2);
     $this->avatar_thumb = bp_core_get_avatar($this->id, 1);
     $this->avatar_mini = bp_core_get_avatar($this->id, 1, 25, 25, false);
 }
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     echo $before_widget;
     // set widget title when logged out
     if (!is_user_logged_in()) {
         $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
         if (!empty($title)) {
             echo $before_title . $title . $after_title;
         }
     }
     // start widget display code
     if (function_exists('bp_is_active')) {
         // check is user is logged in
         if (is_user_logged_in()) {
             echo "<div id='sidebarme'>";
             echo "<a href='" . bp_loggedin_user_domain() . "'>";
             echo bp_loggedin_user_avatar('type=thumb');
             echo "</a>";
             echo "<ul class='sidebarme-quicklinks'>";
             echo "<li class='sidebarme-username'>" . bp_core_get_userlink(bp_loggedin_user_id()) . "</li>";
             echo "<li class='sidebarme-profile'>";
             echo "<a href='" . bp_loggedin_user_domain() . "profile/edit'>" . __('Edit Profile', 'boss') . "</a>";
             echo " &middot; ";
             echo wp_loginout();
             echo "</li>";
             echo "</ul>";
             echo "</div>";
             // check if user is logged out
         } else {
             echo "<form name='login-form' id='sidebar-login-form' class='standard-form' action='" . site_url('wp-login.php', 'login_post') . "' method='post'>";
             echo "<label>" . __('Username', 'boss') . "</label>";
             $return = isset($_POST['value']) ? $_POST['value'] : '';
             $return .= "<input type='text' name='log' id='sidebar-user-login' class='input' value='";
             if (isset($user_login)) {
                 $return .= esc_attr(stripslashes($user_login));
             }
             $return .= "' tabindex='97' />";
             echo $return;
             echo "<label>" . __('Password', 'boss') . "</label>";
             echo "<input type='password' name='pwd' id='sidebar-user-pass' class='input' value='' tabindex='98' />";
             echo "<p class='forgetmenot'><input name='rememberme' type='checkbox' id='sidebar-rememberme' value='forever' tabindex='99' /> " . __('Remember Me', 'boss') . "</p>";
             echo do_action('bp_sidebar_login_form');
             echo "<input type='submit' name='wp-submit' id='sidebar-wp-submit' value='" . __('Log In', 'boss') . "' tabindex='100' />";
             if (bp_get_signup_allowed()) {
                 echo " <a class='sidebar-wp-register' href='" . bp_get_signup_page() . "'>" . __('Register', 'boss') . "</a>";
             }
             echo "</form>";
         }
     }
     // end widget display code
     echo $after_widget;
 }
Beispiel #19
0
 function record_recipe_activity_action($activity_action, $post, $post_permalink)
 {
     global $bp;
     if ($post->post_type == 'recipe') {
         if (is_multisite()) {
             $activity_action = sprintf(__('%1$s submitted a new recipe, %2$s, on the site %3$s', 'socialchef'), bp_core_get_userlink((int) $post->post_author), '' . $post->post_title . '', '' . get_blog_option($blog_id, 'blogname') . '');
         } else {
             $activity_action = sprintf(__('%1$s submitted a new recipe, %2$s', 'socialchef'), bp_core_get_userlink((int) $post->post_author), '' . $post->post_title . '');
         }
         $post_permalink = get_permalink($post->ID);
     }
     return $activity_action;
 }
Beispiel #20
0
 /**
  * Create a wall activity for this user after posting an answer.
  *
  * @param CMA_AnswerThread $instance
  * @param CMA_Answer $answer
  */
 static function answer_posted_activity(CMA_AnswerThread $instance, CMA_Answer $answer)
 {
     if (!$instance->isPublished()) {
         return;
     } else {
         if (!$answer->isApproved()) {
             return;
         }
     }
     $post = $instance->getPost();
     $user_id = $answer->getAuthorId();
     $permalink = $answer->getPermalink();
     bp_activity_add(array('action' => sprintf(CMA::__('%s answered to the question "%s"'), bp_core_get_userlink($user_id), sprintf('<a href="%s">%s</a>', esc_attr($permalink), esc_html($instance->getTitle()))), 'content' => CMA_AnswerThread::lightContent($answer->getContent()), 'component' => self::COMPONENT, 'type' => 'answer_posted', 'primary_link' => $permalink, 'user_id' => $user_id, 'item_id' => $answer->getId()));
 }
Beispiel #21
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'), bp_core_get_userlink($activity->user_id), $media_count, $type, $group_link);
    return $action;
}
function bp_media_upgrade_to_2_2()
{
    global $wpdb;
    remove_filter('bp_activity_get_user_join_filter', 'bp_media_activity_query_filter', 10);
    /* @var $wpdb wpdb */
    $media_files = new WP_Query(array('post_type' => 'bp_media', 'posts_per_page' => -1));
    $media_files = $media_files->posts;
    $wall_posts_album_ids = array();
    if (is_array($media_files) && count($media_files)) {
        foreach ($media_files as $media_file) {
            $attachment_id = get_post_meta($media_file->ID, 'bp_media_child_attachment', true);
            $child_activity = get_post_meta($media_file->ID, 'bp_media_child_activity', true);
            update_post_meta($attachment_id, 'bp_media_child_activity', $child_activity);
            $attachment = get_post($attachment_id, ARRAY_A);
            if (isset($wall_posts_album_ids[$media_file->post_author])) {
                $wall_posts_id = $wall_posts_album_ids[$media_file->post_author];
            } else {
                $wall_posts_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_title = 'Wall Posts' AND post_author = '" . $media_file->post_author . "' AND post_type='bp_media_album'");
                if ($wall_posts_id == null) {
                    $album = new BP_Media_Album();
                    $album->add_album('Wall Posts', $media_file->post_author);
                    $wall_posts_id = $album->get_id();
                }
                if (!$wall_posts_id) {
                    continue;
                    //This condition should never be encountered
                }
                $wall_posts_album_ids[$media_file->post_author] = $wall_posts_id;
            }
            $attachment['post_parent'] = $wall_posts_id;
            wp_update_post($attachment);
            update_post_meta($attachment_id, 'bp-media-key', $media_file->post_author);
            $activity = bp_activity_get(array('in' => intval($child_activity)));
            if (isset($activity['activities'][0]->id)) {
                $activity = $activity['activities'][0];
            }
            $bp_media = new BP_Media_Host_Wordpress($attachment_id);
            $args = array('content' => $bp_media->get_media_activity_content(), 'id' => $child_activity, 'type' => 'media_upload', 'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', 'bp-media'), bp_core_get_userlink($media_file->post_author), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>')), 'primary_link' => $bp_media->get_url(), 'item_id' => $attachment_id, 'recorded_time' => $activity->date_recorded);
            $act_id = bp_media_record_activity($args);
            bp_activity_delete_meta($child_activity, 'bp_media_parent_post');
            wp_delete_post($media_file->ID);
        }
    }
    update_option('bp_media_db_version', BP_MEDIA_DB_VERSION);
    add_action('admin_notices', 'bp_media_database_updated_notice');
    wp_cache_flush();
}
Beispiel #23
0
function qa_buddypress_activity_post($args)
{
    global $bp;
    $defaults = array('content' => false, 'user_id' => $bp->loggedin_user->id);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Record this on the user's profile
    $from_user_link = bp_core_get_userlink($user_id);
    $activity_action = $action;
    $activity_content = $content;
    $primary_link = bp_core_get_userlink($user_id, false, true);
    // Now write the values
    $activity_id = bp_activity_add(array('user_id' => $user_id, 'action' => apply_filters('bp_activity_new_update_action', $activity_action), 'content' => apply_filters('bp_activity_new_update_content', $activity_content), 'primary_link' => apply_filters('bp_activity_new_update_primary_link', $primary_link), 'component' => $bp->activity->id, 'type' => $type));
    // Add this update to the "latest update" usermeta so it can be fetched anywhere.
    bp_update_user_meta($bp->loggedin_user->id, 'bp_latest_update', array('id' => $activity_id, 'content' => wp_filter_kses($content)));
    do_action('bp_activity_posted_update', $content, $user_id, $activity_id);
    return $activity_id;
}
/**
 * Format 'new_member' activity actions.
 *
 * @since BuddyPress (2.2.0)
 *
 * @param string $action   Static activity action.
 * @param object $activity Activity object.
 *
 * @return string
 */
function bp_members_format_activity_action_new_member($action, $activity)
{
    $userlink = bp_core_get_userlink($activity->user_id);
    $action = sprintf(__('%s became a registered member', 'buddypress'), $userlink);
    // Legacy filter - pass $user_id instead of $activity
    if (has_filter('bp_core_activity_registered_member_action')) {
        $action = apply_filters('bp_core_activity_registered_member_action', $action, $activity->user_id);
    }
    /**
     * Filters the formatted 'new member' activity actions.
     *
     * @since BuddyPress (2.2.0)
     *
     * @param string $action   Static activity action.
     * @param object $activity Activity object.
     */
    return apply_filters('bp_members_format_activity_action_new_member', $action, $activity);
}
/**
 * Format 'new_avatar' activity actions.
 *
 * @since 2.0.0
 *
 * @param string $action   Static activity action.
 * @param object $activity Activity object.
 *
 * @return string
 */
function bp_xprofile_format_activity_action_new_avatar($action, $activity)
{
    $userlink = bp_core_get_userlink($activity->user_id);
    $action = sprintf(__('%s changed their profile picture', 'buddypress'), $userlink);
    // Legacy filter - pass $user_id instead of $activity.
    if (has_filter('bp_xprofile_new_avatar_action')) {
        $action = apply_filters('bp_xprofile_new_avatar_action', $action, $activity->user_id);
    }
    /**
     * Filters the formatted 'new_avatar' activity stream action.
     *
     * @since 2.0.0
     *
     * @param string $action   Formatted action for activity stream.
     * @param object $activity Activity object.
     */
    return apply_filters('bp_xprofile_format_activity_action_new_avatar', $action, $activity);
}
Beispiel #26
0
/**
 * Builds the argument of the reshared activity
 *
 * @package BP Reshare
 * @since    1.0
 * 
 * @param  integer $activity_id the activity id
 * @uses   bp_activity_get_specific() to fetch the specific activity
 * @uses   bp_activity_get_meta() to get some meta infos about the activity
 * @uses   bp_loggedin_user_id() to get current user id
 * @uses   bp_activity_update_meta() to save some meta infos for the activity
 * @uses   bp_core_fetch_avatar() to build the avatar for the user
 * @uses   bp_core_get_userlink() to build the user link
 * @uses   bp_core_current_time() to date the reshare
 * @uses   apply_filters() at various places to let plugins/themes override values
 * @return array the reshared activity arguments
 */
function buddyreshare_prepare_reshare($activity_id = 0)
{
    $activity_to_reshare = bp_activity_get_specific(array('activity_ids' => $activity_id));
    if (empty($activity_to_reshare)) {
        return array('error' => __('OOps, looks like the activity does not exist anymore', 'bp-reshare'));
    }
    $activity = $activity_to_reshare['activities'][0];
    $reshared_by = bp_activity_get_meta($activity_id, 'reshared_by');
    if (is_array($reshared_by) && in_array(bp_loggedin_user_id(), $reshared_by)) {
        return array('error' => __('OOps, looks like you already reshared this activity', 'bp-reshare'));
    }
    if ($activity->user_id == bp_loggedin_user_id()) {
        return array('error' => __('OOps, looks like you are trying to reshare your own activity', 'bp-reshare'));
    }
    /* 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);
    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', 'class' => 'avatar', 'width' => 20, 'height' => 20));
    $component = $activity->component;
    $item_id = $activity->item_id;
    if ($component != 'activity') {
        $user_link = bp_core_get_userlink($activity->user_id);
        if (strpos($activity->primary_link, $user_link) === false) {
            $action = apply_filters('buddyreshare_prepare_reshare_content', sprintf(__('%s reshared a <a href="%s">content</a> originally shared by %s', 'bp-reshare'), bp_core_get_userlink(bp_loggedin_user_id()), $activity->primary_link, bp_core_get_userlink($activity->user_id)), $activity);
        } else {
            $action = apply_filters('buddyreshare_prepare_reshare_nocontent', sprintf(__('%s reshared some content originally shared by %s', 'bp-reshare'), bp_core_get_userlink(bp_loggedin_user_id()), bp_core_get_userlink($activity->user_id)), $activity);
        }
    } else {
        $action = apply_filters('buddyreshare_prepare_reshare_activity', 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)), $activity);
    }
    $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('buddyreshare_prepare_reshare', $reshared_args, $activity_id);
}
 public function create_product($product_id = 0, $product_title = '', $author_id = 0)
 {
     // Validate activity data
     $user_id = (int) $author_id;
     $product_id = (int) $product_id;
     // User link for product author
     $user_link = bp_core_get_userlink($user_id);
     // Product
     $product_permalink = get_permalink($product_id);
     $product_link = '<a href="' . $product_permalink . '">' . $product_title . '</a>';
     // Activity action & text
     $activity_text = sprintf(esc_html('%1$s created the a new product %2$s', DLN_ABE), $user_link, $product_link);
     // Compile and record the activity stream results
     $activity_id = self::record_activity(array('id' => null, 'user_id' => $user_id, 'action' => $activity_text, 'content' => null, 'primary_link' => $product_permalink, 'type' => 'dln_create_product', 'item_id' => $product_id, 'recorded_time' => get_the_time('Y-m-d H:i:s', $product_id), 'hide_sitewide' => false));
     // Add the activity entry ID as a meta value to the product
     if (!empty($activity_id)) {
         update_post_meta($product_id, '_dln_activity_id', $activity_id);
     }
 }
Beispiel #28
0
function mpp_get_user_link($user_id, $no_anchor = false, $just_link = false)
{
    if (function_exists('bp_core_get_userlink')) {
        return bp_core_get_userlink($user_id, $no_anchor, $just_link);
    }
    $display_name = mpp_get_user_display_name($user_id);
    if (empty($display_name)) {
        return false;
    }
    if (!empty($no_anchor)) {
        return $display_name;
    }
    if (!($url = mpp_get_user_url($user_id))) {
        return false;
    }
    if (!empty($just_link)) {
        return $url;
    }
    return apply_filters('mpp_get_user_link', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id);
}
 /**
  * request_message($user_id, $body = false, $subject = false )
  * 
  * Generated content for new request messages.
  * 
  * @param Mixed $userdata the user object of the sender and request author
  * @param bool $body if true generates the message body content
  * @param bool $subject if true generates the message subject content
  * @return String $content the generated message content
  */
 function request_message($userdata, $body = false, $subject = false)
 {
     $content = null;
     if ($subject) {
         $content = sprintf(__('Please review %s application to become a teacher.', 'bpsp'), $userdata->user_nicename);
     }
     if ($body) {
         if (empty($userdata->user_url)) {
             $userdata->user_url = bp_core_get_userlink($userdata->ID, false, true);
         }
         $fields_group_id = $this->field_group_id_from_name(__('Courseware', 'bpsp'));
         $admin_url = $userdata->user_url . 'profile/edit/group/' . $fields_group_id;
         $content = $userdata->user_nicename;
         $content .= __(" applied to become a teacher.", 'bpsp');
         $content .= "\n";
         $content .= __("To review the profile, follow the link below.", 'bpsp');
         $content .= "\n";
         $content .= $admin_url;
     }
     return $content;
 }
Beispiel #30
-1
/**
 * When a Notepad is edited, record the fact to the activity stream
 *
 * @since 1.0
 * @param int $post_id
 * @param object $post
 * @return int The id of the activity item posted
 */
function participad_notepad_record_notepad_activity($post_id, $post)
{
    global $bp;
    // Run only for participad_notebook post type
    if (empty($post->post_type) || participad_notepad_post_type_name() != $post->post_type) {
        return;
    }
    // Throttle activity updates: No duplicate posts (same user, same
    // notepad) within 60 minutes
    $already_args = array('max' => 1, 'sort' => 'DESC', 'show_hidden' => 1, 'filter' => array('user_id' => get_current_user_id(), 'action' => 'participad_notepad_edited', 'secondary_id' => $post_id));
    $already_activity = bp_activity_get($already_args);
    // If any activity items are found, compare its date_recorded with time() to
    // see if it's within the allotted throttle time. If so, don't record the
    // activity item
    if (!empty($already_activity['activities'])) {
        $date_recorded = $already_activity['activities'][0]->date_recorded;
        $drunix = strtotime($date_recorded);
        if (time() - $drunix <= apply_filters('participad_notepad_edit_activity_throttle_time', 60 * 60)) {
            return;
        }
    }
    $post_permalink = get_permalink($post_id);
    $action = sprintf(__('%1$s edited a notepad %2$s on the site %3$s', 'participad'), bp_core_get_userlink(get_current_user_id()), '<a href="' . $post_permalink . '">' . esc_html($post->post_title) . '</a>', '<a href="' . get_option('siteurl') . '">' . get_option('blogname') . '</a>');
    $activity_id = bp_activity_add(array('user_id' => get_current_user_id(), 'component' => bp_is_active('blogs') ? $bp->blogs->id : 'blogs', 'action' => $action, 'primary_link' => $post_permalink, 'type' => 'participad_notepad_edited', 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_modified_gmt, 'hide_sitewide' => get_option('blog_public') <= 0));
    if (function_exists('bp_blogs_update_blogmeta')) {
        bp_blogs_update_blogmeta(get_current_blog_id(), 'last_activity', bp_core_current_time());
    }
    return $activity_id;
}