-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalendar.php
97 lines (75 loc) · 2.69 KB
/
calendar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Apocrypha Theme Calendar Archive Template
* Andrew Clayton
* Version 1.0
* 7-25-2013
*/
/* Who is it? */
$user_id = get_current_user_id();
/* Get some information about the calendar */
$apoc = apocrypha();
$calendar = $apoc->queried_object;
$term_id = $calendar->term_id;
$slug = $calendar->slug;
/* Does it belong to a specific group? */
$is_group = is_group_calendar( $term_id );
/* Set the default context */
$header = 'get_header';
$sidebar = 'apoc_primary_sidebar';
/* If it's a group calendar, switch the header accordingly */
if ( $is_group ) :
/* Check if the user is a member */
$group_id = groups_get_id( $slug );
$is_member = groups_is_user_member( $user_id , $group_id );
if ( 'entropy-rising' == $slug ) :
$header = 'entropy_rising_header';
$sidebar = 'entropy_rising_sidebar';
$redirect = SITEURL . '/entropy-rising/';
else :
$redirect = SITEURL . '/groups/' . trailingslashit( $slug );
endif;
/* If not a member, redirect */
if ( !$is_member ) {
bp_core_add_message( 'You cannot access this calendar.' , 'error' );
bp_core_redirect( $redirect );
}
endif;
$header(); // Load the header contextually ?>
<div id="content" role="main">
<?php apoc_breadcrumbs(); ?>
<header class="entry-header <?php post_header_class(); ?>">
<h1 class="entry-title"><?php echo $calendar->name; ?> Calendar</h1>
<p class="entry-byline"><?php echo $calendar->description; ?></p>
</header>
<h2 class="calendar-header">Upcoming Events</h2>
<?php $upcoming_events = apoc_calendar_upcoming_events( $slug );
/* If there are upcoming events */
if ( $upcoming_events->have_posts() ) :
echo '<ol id="calendar-upcoming-list" class="event-list">';
while( $upcoming_events->have_posts() ) : $upcoming_events->the_post();
include( THEME_DIR . '/library/templates/loop-single-event.php' );
endwhile;
echo '</ol>';
/* If there are no events */
else :
echo '<p class="no-results">No upcoming events found.</p>';
endif;
/* Now check for past events */ ?>
<h2 class="calendar-header">Past Events</h2>
<?php wp_reset_query();
$past_events = apoc_calendar_past_events( $slug, $number = 3);
/* If there are past events */
if ( $past_events->have_posts() ) :
echo '<ol id="calendar-past-list" class="event-list">';
while( $past_events->have_posts() ) : $past_events->the_post();
include( THEME_DIR . '/library/templates/loop-single-event.php' );
endwhile;
echo '</ol>';
/* If there are no events */
else :
echo '<p class="no-results">No past events found.</p>';
endif; ?>
</div><!-- #content -->
<?php $sidebar(); // Load the sidebar contextually ?>
<?php get_footer(); // Load the footer ?>