<?php 
    if (bp_checkins_places_was_posted_in_group() && !bp_checkins_places_can_publish_in_group()) {
        ?>
		
		<p class="must-register-in-groupe"><?php 
        printf(__('You must be a member of %s to check in this place or post a comment.', 'bp-checkins'), bp_get_checkins_places_group_permalink());
        ?>
</p>
		
	<?php 
    } else {
        ?>
		
		<?php 
        if (bp_checkins_places_is_live() && 'live' != bp_checkins_places_live_status(0)) {
            ?>
			
			<p class="bpci-live-unavailable"><?php 
            bp_checkins_places_live_status();
            ?>
</p>
			
		<?php 
        } else {
            ?>
	
			<?php 
            $title_reply = apply_filters('bp_checkins_comment_form_title', __('<a href="#" class="add-checkin without">Check-in</a><a href="#" class="add-checkin with">Comment &amp; check-in</a>', 'bp-checkins'));
            ?>
			
    function widget($args, $instance)
    {
        global $bp;
        extract($args);
        if (bp_checkins_is_group_places_area() || bp_checkins_is_user_area() && bp_is_current_action('places-area') || bp_checkins_if_single_place()) {
            return false;
        }
        if (!$instance['max_places']) {
            $instance['max_places'] = 5;
        }
        if (!$instance['places_type']) {
            $instance['places_type'] = -1;
        }
        if ($instance['dynamic'] === false) {
            $instance['dynamic'] = 1;
        }
        echo $before_widget;
        echo $before_title . $instance['title'] . $after_title;
        ?>
		
		<?php 
        $widget_args = array('per_page' => $instance['max_places'], 'type' => $instance['places_type']);
        if ((int) $instance['dynamic'] == 1 && bp_displayed_user_id()) {
            $widget_args['user_id'] = bp_displayed_user_id();
        }
        if ((int) $instance['dynamic'] == 1 && bp_is_groups_component() && bp_is_single_item() && $bp->groups->current_group->status == 'public') {
            $widget_args['group_id'] = $bp->groups->current_group->id;
        }
        ?>
		
		<?php 
        if (!empty($widget_args['group_id']) || !empty($widget_args['user_id'])) {
            ?>
			
			<div class="item-options">
				
				<?php 
            if (bp_displayed_user_id()) {
                printf(__('%s&#039;s places', 'bp-checkins'), bp_core_fetch_avatar(array('item_id' => bp_displayed_user_id(), 'object' => 'user', 'type' => 'thumb', 'width' => 20, 'height' => 20)) . bp_core_get_userlink(bp_displayed_user_id()));
            }
            if (bp_is_groups_component() && bp_is_single_item()) {
                printf(__('%s&#039;s places', 'bp-checkins'), bp_core_fetch_avatar(array('item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => 'thumb', 'width' => 20, 'height' => 20)) . '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_attr($bp->groups->current_group->name) . '</a>');
            }
            ?>
	
				
			</div>
		
		<?php 
        }
        ?>

		<?php 
        if (bp_checkins_has_places($widget_args)) {
            ?>
			
			<ul id="widget-places-list" class="item-list">
				<?php 
            while (bp_checkins_has_places()) {
                bp_checkins_the_place();
                ?>

					<li>
						<div class="item-avatar">
							<?php 
                bp_checkins_places_avatar();
                ?>
						</div>
						<div class="item-title">
							<a href="<?php 
                bp_checkins_places_the_permalink();
                ?>
" title="<?php 
                bp_checkins_places_title();
                ?>
"><?php 
                bp_checkins_places_title();
                ?>
</a>
						</div>
						<?php 
                if (bp_checkins_places_is_live()) {
                    ?>
							<div class="item-meta">
								<span class="activity"><?php 
                    bp_checkins_places_live_status();
                    ?>
</span>
							</div>
						<?php 
                }
                ?>
						<div class="clear"></div>
					</li>

				<?php 
            }
            ?>

		<?php 
        } else {
            ?>

			<div class="widget-error">
				<p><?php 
            _e('Sorry, there was no places found.', 'bp-checkins');
            ?>
</p>
			</div>

		<?php 
        }
        ?>


		<?php 
        echo $after_widget;
        ?>
	<?php 
    }
				
				<?php 
bp_checkins_places_featured_image();
?>

				<h4><a href="<?php 
bp_checkins_places_the_permalink();
?>
" title="<?php 
bp_checkins_places_title();
?>
"><?php 
bp_checkins_places_title();
?>
</a> <?php 
if (bp_checkins_places_is_live()) {
    bp_checkins_places_live_status();
}
?>
</h4>
				
				<p class="place-excerpt"><?php 
bp_checkins_places_excerpt();
?>
</p>

			</div>

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