Skip to content

Commit

Permalink
Add 'Upcoming' tab to user profiles.
Browse files Browse the repository at this point in the history
See #25.
  • Loading branch information
boonebgorges committed May 1, 2015
1 parent b71841d commit 72f2331
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 8 deletions.
20 changes: 19 additions & 1 deletion assets/css/bp-event-organiser.css
Expand Up @@ -54,4 +54,22 @@
line-height: 1.5;
padding-right: 5px;
vertical-align: bottom;
}
}

/* Upcoming Events list */
ul.bpeo-upcoming-events {
list-style-type: none;
}

ul.bpeo-upcoming-events li {
margin-bottom: 1em;
}

.bpeo-upcoming-event-datetime {
float: left;
width: 180px;
}

.bpeo-upcoming-event-title {
font-weight: bold;
}
27 changes: 20 additions & 7 deletions includes/component.php
Expand Up @@ -52,6 +52,15 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
'screen_function' => array( $this, 'template_loader' ),
);

$sub_nav[] = array(
'name' => __( 'Upcoming', 'bp-event-organiser' ),
'slug' => 'upcoming', // @todo better l10n
'parent_url' => bp_displayed_user_domain() . trailingslashit( $this->slug ),
'parent_slug' => $this->slug,
'user_has_access' => bp_core_can_edit_settings(),
'screen_function' => array( $this, 'template_loader' ),
);

$sub_nav[] = array(
'name' => __( 'New Event', 'bp-event-organizer' ),
'slug' => bpeo_get_events_new_slug(),
Expand Down Expand Up @@ -124,7 +133,8 @@ protected function setup_single_event_screen() {
return;
}

if ( bp_is_current_action( 'manage' ) ) {
$reserved_slugs = array( 'manage', 'calendar', 'upcoming' );
if ( in_array( bp_current_action(), $reserved_slugs ) ) {
return;
}

Expand Down Expand Up @@ -185,7 +195,7 @@ public function template_loader() {
add_action( 'bp_template_content', array( $this, 'display_manage_events' ) );

// single event
} elseif ( false === bp_is_current_action( 'calendar' ) ) {
} elseif ( false === bp_is_current_action( 'calendar' ) && false === bp_is_current_action( 'upcoming' ) ) {
$this->single_event_screen();
add_action( 'bp_template_title', array( $this, 'display_single_event_title' ) );
add_action( 'bp_template_content', array( $this, 'display_single_event' ) );
Expand All @@ -199,15 +209,18 @@ public function template_loader() {
}

/**
* Utility function for selecting the correct Docs template to be loaded in the component
* Utility function for selecting the correct template to be loaded in the component
*/
public function select_template() {
$template_slug = bp_current_action();

$args = array(
'bp_displayed_user_id' => bp_displayed_user_id(),
);
// Ceci n'est pas un template stack.
$template = bp_locate_template( 'bp-event-organiser/' . $template_slug . '.php' );
if ( false === $template ) {
$template = BPEO_PATH . 'templates/' . $template_slug . '.php';
}

echo eo_get_event_fullcalendar( $args );
include $template;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions templates/calendar.php
@@ -0,0 +1,5 @@
<?php
$args = array(
'bp_displayed_user_id' => bp_displayed_user_id(),
);
echo eo_get_event_fullcalendar( $args );
33 changes: 33 additions & 0 deletions templates/upcoming.php
@@ -0,0 +1,33 @@
<?php
/**
* Upcoming event list template.
*/

$eo_get_events_args = array(
'showpastevents' => false,
);

if ( bp_is_user() ) {
$eo_get_events_args['bp_displayed_user_id'] = bp_displayed_user_id();
} elseif ( function_exists( 'bp_is_group' ) && bp_is_group() ) {
$eo_get_events_args['bp_group'] = bp_get_current_group_id();
}

$events = eo_get_events( $eo_get_events_args ); ?>

<?php if ( ! empty( $events ) ) : ?>
<ul class="bpeo-upcoming-events">
<?php foreach ( $events as $event ) : ?>
<li class="bpeo-upcoming-event-<?php echo esc_attr( $event->ID ) ?>">
<div class="bpeo-upcoming-event-datetime">
<span class="bpeo-upcoming-event-date"><?php echo date( 'M j, Y', strtotime( $event->StartDate ) ) ?></span> &middot; <span class="bpeo-upcoming-event-time"><?php echo date( 'g:ia', strtotime( $event->StartTime ) ) ?></span>
</div>

<a class="bpeo-upcoming-event-title" href="<?php echo esc_url( apply_filters( 'eventorganiser_calendar_event_link', get_permalink( $event->ID ), $event->ID ) ) ?>"><?php echo esc_html( $event->post_title ) ?></a>

</li>
<?php endforeach; ?>
</ul>
<?php else : // ! empty( $events ) ?>
<p><?php _e( 'No upcoming events found.', 'bp-event-organiser' ) ?></p>
<?php endif; // ! empty( $events ) ?>

0 comments on commit 72f2331

Please sign in to comment.