function bp_reshare_add_reshare_button()
{
    global $bp;
    if (!is_user_logged_in()) {
        return false;
    }
    $activity_types_resharable = bp_reshare_activity_types();
    if (!in_array(bp_get_activity_type(), $activity_types_resharable)) {
        return false;
    }
    if (bp_reshare_activity_is_hidden()) {
        return false;
    }
    if (bp_reshare_is_user_profile_reshares() && $bp->displayed_user->id != $bp->loggedin_user->id) {
        return false;
    }
    $activity_first_id = bp_get_activity_id();
    if ('reshare_update' == bp_get_activity_type()) {
        $activity_first_id = bp_get_activity_secondary_item_id();
    }
    $rs_count = bp_activity_get_meta($activity_first_id, 'reshared_count');
    $rs_count = !empty($rs_count) ? $rs_count : 0;
    if ($bp->loggedin_user->id == bp_get_activity_user_id() || bp_reshare_user_did_reshared($activity_first_id)) {
        $reshared_class = 'reshared';
    }
    $action_url = wp_nonce_url(bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/?to_reshare=' . $activity_first_id, '_reshare_update');
    if ($_POST['scope'] == 'reshares' || bp_reshare_is_user_profile_reshares() || bp_is_activity_component() && !bp_displayed_user_id() && $_COOKIE['bp-activity-scope'] == 'reshares') {
        $extra_class = 'unshare';
        $action_url = wp_nonce_url(bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/?delete_reshare=' . bp_get_activity_id(), '_reshare_delete');
    }
    ?>
	
	<a href="<?php 
    echo $action_url;
    ?>
" class="button bp-primary-action bp-agu-reshare" id="bp-agu-reshare-<?php 
    bp_activity_id();
    ?>
" rel="<?php 
    echo $activity_first_id;
    ?>
"><span class="bp-agu-reshare-img <?php 
    echo $reshared_class . ' ' . $extra_class;
    ?>
"></span><span class="rs-count"><?php 
    echo $rs_count;
    ?>
</span></a>
	<?php 
}
Example #2
0
 function activity_loop_link()
 {
     $act_type = bp_get_activity_type();
     if (empty($this->types_map[$act_type])) {
         return;
     }
     $args = array('type' => $this->types_map[$act_type], 'id' => bp_get_activity_item_id(), 'id2' => bp_get_activity_secondary_item_id(), 'author_id' => bp_get_activity_user_id(), 'is_main_content' => bp_is_single_activity(), 'context' => 'activity-loop', 'custom_class' => 'button');
     $args = apply_filters("bp_moderation_activity_loop_link_args_{$act_type}", $args);
     if ($args) {
         echo $this->generate_link($args);
     }
 }
Example #3
0
    function build_html()
    {
        // Store everything in an output buffer
        ob_start();
        ?>
	
		<div class="widget showcase-widget">
			<header class="widget-header">
				<h3 class="widget-title">Recent Discussion</h3>
			</header>
			<ul class="recent-discussion-list">		
	
			<?php 
        // Iterate topics
        while (bp_activities()) {
            bp_the_activity();
            // Get the activity user
            $user = new Apoc_User(bp_get_activity_user_id(), 'directory', 40);
            // Get the activity type
            $type = bp_get_activity_type();
            // Format activity based on context
            switch ($type) {
                case 'bbp_topic_create':
                    $topic_id = bp_get_activity_item_id();
                    $link = '<a href="' . bbp_get_topic_permalink($topic_id) . '" title="Read topic" target="_blank">' . bbp_get_topic_title($topic_id) . '</a>';
                    $verb = 'created topic';
                    break;
                case 'bbp_reply_create':
                    $reply_id = bp_get_activity_secondary_item_id();
                    $link = '<a href="' . bbp_get_topic_last_reply_url($reply_id) . '" title="Read reply" target="_blank">' . bbp_get_topic_title($reply_id) . '</a>';
                    $verb = 'replied to';
                    break;
                case 'new_blog_comment':
                    $comment_id = bp_get_activity_secondary_item_id();
                    $comment = get_comment($comment_id);
                    $link = '<a href="' . get_comment_link($comment_id) . '" title="Read reply" target="_blank">' . get_the_title($comment->comment_post_ID) . '</a>';
                    $verb = 'commented on';
                    break;
            }
            // Get the activity time
            $time = bp_core_time_since(bp_get_activity_date_recorded());
            // Output the HTML
            ?>
				<li class="recent-discussion double-border">			
					<?php 
            echo $user->avatar;
            ?>
					<div class="recent-discussion-content">
						<span class="recent-discussion-title"><?php 
            echo $user->link . ' ' . $verb . ' ' . $link;
            ?>
</span>
						<span class="recent-discussion-time"><?php 
            echo $time;
            ?>
					</div>
				</li>
			
			<?php 
        }
        ?>
			</ul>
		</div><?php 
        // Get the contents of the buffer
        $html = ob_get_contents();
        ob_end_clean();
        // Return the html to the class
        return $html;
    }
 private function GetBuddyPressRating($ver, $horAlign = true)
 {
     RWLogger::LogEnterence('GetBuddyPressRating');
     global $activities_template;
     // Set current activity-comment to current activity update (recursive comments).
     $this->current_comment = $activities_template->activity;
     $rclass = str_replace('_', '-', bp_get_activity_type());
     $is_forum_topic = $rclass === 'new-forum-topic';
     if ($is_forum_topic && !$this->IsBBPressInstalled()) {
         return false;
     }
     if (!in_array($rclass, array('forum-post', 'forum-reply', 'new-forum-post', 'user-forum-post', 'user', 'activity-update', 'user-activity-update', 'activity-comment', 'user-activity-comment'))) {
         // If unknown activity type, change it to activity update.
         $rclass = 'activity-update';
     }
     if ($is_forum_topic) {
         $rclass = 'new-forum-post';
     }
     // Check if item rating is top positioned.
     if (!isset($this->activity_align[$rclass]) || $ver !== $this->activity_align[$rclass]->ver) {
         return false;
     }
     // Get item id.
     $item_id = 'activity-update' === $rclass || 'activity-comment' === $rclass ? bp_get_activity_id() : bp_get_activity_secondary_item_id();
     if ($is_forum_topic) {
         // If forum topic, then we must extract post id
         // from forum posts table, because secondary_item_id holds
         // topic id.
         if (function_exists('bb_get_first_post')) {
             $post = bb_get_first_post($item_id);
         } else {
             // Extract post id straight from the BB DB.
             global $bb_table_prefix;
             // Load bbPress config file.
             @(include_once WP_RW__BBP_CONFIG_LOCATION);
             // Failed loading config file.
             if (!defined('BBDB_NAME')) {
                 return false;
             }
             $connection = null;
             if (!($connection = mysql_connect(BBDB_HOST, BBDB_USER, BBDB_PASSWORD, true))) {
                 return false;
             }
             if (!mysql_selectdb(BBDB_NAME, $connection)) {
                 return false;
             }
             $results = mysql_query("SELECT * FROM {$bb_table_prefix}posts WHERE topic_id={$item_id} AND post_position=1", $connection);
             $post = mysql_fetch_object($results);
         }
         if (!isset($post->post_id) && empty($post->post_id)) {
             return false;
         }
         $item_id = $post->post_id;
     }
     // If the item is post, queue rating with post title.
     $title = 'new-blog-post' === $rclass ? get_the_title($item_id) : bp_get_activity_content_body();
     // $activities_template->activity->content;
     $options = array();
     $owner_id = bp_get_activity_user_id();
     // Add accumulator id if user accumulated rating.
     if ($this->IsUserAccumulatedRating()) {
         $options['uarid'] = $this->_getUserRatingGuid($owner_id);
     }
     return $this->EmbedRatingIfVisible($item_id, $owner_id, strip_tags($title), bp_activity_get_permalink(bp_get_activity_id()), $rclass, false, $horAlign ? $this->activity_align[$rclass]->hor : false, false, $options, false);
 }
Example #5
0
 public function activity_buttons()
 {
     if ('new_question' == bp_get_activity_type()) {
         echo '<a class="button answer bp-secondary-action" title="' . __('Answer this question', 'anspress-question-answer') . '" href="' . ap_answers_link(bp_get_activity_secondary_item_id()) . '">' . __('Answer', 'anspress-question-answer') . '</a>';
     }
 }
/**
 * Outputs the activity secondary item id
 *
 * @since 1.2.0
 *
 * @uses bp_get_activity_secondary_item_id()
 */
function bp_activity_secondary_item_id()
{
    echo bp_get_activity_secondary_item_id();
}
	<div class="post">
	
		<div class="author-box">
			<?php 
bp_activity_avatar('type=full&width=50&height=50');
?>
			<p><?php 
printf(__('by %s', 'buddypress'), bp_core_get_userlink($post->post_author));
?>
</p>
		</div>
	
		<div class="post-content">
			<?php 
if (bp_get_activity_secondary_item_id()) {
    ?>
				<h2 class="posttitle"><a href="<?php 
    bp_activity_feed_item_link();
    ?>
" rel="bookmark" title="<?php 
    _e('Permanent Link to', 'buddypress');
    ?>
 <?php 
    the_title_attribute();
    ?>
"><?php 
    the_title();
    ?>
</a></h2>
		
/**
 * Append the featured image for the activity excerpt.
 *
 * @since 1.0.5
 * @package GeoDirectory_BuddyPress_Integration
 *
 * @param string $excerpt The appended text for the activity excerpt.
 * @return string The activity excerpt.
 */
function geodir_buddypress_bp_activity_featured_image($excerpt = '')
{
    $activity_name = bp_get_activity_object_name();
    $activity_type = bp_get_activity_type();
    $item_id = bp_get_activity_secondary_item_id();
    if ($activity_name == 'activity' && $item_id > 0 && $activity_type == 'new_' . get_post_type($item_id) && get_option('geodir_buddypress_show_feature_image')) {
        $image = wp_get_attachment_image_src(get_post_thumbnail_id($item_id));
        if (!empty($image) && !empty($image[0])) {
            $listing_title = geodir_get_post_meta($item_id, 'post_title', true);
            $featured_image = '<a class="gdbp-feature-image" href="' . get_permalink($item_id) . '" title="' . esc_attr($listing_title) . '"><img alt="' . esc_attr($listing_title) . '" src="' . $image[0] . '" /></a>';
            /**
             * Filter the new listing featured image in activity.
             *
             * @since 1.0.5
             *
             * @param string $featured_image Featured image content.
             * @param int $item_id Activity item id.
             * @param string $activity_name Current activity name.
             * @param string $activity_type Current activity type.
             */
            $featured_image = apply_filters('geodir_buddypress_bp_activity_featured_image', $featured_image, $item_id, $activity_name, $activity_type);
            echo $featured_image;
        }
    }
    return $excerpt;
}
Example #9
0
 private function GetBuddyPressRating($ver, $horAlign = true)
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence("GetBuddyPressRating", $params);
     }
     global $activities_template;
     // Set current activity-comment to current activity update (recursive comments).
     $this->current_comment = $activities_template->activity;
     $rclass = str_replace("_", "-", bp_get_activity_type());
     $is_forum_topic = $rclass === "new-forum-topic";
     if ($is_forum_topic && !$this->IsBBPressInstalled()) {
         return false;
     }
     if ($is_forum_topic) {
         $rclass = "new-forum-post";
     }
     // Check if item rating is top positioned.
     if (!isset($this->activity_align[$rclass]) || $ver !== $this->activity_align[$rclass]->ver) {
         return false;
     }
     // Get item id.
     $item_id = "activity-update" === $rclass || "activity-comment" === $rclass ? bp_get_activity_id() : bp_get_activity_secondary_item_id();
     if ($is_forum_topic) {
         // If forum topic, then we must extract post id
         // from forum posts table, because secondary_item_id holds
         // topic id.
         if (function_exists("bb_get_first_post")) {
             $post = bb_get_first_post($item_id);
         } else {
             // Extract post id straight from the BB DB.
             global $bb_table_prefix;
             // Load bbPress config file.
             @(include_once WP_RW__BBP_CONFIG_LOCATION);
             // Failed loading config file.
             if (!defined("BBDB_NAME")) {
                 return false;
             }
             $connection = null;
             if (!($connection = mysql_connect(BBDB_HOST, BBDB_USER, BBDB_PASSWORD, true))) {
                 return false;
             }
             if (!mysql_selectdb(BBDB_NAME, $connection)) {
                 return false;
             }
             $results = mysql_query("SELECT * FROM {$bb_table_prefix}posts WHERE topic_id={$item_id} AND post_position=1", $connection);
             $post = mysql_fetch_object($results);
         }
         if (!isset($post->post_id) && empty($post->post_id)) {
             return false;
         }
         $item_id = $post->post_id;
     }
     // If the item is post, queue rating with post title.
     $title = "new-blog-post" === $rclass ? get_the_title($item_id) : bp_get_activity_content_body();
     // $activities_template->activity->content;
     $options = array();
     $owner_id = bp_get_activity_user_id();
     // Add accumulator id if user accumulated rating.
     if ($this->IsUserAccumulatedRating()) {
         $options['uarid'] = $this->_getUserRatingGuid($owner_id);
     }
     return $this->EmbedRatingIfVisible($item_id, $owner_id, strip_tags($title), bp_activity_get_permalink(bp_get_activity_id()), $rclass, false, $horAlign ? $this->activity_align[$rclass]->hor : false, false, $options, false);
     /*
             // Queue activity rating.
             $this->QueueRatingData($urid, strip_tags($title), bp_activity_get_permalink($activities_template->activity->id), $rclass);
     
             // Return rating html container.
             return '<div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $urid . '"></div>';*/
 }
function bp_reshare_check_for_parent_type($can_comment)
{
    global $activities_template;
    if ($activities_template->disable_blogforum_replies == 0) {
        return $can_comment;
    }
    if ('reshare_update' != bp_get_activity_type()) {
        return $can_comment;
    } else {
        if (!(int) bp_get_option('bp-reshare-disable-blogforum-comments') || '' == bp_get_option('bp-reshare-disable-blogforum-comments')) {
            return $can_comment;
        }
        /*
         	the activity is a reshare, 
        	Admin wants to disable comments for blogs and forums
        	we now need to check for parent type
        */
        $activity_first_id = bp_get_activity_secondary_item_id();
        $parent_activity = bp_activity_get_specific('activity_ids=' . $activity_first_id);
        if (in_array($parent_activity['activities'][0]->type, array('new_blog_post', 'new_blog_comment', 'new_forum_topic', 'new_forum_post'))) {
            return false;
        } else {
            return $can_comment;
        }
    }
}