Version Description
- fixed init code not executing WP FullCalendar integration in time
- changed generation of WP_Rewrite rules for children of event post type to query the database directly rather than use get_posts
- updated French translation
- fixed mysql warning/error when creating events with a new location
- changed default events widget format to use #_EVENTDATES
- fixed google maps problem
- fixed 5.5 bug where search attributes being included in pagination links when not necessary
- fixed calendar not using ordering as per settings
- fixed chronological ordering on calendars with long and all-day events
- fixed geo.js not being overridable an overridable template file
- fixed limit=0 being ignored in shortcodes and functions
- fixed pagination being forced for categories_list shortcode regardless of attribute
Download this release
Release Info
Developer | netweblogic |
Plugin | Events Manager |
Version | 5.5.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.98 to 5.5.1
- admin/bookings/em-cancelled.php +136 -132
- admin/bookings/em-confirmed.php +143 -139
- admin/bookings/em-events.php +170 -178
- admin/bookings/em-pending.php +158 -154
- admin/bookings/em-person.php +151 -149
- admin/bookings/em-rejected.php +136 -132
- admin/em-admin.php +271 -284
- admin/em-bookings.php +574 -287
- admin/em-categories.php +0 -177
- admin/em-docs.php +337 -192
- admin/em-event.php +0 -627
- admin/em-events.php +0 -242
- admin/em-help.php +68 -51
- admin/em-locations-search.php +8 -3
- admin/em-locations.php +0 -268
- admin/em-ms-locations.php +52 -0
- admin/em-ms-options.php +205 -0
- admin/em-options.php +2113 -443
- admin/em-people.php +0 -192
- admin/wpfc-admin.php +47 -0
- buddypress/bp-em-activity.php +128 -0
- buddypress/bp-em-core.php +340 -0
- buddypress/bp-em-groups.php +140 -0
- buddypress/bp-em-notifications.php +82 -0
- buddypress/bp-em-templatetags.php +21 -0
- buddypress/screens/attending.php +29 -0
- buddypress/screens/group-events.php +30 -0
- buddypress/screens/my-bookings.php +35 -0
- buddypress/screens/my-events.php +55 -0
- buddypress/screens/my-group-events.php +27 -0
- buddypress/screens/my-locations.php +51 -0
- buddypress/screens/profile.php +32 -0
- classes/em-booking.php +1071 -378
- classes/em-bookings-table.php +647 -0
- classes/em-bookings.php +675 -487
- classes/em-calendar.php +414 -366
- classes/em-categories-taxonomy.php +115 -0
- classes/em-categories.php +282 -156
- classes/em-category-taxonomy.php +181 -0
- classes/em-category.php +250 -151
- classes/em-event-post-admin.php +406 -0
- classes/em-event-post.php +337 -0
- classes/em-event-posts-admin.php +280 -0
- classes/em-event.php +2320 -1005
- classes/em-events.php +436 -253
- classes/em-location-post-admin.php +169 -0
- classes/em-location-post.php +104 -0
- classes/em-location-posts-admin.php +84 -0
- classes/em-location.php +905 -306
- classes/em-locations.php +214 -212
admin/bookings/em-cancelled.php
CHANGED
@@ -1,133 +1,137 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Generates a "widget" table of confirmed bookings for a specific event.
|
4 |
-
*
|
5 |
-
* @param int $event_id
|
6 |
-
*/
|
7 |
-
function em_bookings_cancelled_table(){
|
8 |
-
global $EM_Event, $wpdb, $current_user;
|
9 |
-
|
10 |
-
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_cancelled_table' );
|
11 |
-
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
12 |
-
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
13 |
-
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
14 |
-
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
15 |
-
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
16 |
-
|
17 |
-
if( is_object($
|
18 |
-
$
|
19 |
-
}else{
|
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 |
-
<th class='manage-column' scope='col'>
|
82 |
-
|
83 |
-
|
84 |
-
<th class='manage-column' scope='col'
|
85 |
-
<th class='manage-column' scope='col'
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
<
|
101 |
-
<td><?php echo $EM_Booking->
|
102 |
-
<td>
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
<?php
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
133 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generates a "widget" table of confirmed bookings for a specific event.
|
4 |
+
*
|
5 |
+
* @param int $event_id
|
6 |
+
*/
|
7 |
+
function em_bookings_cancelled_table(){
|
8 |
+
global $EM_Event, $EM_Ticket, $wpdb, $current_user;
|
9 |
+
|
10 |
+
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_cancelled_table' );
|
11 |
+
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
12 |
+
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
13 |
+
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
14 |
+
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
15 |
+
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
16 |
+
|
17 |
+
if( is_object($EM_Ticket) ){
|
18 |
+
$EM_Bookings = $EM_Ticket->get_bookings()->get_cancelled_bookings();
|
19 |
+
}else{
|
20 |
+
if( is_object($EM_Event) ){
|
21 |
+
$EM_Bookings = $EM_Event->get_bookings()->get_cancelled_bookings();
|
22 |
+
}else{
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
$bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
|
27 |
+
?>
|
28 |
+
<div class='wrap em_bookings_pending_table em_obj'>
|
29 |
+
<form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
|
30 |
+
<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
|
31 |
+
<!--
|
32 |
+
<ul class="subsubsub">
|
33 |
+
<li>
|
34 |
+
<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
|
35 |
+
</li>
|
36 |
+
</ul>
|
37 |
+
<p class="search-box">
|
38 |
+
<label class="screen-reader-text" for="post-search-input"><?php _e('Search', 'dbem'); ?>:</label>
|
39 |
+
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
|
40 |
+
<input type="submit" value="<?php _e('Search', 'dbem'); ?>" class="button" />
|
41 |
+
</p>
|
42 |
+
-->
|
43 |
+
<?php if ( $bookings_count >= $limit ) : ?>
|
44 |
+
<div class='tablenav'>
|
45 |
+
<!--
|
46 |
+
<div class="alignleft actions">
|
47 |
+
<select name="action">
|
48 |
+
<option value="-1" selected="selected">
|
49 |
+
<?php _e('Bulk Actions', 'dbem'); ?>
|
50 |
+
</option>
|
51 |
+
<option value="approve">
|
52 |
+
<?php _e('Approve', 'dbem'); ?>
|
53 |
+
</option>
|
54 |
+
<option value="decline">
|
55 |
+
<?php _e('Decline', 'dbem'); ?>
|
56 |
+
</option>
|
57 |
+
</select>
|
58 |
+
<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
|
59 |
+
</div>
|
60 |
+
-->
|
61 |
+
<!--
|
62 |
+
<div class="view-switch">
|
63 |
+
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
64 |
+
</div>
|
65 |
+
-->
|
66 |
+
<?php
|
67 |
+
if ( $bookings_count >= $limit ) {
|
68 |
+
$bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
|
69 |
+
echo $bookings_nav;
|
70 |
+
}
|
71 |
+
?>
|
72 |
+
<div class="clear"></div>
|
73 |
+
</div>
|
74 |
+
<?php endif; ?>
|
75 |
+
<div class="clear"></div>
|
76 |
+
<?php if( $bookings_count > 0 ): ?>
|
77 |
+
<div class='table-wrap'>
|
78 |
+
<table id='dbem-bookings-table' class='widefat post '>
|
79 |
+
<thead>
|
80 |
+
<tr>
|
81 |
+
<th class='manage-column column-cb check-column' scope='col'>
|
82 |
+
<input class='select-all' type="checkbox" value='1' />
|
83 |
+
</th>
|
84 |
+
<th class='manage-column' scope='col'><?php _e('Booker', 'dbem'); ?></th>
|
85 |
+
<th class='manage-column' scope='col'><?php _e('E-mail', 'dbem'); ?></th>
|
86 |
+
<th class='manage-column' scope='col'><?php _e('Phone number', 'dbem'); ?></th>
|
87 |
+
<th class='manage-column' scope='col'><?php _e('Spaces', 'dbem'); ?></th>
|
88 |
+
<th class='manage-column' scope='col'> </th>
|
89 |
+
</tr>
|
90 |
+
</thead>
|
91 |
+
<tbody>
|
92 |
+
<?php
|
93 |
+
$rowno = 0;
|
94 |
+
$event_count = 0;
|
95 |
+
foreach ($EM_Bookings->bookings as $EM_Booking) {
|
96 |
+
if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
|
97 |
+
$rowno++;
|
98 |
+
?>
|
99 |
+
<tr>
|
100 |
+
<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
|
101 |
+
<td><a href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&person_id=<?php echo $EM_Booking->person->ID; ?>"><?php echo $EM_Booking->person->get_name() ?></a></td>
|
102 |
+
<td><?php echo $EM_Booking->person->user_email ?></td>
|
103 |
+
<td><?php echo $EM_Booking->person->phone ?></td>
|
104 |
+
<td><?php echo $EM_Booking->get_spaces() ?></td>
|
105 |
+
<td>
|
106 |
+
<?php
|
107 |
+
$approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id));
|
108 |
+
$delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id));
|
109 |
+
$edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id'=>$EM_Booking->booking_id, 'em_ajax'=>null, 'em_obj'=>null));
|
110 |
+
?>
|
111 |
+
<a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Restore','dbem'); ?></a> |
|
112 |
+
<a class="em-bookings-edit" href="<?php echo $edit_url; ?>"><?php _e('Edit/View','dbem'); ?></a> |
|
113 |
+
<a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
|
114 |
+
</td>
|
115 |
+
</tr>
|
116 |
+
<?php
|
117 |
+
}
|
118 |
+
$event_count++;
|
119 |
+
}
|
120 |
+
?>
|
121 |
+
</tbody>
|
122 |
+
</table>
|
123 |
+
</div>
|
124 |
+
<?php else: ?>
|
125 |
+
<?php _e('No cancelled bookings.', 'dbem'); ?>
|
126 |
+
<?php endif; ?>
|
127 |
+
</form>
|
128 |
+
<?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
|
129 |
+
<div class='tablenav'>
|
130 |
+
<?php echo $bookings_nav; ?>
|
131 |
+
<div class="clear"></div>
|
132 |
+
</div>
|
133 |
+
<?php endif; ?>
|
134 |
+
</div>
|
135 |
+
<?php
|
136 |
+
}
|
137 |
Â
?>
|
admin/bookings/em-confirmed.php
CHANGED
@@ -1,140 +1,144 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generates a "widget" table of confirmed bookings for a specific event.
|
5 |
-
*
|
6 |
-
* @param int $event_id
|
7 |
-
*/
|
8 |
-
function em_bookings_confirmed_table(){
|
9 |
-
global $EM_Event, $wpdb, $current_user;
|
10 |
-
|
11 |
-
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
|
12 |
-
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
13 |
-
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
14 |
-
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
15 |
-
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
16 |
-
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
17 |
-
|
18 |
-
if( is_object($
|
19 |
-
$
|
20 |
-
}else{
|
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 |
-
<th class='manage-column' scope='col'>
|
83 |
-
|
84 |
-
|
85 |
-
<th class='manage-column' scope='col'
|
86 |
-
<th class='manage-column' scope='col'
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
<
|
102 |
-
<td><?php echo $EM_Booking->
|
103 |
-
<td>
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
<?php
|
114 |
-
<a class="em-bookings-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
<?php
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
140 |
Â
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Generates a "widget" table of confirmed bookings for a specific event.
|
5 |
+
*
|
6 |
+
* @param int $event_id
|
7 |
+
*/
|
8 |
+
function em_bookings_confirmed_table(){
|
9 |
+
global $EM_Event, $EM_Ticket, $wpdb, $current_user;
|
10 |
+
|
11 |
+
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
|
12 |
+
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
13 |
+
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
14 |
+
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
15 |
+
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
16 |
+
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
17 |
+
|
18 |
+
if( is_object($EM_Ticket) ){
|
19 |
+
$EM_Bookings = $EM_Ticket->get_bookings()->get_bookings();
|
20 |
+
}else{
|
21 |
+
if( is_object($EM_Event) ){
|
22 |
+
$EM_Bookings = $EM_Event->get_bookings()->get_bookings();
|
23 |
+
}else{
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
$bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
|
28 |
+
?>
|
29 |
+
<div class='wrap em_bookings_pending_table em_obj'>
|
30 |
+
<form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
|
31 |
+
<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
|
32 |
+
<!--
|
33 |
+
<ul class="subsubsub">
|
34 |
+
<li>
|
35 |
+
<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
|
36 |
+
</li>
|
37 |
+
</ul>
|
38 |
+
<p class="search-box">
|
39 |
+
<label class="screen-reader-text" for="post-search-input"><?php _e('Search', 'dbem'); ?>:</label>
|
40 |
+
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
|
41 |
+
<input type="submit" value="<?php _e('Search', 'dbem'); ?>" class="button" />
|
42 |
+
</p>
|
43 |
+
-->
|
44 |
+
<?php if ( $bookings_count >= $limit ) : ?>
|
45 |
+
<div class='tablenav'>
|
46 |
+
<!--
|
47 |
+
<div class="alignleft actions">
|
48 |
+
<select name="action">
|
49 |
+
<option value="-1" selected="selected">
|
50 |
+
<?php _e('Bulk Actions', 'dbem'); ?>
|
51 |
+
</option>
|
52 |
+
<option value="approve">
|
53 |
+
<?php _e('Approve', 'dbem'); ?>
|
54 |
+
</option>
|
55 |
+
<option value="decline">
|
56 |
+
<?php _e('Decline', 'dbem'); ?>
|
57 |
+
</option>
|
58 |
+
</select>
|
59 |
+
<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
|
60 |
+
</div>
|
61 |
+
-->
|
62 |
+
<!--
|
63 |
+
<div class="view-switch">
|
64 |
+
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
65 |
+
</div>
|
66 |
+
-->
|
67 |
+
<?php
|
68 |
+
if ( $bookings_count >= $limit ) {
|
69 |
+
$bookings_nav = em_admin_paginate($bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
|
70 |
+
echo $bookings_nav;
|
71 |
+
}
|
72 |
+
?>
|
73 |
+
<div class="clear"></div>
|
74 |
+
</div>
|
75 |
+
<?php endif; ?>
|
76 |
+
<div class="clear"></div>
|
77 |
+
<?php if( $bookings_count > 0 ): ?>
|
78 |
+
<div class='table-wrap'>
|
79 |
+
<table id='dbem-bookings-table' class='widefat post '>
|
80 |
+
<thead>
|
81 |
+
<tr>
|
82 |
+
<th class='manage-column column-cb check-column' scope='col'>
|
83 |
+
<input class='select-all' type="checkbox" value='1' />
|
84 |
+
</th>
|
85 |
+
<th class='manage-column' scope='col'><?php _e('Booker', 'dbem'); ?></th>
|
86 |
+
<th class='manage-column' scope='col'><?php _e('E-mail', 'dbem'); ?></th>
|
87 |
+
<th class='manage-column' scope='col'><?php _e('Phone number', 'dbem'); ?></th>
|
88 |
+
<th class='manage-column' scope='col'><?php _e('Spaces', 'dbem'); ?></th>
|
89 |
+
<th class='manage-column' scope='col'> </th>
|
90 |
+
</tr>
|
91 |
+
</thead>
|
92 |
+
<tbody>
|
93 |
+
<?php
|
94 |
+
$rowno = 0;
|
95 |
+
$event_count = 0;
|
96 |
+
foreach ($EM_Bookings->bookings as $EM_Booking) {
|
97 |
+
if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
|
98 |
+
$rowno++;
|
99 |
+
?>
|
100 |
+
<tr>
|
101 |
+
<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
|
102 |
+
<td><a href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&person_id=<?php echo $EM_Booking->person_id; ?>"><?php echo $EM_Booking->person->get_name() ?></a></td>
|
103 |
+
<td><?php echo $EM_Booking->person->user_email ?></td>
|
104 |
+
<td><?php echo $EM_Booking->person->phone ?></td>
|
105 |
+
<td><?php echo $EM_Booking->get_spaces() ?></td>
|
106 |
+
<td>
|
107 |
+
<?php
|
108 |
+
$unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_unapprove', 'booking_id'=>$EM_Booking->booking_id));
|
109 |
+
$reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id));
|
110 |
+
$delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id));
|
111 |
+
$edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id'=>$EM_Booking->booking_id, 'em_ajax'=>null, 'em_obj'=>null));
|
112 |
+
?>
|
113 |
+
<?php if( current_user_can('manage_bookings') && get_option('dbem_bookings_approval') ): ?>
|
114 |
+
<a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
|
115 |
+
<?php else: ?>
|
116 |
+
<a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
|
117 |
+
<?php endif; ?>
|
118 |
+
<span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span> |
|
119 |
+
<a class="em-bookings-edit" href="<?php echo $edit_url; ?>"><?php _e('Edit/View','dbem'); ?></a>
|
120 |
+
</td>
|
121 |
+
</tr>
|
122 |
+
<?php
|
123 |
+
}
|
124 |
+
$event_count++;
|
125 |
+
}
|
126 |
+
?>
|
127 |
+
</tbody>
|
128 |
+
</table>
|
129 |
+
</div>
|
130 |
+
<?php else: ?>
|
131 |
+
<?php _e('No confirmed bookings.', 'dbem'); ?>
|
132 |
+
<?php endif; ?>
|
133 |
+
</form>
|
134 |
+
<?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
|
135 |
+
<div class='tablenav'>
|
136 |
+
<?php echo $bookings_nav; ?>
|
137 |
+
<div class="clear"></div>
|
138 |
+
</div>
|
139 |
+
<?php endif; ?>
|
140 |
+
</div>
|
141 |
+
<?php
|
142 |
+
|
143 |
+
}
|
144 |
Â
?>
|
admin/bookings/em-events.php
CHANGED
@@ -1,179 +1,171 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Determines whether to show event page or events page, and saves any updates to the event or events
|
5 |
-
* @return null
|
6 |
-
*/
|
7 |
-
function em_bookings_events_table() {
|
8 |
-
//TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
|
9 |
-
global $wpdb;
|
10 |
-
global $EM_Event;
|
11 |
-
|
12 |
-
$scope_names = array (
|
13 |
-
'past' => __ ( 'Past events', 'dbem' ),
|
14 |
-
'all' => __ ( 'All events', 'dbem' ),
|
15 |
-
'future' => __ ( 'Future events', 'dbem' )
|
16 |
-
);
|
17 |
-
|
18 |
-
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table' );
|
19 |
-
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
20 |
-
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
21 |
-
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
22 |
-
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
23 |
-
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
24 |
-
$scope = ( $action_scope && !empty($_GET ['scope']) && array_key_exists($_GET ['scope'], $scope_names) ) ? $_GET ['scope']:'future';
|
25 |
-
|
26 |
-
// No action, only showing the events list
|
27 |
-
switch ($scope) {
|
28 |
-
case "past" :
|
29 |
-
$title = __ ( 'Past Events', 'dbem' );
|
30 |
-
break;
|
31 |
-
case "all" :
|
32 |
-
$title = __ ( 'All Events', 'dbem' );
|
33 |
-
break;
|
34 |
-
default :
|
35 |
-
$title = __ ( 'Future Events', 'dbem' );
|
36 |
-
$scope = "future";
|
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 |
-
|
97 |
-
|
98 |
-
<th
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
<?php endif; ?>
|
172 |
-
<br class='clear' />
|
173 |
-
</div>
|
174 |
-
</form>
|
175 |
-
</div>
|
176 |
-
<?php
|
177 |
-
}
|
178 |
-
|
179 |
Â
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Determines whether to show event page or events page, and saves any updates to the event or events
|
5 |
+
* @return null
|
6 |
+
*/
|
7 |
+
function em_bookings_events_table() {
|
8 |
+
//TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
|
9 |
+
global $wpdb;
|
10 |
+
global $EM_Event;
|
11 |
+
|
12 |
+
$scope_names = array (
|
13 |
+
'past' => __ ( 'Past events', 'dbem' ),
|
14 |
+
'all' => __ ( 'All events', 'dbem' ),
|
15 |
+
'future' => __ ( 'Future events', 'dbem' )
|
16 |
+
);
|
17 |
+
|
18 |
+
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table' );
|
19 |
+
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
20 |
+
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
21 |
+
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
22 |
+
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
23 |
+
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
24 |
+
$scope = ( $action_scope && !empty($_GET ['scope']) && array_key_exists($_GET ['scope'], $scope_names) ) ? $_GET ['scope']:'future';
|
25 |
+
|
26 |
+
// No action, only showing the events list
|
27 |
+
switch ($scope) {
|
28 |
+
case "past" :
|
29 |
+
$title = __ ( 'Past Events', 'dbem' );
|
30 |
+
break;
|
31 |
+
case "all" :
|
32 |
+
$title = __ ( 'All Events', 'dbem' );
|
33 |
+
break;
|
34 |
+
default :
|
35 |
+
$title = __ ( 'Future Events', 'dbem' );
|
36 |
+
$scope = "future";
|
37 |
+
}
|
38 |
+
$owner = !current_user_can('manage_others_bookings') ? get_current_user_id() : false;
|
39 |
+
$events = EM_Events::get( array('scope'=>$scope, 'limit'=>$limit, 'offset' => $offset, 'order'=>$order, 'bookings'=>true, 'owner' => $owner ) );
|
40 |
+
$events_count = EM_Events::count( array('scope'=>$scope, 'limit'=>0, 'order'=>$order, 'bookings'=>true, 'owner' => $owner ) );
|
41 |
+
|
42 |
+
$use_events_end = get_option ( 'dbem_use_event_end' );
|
43 |
+
?>
|
44 |
+
<div class="wrap em_bookings_events_table em_obj">
|
45 |
+
<form id="posts-filter" action="" method="get">
|
46 |
+
<input type="hidden" name="em_obj" value="em_bookings_events_table" />
|
47 |
+
<?php if(!empty($_GET['page'])): ?>
|
48 |
+
<input type='hidden' name='page' value='events-manager-bookings' />
|
49 |
+
<?php endif; ?>
|
50 |
+
<div class="tablenav">
|
51 |
+
<div class="alignleft actions">
|
52 |
+
<!--
|
53 |
+
<select name="action">
|
54 |
+
<option value="-1" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
|
55 |
+
<option value="deleteEvents"><?php _e ( 'Delete selected','dbem' ); ?></option>
|
56 |
+
</select>
|
57 |
+
<input type="submit" value="<?php _e ( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
58 |
+
-->
|
59 |
+
<select name="scope">
|
60 |
+
<?php
|
61 |
+
foreach ( $scope_names as $key => $value ) {
|
62 |
+
$selected = "";
|
63 |
+
if ($key == $scope)
|
64 |
+
$selected = "selected='selected'";
|
65 |
+
echo "<option value='$key' $selected>$value</option> ";
|
66 |
+
}
|
67 |
+
?>
|
68 |
+
</select>
|
69 |
+
<input id="post-query-submit" class="button-secondary" type="submit" value="<?php _e ( 'Filter' )?>" />
|
70 |
+
</div>
|
71 |
+
<!--
|
72 |
+
<div class="view-switch">
|
73 |
+
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
74 |
+
</div>
|
75 |
+
-->
|
76 |
+
<?php
|
77 |
+
if ( $events_count >= $limit ) {
|
78 |
+
$events_nav = em_admin_paginate( $events_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_events_table'));
|
79 |
+
echo $events_nav;
|
80 |
+
}
|
81 |
+
?>
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<?php
|
85 |
+
if (empty ( $events )) {
|
86 |
+
// TODO localize
|
87 |
+
_e ( 'no events','dbem' );
|
88 |
+
} else {
|
89 |
+
?>
|
90 |
+
<div class='table-wrap'>
|
91 |
+
<table class="widefat">
|
92 |
+
<thead>
|
93 |
+
<tr>
|
94 |
+
<th class='manage-column column-cb check-column' scope='col'>
|
95 |
+
<input class='select-all' type="checkbox" value='1' />
|
96 |
+
</th>
|
97 |
+
<th><?php _e ( 'Event', 'dbem' ); ?></th>
|
98 |
+
<th><?php _e ( 'Date and time', 'dbem' ); ?></th>
|
99 |
+
</tr>
|
100 |
+
</thead>
|
101 |
+
<tbody>
|
102 |
+
<?php
|
103 |
+
$rowno = 0;
|
104 |
+
foreach ( $events as $event ) {
|
105 |
+
/* @var $event EM_Event */
|
106 |
+
$rowno++;
|
107 |
+
$class = ($rowno % 2) ? ' class="alternate"' : '';
|
108 |
+
// FIXME set to american
|
109 |
+
$localised_start_date = date_i18n(get_option('date_format'), $event->start);
|
110 |
+
$localised_end_date = date_i18n(get_option('date_format'), $event->end);
|
111 |
+
$style = "";
|
112 |
+
$today = date ( "Y-m-d" );
|
113 |
+
|
114 |
+
if ($event->start_date < $today && $event->end_date < $today){
|
115 |
+
$style = "style ='background-color: #FADDB7;'";
|
116 |
+
}
|
117 |
+
?>
|
118 |
+
<tr <?php echo "$class $style"; ?>>
|
119 |
+
|
120 |
+
<td>
|
121 |
+
<input type='checkbox' class='row-selector' value='<?php echo $event->event_id; ?>' name='events[]' />
|
122 |
+
</td>
|
123 |
+
<td>
|
124 |
+
<strong>
|
125 |
+
<?php echo $event->output('#_BOOKINGSLINK'); ?>
|
126 |
+
</strong>
|
127 |
+
–
|
128 |
+
<?php _e("Booked Spaces",'dbem') ?>: <?php echo $event->get_bookings()->get_booked_spaces()."/".$event->get_spaces() ?>
|
129 |
+
<?php if( get_option('dbem_bookings_approval') == 1 ) : ?>
|
130 |
+
| <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_spaces(); ?>
|
131 |
+
<?php endif; ?>
|
132 |
+
</td>
|
133 |
+
|
134 |
+
<td>
|
135 |
+
<?php echo $localised_start_date; ?>
|
136 |
+
<?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
|
137 |
+
–
|
138 |
+
<?php
|
139 |
+
//TODO Should 00:00 - 00:00 be treated as an all day event?
|
140 |
+
echo substr ( $event->start_time, 0, 5 ) . " - " . substr ( $event->end_time, 0, 5 );
|
141 |
+
?>
|
142 |
+
</td>
|
143 |
+
</tr>
|
144 |
+
<?php
|
145 |
+
}
|
146 |
+
?>
|
147 |
+
</tbody>
|
148 |
+
</table>
|
149 |
+
</div>
|
150 |
+
<?php
|
151 |
+
} // end of table
|
152 |
+
?>
|
153 |
+
<div class='tablenav'>
|
154 |
+
<div class="alignleft actions">
|
155 |
+
<br class='clear' />
|
156 |
+
</div>
|
157 |
+
<?php if (!empty($events_nav) && $events_count >= $limit ) : ?>
|
158 |
+
<div class="tablenav-pages">
|
159 |
+
<?php
|
160 |
+
echo $events_nav;
|
161 |
+
?>
|
162 |
+
</div>
|
163 |
+
<?php endif; ?>
|
164 |
+
<br class='clear' />
|
165 |
+
</div>
|
166 |
+
</form>
|
167 |
+
</div>
|
168 |
+
<?php
|
169 |
+
}
|
170 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
171 |
Â
?>
|
admin/bookings/em-pending.php
CHANGED
@@ -1,155 +1,159 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generates a "widget" table of pending bookings with some quick admin operation options.
|
5 |
-
* If event id supplied then only pending bookings for that event will show.
|
6 |
-
*
|
7 |
-
* @param int $event_id
|
8 |
-
*/
|
9 |
-
function em_bookings_pending_table($event_id = false){
|
10 |
-
global $EM_Event, $wpdb, $current_user;
|
11 |
-
|
12 |
-
if( get_option('dbem_bookings_approval') == 0 ){
|
13 |
-
return false;
|
14 |
-
}
|
15 |
-
|
16 |
-
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_pending_table' );
|
17 |
-
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
18 |
-
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
19 |
-
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
20 |
-
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
21 |
-
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
22 |
-
|
23 |
-
if( is_object($
|
24 |
-
$
|
25 |
-
}else{
|
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 |
-
<th class='manage-column' scope='col'>
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
<th class='manage-column' scope=
|
102 |
-
|
103 |
-
<th class='manage-column' scope='col'
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
<
|
119 |
-
<?php
|
120 |
-
|
121 |
-
<td><?php echo $EM_Booking->
|
122 |
-
|
123 |
-
<td>
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
</
|
150 |
-
<?php
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
155 |
Â
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Generates a "widget" table of pending bookings with some quick admin operation options.
|
5 |
+
* If event id supplied then only pending bookings for that event will show.
|
6 |
+
*
|
7 |
+
* @param int $event_id
|
8 |
+
*/
|
9 |
+
function em_bookings_pending_table($event_id = false){
|
10 |
+
global $EM_Event, $EM_Ticket, $wpdb, $current_user;
|
11 |
+
|
12 |
+
if( get_option('dbem_bookings_approval') == 0 ){
|
13 |
+
return false;
|
14 |
+
}
|
15 |
+
|
16 |
+
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_pending_table' );
|
17 |
+
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
18 |
+
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
19 |
+
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
20 |
+
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
21 |
+
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
22 |
+
|
23 |
+
if( is_object($EM_Ticket) ){
|
24 |
+
$EM_Bookings = $EM_Ticket->get_bookings()->get_pending_bookings();
|
25 |
+
}else{
|
26 |
+
if( is_object($EM_Event) ){
|
27 |
+
$EM_Bookings = $EM_Event->get_bookings()->get_pending_bookings();
|
28 |
+
}else{
|
29 |
+
//To optimize performance, we can do one query here for all pending bookings to show.
|
30 |
+
$EM_Bookings = EM_Bookings::get(array('status'=>0));
|
31 |
+
$events = array();
|
32 |
+
//Now let's create events and bookings for this:
|
33 |
+
foreach($EM_Bookings->bookings as $EM_Booking){
|
34 |
+
//create event
|
35 |
+
if( !array_key_exists($EM_Booking->event_id,$events) ){
|
36 |
+
$events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
$bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
|
42 |
+
?>
|
43 |
+
<div class='wrap em_bookings_pending_table em_obj'>
|
44 |
+
<form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
|
45 |
+
<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
|
46 |
+
<!--
|
47 |
+
<ul class="subsubsub">
|
48 |
+
<li>
|
49 |
+
<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
|
50 |
+
</li>
|
51 |
+
</ul>
|
52 |
+
<p class="search-box">
|
53 |
+
<label class="screen-reader-text" for="post-search-input"><?php _e('Search', 'dbem'); ?>:</label>
|
54 |
+
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
|
55 |
+
<input type="submit" value="<?php _e('Search', 'dbem'); ?>" class="button" />
|
56 |
+
</p>
|
57 |
+
-->
|
58 |
+
<?php if ( $bookings_count >= $limit ) : ?>
|
59 |
+
<div class='tablenav'>
|
60 |
+
<!--
|
61 |
+
<div class="alignleft actions">
|
62 |
+
<select name="action">
|
63 |
+
<option value="-1" selected="selected">
|
64 |
+
<?php _e('Bulk Actions', 'dbem'); ?>
|
65 |
+
</option>
|
66 |
+
<option value="approve">
|
67 |
+
<?php _e('Approve', 'dbem'); ?>
|
68 |
+
</option>
|
69 |
+
<option value="decline">
|
70 |
+
<?php _e('Decline', 'dbem'); ?>
|
71 |
+
</option>
|
72 |
+
</select>
|
73 |
+
<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
|
74 |
+
</div>
|
75 |
+
-->
|
76 |
+
<!--
|
77 |
+
<div class="view-switch">
|
78 |
+
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
79 |
+
</div>
|
80 |
+
-->
|
81 |
+
<?php
|
82 |
+
if ( $bookings_count >= $limit ) {
|
83 |
+
$bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_pending_table'));
|
84 |
+
echo $bookings_nav;
|
85 |
+
}
|
86 |
+
?>
|
87 |
+
<div class="clear"></div>
|
88 |
+
</div>
|
89 |
+
<?php endif; ?>
|
90 |
+
<div class="clear"></div>
|
91 |
+
<?php if( $bookings_count > 0 ): ?>
|
92 |
+
<div class='table-wrap'>
|
93 |
+
<table id='dbem-bookings-table' class='widefat post '>
|
94 |
+
<thead>
|
95 |
+
<tr>
|
96 |
+
<th class='manage-column column-cb check-column' scope='col'>
|
97 |
+
<input class='select-all' type="checkbox" value='1' />
|
98 |
+
</th>
|
99 |
+
<th class='manage-column' scope='col'><?php _e('Booker', 'dbem'); ?></th>
|
100 |
+
<?php if( !is_object($EM_Event) && !is_object($EM_Ticket) ): ?>
|
101 |
+
<th class='manage-column' scope="col"><?php _e('Event', 'dbem'); ?></th>
|
102 |
+
<?php endif; ?>
|
103 |
+
<th class='manage-column' scope='col'><?php _e('E-mail', 'dbem'); ?></th>
|
104 |
+
<th class='manage-column' scope='col'><?php _e('Phone number', 'dbem'); ?></th>
|
105 |
+
<th class='manage-column' scope='col'><?php _e('Spaces', 'dbem'); ?></th>
|
106 |
+
<th class='manage-column' scope='col'> </th>
|
107 |
+
</tr>
|
108 |
+
</thead>
|
109 |
+
<tbody>
|
110 |
+
<?php
|
111 |
+
$rowno = 0;
|
112 |
+
$event_count = 0;
|
113 |
+
foreach ($EM_Bookings->bookings as $EM_Booking) {
|
114 |
+
if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
|
115 |
+
$rowno++;
|
116 |
+
?>
|
117 |
+
<tr>
|
118 |
+
<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
|
119 |
+
<td><a href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&person_id=<?php echo $EM_Booking->person->ID; ?>"><?php echo $EM_Booking->person->get_name() ?></a></td>
|
120 |
+
<?php if( !is_object($EM_Event) && !is_object($EM_Ticket) ): ?>
|
121 |
+
<td><a href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&event_id=<?php echo $EM_Booking->event_id; ?>"><?php echo $events[$EM_Booking->event_id]->name ?></a></td>
|
122 |
+
<?php endif; ?>
|
123 |
+
<td><?php echo $EM_Booking->person->user_email ?></td>
|
124 |
+
<td><?php echo $EM_Booking->person->phone ?></td>
|
125 |
+
<td><?php echo $EM_Booking->get_spaces() ?></td>
|
126 |
+
<td>
|
127 |
+
<?php
|
128 |
+
$approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id));
|
129 |
+
$reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id));
|
130 |
+
$delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id));
|
131 |
+
?>
|
132 |
+
<a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
|
133 |
+
<a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
|
134 |
+
<span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span> |
|
135 |
+
<a class="em-bookings-edit" href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&booking_id=<?php echo $EM_Booking->booking_id; ?>"><?php _e('Edit/View','dbem'); ?></a>
|
136 |
+
</td>
|
137 |
+
</tr>
|
138 |
+
<?php
|
139 |
+
}
|
140 |
+
$event_count++;
|
141 |
+
}
|
142 |
+
?>
|
143 |
+
</tbody>
|
144 |
+
</table>
|
145 |
+
</div>
|
146 |
+
<?php else: ?>
|
147 |
+
<?php _e('No pending bookings.', 'dbem'); ?>
|
148 |
+
<?php endif; ?>
|
149 |
+
</form>
|
150 |
+
<?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
|
151 |
+
<div class='tablenav'>
|
152 |
+
<?php echo $bookings_nav; ?>
|
153 |
+
<div class="clear"></div>
|
154 |
+
</div>
|
155 |
+
<?php endif; ?>
|
156 |
+
</div>
|
157 |
+
<?php
|
158 |
+
}
|
159 |
Â
?>
|
admin/bookings/em-person.php
CHANGED
@@ -1,150 +1,152 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Generates a "widget" table of confirmed bookings for a specific event.
|
5 |
-
*
|
6 |
-
* @param int $event_id
|
7 |
-
*/
|
8 |
-
function em_bookings_person_table(){
|
9 |
-
global $wpdb, $current_user,$EM_Person;
|
10 |
-
if(!is_object($EM_Person)){
|
11 |
-
return false;
|
12 |
-
}
|
13 |
-
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
|
14 |
-
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
15 |
-
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
16 |
-
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
17 |
-
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
18 |
-
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
19 |
-
|
20 |
-
$bookings = $EM_Person->get_bookings();
|
21 |
-
$bookings_count =
|
22 |
-
if($bookings_count > 0){
|
23 |
-
//Get events here in one query to speed things up
|
24 |
-
foreach($bookings as $EM_Booking){
|
25 |
-
$event_ids[] = $EM_Booking->event_id;
|
26 |
-
}
|
27 |
-
$events = EM_Events::get($event_ids);
|
28 |
-
}
|
29 |
-
?>
|
30 |
-
<div class='wrap em_bookings_pending_table em_obj'>
|
31 |
-
<form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
|
32 |
-
<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
|
33 |
-
<!--
|
34 |
-
<ul class="subsubsub">
|
35 |
-
<li>
|
36 |
-
<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
|
37 |
-
</li>
|
38 |
-
</ul>
|
39 |
-
<p class="search-box">
|
40 |
-
<label class="screen-reader-text" for="post-search-input"><?php _e('Search'); ?>:</label>
|
41 |
-
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
|
42 |
-
<input type="submit" value="<?php _e('Search'); ?>" class="button" />
|
43 |
-
</p>
|
44 |
-
-->
|
45 |
-
<?php if ( $bookings_count >= $limit ) : ?>
|
46 |
-
<div class='tablenav'>
|
47 |
-
<!--
|
48 |
-
<div class="alignleft actions">
|
49 |
-
<select name="action">
|
50 |
-
<option value="-1" selected="selected">
|
51 |
-
<?php _e('Bulk Actions'); ?>
|
52 |
-
</option>
|
53 |
-
<option value="approve">
|
54 |
-
<?php _e('Approve', 'dbem'); ?>
|
55 |
-
</option>
|
56 |
-
<option value="decline">
|
57 |
-
<?php _e('Decline', 'dbem'); ?>
|
58 |
-
</option>
|
59 |
-
</select>
|
60 |
-
<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
|
61 |
-
</div>
|
62 |
-
-->
|
63 |
-
<!--
|
64 |
-
<div class="view-switch">
|
65 |
-
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
66 |
-
</div>
|
67 |
-
-->
|
68 |
-
<?php
|
69 |
-
if ( $bookings_count >= $limit ) {
|
70 |
-
$
|
71 |
-
$bookings_nav
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
<
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
<th class='manage-column' scope='col'
|
88 |
-
<th class='manage-column' scope='col'
|
89 |
-
<th class='manage-column' scope='col'
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$
|
96 |
-
$
|
97 |
-
|
98 |
-
$EM_Event
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
<
|
104 |
-
<td
|
105 |
-
<td><?php echo $EM_Booking->
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
$
|
112 |
-
$
|
113 |
-
|
114 |
-
?>
|
115 |
-
<?php
|
116 |
-
|
117 |
-
<?php
|
118 |
-
<?php
|
119 |
-
|
120 |
-
<?php
|
121 |
-
<?php
|
122 |
-
|
123 |
-
<?php
|
124 |
-
<a class="em-bookings-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
<?php
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
Â
|
|
Â
|
|
150 |
Â
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Generates a "widget" table of confirmed bookings for a specific event.
|
5 |
+
*
|
6 |
+
* @param int $event_id
|
7 |
+
*/
|
8 |
+
function em_bookings_person_table(){
|
9 |
+
global $wpdb, $current_user,$EM_Person;
|
10 |
+
if(!is_object($EM_Person)){
|
11 |
+
return false;
|
12 |
+
}
|
13 |
+
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
|
14 |
+
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
15 |
+
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
16 |
+
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
17 |
+
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
18 |
+
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
19 |
+
|
20 |
+
$bookings = $EM_Person->get_bookings();
|
21 |
+
$bookings_count = count($bookings);
|
22 |
+
if($bookings_count > 0){
|
23 |
+
//Get events here in one query to speed things up
|
24 |
+
foreach($bookings as $EM_Booking){
|
25 |
+
$event_ids[] = $EM_Booking->event_id;
|
26 |
+
}
|
27 |
+
$events = EM_Events::get($event_ids);
|
28 |
+
}
|
29 |
+
?>
|
30 |
+
<div class='wrap em_bookings_pending_table em_obj'>
|
31 |
+
<form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
|
32 |
+
<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
|
33 |
+
<!--
|
34 |
+
<ul class="subsubsub">
|
35 |
+
<li>
|
36 |
+
<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
|
37 |
+
</li>
|
38 |
+
</ul>
|
39 |
+
<p class="search-box">
|
40 |
+
<label class="screen-reader-text" for="post-search-input"><?php _e('Search', 'dbem'); ?>:</label>
|
41 |
+
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
|
42 |
+
<input type="submit" value="<?php _e('Search', 'dbem'); ?>" class="button" />
|
43 |
+
</p>
|
44 |
+
-->
|
45 |
+
<?php if ( $bookings_count >= $limit ) : ?>
|
46 |
+
<div class='tablenav'>
|
47 |
+
<!--
|
48 |
+
<div class="alignleft actions">
|
49 |
+
<select name="action">
|
50 |
+
<option value="-1" selected="selected">
|
51 |
+
<?php _e('Bulk Actions', 'dbem'); ?>
|
52 |
+
</option>
|
53 |
+
<option value="approve">
|
54 |
+
<?php _e('Approve', 'dbem'); ?>
|
55 |
+
</option>
|
56 |
+
<option value="decline">
|
57 |
+
<?php _e('Decline', 'dbem'); ?>
|
58 |
+
</option>
|
59 |
+
</select>
|
60 |
+
<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
|
61 |
+
</div>
|
62 |
+
-->
|
63 |
+
<!--
|
64 |
+
<div class="view-switch">
|
65 |
+
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
66 |
+
</div>
|
67 |
+
-->
|
68 |
+
<?php
|
69 |
+
if ( $bookings_count >= $limit ) {
|
70 |
+
$bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
|
71 |
+
echo $bookings_nav;
|
72 |
+
}
|
73 |
+
?>
|
74 |
+
<div class="clear"></div>
|
75 |
+
</div>
|
76 |
+
<?php endif; ?>
|
77 |
+
<div class="clear"></div>
|
78 |
+
<?php if( $bookings_count > 0 ): ?>
|
79 |
+
<div class='table-wrap'>
|
80 |
+
<table id='dbem-bookings-table' class='widefat post '>
|
81 |
+
<thead>
|
82 |
+
<tr>
|
83 |
+
<th class='manage-column column-cb check-column' scope='col'>
|
84 |
+
<input class='select-all' type="checkbox" value='1' />
|
85 |
+
</th>
|
86 |
+
<th class='manage-column' scope='col'><?php _e('Event', 'dbem'); ?></th>
|
87 |
+
<th class='manage-column' scope='col'><?php _e('Spaces', 'dbem'); ?></th>
|
88 |
+
<th class='manage-column' scope='col'><?php _e('Status', 'dbem'); ?></th>
|
89 |
+
<th class='manage-column' scope='col'> </th>
|
90 |
+
</tr>
|
91 |
+
</thead>
|
92 |
+
<tbody>
|
93 |
+
<?php
|
94 |
+
$rowno = 0;
|
95 |
+
$event_count = 0;
|
96 |
+
foreach ($bookings as $EM_Booking) {
|
97 |
+
$EM_Event = $events[$EM_Booking->event_id];
|
98 |
+
if( $EM_Event->can_manage('edit_events','edit_others_events') && ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
|
99 |
+
$rowno++;
|
100 |
+
?>
|
101 |
+
<tr>
|
102 |
+
<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
|
103 |
+
<td><a class="row-title" href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&event_id=<?php echo $EM_Event->event_id ?>"><?php echo ($EM_Event->event_name); ?></a></td>
|
104 |
+
<td><?php echo $EM_Booking->get_spaces() ?></td>
|
105 |
+
<td><?php echo $EM_Booking->status_array[$EM_Booking->booking_status]; ?>
|
106 |
+
</td>
|
107 |
+
<td>
|
108 |
+
<?php
|
109 |
+
$unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_unapprove', 'booking_id'=>$EM_Booking->booking_id));
|
110 |
+
$approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id));
|
111 |
+
$reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id));
|
112 |
+
$delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id));
|
113 |
+
?>
|
114 |
+
<?php if( get_option('dbem_bookings_approval') && ($EM_Booking->booking_status == 0 ) ): ?>
|
115 |
+
<a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
|
116 |
+
<?php endif; ?>
|
117 |
+
<?php if( get_option('dbem_bookings_approval') && $EM_Booking->booking_status == 1 ): ?>
|
118 |
+
<a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
|
119 |
+
<?php endif; ?>
|
120 |
+
<?php if( $EM_Booking->booking_status == 2 ): ?>
|
121 |
+
<a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Restore','dbem'); ?></a> |
|
122 |
+
<?php endif; ?>
|
123 |
+
<?php if( $EM_Booking->booking_status == 0 || $EM_Booking->booking_status == 1 ): ?>
|
124 |
+
<a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
|
125 |
+
<?php endif; ?>
|
126 |
+
<a class="em-bookings-edit" href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&booking_id=<?php echo $EM_Booking->booking_id; ?>"><?php _e('Edit/View','dbem'); ?></a> |
|
127 |
+
<span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span>
|
128 |
+
</td>
|
129 |
+
</tr>
|
130 |
+
<?php
|
131 |
+
}
|
132 |
+
$event_count++;
|
133 |
+
}
|
134 |
+
?>
|
135 |
+
</tbody>
|
136 |
+
</table>
|
137 |
+
</div>
|
138 |
+
<?php else: ?>
|
139 |
+
<?php _e('No confirmed bookings.', 'dbem'); ?>
|
140 |
+
<?php endif; ?>
|
141 |
+
</form>
|
142 |
+
<?php if( !empty($bookings_nav) && $bookings >= $limit ) : ?>
|
143 |
+
<div class='tablenav'>
|
144 |
+
<?php echo $bookings_nav; ?>
|
145 |
+
<div class="clear"></div>
|
146 |
+
</div>
|
147 |
+
<?php endif; ?>
|
148 |
+
</div>
|
149 |
+
<?php
|
150 |
+
|
151 |
+
}
|
152 |
Â
?>
|
admin/bookings/em-rejected.php
CHANGED
@@ -1,133 +1,137 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Generates a "widget" table of confirmed bookings for a specific event.
|
4 |
-
*
|
5 |
-
* @param int $event_id
|
6 |
-
*/
|
7 |
-
function em_bookings_rejected_table(){
|
8 |
-
global $EM_Event, $wpdb, $current_user;
|
9 |
-
|
10 |
-
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
|
11 |
-
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
12 |
-
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
13 |
-
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
14 |
-
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
15 |
-
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
16 |
-
|
17 |
-
if( is_object($
|
18 |
-
$
|
19 |
-
}else{
|
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 |
-
<th class='manage-column' scope='col'>
|
82 |
-
|
83 |
-
|
84 |
-
<th class='manage-column' scope='col'
|
85 |
-
<th class='manage-column' scope='col'
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
<
|
101 |
-
<td><?php echo $EM_Booking->
|
102 |
-
<td>
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
<?php
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
133 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generates a "widget" table of confirmed bookings for a specific event.
|
4 |
+
*
|
5 |
+
* @param int $event_id
|
6 |
+
*/
|
7 |
+
function em_bookings_rejected_table(){
|
8 |
+
global $EM_Event, $EM_Ticket, $wpdb, $current_user;
|
9 |
+
|
10 |
+
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
|
11 |
+
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
12 |
+
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
13 |
+
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
14 |
+
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
15 |
+
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
|
16 |
+
|
17 |
+
if( is_object($EM_Ticket) ){
|
18 |
+
$EM_Bookings = $EM_Ticket->get_bookings()->get_rejected_bookings();
|
19 |
+
}else{
|
20 |
+
if( is_object($EM_Event) ){
|
21 |
+
$EM_Bookings = $EM_Event->get_bookings()->get_rejected_bookings();
|
22 |
+
}else{
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
$bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
|
27 |
+
?>
|
28 |
+
<div class='wrap em_bookings_pending_table em_obj'>
|
29 |
+
<form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
|
30 |
+
<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
|
31 |
+
<!--
|
32 |
+
<ul class="subsubsub">
|
33 |
+
<li>
|
34 |
+
<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
|
35 |
+
</li>
|
36 |
+
</ul>
|
37 |
+
<p class="search-box">
|
38 |
+
<label class="screen-reader-text" for="post-search-input"><?php _e('Search', 'dbem'); ?>:</label>
|
39 |
+
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
|
40 |
+
<input type="submit" value="<?php _e('Search', 'dbem'); ?>" class="button" />
|
41 |
+
</p>
|
42 |
+
-->
|
43 |
+
<?php if ( $bookings_count >= $limit ) : ?>
|
44 |
+
<div class='tablenav'>
|
45 |
+
<!--
|
46 |
+
<div class="alignleft actions">
|
47 |
+
<select name="action">
|
48 |
+
<option value="-1" selected="selected">
|
49 |
+
<?php _e('Bulk Actions', 'dbem'); ?>
|
50 |
+
</option>
|
51 |
+
<option value="approve">
|
52 |
+
<?php _e('Approve', 'dbem'); ?>
|
53 |
+
</option>
|
54 |
+
<option value="decline">
|
55 |
+
<?php _e('Decline', 'dbem'); ?>
|
56 |
+
</option>
|
57 |
+
</select>
|
58 |
+
<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
|
59 |
+
</div>
|
60 |
+
-->
|
61 |
+
<!--
|
62 |
+
<div class="view-switch">
|
63 |
+
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
64 |
+
</div>
|
65 |
+
-->
|
66 |
+
<?php
|
67 |
+
if ( $bookings_count >= $limit ) {
|
68 |
+
$bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
|
69 |
+
echo $bookings_nav;
|
70 |
+
}
|
71 |
+
?>
|
72 |
+
<div class="clear"></div>
|
73 |
+
</div>
|
74 |
+
<?php endif; ?>
|
75 |
+
<div class="clear"></div>
|
76 |
+
<?php if( $bookings_count > 0 ): ?>
|
77 |
+
<div class='table-wrap'>
|
78 |
+
<table id='dbem-bookings-table' class='widefat post '>
|
79 |
+
<thead>
|
80 |
+
<tr>
|
81 |
+
<th class='manage-column column-cb check-column' scope='col'>
|
82 |
+
<input class='select-all' type="checkbox" value='1' />
|
83 |
+
</th>
|
84 |
+
<th class='manage-column' scope='col'><?php _e('Booker', 'dbem'); ?></th>
|
85 |
+
<th class='manage-column' scope='col'><?php _e('E-mail', 'dbem'); ?></th>
|
86 |
+
<th class='manage-column' scope='col'><?php _e('Phone number', 'dbem'); ?></th>
|
87 |
+
<th class='manage-column' scope='col'><?php _e('Spaces', 'dbem'); ?></th>
|
88 |
+
<th class='manage-column' scope='col'> </th>
|
89 |
+
</tr>
|
90 |
+
</thead>
|
91 |
+
<tbody>
|
92 |
+
<?php
|
93 |
+
$rowno = 0;
|
94 |
+
$event_count = 0;
|
95 |
+
foreach ($EM_Bookings->bookings as $EM_Booking) {
|
96 |
+
if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
|
97 |
+
$rowno++;
|
98 |
+
?>
|
99 |
+
<tr>
|
100 |
+
<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
|
101 |
+
<td><a href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&person_id=<?php echo $EM_Booking->person->ID; ?>"><?php echo $EM_Booking->person->get_name() ?></a></td>
|
102 |
+
<td><?php echo $EM_Booking->person->user_email ?></td>
|
103 |
+
<td><?php echo $EM_Booking->person->phone ?></td>
|
104 |
+
<td><?php echo $EM_Booking->get_spaces() ?></td>
|
105 |
+
<td>
|
106 |
+
<?php
|
107 |
+
$approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id));
|
108 |
+
$delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id));
|
109 |
+
$edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id'=>$EM_Booking->booking_id, 'em_ajax'=>null, 'em_obj'=>null));
|
110 |
+
?>
|
111 |
+
<a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
|
112 |
+
<a class="em-bookings-edit" href="<?php echo $edit_url ?>"><?php _e('Edit/View','dbem'); ?></a> |
|
113 |
+
<span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span>
|
114 |
+
</td>
|
115 |
+
</tr>
|
116 |
+
<?php
|
117 |
+
}
|
118 |
+
$event_count++;
|
119 |
+
}
|
120 |
+
?>
|
121 |
+
</tbody>
|
122 |
+
</table>
|
123 |
+
</div>
|
124 |
+
<?php else: ?>
|
125 |
+
<?php _e('No rejected bookings.', 'dbem'); ?>
|
126 |
+
<?php endif; ?>
|
127 |
+
</form>
|
128 |
+
<?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
|
129 |
+
<div class='tablenav'>
|
130 |
+
<?php echo $bookings_nav; ?>
|
131 |
+
<div class="clear"></div>
|
132 |
+
</div>
|
133 |
+
<?php endif; ?>
|
134 |
+
</div>
|
135 |
+
<?php
|
136 |
+
}
|
137 |
Â
?>
|
admin/em-admin.php
CHANGED
@@ -1,285 +1,272 @@
|
|
1 |
-
<?php
|
2 |
-
//Admin functions
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
/**
|
109 |
-
*
|
110 |
-
*/
|
111 |
-
function
|
112 |
-
|
113 |
-
//
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
if(
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
}
|
273 |
-
if(errors != "") {
|
274 |
-
alert(errors);
|
275 |
-
return false;
|
276 |
-
}
|
277 |
-
return true;
|
278 |
-
}
|
279 |
-
$('#event-form').bind("submit", validateEventForm);
|
280 |
-
});
|
281 |
-
//]]>
|
282 |
-
</script>
|
283 |
-
<?php
|
284 |
-
}
|
285 |
Â
?>
|
1 |
+
<?php
|
2 |
+
//Admin functions
|
3 |
+
function em_admin_menu(){
|
4 |
+
global $menu, $submenu, $pagenow;
|
5 |
+
//Count pending bookings
|
6 |
+
if( get_option('dbem_rsvp_enabled') ){
|
7 |
+
$bookings_num = '';
|
8 |
+
$bookings_pending_count = apply_filters('em_bookings_pending_count',0);
|
9 |
+
if( get_option('dbem_bookings_approval') == 1){
|
10 |
+
$bookings_pending_count += count(EM_Bookings::get(array('status'=>'0', 'blog'=>get_current_blog_id()))->bookings);
|
11 |
+
}
|
12 |
+
if($bookings_pending_count > 0){
|
13 |
+
$bookings_num = '<span class="update-plugins count-'.$bookings_pending_count.'"><span class="plugin-count">'.$bookings_pending_count.'</span></span>';
|
14 |
+
}
|
15 |
+
}else{
|
16 |
+
$bookings_num = '';
|
17 |
+
$bookings_pending_count = 0;
|
18 |
+
}
|
19 |
+
//Count pending events
|
20 |
+
$events_num = '';
|
21 |
+
$events_pending_count = EM_Events::count(array('status'=>0, 'scope'=>'all', 'blog'=>get_current_blog_id()));
|
22 |
+
//TODO Add flexible permissions
|
23 |
+
if($events_pending_count > 0){
|
24 |
+
$events_num = '<span class="update-plugins count-'.$events_pending_count.'"><span class="plugin-count">'.$events_pending_count.'</span></span>';
|
25 |
+
}
|
26 |
+
//Count pending recurring events
|
27 |
+
$events_recurring_num = '';
|
28 |
+
$events_recurring_pending_count = EM_Events::count(array('status'=>0, 'recurring'=>1, 'scope'=>'all', 'blog'=>get_current_blog_id()));
|
29 |
+
//TODO Add flexible permissions
|
30 |
+
if($events_recurring_pending_count > 0){
|
31 |
+
$events_recurring_num = '<span class="update-plugins count-'.$events_recurring_pending_count.'"><span class="plugin-count">'.$events_recurring_pending_count.'</span></span>';
|
32 |
+
}
|
33 |
+
$both_pending_count = apply_filters('em_items_pending_count', $events_pending_count + $bookings_pending_count + $events_recurring_pending_count);
|
34 |
+
$both_num = ($both_pending_count > 0) ? '<span class="update-plugins count-'.$both_pending_count.'"><span class="plugin-count">'.$both_pending_count.'</span></span>':'';
|
35 |
+
// Add a submenu to the custom top-level menu:
|
36 |
+
$plugin_pages = array();
|
37 |
+
if( get_option('dbem_rsvp_enabled') ){
|
38 |
+
$plugin_pages['bookings'] = add_submenu_page('edit.php?post_type='.EM_POST_TYPE_EVENT, __('Bookings', 'dbem'), __('Bookings', 'dbem').$bookings_num, 'manage_bookings', 'events-manager-bookings', "em_bookings_page");
|
39 |
+
}
|
40 |
+
$plugin_pages['options'] = add_submenu_page('edit.php?post_type='.EM_POST_TYPE_EVENT, __('Events Manager Settings','dbem'),__('Settings','dbem'), 'list_users', "events-manager-options", 'em_admin_options_page');
|
41 |
+
$plugin_pages['help'] = add_submenu_page('edit.php?post_type='.EM_POST_TYPE_EVENT, __('Getting Help for Events Manager','dbem'),__('Help','dbem'), 'list_users', "events-manager-help", 'em_admin_help_page');
|
42 |
+
//If multisite global with locations set to be saved in main blogs we can force locations to be created on the main blog only
|
43 |
+
if( EM_MS_GLOBAL && !is_main_site() && get_site_option('dbem_ms_mainblog_locations') ){
|
44 |
+
include( dirname(__FILE__)."/em-ms-locations.php" );
|
45 |
+
$plugin_pages['locations'] = add_submenu_page('edit.php?post_type='.EM_POST_TYPE_EVENT, __('Locations','dbem'),__('Locations','dbem'), 'read_others_locations', "locations", 'em_admin_ms_locations');
|
46 |
+
}
|
47 |
+
$plugin_pages = apply_filters('em_create_events_submenu',$plugin_pages);
|
48 |
+
//We have to modify the menus manually
|
49 |
+
if( !empty($both_num) ){ //Main Event Menu
|
50 |
+
//go through the menu array and modify the events menu if found
|
51 |
+
foreach ( (array)$menu as $key => $parent_menu ) {
|
52 |
+
if ( $parent_menu[2] == 'edit.php?post_type='.EM_POST_TYPE_EVENT ){
|
53 |
+
$menu[$key][0] = $menu[$key][0]. $both_num;
|
54 |
+
break;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
if( !empty($events_num) && !empty($submenu['edit.php?post_type='.EM_POST_TYPE_EVENT]) ){ //Submenu Event Item
|
59 |
+
//go through the menu array and modify the events menu if found
|
60 |
+
foreach ( (array)$submenu['edit.php?post_type='.EM_POST_TYPE_EVENT] as $key => $submenu_item ) {
|
61 |
+
if ( $submenu_item[2] == 'edit.php?post_type='.EM_POST_TYPE_EVENT ){
|
62 |
+
$submenu['edit.php?post_type='.EM_POST_TYPE_EVENT][$key][0] = $submenu['edit.php?post_type='.EM_POST_TYPE_EVENT][$key][0]. $events_num;
|
63 |
+
break;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
if( !empty($events_recurring_num) && !empty($submenu['edit.php?post_type='.EM_POST_TYPE_EVENT]) ){ //Submenu Recurring Event Item
|
68 |
+
//go through the menu array and modify the events menu if found
|
69 |
+
foreach ( (array)$submenu['edit.php?post_type='.EM_POST_TYPE_EVENT] as $key => $submenu_item ) {
|
70 |
+
if ( $submenu_item[2] == 'edit.php?post_type=event-recurring' ){
|
71 |
+
$submenu['edit.php?post_type='.EM_POST_TYPE_EVENT][$key][0] = $submenu['edit.php?post_type='.EM_POST_TYPE_EVENT][$key][0]. $events_recurring_num;
|
72 |
+
break;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
/* Hack! Add location/recurrence isn't possible atm so this is a workaround */
|
77 |
+
global $_wp_submenu_nopriv;
|
78 |
+
if( $pagenow == 'post-new.php' && !empty($_REQUEST['post_type']) ){
|
79 |
+
if( $_REQUEST['post_type'] == EM_POST_TYPE_LOCATION && !empty($_wp_submenu_nopriv['edit.php']['post-new.php']) && current_user_can('edit_locations') ){
|
80 |
+
unset($_wp_submenu_nopriv['edit.php']['post-new.php']);
|
81 |
+
}
|
82 |
+
if( $_REQUEST['post_type'] == 'event-recurring' && !empty($_wp_submenu_nopriv['edit.php']['post-new.php']) && current_user_can('edit_recurring_events') ){
|
83 |
+
unset($_wp_submenu_nopriv['edit.php']['post-new.php']);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
add_action('admin_menu','em_admin_menu');
|
88 |
+
|
89 |
+
function em_ms_admin_menu(){
|
90 |
+
add_menu_page( __('Events Manager','dbem'), __('Events Manager','dbem'), 'activate_plugins', 'events-manager-options', 'em_ms_admin_options_page', plugins_url('includes/images/calendar-16.png', dirname(dirname(__FILE__)).'/events-manager.php') );
|
91 |
+
add_submenu_page('events-manager-options', __('Update Blogs','dbem'),__('Update Blogs','dbem'), 'activate_plugins', "events-manager-update", 'em_ms_upgrade');
|
92 |
+
}
|
93 |
+
add_action('network_admin_menu','em_ms_admin_menu');
|
94 |
+
|
95 |
+
function em_admin_init(){
|
96 |
+
//in MS global mode and locations are stored in the main blog, then a user must have at least a subscriber role
|
97 |
+
if( EM_MS_GLOBAL && is_user_logged_in() && !is_main_site() && get_site_option('dbem_ms_mainblog_locations') ){
|
98 |
+
EM_Object::ms_global_switch();
|
99 |
+
$user = new WP_User(get_current_user_id());
|
100 |
+
if( count($user->roles) == 0 ){
|
101 |
+
$user->set_role('subscriber');
|
102 |
+
}
|
103 |
+
EM_Object::ms_global_switch_back();
|
104 |
+
}
|
105 |
+
}
|
106 |
+
add_action('admin_init','em_admin_init');
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Generate warnings and notices in the admin area
|
110 |
+
*/
|
111 |
+
function em_admin_warnings() {
|
112 |
+
global $EM_Notices;
|
113 |
+
//If we're editing the events page show hello to new user
|
114 |
+
$events_page_id = get_option ( 'dbem_events_page' );
|
115 |
+
$dismiss_link_joiner = ( count($_GET) > 0 ) ? '&':'?';
|
116 |
+
|
117 |
+
if( current_user_can('activate_plugins') ){
|
118 |
+
//New User Intro
|
119 |
+
if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true'){
|
120 |
+
// Disable Hello to new user if requested
|
121 |
+
update_option('dbem_hello_to_user',0);
|
122 |
+
}elseif ( get_option ( 'dbem_hello_to_user' ) ) {
|
123 |
+
//FIXME update welcome msg with good links
|
124 |
+
$advice = sprintf( __("<p>Events Manager is ready to go! It is highly recommended you read the <a href='%s'>Getting Started</a> guide on our site, as well as checking out the <a href='%s'>Settings Page</a>. <a href='%s' title='Don't show this advice again'>Dismiss</a></p>", 'dbem'), 'http://wp-events-plugin.com/documentation/getting-started/?utm_source=em&utm_medium=plugin&utm_content=installationlink&utm_campaign=plugin_links', EM_ADMIN_URL .'&page=events-manager-options', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'disable_hello_to_user=true');
|
125 |
+
?>
|
126 |
+
<div id="message" class="updated">
|
127 |
+
<?php echo $advice; ?>
|
128 |
+
</div>
|
129 |
+
<?php
|
130 |
+
}
|
131 |
+
|
132 |
+
//If events page couldn't be created or is missing
|
133 |
+
if( !empty($_GET['em_dismiss_events_page']) ){
|
134 |
+
update_option('dbem_dismiss_events_page',1);
|
135 |
+
}else{
|
136 |
+
if ( !get_page($events_page_id) && !get_option('dbem_dismiss_events_page') ){
|
137 |
+
?>
|
138 |
+
<div id="em_page_error" class="updated">
|
139 |
+
<p><?php echo sprintf ( __( 'Uh Oh! For some reason WordPress could not create an events page for you (or you just deleted it). Not to worry though, all you have to do is create an empty page, name it whatever you want, and select it as your events page in your <a href="%s">settings page</a>. Sorry for the extra step! If you know what you are doing, you may have done this on purpose, if so <a href="%s">ignore this message</a>', 'dbem'), EM_ADMIN_URL .'&page=events-manager-options', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'em_dismiss_events_page=1' ); ?></p>
|
140 |
+
</div>
|
141 |
+
<?php
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
if( defined('EMP_VERSION') && EMP_VERSION < EM_PRO_MIN_VERSION && !defined('EMP_DISABLE_WARNINGS')){
|
146 |
+
?>
|
147 |
+
<div id="em_page_error" class="updated">
|
148 |
+
<p><?php _e('There is a newer version of Events Manager Pro which is recommended for this current version of Events Manager as new features have been added. Please go to the plugin website and download the latest update.','dbem'); ?></p>
|
149 |
+
</div>
|
150 |
+
<?php
|
151 |
+
}
|
152 |
+
|
153 |
+
if( is_multisite() && !empty($_REQUEST['page']) && $_REQUEST['page']=='events-manager-options' && is_super_admin() && get_option('dbem_ms_update_nag') ){
|
154 |
+
if( !empty($_GET['disable_dbem_ms_update_nag']) ){
|
155 |
+
delete_site_option('dbem_ms_update_nag');
|
156 |
+
}else{
|
157 |
+
?>
|
158 |
+
<div id="em_page_error" class="updated">
|
159 |
+
<p><?php echo sprintf(__('MultiSite options have moved <a href="%s">here</a>. <a href="%s">Dismiss message</a>','dbem'),admin_url().'network/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'].'&disable_dbem_ms_update_nag=1'); ?></p>
|
160 |
+
</div>
|
161 |
+
<?php
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
if( is_super_admin() && get_option('dbem_migrate_images_nag') ){
|
166 |
+
if( !empty($_GET['disable_dbem_migrate_images_nag']) ){
|
167 |
+
delete_site_option('dbem_migrate_images_nag');
|
168 |
+
}else{
|
169 |
+
?>
|
170 |
+
<div id="em_page_error" class="updated">
|
171 |
+
<p><?php echo sprintf(__('Whilst they will still appear using placeholders, you need to <a href="%s">migrate your location and event images</a> in order for them to appear in your edit forms and media library. <a href="%s">Dismiss message</a>','dbem'),admin_url().'edit.php?post_type=event&page=events-manager-options&em_migrate_images=1&_wpnonce='.wp_create_nonce('em_migrate_images'), em_add_get_params($_SERVER['REQUEST_URI'], array('disable_dbem_migrate_images_nag' => 1))); ?></p>
|
172 |
+
</div>
|
173 |
+
<?php
|
174 |
+
}
|
175 |
+
}
|
176 |
+
if( !empty($_REQUEST['page']) && 'events-manager-options' == $_REQUEST['page'] && get_option('dbem_pro_dev_updates') == 1 ){
|
177 |
+
?>
|
178 |
+
<div id="message" class="updated">
|
179 |
+
<p><?php echo sprintf(__('Dev Mode active: Just a friendly reminder that you are updating to development versions. Only admins see this message, and it will go away when you disable this <a href="#pro-api">here</a> in your settings.','dbem'),'<code>define(\'EMP_DEV_UPDATES\',true);</code>'); ?></p>
|
180 |
+
</div>
|
181 |
+
<?php
|
182 |
+
}
|
183 |
+
if( class_exists('SitePress') && !class_exists('EM_WPML') && !get_site_option('disable_em_wpml_warning') ){
|
184 |
+
if( !empty($_REQUEST['disable_em_wpml_warning']) ){
|
185 |
+
update_site_option('disable_em_wpml_warning',1);
|
186 |
+
}else{
|
187 |
+
?>
|
188 |
+
<div id="message" class="updated">
|
189 |
+
<p><?php echo sprintf(__('It looks like you have WPML enabled on your site. We advise you also install our extra <a href="%s">Events Manager WPML Connector</a> plugin which helps the two work better together. <a href="%s">Dismiss message</a>','dbem'),'http://wordpress.org/extend/plugins/events-manager-wpml/', add_query_arg(array('disable_em_wpml_warning'=>1))); ?></p>
|
190 |
+
</div>
|
191 |
+
<?php
|
192 |
+
}
|
193 |
+
}
|
194 |
+
}
|
195 |
+
//Warn about EM page edit
|
196 |
+
if ( preg_match( '/(post|page).php/', $_SERVER ['SCRIPT_NAME']) && isset ( $_GET ['action'] ) && $_GET ['action'] == 'edit' && isset ( $_GET ['post'] ) && $_GET ['post'] == "$events_page_id") {
|
197 |
+
$message = sprintf ( __ ( "This page corresponds to the <strong>Events Manager</strong> %s page. Its content will be overriden by Events Manager, although if you include the word CONTENTS (exactly in capitals) and surround it with other text, only CONTENTS will be overwritten. If you want to change the way your events look, go to the <a href='%s'>settings</a> page. ", 'dbem' ), __('Events','dbem'), EM_ADMIN_URL .'&page=events-manager-options' );
|
198 |
+
$notice = "<div class='error'><p>$message</p></div>";
|
199 |
+
echo $notice;
|
200 |
+
}
|
201 |
+
echo $EM_Notices;
|
202 |
+
}
|
203 |
+
add_action ( 'admin_notices', 'em_admin_warnings', 100 );
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Settings link in the plugins page menu
|
207 |
+
* @param array $links
|
208 |
+
* @param string $file
|
209 |
+
* @return array
|
210 |
+
*/
|
211 |
+
function em_plugin_action_links($actions, $file, $plugin_data) {
|
212 |
+
$new_actions = array();
|
213 |
+
$new_actions[] = sprintf( '<a href="'.EM_ADMIN_URL.'&page=events-manager-options">%s</a>', __('Settings', 'dbem') );
|
214 |
+
$new_actions = array_merge($new_actions, $actions);
|
215 |
+
if( is_multisite() ){
|
216 |
+
$uninstall_url = admin_url().'network/admin.php?page=events-manager-options&action=uninstall&_wpnonce='.wp_create_nonce('em_uninstall_'.get_current_user_id().'_wpnonce');
|
217 |
+
}else{
|
218 |
+
$uninstall_url = EM_ADMIN_URL.'&page=events-manager-options&action=uninstall&_wpnonce='.wp_create_nonce('em_uninstall_'.get_current_user_id().'_wpnonce');
|
219 |
+
}
|
220 |
+
$new_actions[] = '<span class="delete"><a href="'.$uninstall_url.'" class="delete">'.__('Uninstall','dbem').'</a></span>';
|
221 |
+
return $new_actions;
|
222 |
+
}
|
223 |
+
add_filter( 'plugin_action_links_events-manager/events-manager.php', 'em_plugin_action_links', 10, 3 );
|
224 |
+
|
225 |
+
//Updates and Dev versions
|
226 |
+
function em_updates_check( $transient ) {
|
227 |
+
// Check if the transient contains the 'checked' information
|
228 |
+
if( empty( $transient->checked ) )
|
229 |
+
return $transient;
|
230 |
+
|
231 |
+
//only bother if we're checking for dev versions
|
232 |
+
if( get_option('em_check_dev_version') || get_option('dbem_pro_dev_updates') ){
|
233 |
+
//check WP repo for trunk version
|
234 |
+
$request = wp_remote_get('http://plugins.svn.wordpress.org/events-manager/trunk/events-manager.php');
|
235 |
+
|
236 |
+
if( !is_wp_error($request) ){
|
237 |
+
preg_match('/Version: ([0-9a-z\.]+)/', $request['body'], $matches);
|
238 |
+
|
239 |
+
if( !empty($matches[1]) ){
|
240 |
+
//we have a version number!
|
241 |
+
if( version_compare($transient->checked[EM_SLUG], $matches[1]) < 0) {
|
242 |
+
$response = new stdClass();
|
243 |
+
$response->slug = EM_SLUG;
|
244 |
+
$response->new_version = $matches[1] ;
|
245 |
+
$response->url = 'http://wordpress.org/extend/plugins/events-manager/';
|
246 |
+
$response->package = 'http://downloads.wordpress.org/plugin/events-manager.zip';
|
247 |
+
$transient->response[EM_SLUG] = $response;
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
delete_option('em_check_dev_version');
|
253 |
+
}
|
254 |
+
|
255 |
+
return $transient;
|
256 |
+
}
|
257 |
+
add_filter('pre_set_site_transient_update_plugins', 'em_updates_check'); // Hook into the plugin update check and mod for dev version
|
258 |
+
|
259 |
+
function em_user_action_links( $actions, $user ){
|
260 |
+
if ( !is_network_admin() && current_user_can( 'manage_others_bookings' ) ){
|
261 |
+
if( get_option('dbem_edit_bookings_page') && (!is_admin() || !empty($_REQUEST['is_public'])) ){
|
262 |
+
$my_bookings_page = get_permalink(get_option('dbem_edit_bookings_page'));
|
263 |
+
$bookings_link = em_add_get_params($my_bookings_page, array('person_id'=>$user->ID), false);
|
264 |
+
}else{
|
265 |
+
$bookings_link = EM_ADMIN_URL. "&page=events-manager-bookings&person_id=".$user->ID;
|
266 |
+
}
|
267 |
+
$actions['bookings'] = "<a href='$bookings_link'>" . __( 'Bookings','dbem' ) . "</a>";
|
268 |
+
}
|
269 |
+
return $actions;
|
270 |
+
}
|
271 |
+
add_filter('user_row_actions','em_user_action_links',10,2);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
272 |
Â
?>
|
admin/em-bookings.php
CHANGED
@@ -1,288 +1,575 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Check if there's any admin-related actions to take for bookings. All actions are caught here.
|
4 |
-
* @return null
|
5 |
-
*/
|
6 |
-
function em_admin_actions_bookings() {
|
7 |
-
global $dbem_form_add_message;
|
8 |
-
global $dbem_form_delete_message;
|
9 |
-
global $wpdb, $EM_Booking, $EM_Event;
|
10 |
-
|
11 |
-
if(
|
12 |
-
if( $_REQUEST['action'] == '
|
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 |
-
<br
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
<?php
|
115 |
-
|
116 |
-
</h2>
|
117 |
-
|
118 |
-
<div>
|
119 |
-
<p><strong><?php _e('Event Name','dbem'); ?></strong> : <?php echo ($EM_Event->
|
120 |
-
<p
|
121 |
-
|
122 |
-
|
123 |
-
<?php
|
124 |
-
<?php echo (
|
125 |
-
<?php
|
126 |
-
</p>
|
127 |
-
<p>
|
128 |
-
<strong><?php _e('
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
<
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
<
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
288 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Check if there's any admin-related actions to take for bookings. All actions are caught here.
|
4 |
+
* @return null
|
5 |
+
*/
|
6 |
+
function em_admin_actions_bookings() {
|
7 |
+
global $dbem_form_add_message;
|
8 |
+
global $dbem_form_delete_message;
|
9 |
+
global $wpdb, $EM_Booking, $EM_Event, $EM_Notices;
|
10 |
+
|
11 |
+
if( is_object($EM_Booking) && !empty($_REQUEST['action']) && $EM_Booking->can_manage('manage_bookings','manage_others_bookings') ) {
|
12 |
+
if( $_REQUEST['action'] == 'bookings_add_note' ){
|
13 |
+
$EM_Booking->add_note($_REQUEST['booking_note']);
|
14 |
+
function em_booking_save_notification(){ global $EM_Booking; ?><div class="updated"><p><strong><?php echo $EM_Booking->feedback_message; ?></strong></p></div><?php }
|
15 |
+
add_action ( 'admin_notices', 'em_booking_save_notification' );
|
16 |
+
}
|
17 |
+
}
|
18 |
+
if( is_object($EM_Event) && !empty($_REQUEST['action']) ){
|
19 |
+
if( $_REQUEST['action'] == 'bookings_export_csv' && wp_verify_nonce($_REQUEST['_wpnonce'],'bookings_export_csv') ){
|
20 |
+
$EM_Event->get_bookings()->export_csv();
|
21 |
+
exit();
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
add_action('admin_init','em_admin_actions_bookings',100);
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Decide what content to show in the bookings section.
|
29 |
+
*/
|
30 |
+
function em_bookings_page(){
|
31 |
+
//First any actions take priority
|
32 |
+
do_action('em_bookings_admin_page');
|
33 |
+
if( !empty($_REQUEST['_wpnonce']) ){ $_REQUEST['_wpnonce'] = $_GET['_wpnonce'] = $_POST['_wpnonce'] = esc_attr($_REQUEST['_wpnonce']); } //XSS fix just in case here too
|
34 |
+
if( !empty($_REQUEST['action']) && substr($_REQUEST['action'],0,7) != 'booking' ){ //actions not starting with booking_
|
35 |
+
do_action('em_bookings_'.$_REQUEST['action']);
|
36 |
+
}elseif( !empty($_REQUEST['booking_id']) ){
|
37 |
+
em_bookings_single();
|
38 |
+
}elseif( !empty($_REQUEST['person_id']) ){
|
39 |
+
em_bookings_person();
|
40 |
+
}elseif( !empty($_REQUEST['event_id']) ){
|
41 |
+
em_bookings_event();
|
42 |
+
}elseif( !empty($_REQUEST['ticket_id']) ){
|
43 |
+
em_bookings_ticket();
|
44 |
+
}else{
|
45 |
+
em_bookings_dashboard();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Generates the bookings dashboard, showing information on all events
|
51 |
+
*/
|
52 |
+
function em_bookings_dashboard(){
|
53 |
+
global $EM_Notices;
|
54 |
+
?>
|
55 |
+
<div class='wrap em-bookings-dashboard'>
|
56 |
+
<?php if( is_admin() ): ?>
|
57 |
+
<div id='icon-users' class='icon32'>
|
58 |
+
<br/>
|
59 |
+
</div>
|
60 |
+
<h2>
|
61 |
+
<?php _e('Event Bookings Dashboard', 'dbem'); ?>
|
62 |
+
</h2>
|
63 |
+
<?php else: echo $EM_Notices; ?>
|
64 |
+
<?php endif; ?>
|
65 |
+
<div class="em-bookings-recent">
|
66 |
+
<?php if( is_admin() ): ?>
|
67 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
68 |
+
<?php endif; ?>
|
69 |
+
<h2><?php _e('Recent Bookings','dbem'); ?></h2>
|
70 |
+
<?php
|
71 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
72 |
+
$EM_Bookings_Table->status = get_option('dbem_bookings_approval') ? 'needs-attention':'confirmed';
|
73 |
+
$EM_Bookings_Table->output();
|
74 |
+
?>
|
75 |
+
</div>
|
76 |
+
<br class="clear" />
|
77 |
+
<div class="em-bookings-events">
|
78 |
+
<?php if( is_admin() ): ?>
|
79 |
+
<div class="icon32" id="events"><br></div>
|
80 |
+
<?php endif; ?>
|
81 |
+
<h2><?php _e('Events With Bookings Enabled','dbem'); ?></h2>
|
82 |
+
<?php em_bookings_events_table(); ?>
|
83 |
+
<?php do_action('em_bookings_dashboard'); ?>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
<?php
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Shows all booking data for a single event
|
91 |
+
*/
|
92 |
+
function em_bookings_event(){
|
93 |
+
global $EM_Event,$EM_Person,$EM_Notices;
|
94 |
+
//check that user can access this page
|
95 |
+
if( is_object($EM_Event) && !$EM_Event->can_manage('manage_bookings','manage_others_bookings') ){
|
96 |
+
?>
|
97 |
+
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
|
98 |
+
<?php
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
$localised_start_date = date_i18n('D d M Y', $EM_Event->start);
|
102 |
+
$localised_end_date = date_i18n('D d M Y', $EM_Event->end);
|
103 |
+
?>
|
104 |
+
<div class='wrap'>
|
105 |
+
<div id='icon-users' class='icon32'>
|
106 |
+
<br/>
|
107 |
+
</div>
|
108 |
+
<h2>
|
109 |
+
<?php echo sprintf(__('Manage %s Bookings', 'dbem'), "'{$EM_Event->event_name}'"); ?>
|
110 |
+
<a href="<?php echo $EM_Event->get_permalink(); ?>" class="button add-new-h2"><?php echo sprintf(__('View %s','dbem'), __('Event', 'dbem')) ?></a>
|
111 |
+
<a href="<?php echo $EM_Event->get_edit_url(); ?>" class="button add-new-h2"><?php echo sprintf(__('Edit %s','dbem'), __('Event', 'dbem')) ?></a>
|
112 |
+
<?php if( locate_template('plugins/events-manager/templates/csv-event-bookings.php', false) ): ?>
|
113 |
+
<a href='<?php echo EM_ADMIN_URL ."&page=events-manager-bookings&action=bookings_export_csv&_wpnonce=".wp_create_nonce('bookings_export_csv')."&event_id=".$EM_Event->event_id ?>' class="button add-new-h2"><?php _e('Export CSV','dbem')?></a>
|
114 |
+
<?php endif; ?>
|
115 |
+
<?php do_action('em_admin_event_booking_options_buttons'); ?>
|
116 |
+
</h2>
|
117 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
118 |
+
<div>
|
119 |
+
<p><strong><?php _e('Event Name','dbem'); ?></strong> : <?php echo ($EM_Event->event_name); ?></p>
|
120 |
+
<p>
|
121 |
+
<strong><?php _e('Availability','dbem'); ?></strong> :
|
122 |
+
<?php echo $EM_Event->get_bookings()->get_booked_spaces() . '/'. $EM_Event->get_spaces() ." ". __('Spaces confirmed','dbem'); ?>
|
123 |
+
<?php if( get_option('dbem_bookings_approval_reserved') ): ?>
|
124 |
+
, <?php echo $EM_Event->get_bookings()->get_available_spaces() . '/'. $EM_Event->get_spaces() ." ". __('Available spaces','dbem'); ?>
|
125 |
+
<?php endif; ?>
|
126 |
+
</p>
|
127 |
+
<p>
|
128 |
+
<strong><?php _e('Date','dbem'); ?></strong> :
|
129 |
+
<?php echo $localised_start_date; ?>
|
130 |
+
<?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
|
131 |
+
<?php echo substr ( $EM_Event->event_start_time, 0, 5 ) . " - " . substr ( $EM_Event->event_end_time, 0, 5 ); ?>
|
132 |
+
</p>
|
133 |
+
<p>
|
134 |
+
<strong><?php _e('Location','dbem'); ?></strong> :
|
135 |
+
<a class="row-title" href="<?php echo admin_url(); ?>post.php?action=edit&post=<?php echo $EM_Event->get_location()->post_id ?>"><?php echo ($EM_Event->get_location()->location_name); ?></a>
|
136 |
+
</p>
|
137 |
+
</div>
|
138 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
139 |
+
<h2><?php _e('Bookings','dbem'); ?></h2>
|
140 |
+
<?php
|
141 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
142 |
+
$EM_Bookings_Table->status = 'all';
|
143 |
+
$EM_Bookings_Table->output();
|
144 |
+
?>
|
145 |
+
<?php do_action('em_bookings_event_footer', $EM_Event); ?>
|
146 |
+
</div>
|
147 |
+
<?php
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Shows a ticket view
|
152 |
+
*/
|
153 |
+
function em_bookings_ticket(){
|
154 |
+
global $EM_Ticket,$EM_Notices;
|
155 |
+
$EM_Event = $EM_Ticket->get_event();
|
156 |
+
//check that user can access this page
|
157 |
+
if( is_object($EM_Ticket) && !$EM_Ticket->can_manage() ){
|
158 |
+
?>
|
159 |
+
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this ticket.','dbem'); ?></p></div>
|
160 |
+
<?php
|
161 |
+
return false;
|
162 |
+
}
|
163 |
+
?>
|
164 |
+
<div class='wrap'>
|
165 |
+
<div id='icon-users' class='icon32'>
|
166 |
+
<br/>
|
167 |
+
</div>
|
168 |
+
<h2>
|
169 |
+
<?php echo sprintf(__('Ticket for %s', 'dbem'), "'{$EM_Event->name}'"); ?>
|
170 |
+
<a href="<?php echo $EM_Event->get_edit_url(); ?>" class="button add-new-h2"><?php _e('View/Edit Event','dbem') ?></a>
|
171 |
+
<a href="<?php echo $EM_Event->get_bookings_url(); ?>" class="button add-new-h2"><?php _e('View Event Bookings','dbem') ?></a>
|
172 |
+
</h2>
|
173 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
174 |
+
<div>
|
175 |
+
<table>
|
176 |
+
<tr><td><?php echo __('Name','dbem'); ?></td><td></td><td><?php echo $EM_Ticket->ticket_name; ?></td></tr>
|
177 |
+
<tr><td><?php echo __('Description','dbem'); ?> </td><td></td><td><?php echo ($EM_Ticket->ticket_description) ? $EM_Ticket->ticket_description : '-'; ?></td></tr>
|
178 |
+
<tr><td><?php echo __('Price','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_price) ? $EM_Ticket->ticket_price : '-'; ?></td></tr>
|
179 |
+
<tr><td><?php echo __('Spaces','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_spaces) ? $EM_Ticket->ticket_spaces : '-'; ?></td></tr>
|
180 |
+
<tr><td><?php echo __('Min','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_min) ? $EM_Ticket->ticket_min : '-'; ?></td></tr>
|
181 |
+
<tr><td><?php echo __('Max','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_max) ? $EM_Ticket->ticket_max : '-'; ?></td></tr>
|
182 |
+
<tr><td><?php echo __('Start','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_start) ? $EM_Ticket->ticket_start : '-'; ?></td></tr>
|
183 |
+
<tr><td><?php echo __('End','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_end) ? $EM_Ticket->ticket_end : '-'; ?></td></tr>
|
184 |
+
<?php do_action('em_booking_admin_ticket_row', $EM_Ticket); ?>
|
185 |
+
</table>
|
186 |
+
</div>
|
187 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
188 |
+
<h2><?php _e('Bookings','dbem'); ?></h2>
|
189 |
+
<?php
|
190 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
191 |
+
$EM_Bookings_Table->status = get_option('dbem_bookings_approval') ? 'needs-attention':'confirmed';
|
192 |
+
$EM_Bookings_Table->output();
|
193 |
+
?>
|
194 |
+
<?php do_action('em_bookings_ticket_footer', $EM_Ticket); ?>
|
195 |
+
</div>
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Shows a single booking for a single person.
|
201 |
+
*/
|
202 |
+
function em_bookings_single(){
|
203 |
+
global $EM_Booking, $EM_Notices; /* @var $EM_Booking EM_Booking */
|
204 |
+
//check that user can access this page
|
205 |
+
if( is_object($EM_Booking) && !$EM_Booking->can_manage() ){
|
206 |
+
?>
|
207 |
+
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
|
208 |
+
<?php
|
209 |
+
return false;
|
210 |
+
}
|
211 |
+
?>
|
212 |
+
<div class='wrap' id="em-bookings-admin-booking">
|
213 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
214 |
+
<h2>
|
215 |
+
<?php _e('Edit Booking', 'dbem'); ?>
|
216 |
+
</h2>
|
217 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
218 |
+
<div id="poststuff" class="metabox-holder">
|
219 |
+
<div id="post-body">
|
220 |
+
<div id="post-body-content">
|
221 |
+
<div class="stuffbox">
|
222 |
+
<h3>
|
223 |
+
<?php _e ( 'Event Details', 'dbem' ); ?>
|
224 |
+
</h3>
|
225 |
+
<div class="inside">
|
226 |
+
<?php
|
227 |
+
$EM_Event = $EM_Booking->get_event();
|
228 |
+
$localised_start_date = date_i18n(get_option('dbem_date_format'), $EM_Event->start);
|
229 |
+
$localised_end_date = date_i18n(get_option('dbem_date_format'), $EM_Event->end);
|
230 |
+
?>
|
231 |
+
<table>
|
232 |
+
<tr><td><strong><?php _e('Name','dbem'); ?></strong></td><td><a class="row-title" href="<?php echo $EM_Event->get_bookings_url(); ?>"><?php echo ($EM_Event->event_name); ?></a></td></tr>
|
233 |
+
<tr>
|
234 |
+
<td><strong><?php _e('Date/Time','dbem'); ?> </strong></td>
|
235 |
+
<td>
|
236 |
+
<?php echo $localised_start_date; ?>
|
237 |
+
<?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
|
238 |
+
<?php echo substr ( $EM_Event->start_time, 0, 5 ) . " - " . substr ( $EM_Event->end_time, 0, 5 ); ?>
|
239 |
+
</td>
|
240 |
+
</tr>
|
241 |
+
</table>
|
242 |
+
<?php do_action('em_bookings_admin_booking_event', $EM_Event); ?>
|
243 |
+
</div>
|
244 |
+
</div>
|
245 |
+
<div class="stuffbox">
|
246 |
+
<h3>
|
247 |
+
<?php _e ( 'Personal Details', 'dbem' ); ?>
|
248 |
+
</h3>
|
249 |
+
<div class="inside">
|
250 |
+
<?php $no_user = get_option('dbem_bookings_registration_disable') && $EM_Booking->get_person()->ID == get_option('dbem_bookings_registration_user'); ?>
|
251 |
+
<div class="em-booking-person-details">
|
252 |
+
<?php echo $EM_Booking->get_person()->display_summary(); ?>
|
253 |
+
<?php if( $no_user ): ?>
|
254 |
+
<input type="button" id="em-booking-person-modify" value="<?php esc_attr_e('Edit Details','dbem'); ?>" />
|
255 |
+
<?php endif; ?>
|
256 |
+
</div>
|
257 |
+
<?php if( $no_user ): ?>
|
258 |
+
<form action="" method="post" class="em-booking-person-form">
|
259 |
+
<div class="em-booking-person-editor" style="display:none;">
|
260 |
+
<?php echo $EM_Booking->get_person_editor(); ?>
|
261 |
+
<input type='hidden' name='action' value='booking_modify_person'/>
|
262 |
+
<input type='hidden' name='booking_id' value='<?php echo $EM_Booking->booking_id; ?>'/>
|
263 |
+
<input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
|
264 |
+
<input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_modify_person_'.$EM_Booking->booking_id); ?>'/>
|
265 |
+
<input type="submit" class="em-booking-person-modify-submit" id="em-booking-person-modify-submit" value="<?php _e('Submit Changes', 'dbem'); ?>" />
|
266 |
+
<input type="button" id="em-booking-person-modify-cancel" value="<?php esc_attr_e('Cancel','dbem'); ?>" />
|
267 |
+
</div>
|
268 |
+
</form>
|
269 |
+
<script type="text/javascript">
|
270 |
+
jQuery(document).ready( function($){
|
271 |
+
$('#em-booking-person-modify').click(function(){
|
272 |
+
$('.em-booking-person-details').hide();
|
273 |
+
$('.em-booking-person-editor').show();
|
274 |
+
});
|
275 |
+
$('#em-booking-person-modify-cancel').click(function(){
|
276 |
+
$('.em-booking-person-details').show();
|
277 |
+
$('.em-booking-person-editor').hide();
|
278 |
+
});
|
279 |
+
});
|
280 |
+
</script>
|
281 |
+
<?php endif; ?>
|
282 |
+
<?php do_action('em_bookings_admin_booking_person', $EM_Booking); ?>
|
283 |
+
</div>
|
284 |
+
</div>
|
285 |
+
<div class="stuffbox">
|
286 |
+
<h3>
|
287 |
+
<?php _e ( 'Booking Details', 'dbem' ); ?>
|
288 |
+
</h3>
|
289 |
+
<div class="inside">
|
290 |
+
<?php
|
291 |
+
$EM_Event = $EM_Booking->get_event();
|
292 |
+
$localised_start_date = date_i18n(get_option('date_format'), $EM_Event->start);
|
293 |
+
$localised_end_date = date_i18n(get_option('date_format'), $EM_Event->end);
|
294 |
+
$shown_tickets = array();
|
295 |
+
?>
|
296 |
+
<div>
|
297 |
+
<form action="" method="post" class="em-booking-single-status-info">
|
298 |
+
<strong><?php _e('Status','dbem'); ?> : </strong>
|
299 |
+
<?php echo $EM_Booking->get_status(); ?>
|
300 |
+
<input type="button" class="em-booking-submit-status-modify" id="em-booking-submit-status-modify" value="<?php _e('Change', 'dbem'); ?>" />
|
301 |
+
<input type="submit" class="em-booking-resend-email" id="em-booking-resend-email" value="<?php _e('Resend Email', 'dbem'); ?>" />
|
302 |
+
<input type='hidden' name='action' value='booking_resend_email'/>
|
303 |
+
<input type='hidden' name='booking_id' value='<?php echo $EM_Booking->booking_id; ?>'/>
|
304 |
+
<input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
|
305 |
+
<input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_resend_email_'.$EM_Booking->booking_id); ?>'/>
|
306 |
+
</form>
|
307 |
+
<form action="" method="post" class="em-booking-single-status-edit">
|
308 |
+
<strong><?php _e('Status','dbem'); ?> : </strong>
|
309 |
+
<select name="booking_status">
|
310 |
+
<?php foreach($EM_Booking->status_array as $status => $status_name): ?>
|
311 |
+
<option value="<?php echo esc_attr($status); ?>" <?php if($status == $EM_Booking->booking_status){ echo 'selected="selected"'; } ?>><?php echo esc_html($status_name); ?></option>
|
312 |
+
<?php endforeach; ?>
|
313 |
+
</select>
|
314 |
+
<input type="checkbox" checked="checked" name="send_email" value="1" />
|
315 |
+
<?php _e('Send Email','dbem'); ?>
|
316 |
+
<input type="submit" class="em-booking-submit-status" id="em-booking-submit-status" value="<?php _e('Submit Changes', 'dbem'); ?>" />
|
317 |
+
<input type="button" class="em-booking-submit-status-cancel" id="em-booking-submit-status-cancel" value="<?php _e('Cancel', 'dbem'); ?>" />
|
318 |
+
<input type='hidden' name='action' value='booking_set_status'/>
|
319 |
+
<input type='hidden' name='booking_id' value='<?php echo $EM_Booking->booking_id; ?>'/>
|
320 |
+
<input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
|
321 |
+
<input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_set_status_'.$EM_Booking->booking_id); ?>'/>
|
322 |
+
<br /><em><?php _e('<strong>Notes:</strong> Ticket availability not taken into account when approving new bookings (i.e. you can overbook).','dbem'); ?></em>
|
323 |
+
</form>
|
324 |
+
</div>
|
325 |
+
<form action="" method="post" class="em-booking-form">
|
326 |
+
<table class="em-tickets-bookings-table" cellpadding="0" cellspacing="0">
|
327 |
+
<thead>
|
328 |
+
<tr>
|
329 |
+
<th><?php _e('Ticket Type','dbem'); ?></th>
|
330 |
+
<th><?php _e('Spaces','dbem'); ?></th>
|
331 |
+
<th><?php _e('Price','dbem'); ?></th>
|
332 |
+
</tr>
|
333 |
+
</thead>
|
334 |
+
<tbody>
|
335 |
+
<?php foreach($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking): /* @var $EM_Ticket_Booking EM_Ticket_Booking */ ?>
|
336 |
+
<tr>
|
337 |
+
<td class="ticket-type"><a class="row-title" href="<?php echo em_add_get_params($EM_Event->get_bookings_url(), array('ticket_id'=>$EM_Ticket_Booking->ticket_id)); ?>"><?php echo $EM_Ticket_Booking->get_ticket()->ticket_name ?></a></td>
|
338 |
+
<td>
|
339 |
+
<span class="em-booking-single-info"><?php echo $EM_Ticket_Booking->get_spaces(); ?></span>
|
340 |
+
<div class="em-booking-single-edit"><input name="em_tickets[<?php echo $EM_Ticket_Booking->ticket_id; ?>][spaces]" class="em-ticket-select" id="em-ticket-spaces-<?php echo $EM_Ticket_Booking->ticket_id; ?>" value="<?php echo $EM_Ticket_Booking->get_spaces(); ?>" /></div>
|
341 |
+
</td>
|
342 |
+
<td><?php echo $EM_Ticket_Booking->get_price(true,true); ?></td>
|
343 |
+
</tr>
|
344 |
+
<?php
|
345 |
+
$shown_tickets[] = $EM_Ticket_Booking->ticket_id;
|
346 |
+
do_action('em_bookings_admin_ticket_row', $EM_Ticket_Booking->get_ticket(), $EM_Booking);
|
347 |
+
?>
|
348 |
+
<?php endforeach; ?>
|
349 |
+
<?php if( count($shown_tickets) < count($EM_Event->get_bookings()->get_tickets()->tickets)): ?><tr>
|
350 |
+
<?php foreach($EM_Event->get_bookings()->get_tickets()->tickets as $EM_Ticket): /* @var $EM_Ticket EM_Ticket */ ?>
|
351 |
+
<?php if( !in_array($EM_Ticket->ticket_id, $shown_tickets) ): ?>
|
352 |
+
<tr>
|
353 |
+
<td class="ticket-type"><a class="row-title" href="<?php echo em_add_get_params($EM_Event->get_bookings_url(), array('ticket_id'=>$EM_Ticket->ticket_id)); ?>"><?php echo $EM_Ticket->ticket_name ?></a></td>
|
354 |
+
<td>
|
355 |
+
<span class="em-booking-single-info">0</span>
|
356 |
+
<div class="em-booking-single-edit"><input name="em_tickets[<?php echo $EM_Ticket->ticket_id; ?>][spaces]" class="em-ticket-select" id="em-ticket-spaces-<?php echo $EM_Ticket_Booking->ticket_id; ?>" value="0" /></div>
|
357 |
+
</td>
|
358 |
+
<td><?php echo em_get_currency_symbol() ?>0.00</td>
|
359 |
+
</tr>
|
360 |
+
<?php do_action('em_bookings_admin_ticket_row', $EM_Ticket, $EM_Booking); ?>
|
361 |
+
<?php endif; ?>
|
362 |
+
<?php endforeach; ?>
|
363 |
+
<?php endif; ?>
|
364 |
+
</tbody>
|
365 |
+
<tfoot>
|
366 |
+
<?php
|
367 |
+
do_action('em_bookings_admin_ticket_totals_header');
|
368 |
+
$price_summary = $EM_Booking->get_price_summary_array();
|
369 |
+
//we should now have an array of information including base price, taxes and post/pre tax discounts
|
370 |
+
?>
|
371 |
+
<tr>
|
372 |
+
<th><?php _e('Price','dbem'); ?></th>
|
373 |
+
<th><?php echo sprintf(__('%d Spaces','dbem'), $EM_Booking->get_spaces()); ?></th>
|
374 |
+
<th><?php echo $EM_Booking->get_price_base(true); ?></th>
|
375 |
+
</tr>
|
376 |
+
<?php if( count($price_summary['discounts_pre_tax']) > 0 ): ?>
|
377 |
+
<?php foreach( $price_summary['discounts_pre_tax'] as $discount_summary ): ?>
|
378 |
+
<tr>
|
379 |
+
<th><?php echo $discount_summary['name']; ?></th>
|
380 |
+
<th><?php echo $discount_summary['discount']; ?></th>
|
381 |
+
<th>- <?php echo $discount_summary['amount']; ?></th>
|
382 |
+
</tr>
|
383 |
+
<?php endforeach; ?>
|
384 |
+
<?php endif; ?>
|
385 |
+
<?php if( !empty($price_summary['taxes']['amount']) ): ?>
|
386 |
+
<tr>
|
387 |
+
<th><?php _e('Tax','dbem'); ?></th>
|
388 |
+
<th>
|
389 |
+
<span class="em-booking-single-info"><?php echo $price_summary['taxes']['rate'] ?></span>
|
390 |
+
<div class="em-booking-single-edit"><input name="booking_tax_rate" value="<?php echo esc_attr($EM_Booking->get_tax_rate()); ?>">%</div>
|
391 |
+
</th>
|
392 |
+
<th><?php echo $price_summary['taxes']['amount']; ?></th>
|
393 |
+
</tr>
|
394 |
+
<?php endif; ?>
|
395 |
+
<?php if( count($price_summary['discounts_post_tax']) > 0 ): ?>
|
396 |
+
<?php foreach( $price_summary['discounts_post_tax'] as $discount_summary ): ?>
|
397 |
+
<tr>
|
398 |
+
<th><?php echo $discount_summary['name']; ?></th>
|
399 |
+
<th><?php echo $discount_summary['discount']; ?></th>
|
400 |
+
<th>- <?php echo $discount_summary['amount']; ?></th>
|
401 |
+
</tr>
|
402 |
+
<?php endforeach; ?>
|
403 |
+
<?php endif; ?>
|
404 |
+
<tr>
|
405 |
+
<th><?php _e('Total Price','dbem'); ?></th>
|
406 |
+
<th> </th>
|
407 |
+
<th><?php echo $price_summary['total']; ?></th>
|
408 |
+
</tr>
|
409 |
+
<?php do_action('em_bookings_admin_ticket_totals_footer'); ?>
|
410 |
+
</tfoot>
|
411 |
+
</table>
|
412 |
+
<table class="em-form-fields" cellspacing="0" cellpadding="0">
|
413 |
+
<?php if( !has_action('em_bookings_single_custom') ): //default behaviour ?>
|
414 |
+
<tr>
|
415 |
+
<th><?php _e('Comment','dbem'); ?></th>
|
416 |
+
<td>
|
417 |
+
<span class="em-booking-single-info"><?php echo $EM_Booking->booking_comment; ?></span>
|
418 |
+
<div class="em-booking-single-edit"><textarea name="booking_comment"><?php echo $EM_Booking->booking_comment; ?></textarea></div>
|
419 |
+
</td>
|
420 |
+
</tr>
|
421 |
+
<?php else: do_action('em_bookings_single_custom',$EM_Booking); //do your own thing, e.g. pro ?>
|
422 |
+
<?php endif; ?>
|
423 |
+
</table>
|
424 |
+
<p class="em-booking-single-info">
|
425 |
+
<input type="button" class="em-booking-submit-modify" id="em-booking-submit-modify" value="<?php _e('Modify Booking', 'dbem'); ?>" />
|
426 |
+
</p>
|
427 |
+
<p class="em-booking-single-edit">
|
428 |
+
<em><?php _e('<strong>Notes:</strong> Ticket availability not taken into account (i.e. you can overbook). Emails are not resent automatically.','dbem'); ?></em>
|
429 |
+
<br /><br />
|
430 |
+
<input type="submit" class="em-booking-submit" id="em-booking-submit" value="<?php _e('Submit Changes', 'dbem'); ?>" />
|
431 |
+
<input type="button" class="em-booking-submit-cancel" id="em-booking-submit-cancel" value="<?php _e('Cancel', 'dbem'); ?>" />
|
432 |
+
<input type='hidden' name='action' value='booking_save'/>
|
433 |
+
<input type='hidden' name='booking_id' value='<?php echo $EM_Booking->booking_id; ?>'/>
|
434 |
+
<input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
|
435 |
+
<input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_save_'.$EM_Booking->booking_id); ?>'/>
|
436 |
+
</p>
|
437 |
+
</form>
|
438 |
+
<script type="text/javascript">
|
439 |
+
jQuery(document).ready( function($){
|
440 |
+
$('#em-booking-submit-modify').click(function(){
|
441 |
+
$('.em-booking-single-info').hide();
|
442 |
+
$('.em-booking-single-edit').show();
|
443 |
+
});
|
444 |
+
$('#em-booking-submit-cancel').click(function(){
|
445 |
+
$('.em-booking-single-info').show();
|
446 |
+
$('.em-booking-single-edit').hide();
|
447 |
+
});
|
448 |
+
$('.em-booking-single-info').show();
|
449 |
+
$('.em-booking-single-edit').hide();
|
450 |
+
|
451 |
+
$('#em-booking-submit-status-modify').click(function(){
|
452 |
+
$('.em-booking-single-status-info').hide();
|
453 |
+
$('.em-booking-single-status-edit').show();
|
454 |
+
});
|
455 |
+
$('#em-booking-submit-status-cancel').click(function(){
|
456 |
+
$('.em-booking-single-status-info').show();
|
457 |
+
$('.em-booking-single-status-edit').hide();
|
458 |
+
});
|
459 |
+
$('.em-booking-single-status-info').show();
|
460 |
+
$('.em-booking-single-status-edit').hide();
|
461 |
+
});
|
462 |
+
</script>
|
463 |
+
</div>
|
464 |
+
</div>
|
465 |
+
<div id="em-booking-notes" class="stuffbox">
|
466 |
+
<h3>
|
467 |
+
<?php _e ( 'Booking Notes', 'dbem' ); ?>
|
468 |
+
</h3>
|
469 |
+
<div class="inside">
|
470 |
+
<p><?php _e('You can add private notes below for internal reference that only event managers will see.','dbem'); ?></p>
|
471 |
+
<?php foreach( $EM_Booking->get_notes() as $note ):
|
472 |
+
$user = new EM_Person($note['author']);
|
473 |
+
?>
|
474 |
+
<div>
|
475 |
+
<?php echo date(get_option('date_format'), $note['timestamp']) .' - '. $user->get_name(); ?> <?php _e('wrote','dbem'); ?>:
|
476 |
+
<p style="background:#efefef; padding:5px;"><?php echo nl2br($note['note']); ?></p>
|
477 |
+
</div>
|
478 |
+
<?php endforeach; ?>
|
479 |
+
<form method="post" action="" style="padding:5px;">
|
480 |
+
<textarea class="widefat" rows="5" name="booking_note"></textarea>
|
481 |
+
<input type="hidden" name="action" value="bookings_add_note" />
|
482 |
+
<input type="submit" value="Add Note" />
|
483 |
+
</form>
|
484 |
+
</div>
|
485 |
+
</div>
|
486 |
+
<?php do_action('em_bookings_single_metabox_footer', $EM_Booking); ?>
|
487 |
+
</div>
|
488 |
+
</div>
|
489 |
+
</div>
|
490 |
+
<br style="clear:both;" />
|
491 |
+
<?php do_action('em_bookings_single_footer', $EM_Booking); ?>
|
492 |
+
</div>
|
493 |
+
<?php
|
494 |
+
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* Shows all bookings made by one person.
|
499 |
+
*/
|
500 |
+
function em_bookings_person(){
|
501 |
+
global $EM_Person, $EM_Notices;
|
502 |
+
$EM_Person->get_bookings();
|
503 |
+
$has_booking = false;
|
504 |
+
foreach($EM_Person->get_bookings() as $EM_Booking){
|
505 |
+
if($EM_Booking->can_manage('manage_bookings','manage_others_bookings')){
|
506 |
+
$has_booking = true;
|
507 |
+
}
|
508 |
+
}
|
509 |
+
if( !$has_booking && !current_user_can('manage_others_bookings') ){
|
510 |
+
?>
|
511 |
+
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
|
512 |
+
<?php
|
513 |
+
return false;
|
514 |
+
}
|
515 |
+
?>
|
516 |
+
<div class='wrap'>
|
517 |
+
<div id='icon-users' class='icon32'>
|
518 |
+
<br/>
|
519 |
+
</div>
|
520 |
+
<h2>
|
521 |
+
<?php _e('Manage Person\'s Booking', 'dbem'); ?>
|
522 |
+
<?php if( current_user_can('edit_users') ) : ?>
|
523 |
+
<a href="<?php echo admin_url('user-edit.php?user_id='.$EM_Person->ID); ?>" class="button add-new-h2"><?php _e('Edit User','dbem') ?></a>
|
524 |
+
<?php endif; ?>
|
525 |
+
<?php if( current_user_can('delete_users') ) : ?>
|
526 |
+
<a href="<?php echo wp_nonce_url( admin_url("users.php?action=delete&user=$EM_Person->ID"), 'bulk-users' ); ?>" class="button add-new-h2"><?php _e('Delete User','dbem') ?></a>
|
527 |
+
<?php endif; ?>
|
528 |
+
</h2>
|
529 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
530 |
+
<?php do_action('em_bookings_person_header'); ?>
|
531 |
+
<div id="poststuff" class="metabox-holder has-right-sidebar">
|
532 |
+
<div id="post-body">
|
533 |
+
<div id="post-body-content">
|
534 |
+
<div id="event_name" class="stuffbox">
|
535 |
+
<h3>
|
536 |
+
<?php _e ( 'Personal Details', 'dbem' ); ?>
|
537 |
+
</h3>
|
538 |
+
<div class="inside">
|
539 |
+
<?php echo $EM_Person->display_summary(); ?>
|
540 |
+
</div>
|
541 |
+
</div>
|
542 |
+
</div>
|
543 |
+
</div>
|
544 |
+
</div>
|
545 |
+
<br style="clear:both;" />
|
546 |
+
<?php do_action('em_bookings_person_body_1'); ?>
|
547 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
548 |
+
<h2><?php _e('Past And Present Bookings','dbem'); ?></h2>
|
549 |
+
<?php
|
550 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
551 |
+
$EM_Bookings_Table->status = 'all';
|
552 |
+
$EM_Bookings_Table->scope = 'all';
|
553 |
+
$EM_Bookings_Table->output();
|
554 |
+
?>
|
555 |
+
<?php do_action('em_bookings_person_footer', $EM_Person); ?>
|
556 |
+
</div>
|
557 |
+
<?php
|
558 |
+
}
|
559 |
+
|
560 |
+
function em_printable_booking_report() {
|
561 |
+
global $EM_Event;
|
562 |
+
//check that user can access this page
|
563 |
+
if( isset($_GET['page']) && $_GET['page']=='events-manager-bookings' && isset($_GET['action']) && $_GET['action'] == 'bookings_report' && is_object($EM_Event)){
|
564 |
+
if( is_object($EM_Event) && !$EM_Event->can_manage('edit_events','edit_others_events') ){
|
565 |
+
?>
|
566 |
+
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
|
567 |
+
<?php
|
568 |
+
return false;
|
569 |
+
}
|
570 |
+
em_locate_template('templates/bookings-event-printable.php', true);
|
571 |
+
die();
|
572 |
+
}
|
573 |
+
}
|
574 |
+
add_action('admin_init', 'em_printable_booking_report');
|
575 |
Â
?>
|
admin/em-categories.php
DELETED
@@ -1,177 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
function em_admin_categories_page() {
|
3 |
-
global $wpdb, $EM_Category;
|
4 |
-
|
5 |
-
if( !empty($_REQUEST['action']) ){
|
6 |
-
if( $_REQUEST['action'] == "save") {
|
7 |
-
// save (add/update) category
|
8 |
-
if( empty($EM_Category) || !is_object($EM_Category) ){
|
9 |
-
$EM_Category = new EM_Category(); //blank category
|
10 |
-
$success_message = __('The category has been added.', 'dbem');
|
11 |
-
}else{
|
12 |
-
$success_message = __('The category has been updated.', 'dbem');
|
13 |
-
}
|
14 |
-
$EM_Category->get_post();
|
15 |
-
if ( $EM_Category->validate() ) {
|
16 |
-
$EM_Category->save(); //FIXME better handling of db write fails when saving category
|
17 |
-
em_categories_table_layout($success_message);
|
18 |
-
} else {
|
19 |
-
?>
|
20 |
-
<div id='message' class='error '>
|
21 |
-
<p>
|
22 |
-
<strong><?php _e( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br /><?php echo implode('<br />', $EM_Category->errors); ?>
|
23 |
-
</p>
|
24 |
-
</div>
|
25 |
-
<?php
|
26 |
-
em_categories_edit_layout();
|
27 |
-
}
|
28 |
-
} elseif( $_REQUEST['action'] == "edit" ){
|
29 |
-
em_categories_edit_layout();
|
30 |
-
} elseif( $_REQUEST['action'] == "delete" ){
|
31 |
-
//delelte category
|
32 |
-
EM_Categories::delete($_REQUEST['categories']);
|
33 |
-
//FIXME no result verification when deleting various categories
|
34 |
-
$message = __('Categories Deleted', "dbem" );
|
35 |
-
em_categories_table_layout($message);
|
36 |
-
}
|
37 |
-
}else{
|
38 |
-
em_categories_table_layout($message);
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
function em_categories_table_layout($message = "") {
|
43 |
-
$categories = EM_Categories::get();
|
44 |
-
$destination = get_bloginfo('url')."/wp-admin/admin.php";
|
45 |
-
?>
|
46 |
-
<div class='wrap nosubsub'>
|
47 |
-
<div id='icon-edit' class='icon32'>
|
48 |
-
<br/>
|
49 |
-
</div>
|
50 |
-
<h2><?php echo __('Categories', 'dbem') ?></h2>
|
51 |
-
|
52 |
-
<?php if($message != "") : ?>
|
53 |
-
<div id='message' class='updated fade below-h2' style='background-color: rgb(255, 251, 204);'>
|
54 |
-
<p><?php echo $message ?></p>
|
55 |
-
</div>
|
56 |
-
<?php endif; ?>
|
57 |
-
|
58 |
-
<div id='col-container'>
|
59 |
-
<!-- begin col-right -->
|
60 |
-
<div id='col-right'>
|
61 |
-
<div class='col-wrap'>
|
62 |
-
<form id='bookings-filter' method='post' action='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=events-manager-categories'>
|
63 |
-
<input type='hidden' name='action' value='delete'/>
|
64 |
-
<?php if (count($categories)>0) : ?>
|
65 |
-
<table class='widefat'>
|
66 |
-
<thead>
|
67 |
-
<tr>
|
68 |
-
<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
|
69 |
-
<th><?php echo __('ID', 'dbem') ?></th>
|
70 |
-
<th><?php echo __('Name', 'dbem') ?></th>
|
71 |
-
</tr>
|
72 |
-
</thead>
|
73 |
-
<tfoot>
|
74 |
-
<tr>
|
75 |
-
<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
|
76 |
-
<th><?php echo __('ID', 'dbem') ?></th>
|
77 |
-
<th><?php echo __('Name', 'dbem') ?></th>
|
78 |
-
</tr>
|
79 |
-
</tfoot>
|
80 |
-
<tbody>
|
81 |
-
<?php foreach ($categories as $EM_Category) : ?>
|
82 |
-
<tr>
|
83 |
-
<td><input type='checkbox' class ='row-selector' value='<?php echo $EM_Category->id ?>' name='categories[]'/></td>
|
84 |
-
<td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=events-manager-categories&action=edit&category_id=<?php echo $EM_Category->id ?>'><?php echo htmlspecialchars($EM_Category->id, ENT_QUOTES); ?></a></td>
|
85 |
-
<td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=events-manager-categories&action=edit&category_id=<?php echo $EM_Category->id ?>'><?php echo htmlspecialchars($EM_Category->name, ENT_QUOTES); ?></a></td>
|
86 |
-
</tr>
|
87 |
-
<?php endforeach; ?>
|
88 |
-
</tbody>
|
89 |
-
|
90 |
-
</table>
|
91 |
-
|
92 |
-
<div class='tablenav'>
|
93 |
-
<div class='alignleft actions'>
|
94 |
-
<input class='button-secondary action' type='submit' name='doaction2' value='Delete'/>
|
95 |
-
<br class='clear'/>
|
96 |
-
</div>
|
97 |
-
<br class='clear'/>
|
98 |
-
</div>
|
99 |
-
<?php else: ?>
|
100 |
-
<p><?php echo __('No categories have been inserted yet!', 'dbem'); ?></p>
|
101 |
-
<?php endif; ?>
|
102 |
-
</form>
|
103 |
-
</div>
|
104 |
-
</div>
|
105 |
-
<!-- end col-right -->
|
106 |
-
|
107 |
-
<!-- begin col-left -->
|
108 |
-
<div id='col-left'>
|
109 |
-
<div class='col-wrap'>
|
110 |
-
<div class='form-wrap'>
|
111 |
-
<div id='ajax-response'>
|
112 |
-
<h3><?php echo __('Add category', 'dbem') ?></h3>
|
113 |
-
<form name='add' id='add' method='post' action='admin.php?page=events-manager-categories' class='add:the-list: validate'>
|
114 |
-
<input type='hidden' name='action' value='save' />
|
115 |
-
<div class='form-field form-required'>
|
116 |
-
<label for='category_name'><?php echo __('Category name', 'dbem') ?></label>
|
117 |
-
<input id='category-name' name='category_name' id='category_name' type='text' size='40' />
|
118 |
-
<p><?php echo __('The name of the category', 'dbem'); ?></p>
|
119 |
-
</div>
|
120 |
-
<p class='submit'><input type='submit' class='button' name='submit' value='<?php echo __('Add category', 'dbem') ?>' /></p>
|
121 |
-
</form>
|
122 |
-
</div>
|
123 |
-
</div>
|
124 |
-
</div>
|
125 |
-
</div>
|
126 |
-
<!-- end col-left -->
|
127 |
-
</div>
|
128 |
-
</div>
|
129 |
-
<?php
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
function em_categories_edit_layout($message = "") {
|
134 |
-
global $EM_Category;
|
135 |
-
if( !is_object($EM_Category) ){
|
136 |
-
$EM_Category = new EM_Category();
|
137 |
-
}
|
138 |
-
//check that user can access this page
|
139 |
-
if( is_object($EM_Category) && !$EM_Category->can_manage() ){
|
140 |
-
?>
|
141 |
-
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
|
142 |
-
<?php
|
143 |
-
return;
|
144 |
-
}
|
145 |
-
?>
|
146 |
-
<div class='wrap'>
|
147 |
-
<div id='icon-edit' class='icon32'>
|
148 |
-
<br/>
|
149 |
-
</div>
|
150 |
-
|
151 |
-
<h2><?php echo __('Edit category', 'dbem') ?></h2>
|
152 |
-
|
153 |
-
<?php if($message != "") : ?>
|
154 |
-
<div id='message' class='updated fade below-h2' style='background-color: rgb(255, 251, 204);'>
|
155 |
-
<p><?php echo $message ?></p>
|
156 |
-
</div>
|
157 |
-
<?php endif; ?>
|
158 |
-
|
159 |
-
<div id='ajax-response'></div>
|
160 |
-
|
161 |
-
<form name='editcat' id='editcat' method='post' action='admin.php?page=events-manager-categories' class='validate'>
|
162 |
-
<input type='hidden' name='action' value='save' />
|
163 |
-
<input type='hidden' name='category_id' value='<?php echo $EM_Category->id ?>'/>
|
164 |
-
|
165 |
-
<table class='form-table'>
|
166 |
-
<tr class='form-field form-required'>
|
167 |
-
<th scope='row' valign='top'><label for='category_name'><?php echo __('Category name', 'dbem') ?></label></th>
|
168 |
-
<td><input name='category_name' id='category-name' type='text' value='<?php echo $EM_Category->name ?>' size='40' /><br />
|
169 |
-
<?php echo __('The name of the category', 'dbem') ?></td>
|
170 |
-
</tr>
|
171 |
-
</table>
|
172 |
-
<p class='submit'><input type='submit' class='button-primary' name='submit' value='<?php echo __('Update category', 'dbem') ?>' /></p>
|
173 |
-
</form>
|
174 |
-
</div>
|
175 |
-
<?php
|
176 |
-
}
|
177 |
-
?>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
admin/em-docs.php
CHANGED
@@ -1,193 +1,338 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function em_docs_init(){
|
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 |
-
'scope' => array( 'default'
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
'#
|
103 |
-
'#
|
104 |
-
)
|
105 |
-
),
|
106 |
-
'
|
107 |
-
'
|
108 |
-
|
109 |
-
'#
|
110 |
-
'#
|
111 |
-
'#
|
112 |
-
'#
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
'#
|
127 |
-
'#
|
128 |
-
'#
|
129 |
-
'#
|
130 |
-
'#
|
131 |
-
'#
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
'#
|
137 |
-
'#
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
'#
|
154 |
-
'#
|
155 |
-
'#
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
193 |
Â
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function em_docs_init($force_init = false){
|
4 |
+
global $pagenow;
|
5 |
+
if( ($pagenow == 'edit.php' && !empty($_GET['page']) && $_GET['page']=='events-manager-help' && class_exists('EM_Event')) || $force_init){
|
6 |
+
add_action('wp_head', 'emd_head');
|
7 |
+
//Generate the docs
|
8 |
+
global $EM_Documentation;
|
9 |
+
$EM_Event = new EM_Event();
|
10 |
+
$event_fields = $EM_Event->get_fields(true);
|
11 |
+
$EM_Location = new EM_Location();
|
12 |
+
$location_fields = $EM_Location->get_fields(true);
|
13 |
+
$EM_Documentation = array(
|
14 |
+
'arguments' => array(
|
15 |
+
'events' => array(
|
16 |
+
'blog' => array( 'desc' => sprintf('Limit search to %s created in a specific blog id (MultiSite only)','events')),
|
17 |
+
'bookings' => array( 'desc'=> 'Include only events with bookings enabled. Use \'user\' to show events a logged in user has booked.'.'1 = yes, 0 = no'),
|
18 |
+
'category' => array( 'desc'=> sprintf('Supply a single id or comma-seperated ids (e.g. "1,2,3") to limit the search to events in these %s. You can also use negative numbers to exclude specific categories (e.g. -1,-2,-3).','categories'), 'default'=>0),
|
19 |
+
'tag' => array( 'desc'=> sprintf('Supply a single id or comma-seperated ids (e.g. "music,theatre,sport") to limit the search to events in these %s.','tags'), 'default'=>0),
|
20 |
+
'event' => array( 'desc'=> sprintf('Supply a single id or comma-seperated ids (e.g. "1,2,3") to limit the search to %s with the %s.','events', 'event_id(s)'), 'default'=>0),
|
21 |
+
'group' => array( 'desc' => 'Limit search to events belonging to a specific group id (BuddyPress only). Using \'my\' will show events belonging to groups the logged in user is a member of.'),
|
22 |
+
'post_id' => array( 'desc' => sprintf('Supply a single id or comma-seperated ids (e.g. "1,2,3") to limit the search to %s with the %s.','events', 'post_id(s)')),
|
23 |
+
'private' => array( 'desc' => sprintf('Display private %s within your list?','events'), 'args' => '1 = yes, 0 = no', 'default' => 'If user can view private events, 1, otherwise 0.'),
|
24 |
+
'private_only' => array( 'desc' =>sprintf('Display only private %s ?','events'), 'args' => '1 = yes, 0 = no', 'default' => '0'),
|
25 |
+
'recurrence' => array( 'desc'=> 'If set to the event id of the recurring event, this will show only events this event recurrences.', 'default'=>0),
|
26 |
+
'recurring' => array( 'desc'=> 'If set to 1, will only show recurring event templates. Only useful if you know what you\'re doing, use recurrence if you want events that are recurrences.', 'default'=>0),
|
27 |
+
'search' => array( 'desc'=> 'Do a search for this string within event name, details and location address.' ),
|
28 |
+
'status' => array( 'desc' => sprintf('Limit search to %s with a spefic status (1 is active, 0 is pending approval)','events'), 'default'=>1),
|
29 |
+
'scope' => array( 'desc'=> 'Choose the time frame of events to show. Additionally you can supply dates (in format of YYYY-MM-DD), either single for events on a specific date or two dates seperated by a comma (e.g. 2010-12-25,2010-12-31) for events ocurring between these dates.', 'default'=>'future', 'args'=>array("future", "past", "today", "tomorrow", "month", "next-month", "1-months", "2-months", "3-months", "6-months", "12-months","all")),
|
30 |
+
'year' => array( 'desc'=> 'If set to a year (e.g. 2010) only events that start or end during this year/month will be returned. Does not work as intended if used with scope.', 'default'=>''),
|
31 |
+
),
|
32 |
+
'locations' => array(
|
33 |
+
'blog' => array( 'desc' => sprintf('Limit search to %s created in a specific blog id (MultiSite only)','locations')),
|
34 |
+
'eventful' => array( 'desc'=> 'If set to 1 will only show locations that have at least one event occurring during the scope.', 'default' => 0),
|
35 |
+
'eventless' => array( 'desc'=> 'If set to 1 will only show locations that have no events occurring during the scope.', 'default' => 0),
|
36 |
+
'location' => array( 'desc'=> sprintf('Supply a single id or comma-seperated ids (e.g. "1,2,3") to limit the search to %s with the %s.','locations', 'location_id(s)'), 'default'=>0),
|
37 |
+
'post_id' => array( 'desc' => sprintf('Supply a single id or comma-seperated ids (e.g. "1,2,3") to limit the search to %s with the %s.','locations', 'post_id(s)')),
|
38 |
+
'private' => array( 'desc' => sprintf('Display private %s within your list?','locations'), 'args' => '1 = yes, 0 = no', 'default' => 'If user can view private locations, 1, otherwise 0.'),
|
39 |
+
'private_only' => array( 'desc' =>sprintf('Display only private %s ?','locations'), 'args' => '1 = yes, 0 = no', 'default' => '0'),
|
40 |
+
'scope' => array( 'default' => 'all'),
|
41 |
+
'status' => array( 'desc' => sprintf('Limit search to %s with a spefic status (1 is active, 0 is pending approval)','locations'), 'default'=>1),
|
42 |
+
'country' => array( 'desc'=> sprintf('Search for %s in this %s (no partial matches, case sensitive).','locations','Country'), 'default' => 'none', 'args'=>'Use two-character country codes as defined in <a href="http://countrycode.org/">countrycode.org</a>, e.g. US,GB,ES'),
|
43 |
+
'region' => array( 'desc'=> sprintf('Search for %s in this %s (no partial matches, case sensitive).','locations','Region'), 'default' => 'none'),
|
44 |
+
'state' => array( 'desc'=> sprintf('Search for %s in this %s (no partial matches, case sensitive).','locations','State'), 'default' => 'none'),
|
45 |
+
'town' => array( 'desc'=> sprintf('Search for %s in this %s (no partial matches, case sensitive).','locations','Town'), 'default' => 'none'),
|
46 |
+
'postcode' => array( 'desc'=> sprintf('Search for %s in this %s (no partial matches, case sensitive).','locations','Postcode'), 'default' => 'none')
|
47 |
+
),
|
48 |
+
'categories' => array(
|
49 |
+
'' => array( 'desc' => 'See the <a href="http://codex.wordpress.org/Function_Reference/get_terms">WordPress get_terms() Codex</a> for a list of possible search attributes/arguments.'),
|
50 |
+
),
|
51 |
+
'tags' => array(
|
52 |
+
'' => array( 'desc' => 'See the <a href="http://codex.wordpress.org/Function_Reference/get_terms">WordPress get_terms() Codex</a> for a list of possible search attributes/arguments.'),
|
53 |
+
),
|
54 |
+
'calendar' => array(
|
55 |
+
'full' => array( 'desc'=> 'If set to 1 it will display a full calendar that shows event names.', 'default' => 0),
|
56 |
+
'long_events' => array( 'desc'=> 'If set to 1, will show events that last longer than a day.', 'default' => 0),
|
57 |
+
),
|
58 |
+
//The object is commonly shared by all, so entries above overwrite entries here
|
59 |
+
'general' => array(
|
60 |
+
'array' => array( 'desc'=> 'If you supply this as an argument, the returned data will be in an array, not an object (only useful wen using PHP, not shortcodes)', 'default'=>0),
|
61 |
+
'format_header' => array( 'desc'=> sprintf('If you are displaying lists (e.g. listing events), you can supply the %s html and placeholders here.','header'), 'default'=> 'The relevant default format will be taken from the settings page.'),
|
62 |
+
'format' => array( 'desc'=> 'If you are displaying some information with the shortcode or function (e.g. listing events), you can supply the html and placeholders here.', 'default'=> 'The relevant default format will be taken from the settings page.'),
|
63 |
+
'format_footer' => array( 'desc'=> sprintf('If you are displaying lists (e.g. listing events), you can supply the %s html and placeholders here.','footer'), 'default'=> 'The relevant default format will be taken from the settings page.'),
|
64 |
+
'limit' => array( 'desc'=> 'Limits the amount of values returned to this number.', 'default'=>'0 (no limit)'),
|
65 |
+
'offset' => array( 'desc'=> 'For example, if you have ten results, if you set this to 5, only the last 5 results will be returned. Useful for pagination.', 'default'=>0),
|
66 |
+
'order' => array( 'desc'=> 'Indicates the alphabeitcal/numerical order of the lists. Choose between ASC (ascending) and DESC (descending).', 'default'=>'ASC'),
|
67 |
+
'orderby' => array( 'desc'=> 'Choose what fields to order your results by. You can supply a single field or multiple comma-seperated fields (e.g. "event_start_date,event_name").', 'default'=>0, 'args'=>'Database table fields, e.g. <code>event_name</code> or <code>location_name</code>'),
|
68 |
+
'owner' => array('desc'=> 'Limits returned results to a specific owner, identified by their user id (e.g. list events or locations owned by user)', 'default'=>0),
|
69 |
+
'pagination' => array('desc'=> 'When using a function or shortcode that outputs items (e.g. [events_list] for events, [locations_list] for locations), if the number of items supercede the limit of items to show, setting this to 1 will show page links under the list.', 'default'=>0),
|
70 |
+
)
|
71 |
+
),
|
72 |
+
'placeholders' => array(
|
73 |
+
'events' => array(
|
74 |
+
'Event Details' => array(
|
75 |
+
'placeholders' => array(
|
76 |
+
'#_EVENTID' => array( 'desc' => 'Shows the event ID number in the wp_em_events table.' ),
|
77 |
+
'#_EVENTPOSTID' => array( 'desc' => 'Shows the event corresponding Post ID in the wp_posts table.' ),
|
78 |
+
'#_EVENTNAME' => array( 'desc' => 'Displays the name of the event.' ),
|
79 |
+
'#_EVENTNOTES' => array( 'desc' => 'Shows the description of the event.' ),
|
80 |
+
'#_EVENTEXCERPT' => array( 'desc' => 'If you added a <a href="http://en.support.wordpress.com/splitting-content/more-tag/">more tag</a> to your event description, only the content before this tag will show (currently, no read more link is added).' ),
|
81 |
+
'#_EVENTIMAGE' => array( 'desc' => 'Shows the event image, if available.' ),
|
82 |
+
'#_EVENTIMAGE{x,y}' => array( 'desc' => 'Shows the event image thumbnail, x and y are width and height respectively, both being numbers e.g. <code>#_EVENTIMAGE{100,100}</code>' ),
|
83 |
+
'#_EVENTCATEGORIES' => array( 'desc' => 'Shows a list of category links this event belongs to.' ),
|
84 |
+
'#_EVENTCATEGORIESIMAGES' => array( 'desc' => 'Shows a list of category images this event belongs to. Categories without an image will be ignored.' ),
|
85 |
+
'#_EVENTTAGS' => array( 'desc' => 'Shows a list of tag links this event belongs to.' ),
|
86 |
+
)
|
87 |
+
),
|
88 |
+
'Date and Times' => array(
|
89 |
+
'desc' => '',
|
90 |
+
'placeholders' => array(
|
91 |
+
'#_24HSTARTTIME' => array( 'desc' => 'Displays the start time in a 24 hours format (e.g. 16:30).' ),
|
92 |
+
'#_24HENDTIME' => array( 'desc' => 'Displays the end time in a 24 hours format (e.g. 18:30).' ),
|
93 |
+
'#_12HSTARTTIME' => array( 'desc' => 'Displays the start time in a 12 hours format (e.g. 4:30 PM).' ),
|
94 |
+
'#_12HENDTIME' => array( 'desc' => 'Displays the end time in a 12 hours format (e.g. 6:30 PM).' ),
|
95 |
+
'#_EVENTTIMES' => array( 'desc' => 'Displays either a single time, time-span, or "All Day" depending on your event times. Format is taken from your Events Manager settings page.' ),
|
96 |
+
'#_EVENTDATES' => array( 'desc' => 'Displays either a single date or a date range depending on your event dates. Format is taken from your Events Manager settings page.' ),
|
97 |
+
)
|
98 |
+
),
|
99 |
+
'Custom Date/Time Formatting' => array(
|
100 |
+
'desc' => 'Events Manager allows extremely flexible date formatting by using <a href="http://www.php.net/manual/en/function.date.php">PHP date syntax format characters</a> along with placeholders.',
|
101 |
+
'placeholders' => array(
|
102 |
+
'# or #@' => array( 'desc' => 'Prepend <code>#</code> or <code>#@</code> before a valid PHP date syntax format character to show start and end date/time information respectively (e.g. <code>#F</code> will show the starting month name like "January", #@h shows the end hour).' ),
|
103 |
+
'#{x} or #@{x}' => array( 'desc' => 'You can also create a date format without prepending # to each character by wrapping a valid php date() format in <code>#{}</code> or <code>#@{}</code> (e.g. <code>#_{d/m/Y}</code>). If there is no end date (or is same as start date), the value is not shown. This is useful if you want to show event end dates only on events that are longer than one day, e.g. <code>#j #M #Y #@_{ \u\n\t\i\l j M Y}</code>.' ),
|
104 |
+
)
|
105 |
+
),
|
106 |
+
'Links/URLs' => array(
|
107 |
+
'placeholders' => array(
|
108 |
+
'#_EVENTIMAGEURL' => array( 'desc' => 'Shows the event image url, if available.' ),
|
109 |
+
'#_EVENTURL' => array( 'desc' => 'Simply prints the event URL. You can use this placeholder to build your own customised links.' ),
|
110 |
+
'#_EVENTLINK' => array( 'desc' => 'Displays the event name with a link to the event page.' ),
|
111 |
+
'#_EDITEVENTLINK' => array( 'desc' => 'Inserts a link to the admin or buddypress (if activated) edit event page, only if a user is logged in and is allowed to edit the event.' ),
|
112 |
+
'#_EDITEVENTURL' => array( 'desc' => 'Inserts a url to the admin or buddypress (if activated) edit event page, only if a user is logged in and is allowed to edit the event.' )
|
113 |
+
)
|
114 |
+
),
|
115 |
+
'Custom Attributes' => array(
|
116 |
+
'desc' => 'Events Manager allows you to create dynamic attributes to your events, which act as extra information fields for your events (e.g. "Dress Code"). For more information see <a href="http://wp-events-plugin.com/documentation/event-attributes/">our online documentation</a> for more info on attributes.',
|
117 |
+
'placeholders' => array(
|
118 |
+
'#_ATT{key}' => array('desc'=> 'This key will appear as an option when adding attributes to your event.'),
|
119 |
+
'#_ATT{key}{alternative text}' => array('desc'=> 'This key will appear as an option when adding attributes to your event. The text in the second braces will appear if the attribute is not defined or left blank for that event.'),
|
120 |
+
'#_ATT{key}{option 1|option 2|option 3|etc.}' => array('desc'=> 'This key will appear as an option when adding attributes to your event. The second braces are optional and will use a select box with these values as input. If no valid value is defined, the first option is used.'),
|
121 |
+
)
|
122 |
+
),
|
123 |
+
'Bookings' => array(
|
124 |
+
'desc' => 'These placeholders will only show if bookings are enabled for the given event and in the events manager settings page. Spaces placeholders will default to 0',
|
125 |
+
'placeholders' => array(
|
126 |
+
'#_BOOKINGFORM' => array( 'desc' => 'Adds a booking forms for this event.' ),
|
127 |
+
'#_BOOKINGBUTTON' => array( 'desc' => 'A single button that will appear to logged in users, if they click on it, they apply for a booking. This button will only display if there is one ticket.' ),
|
128 |
+
'#_AVAILABLESPACES' => array( 'desc' => 'Shows available spaces for the event.' ),
|
129 |
+
'#_BOOKEDSPACES' => array( 'desc' => 'Shows the amount of currently booked spaces for the event.' ),
|
130 |
+
'#_PENDINGSPACES' => array( 'desc' => 'Shows the amount of pending spaces for the event.' ),
|
131 |
+
'#_SPACES' => array( 'desc' => 'Shows the total spaces for the event.' ),
|
132 |
+
'#_ATTENDEES' => array( 'desc' => 'Shows the list of user avatars attending the event.' ),
|
133 |
+
'#_ATTENDEESLIST' => array( 'desc' => 'Shows the list of people attending the event.' ),
|
134 |
+
'#_ATTENDEESPENDINGLIST' => array( 'desc' => 'Shows the list of people with a pending booking for the event.' ),
|
135 |
+
'#_BOOKINGSURL' => array( 'desc' => 'Shows the url to the admin, front-end or buddypress (if activated) bookings management page for this event. Only shown if user is logged in and able to manage bookings.' ),
|
136 |
+
'#_BOOKINGSLINK' => array( 'desc' => 'Shows a link to the admin, front-end or buddypress (if activated) bookings management page for this event. Only shown if user is logged in and able to manage bookings.' ),
|
137 |
+
'#_EVENTPRICERANGE' => array( 'desc' => 'Shows a "maximum - minimum" price range for available tickets at the time of display, or a single price if there is no range. Once bookings are closed this will show a 0 value, if you have enabled \'Show unavailable tickets\' in your booking settings these will be included. Price is formatted according to currency formatting in your settings page.' ),
|
138 |
+
'#_EVENTPRICERANGEALL' => array( 'desc' => 'Like #_EVENTPRICERANGE but shows all tickets price range whether or not bookings or individual tickets are available.' ),
|
139 |
+
'#_EVENTPRICEMIN' => array( 'desc' => 'Shows the lowest ticket price for this event.' ),
|
140 |
+
'#_EVENTPRICEMAX' => array( 'desc' => 'Shows the highest ticket price for this event.' ),
|
141 |
+
)
|
142 |
+
),
|
143 |
+
'Contact Details' => array(
|
144 |
+
'desc' => 'The values here are taken from the chosen contact for the specific event, or the default contact in the settings page.',
|
145 |
+
'placeholders' => array(
|
146 |
+
'#_CONTACTNAME' => array( 'desc' => 'Name of the contact person for this event (as shown in the dropdown when adding an event).' ),
|
147 |
+
'#_CONTACTUSERNAME' => array( 'desc' => 'Contact person\'s username.' ),
|
148 |
+
'#_CONTACTEMAIL' => array( 'desc' => 'E-mail of the contact person for this event.' ),
|
149 |
+
'#_CONTACTURL' => array( 'desc' => 'Website of the contact person for this event.' ),
|
150 |
+
'#_CONTACTPHONE' => array( 'desc' => 'Phone number of the contact person for this event. Can be set in the user profile page.' ),
|
151 |
+
'#_CONTACTAVATAR' => array( 'desc' => 'Contact person\'s avatar.' ),
|
152 |
+
'#_CONTACTPROFILELINK' => array( 'desc' => 'Contact person\'s "Profile" link. Only works with BuddyPress enabled.' ),
|
153 |
+
'#_CONTACTPROFILEURL' => array( 'desc' => 'Contact person\'s profile url. Only works with BuddyPress enabled.' ),
|
154 |
+
'#_CONTACTID' => array( 'desc' => 'Contact person\'s WordPress user ID.'),
|
155 |
+
'#_CONTACTMETA' => array( 'desc' => 'Display any user meta of a WordPress account by including the meta key, e.g. #_CONTACTMETA{dbem_phone}'),
|
156 |
+
)
|
157 |
+
),
|
158 |
+
'iCal/Calendar' => array(
|
159 |
+
'placeholders' => array(
|
160 |
+
'#_EVENTICALURL' => array( 'desc' => 'Displays the URL of the event ical feed (ics file format).' ),
|
161 |
+
'#_EVENTICALLINK' => array( 'desc' => 'Displays an html link to the event ical feed (ics file format).' ),
|
162 |
+
'#_EVENTGCALURL' => array( 'desc' => 'Displays URL which would take the user to Google Calendar and pre-fill their add new event form.' ),
|
163 |
+
'#_EVENTGCALLINK' => array( 'desc' => 'Displays a button which would take the user to Google Calendar and pre-fill their add new event form.' )
|
164 |
+
)
|
165 |
+
),
|
166 |
+
),
|
167 |
+
'categories' => array(
|
168 |
+
'Category Details' => array(
|
169 |
+
'desc' => 'You can use these when displaying categories or for showing the first available category in an event format.',
|
170 |
+
'placeholders' => array(
|
171 |
+
'#_CATEGORYNAME' => array( 'desc' => 'Shows the category name.' ),
|
172 |
+
'#_CATEGORYID' => array( 'desc' => 'Shows the category ID.' ),
|
173 |
+
'#_CATEGORYSLUG' => array( 'desc' => 'Shows the category slug.' ),
|
174 |
+
'#_CATEGORYIMAGE' => array( 'desc' => 'Shows the category image, if available.' ),
|
175 |
+
'#_CATEGORYIMAGE{x,y}' => array( 'desc' => 'Shows the category image thumbnail if available, x and y are width and height respectively, both being numbers e.g. <code>#_CATEGORYIMAGE{100,100}</code>' ),
|
176 |
+
'#_CATEGORYIMAGEURL' => array( 'desc' => 'Shows the category image url, if available.' ),
|
177 |
+
'#_CATEGORYNOTES' => array( 'desc' => 'Shows the category description.' )
|
178 |
+
)
|
179 |
+
),
|
180 |
+
'Related Events' => array(
|
181 |
+
'desc' => 'You can show lists of other events belonging to this category. The formatting of the list is the same as a normal events list.',
|
182 |
+
'placeholders' => array(
|
183 |
+
'#_CATEGORYPASTEVENTS' => array( 'desc' => 'Will show a list of all past events at this category.' ),
|
184 |
+
'#_CATEGORYNEXTEVENTS' => array( 'desc' => 'Will show a list of all future events at this category.' ),
|
185 |
+
'#_CATEGORYALLEVENTS' => array( 'desc' => 'Will show a list of all events at this category.' )
|
186 |
+
)
|
187 |
+
)
|
188 |
+
),
|
189 |
+
'locations' => array(
|
190 |
+
'Location Details' => array(
|
191 |
+
'desc' => '',
|
192 |
+
'placeholders' => array(
|
193 |
+
'#_LOCATIONID' => array( 'desc' => 'Shows the event ID number in the wp_em_locations table.' ),
|
194 |
+
'#_LOCATIONPOSTID' => array( 'desc' => 'Shows the location corresponding Post ID in the wp_posts table.' ),
|
195 |
+
'#_LOCATIONNAME' => array( 'desc' => 'Displays the location name.' ),
|
196 |
+
'#_LOCATIONADDRESS' => array( 'desc' => 'Displays the address.' ),
|
197 |
+
'#_LOCATIONTOWN' => array( 'desc' => 'Displays the town.' ),
|
198 |
+
'#_LOCATIONSTATE' => array( 'desc' => 'Displays the state/county.' ),
|
199 |
+
'#_LOCATIONPOSTCODE' => array( 'desc' => 'Displays the postcode.' ),
|
200 |
+
'#_LOCATIONREGION' => array( 'desc' => 'Displays the region.' ),
|
201 |
+
'#_LOCATIONCOUNTRY' => array( 'desc' => 'Displays the country.' ),
|
202 |
+
'#_LOCATIONLONGITUDE' => array( 'desc' => 'Displays the longitude, used for locating in Google Maps.' ),
|
203 |
+
'#_LOCATIONLATITUDE' => array( 'desc' => 'Displays the latitude, used for locating in Google Maps.' ),
|
204 |
+
'#_LOCATIONMAP' => array( 'desc' => 'Displays a google map showing where the event is located (Will not show if maps are disabled in the settings page)' ),
|
205 |
+
'#_LOCATIONNOTES' => array( 'desc' => 'Shows the location description.' ),
|
206 |
+
'#_LOCATIONEXCERPT' => array( 'desc' => 'If you added a <a href="http://en.support.wordpress.com/splitting-content/more-tag/">more tag</a> to your location description, only the content before this tag will show (currently, no read more link is added).' ),
|
207 |
+
'#_LOCATIONIMAGE' => array( 'desc' => 'Shows the location image.' ),
|
208 |
+
'#_LOCATIONIMAGE{x,y}' => array( 'desc' => 'Shows the location image thumbnail, x and y are width and height respectively, both being numbers e.g. <code>#_LOCATIONIMAGE{100,100}</code>' ),
|
209 |
+
'#_LOCATIONIMAGEURL' => array( 'desc' => 'Shows the location image url, if available.' ),
|
210 |
+
'#_LOCATIONFULLLINE' => array( 'desc' => 'Shows a comma-seperated line of location information, ommitting blanks (format of address, town, state, postcode, region' ),
|
211 |
+
'#_LOCATIONFULLBR' => array( 'desc' => 'Shows a line-break (br tag) seperated location information, ommitting blanks (format of address, town, state, postcode, region' ),
|
212 |
+
)
|
213 |
+
),
|
214 |
+
'Custom Attributes' => array(
|
215 |
+
'desc' => 'Events Manager allows you to create dynamic attributes to your locations, which act as extra information fields for your locations (e.g. "Dress Code"). For more information see <a href="http://wp-events-plugin.com/documentation/event-attributes/">our online documentation</a> for more info on attributes.',
|
216 |
+
'placeholders' => array(
|
217 |
+
'#_LATT{key}' => array('desc'=> 'This key will appear as an option when adding attributes to your location.'),
|
218 |
+
'#_LATT{key}{alternative text}' => array('desc'=> 'This key will appear as an option when adding attributes to your location. The text in the second braces will appear if the attribute is not defined or left blank for that location.'),
|
219 |
+
'#_LATT{key}{option 1|option 2|option 3|etc.}' => array('desc'=> 'This key will appear as an option when adding attributes to your location. The second braces are optional and will use a select box with these values as input. If no valid value is defined, the first option is used.'),
|
220 |
+
)
|
221 |
+
),
|
222 |
+
'Links' => array(
|
223 |
+
'placeholders' => array(
|
224 |
+
'#_LOCATIONURL' => array( 'desc' => 'Simply prints the location URL. You can use this placeholder to build your own customised links.' ),
|
225 |
+
'#_LOCATIONLINK' => array( 'desc' => 'Displays the location name with a link to the location page.' ),
|
226 |
+
'#_EDITLOCATIONLINK' => array( 'desc' => 'Inserts a link to the admin or buddypress (if activated) edit location page, only if a user is logged in and is allowed to edit the location.' ),
|
227 |
+
'#_EDITLOCATIONURL' => array( 'desc' => 'Inserts a url to the admin or buddypress (if activated) edit location page, only if a user is logged in and is allowed to edit the location.' )
|
228 |
+
)
|
229 |
+
),
|
230 |
+
'Related Events' => array(
|
231 |
+
'desc' => 'You can show lists of other events that are being held at this location. The formatting of the list is the same as a normal events list.',
|
232 |
+
'placeholders' => array(
|
233 |
+
'#_LOCATIONPASTEVENTS' => array( 'desc' => 'Will show a list of all past events at this location.' ),
|
234 |
+
'#_LOCATIONNEXTEVENTS' => array( 'desc' => 'Will show a list of all future events at this location.' ),
|
235 |
+
'#_LOCATIONALLEVENTS' => array( 'desc' => 'Will show a list of all events at this location.' ),
|
236 |
+
'#_LOCATIONNEXTEVENT' => array( 'desc' => 'Will show a link to the next event at this location, or the no events message.' ),
|
237 |
+
)
|
238 |
+
),
|
239 |
+
),
|
240 |
+
'bookings' => array(
|
241 |
+
'Individual Booking Information' => array(
|
242 |
+
'desc' => 'When a specific booking is displayed (on screen and on email), you can use these placeholders to show specific information about the booking. Event and Location placeholders are also available in these cases.',
|
243 |
+
'placeholders' => array(
|
244 |
+
'#_BOOKINGID' => array( 'desc' => 'The unique ID of this booking, useful if you are making your own customizations to this plugin.' ),
|
245 |
+
'#_BOOKINGNAME' => array( 'desc' => 'Name of person who made the booking.' ),
|
246 |
+
'#_BOOKINGEMAIL' => array( 'desc' => 'Email of person who made the booking.' ),
|
247 |
+
'#_BOOKINGPHONE' => array( 'desc' => 'Phone number of person who made the booking.' ),
|
248 |
+
'#_BOOKINGSPACES' => array( 'desc' => 'Number of spaces the person has booked.' ),
|
249 |
+
'#_BOOKINGCOMMENT' => array( 'desc' => 'Any specific comments made by the person who made the booking.' ),
|
250 |
+
'#_BOOKINGTICKETNAME' => array( 'desc' => 'Name of the ticket booked. Useful in single ticket mode, if multiple tickets are booked a random ticket is used.' ),
|
251 |
+
'#_BOOKINGTICKETDESCRIPTION' => array( 'desc' => 'Description of the ticket booked. Useful in single ticket mode, if multiple tickets are booked a random ticket is used.' ),
|
252 |
+
'#_BOOKINGTICKETPRICE' => array( 'desc' => 'Booked ticket price with currency symbol (e.g. $ 10.00). Useful in single ticket mode, if multiple tickets are booked a random ticket is used.' ),
|
253 |
+
'#_BOOKINGTICKETS' => array( 'desc' => 'A list of booked tickets. You can modify this by using template files and modifying templates/emails/bookingtickets.php' ),
|
254 |
+
'#_BOOKINGSUMMARY' => array( 'desc' => 'Shows a breakdown of price/quantity booked by ticket, followed by a summary of price totals, taxes, and other discounts applied.' ),
|
255 |
+
'#_BOOKINGFORMCUSTOM{field_id}' => array( 'desc' => sprintf('(<a href="%s">pro only</a>) Shows booking form custom fields. The field_id value must match that of your custom booking form field.','http://wp-events-plugin.com/features/') ),
|
256 |
+
'#_BOOKINGFORMCUSTOMREG{field_id}' => array( 'desc' => sprintf('(<a href="%s">pro only</a>) Shows booking form custom fields that are used for guest user registration. The field_id value must match that of your custom booking form field.','http://wp-events-plugin.com/features/') ),
|
257 |
+
'#_BOOKINGFORMCUSTOMFIELDS' => array( 'desc' => sprintf('(<a href="%s">pro only</a>) Generates a list of booking form custom fields that are used in the booking.','http://wp-events-plugin.com/features/') ),
|
258 |
+
'#_BOOKINGATTENDEES' => array('desc' => sprintf('(<a href="%s">pro only</a>) Generates a list of attendee information displaying the filled in form data for each attendee (requires individual attendee forms enabled for the event). This list is split by ticket type, then by individual attendee.','http://wp-events-plugin.com/features/')), //coupons too!
|
259 |
+
)
|
260 |
+
),
|
261 |
+
'Pricing Information' => array(
|
262 |
+
'desc' => '',
|
263 |
+
'placeholders' => array(
|
264 |
+
'#_BOOKINGPRICE' => array( 'desc' => 'Displays booking total price (tax inclusion depends on your booking settings).' ),
|
265 |
+
'#_BOOKINGPRICETAX' => array( 'desc' => 'Displays booking total tax.' ),
|
266 |
+
'#_BOOKINGPRICEWITHOUTTAX' => array( 'desc' => 'Displays booking total without tax.' ),
|
267 |
+
'#_BOOKINGPRICEWITHTAX' => array( 'desc' => 'Displays booking total with tax.' ),
|
268 |
+
)
|
269 |
+
),
|
270 |
+
'Ticket Information' => array(
|
271 |
+
'desc' => '',
|
272 |
+
'placeholders' => array(
|
273 |
+
'#_BOOKINGTICKETS' => array( 'desc' => 'Shows a breakdown of tickets and pricing, defined in the <code>emails/bookingtickets.php</code> template. (See <a href="http://wp-events-plugin.com/documentation/using-template-files/">Using Template Files</a> for more information)' ),
|
274 |
+
'#_BOOKINGTICKETDESCRIPTION' => array( 'desc' => 'Shows the description of the first ticket booked (useful in single ticket mode/events).' ),
|
275 |
+
'#_BOOKINGTICKETPRICE' => array( 'desc' => 'Shows the price of the first ticket booked, tax inclusion depending on your booking settings (useful in single ticket mode/events).' ),
|
276 |
+
'#_BOOKINGTICKETTAX' => array( 'desc' => 'Shows the tax of the first ticket booked (useful in single ticket mode/events).' ),
|
277 |
+
'#_BOOKINGTICKETPRICEWITHTAX' => array( 'desc' => 'Shows the price including tax of the first ticket booked (useful in single ticket mode/events).' ),
|
278 |
+
'#_BOOKINGTICKETPRICEWITHOUTTAX' => array( 'desc' => 'Shows the price excluding tax of the first ticket booked (useful in single ticket mode/events).' ),
|
279 |
+
)
|
280 |
+
),
|
281 |
+
'Links' => array(
|
282 |
+
'desc' => 'People are able to manage their bookings. Below are some placeholder which automatically provides correctly formatted urls',
|
283 |
+
'placeholders' => array(
|
284 |
+
'#_BOOKINGLISTURL' => array( 'desc' => 'URL to page showing that users booked events.' )
|
285 |
+
)
|
286 |
+
),
|
287 |
+
'Gateway-Specific Information' => array(
|
288 |
+
'desc' => 'Information pertaining to speicifc gateways. '. sprintf('Requires <a href="%s">Events Manager Pro</a>','http://wp-events-plugin.com/features/'),
|
289 |
+
'placeholders' => array(
|
290 |
+
'#_BOOKINGTXNID' => array( 'desc' => '<em>Online Payments Only</em> - Prints the transaction ID of this booking if available.' )
|
291 |
+
)
|
292 |
+
),
|
293 |
+
'Coupon Information' => array(
|
294 |
+
'desc' => 'When a booking has been made with a coupon, you can display coupon information using these placeholders. If no coupon is used, nothing will be shown. '.sprintf('Requires <a href="%s">Events Manager Pro</a>','http://wp-events-plugin.com/features/'),
|
295 |
+
'placeholders' => array(
|
296 |
+
'#_BOOKINGCOUPON' => array('desc' => 'Displays the coupon code followed by the amount/percentage discounted.'),
|
297 |
+
'#_BOOKINGCOUPONCODE' => array('desc' => 'Displays the coupon code used.'),
|
298 |
+
'#_BOOKINGCOUPONNAME' => array('desc' => 'Displays the name given to this coupon.'),
|
299 |
+
'#_BOOKINGCOUPONDISCOUNT' => array('desc' => 'Displays amount/percentage discounted (e.g. 25% Off).'),
|
300 |
+
'#_BOOKINGCOUPONDESCRIPTION' => array('desc' => 'Displays the coupon description.'),
|
301 |
+
)
|
302 |
+
),
|
303 |
+
),
|
304 |
+
),
|
305 |
+
//TODO add capabilites explanations
|
306 |
+
'capabilities' => array()
|
307 |
+
);
|
308 |
+
}
|
309 |
+
}
|
310 |
+
add_action('init', 'em_docs_init');
|
311 |
+
|
312 |
+
function em_docs_placeholders($atts){
|
313 |
+
ob_start();
|
314 |
+
?>
|
315 |
+
<div class="em-docs">
|
316 |
+
<?php
|
317 |
+
global $EM_Documentation;
|
318 |
+
$type = $atts['type'];
|
319 |
+
$data = $EM_Documentation['placeholders'][$type];
|
320 |
+
foreach($data as $sectionTitle => $details) : ?>
|
321 |
+
<div>
|
322 |
+
<h3><?php echo $sectionTitle; ?></h3>
|
323 |
+
<?php if( !empty($details['desc']) ): ?>
|
324 |
+
<p><?php echo $details['desc']; ?></p>
|
325 |
+
<?php endif; ?>
|
326 |
+
<dl>
|
327 |
+
<?php foreach($details['placeholders'] as $placeholder => $desc ): ?>
|
328 |
+
<dt><b><?php echo $placeholder; ?></b></dt>
|
329 |
+
<dd><?php echo $desc['desc']; ?></dd>
|
330 |
+
<?php endforeach; ?>
|
331 |
+
</dl>
|
332 |
+
</div>
|
333 |
+
<?php endforeach; ?>
|
334 |
+
</div>
|
335 |
+
<?php
|
336 |
+
return ob_get_clean();
|
337 |
+
}
|
338 |
Â
?>
|
admin/em-event.php
DELETED
@@ -1,627 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
function em_admin_event_actions(){
|
3 |
-
if( current_user_can(EM_MIN_CAPABILITY) && !empty($_GET['page']) && $_GET['page'] == 'events-manager-event' && !empty($_REQUEST ['action']) ){
|
4 |
-
global $wpdb;
|
5 |
-
global $EM_Event;
|
6 |
-
|
7 |
-
//if dealing with new event, we still want an event object
|
8 |
-
if( !is_object($EM_Event) ){
|
9 |
-
$EM_Event = new EM_Event();
|
10 |
-
}
|
11 |
-
|
12 |
-
// UPDATE or CREATE action
|
13 |
-
if ($_REQUEST['action'] == 'save') {
|
14 |
-
$validation = $EM_Event->get_post();
|
15 |
-
if ( $validation ) { //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
|
16 |
-
//Save
|
17 |
-
if( $EM_Event->save() ) {
|
18 |
-
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno']:'';
|
19 |
-
$scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope']:'';
|
20 |
-
wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager&p='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
|
21 |
-
}
|
22 |
-
}//errors added automatically to event global object
|
23 |
-
}
|
24 |
-
|
25 |
-
//Copy the event
|
26 |
-
if ($_REQUEST['action'] == 'duplicate') {
|
27 |
-
global $EZSQL_ERROR;
|
28 |
-
$EM_Event = $EM_Event->duplicate();
|
29 |
-
if( $EM_Event === false ){
|
30 |
-
$redirect_url = em_add_get_params($_SERVER['HTTP_REFERER'], array('error' => __('There was an error duplicating the event. Try again maybe?', 'dbem'), 'message'=>''), false);
|
31 |
-
wp_redirect($redirect_url);
|
32 |
-
}else{
|
33 |
-
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno']:'';
|
34 |
-
$scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope']:'';
|
35 |
-
wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-event&event_id='.$EM_Event->id.'&p='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
|
36 |
-
}
|
37 |
-
}
|
38 |
-
}
|
39 |
-
}
|
40 |
-
add_action('admin_init', 'em_admin_event_actions');
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Generates Event Admin page, for adding and updating a single (or recurring) event.
|
44 |
-
* @param $title
|
45 |
-
* @return null
|
46 |
-
*/
|
47 |
-
function em_admin_event_page() {
|
48 |
-
global $EM_Event, $current_user;
|
49 |
-
global $localised_date_formats;
|
50 |
-
|
51 |
-
//check that user can access this page
|
52 |
-
if( is_object($EM_Event) && !$EM_Event->can_manage() ){
|
53 |
-
?>
|
54 |
-
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
|
55 |
-
<?php
|
56 |
-
return false;
|
57 |
-
}
|
58 |
-
|
59 |
-
if( is_object($EM_Event) && $EM_Event->id > 0 ){
|
60 |
-
if($EM_Event->is_recurring()){
|
61 |
-
$title = __( "Reschedule", 'dbem' )." '{$EM_Event->name}'";
|
62 |
-
}else{
|
63 |
-
$title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
|
64 |
-
}
|
65 |
-
} else {
|
66 |
-
$EM_Event = ( is_object($EM_Event) && get_class($EM_Event) == 'EM_Event') ? $EM_Event : new EM_Event();
|
67 |
-
$title = __ ( "Insert New Event", 'dbem' );
|
68 |
-
//Give a default location & category
|
69 |
-
$default_cat = get_option('dbem_default_category');
|
70 |
-
$default_loc = get_option('dbem_default_location');
|
71 |
-
if( is_numeric($default_cat) && $default_cat > 0 ){
|
72 |
-
$EM_Event->category_id = $default_cat;
|
73 |
-
$EM_Event->category = new EM_Category($default_cat);
|
74 |
-
}
|
75 |
-
if( is_numeric($default_loc) && $default_loc > 0 && ( empty($EM_Event->location->id) && empty($EM_Event->location->name) && empty($EM_Event->location->address) && empty($EM_Event->location->town) ) ){
|
76 |
-
$EM_Event->location_id = $default_loc;
|
77 |
-
$EM_Event->location = new EM_Location($default_loc);
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
$use_select_for_locations = get_option('dbem_use_select_for_locations');
|
82 |
-
// change prefix according to event/recurrence
|
83 |
-
$pref = "event_";
|
84 |
-
|
85 |
-
$locale_code = substr ( get_locale (), 0, 2 );
|
86 |
-
$localised_date_format = $localised_date_formats[$locale_code];
|
87 |
-
|
88 |
-
//FIXME time useage is very flimsy imho
|
89 |
-
$hours_locale_regexp = "H:i";
|
90 |
-
// Setting 12 hours format for those countries using it
|
91 |
-
if (preg_match ( "/en|sk|zh|us|uk/", $locale_code ))
|
92 |
-
$hours_locale_regexp = "h:iA";
|
93 |
-
|
94 |
-
$days_names = array (1 => __ ( 'Mon' ), 2 => __ ( 'Tue' ), 3 => __ ( 'Wed' ), 4 => __ ( 'Thu' ), 5 => __ ( 'Fri' ), 6 => __ ( 'Sat' ), 0 => __ ( 'Sun' ) );
|
95 |
-
?>
|
96 |
-
<?php if ( count($EM_Event->errors) > 0 || !empty($_GET['error']) ) : ?>
|
97 |
-
<div id='message' class='error '>
|
98 |
-
<p>
|
99 |
-
<?php if( count($EM_Event->errors) ){ ?>
|
100 |
-
<strong><?php echo __( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br />
|
101 |
-
<?php echo implode('<br />', $EM_Event->errors); ?>
|
102 |
-
<?php } else { echo $_GET['error']; } ?>
|
103 |
-
</p>
|
104 |
-
</div>
|
105 |
-
<?php endif; ?>
|
106 |
-
<?php if ( !empty($EM_Event->feedback_message) || !empty($_GET['message']) ) : ?>
|
107 |
-
<div id='message' class='updated fade'>
|
108 |
-
<p><?php echo !empty($EM_Event->feedback_message) ? $EM_Event->feedback_message : $_GET['message']; ?></p>
|
109 |
-
</div>
|
110 |
-
<?php endif; ?>
|
111 |
-
<form id="event-form" method="post" action="">
|
112 |
-
<div class="wrap">
|
113 |
-
<div id="icon-events" class="icon32"><br /></div>
|
114 |
-
<h2><?php echo $title; ?></h2>
|
115 |
-
<?php if ( $EM_Event->is_recurrence() || $EM_Event->is_recurring() ) : ?>
|
116 |
-
<p id='recurrence_warning'>
|
117 |
-
<?php
|
118 |
-
//TODO better warning system when changing a recurring event (e.g. when removing recurrences).
|
119 |
-
if ( $EM_Event->is_recurring() ) {
|
120 |
-
_e ( 'WARNING: This is a recurring event.', 'dbem' );
|
121 |
-
echo "<br />";
|
122 |
-
_e ( 'Modifying these data all the events linked to this recurrence will be rescheduled', 'dbem' );
|
123 |
-
echo " ";
|
124 |
-
_e ( 'and all booking information will be deleted!', 'dbem' );
|
125 |
-
} elseif ( $EM_Event->is_recurrence() ) {
|
126 |
-
//TODO Terminology confusing with methods, maybe worth changing?
|
127 |
-
_e ( 'WARNING: This is a recurrence.', 'dbem' );
|
128 |
-
echo "<br />";
|
129 |
-
_e ( 'If you change these data and save, this will become an independent event.', 'dbem' );
|
130 |
-
}
|
131 |
-
?>
|
132 |
-
</p>
|
133 |
-
<?php endif; ?>
|
134 |
-
<div id="poststuff" class="metabox-holder has-right-sidebar">
|
135 |
-
<!-- SIDEBAR -->
|
136 |
-
<div id="side-info-column" class='inner-sidebar'>
|
137 |
-
<div id='side-sortables'>
|
138 |
-
<?php if(get_option('dbem_recurrence_enabled')) : ?>
|
139 |
-
<!-- START recurrence postbox -->
|
140 |
-
<div class="postbox ">
|
141 |
-
<div class="handlediv" title="Fare clic per cambiare."><br />
|
142 |
-
</div>
|
143 |
-
<h3 class='hndle'><span>
|
144 |
-
<?php _e ( "Recurrence", 'dbem' ); ?>
|
145 |
-
</span></h3>
|
146 |
-
<div class="inside">
|
147 |
-
<?php //TODO add js warning if rescheduling, since all bookings are deleted ?>
|
148 |
-
<?php if ( !$EM_Event->id || $EM_Event->is_recurring() ) : ?>
|
149 |
-
<p>
|
150 |
-
<input id="event-recurrence" type="checkbox" name="repeated_event" value="1" <?php echo ( $EM_Event->is_recurring() ) ? 'checked="checked"':'' ; ?> />
|
151 |
-
<?php _e ( 'Repeated event', 'dbem' ); ?>
|
152 |
-
</p>
|
153 |
-
<div id="event_recurrence_pattern">
|
154 |
-
<p>
|
155 |
-
Frequency:
|
156 |
-
<select id="recurrence-frequency" name="recurrence_freq">
|
157 |
-
<?php
|
158 |
-
$freq_options = array ("daily" => __ ( 'Daily', 'dbem' ), "weekly" => __ ( 'Weekly', 'dbem' ), "monthly" => __ ( 'Monthly', 'dbem' ) );
|
159 |
-
em_option_items ( $freq_options, $EM_Event->freq );
|
160 |
-
?>
|
161 |
-
</select>
|
162 |
-
</p>
|
163 |
-
<p>
|
164 |
-
<?php _e ( 'Every', 'dbem' )?>
|
165 |
-
<input id="recurrence-interval" name='recurrence_interval' size='2' value='<?php echo $EM_Event->interval ; ?>' />
|
166 |
-
<span class='interval-desc' id="interval-daily-singular">
|
167 |
-
<?php _e ( 'day', 'dbem' )?>
|
168 |
-
</span> <span class='interval-desc' id="interval-daily-plural">
|
169 |
-
<?php _e ( 'days', 'dbem' ) ?>
|
170 |
-
</span> <span class='interval-desc' id="interval-weekly-singular">
|
171 |
-
<?php _e ( 'week', 'dbem' )?>
|
172 |
-
</span> <span class='interval-desc' id="interval-weekly-plural">
|
173 |
-
<?php _e ( 'weeks', 'dbem' )?>
|
174 |
-
</span> <span class='interval-desc' id="interval-monthly-singular">
|
175 |
-
<?php _e ( 'month', 'dbem' )?>
|
176 |
-
</span> <span class='interval-desc' id="interval-monthly-plural">
|
177 |
-
<?php _e ( 'months', 'dbem' )?>
|
178 |
-
</span>
|
179 |
-
</p>
|
180 |
-
<p class="alternate-selector" id="weekly-selector">
|
181 |
-
<?php
|
182 |
-
$saved_bydays = ($EM_Event->is_recurring()) ? explode ( ",", $EM_Event->byday ) : array();
|
183 |
-
em_checkbox_items ( 'recurrence_bydays[]', $days_names, $saved_bydays );
|
184 |
-
?>
|
185 |
-
</p>
|
186 |
-
<p class="alternate-selector" id="monthly-selector">
|
187 |
-
<?php _e ( 'Every', 'dbem' )?>
|
188 |
-
<select id="monthly-modifier" name="recurrence_byweekno">
|
189 |
-
<?php
|
190 |
-
$weekno_options = array ("1" => __ ( 'first', 'dbem' ), '2' => __ ( 'second', 'dbem' ), '3' => __ ( 'third', 'dbem' ), '4' => __ ( 'fourth', 'dbem' ), '-1' => __ ( 'last', 'dbem' ) );
|
191 |
-
em_option_items ( $weekno_options, $EM_Event->byweekno );
|
192 |
-
?>
|
193 |
-
</select>
|
194 |
-
<select id="recurrence-weekday" name="recurrence_byday">
|
195 |
-
<?php em_option_items ( $days_names, $EM_Event->byday ); ?>
|
196 |
-
</select>
|
197 |
-
|
198 |
-
</p>
|
199 |
-
</div>
|
200 |
-
<p id="recurrence-tip">
|
201 |
-
<?php _e ( 'Check if your event happens more than once according to a regular pattern', 'dbem' )?>
|
202 |
-
</p>
|
203 |
-
<?php elseif( $EM_Event->is_recurrence() ) : ?>
|
204 |
-
<p>
|
205 |
-
<?php echo $EM_Event->get_recurrence_description(); ?>
|
206 |
-
<br />
|
207 |
-
<a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&event_id=<?php echo $EM_Event->recurrence_id; ?>">
|
208 |
-
<?php _e ( 'Reschedule', 'dbem' ); ?>
|
209 |
-
</a>
|
210 |
-
<input type="hidden" name="recurrence_id" value="<?php echo $EM_Event->recurrence_id; ?>" />
|
211 |
-
</p>
|
212 |
-
<?php else : ?>
|
213 |
-
<p><?php _e ( 'This is\'t a recurrent event', 'dbem' ) ?></p>
|
214 |
-
<?php endif; ?>
|
215 |
-
</div>
|
216 |
-
</div>
|
217 |
-
<!-- END recurrence postbox -->
|
218 |
-
<?php endif; ?>
|
219 |
-
<?php if(get_option('dbem_rsvp_enabled')) : ?>
|
220 |
-
<!-- START RSVP -->
|
221 |
-
<?php if ( em_verify_admin() ): ?>
|
222 |
-
<div class="postbox ">
|
223 |
-
<div class="handlediv" title="Fare clic per cambiare."><br />
|
224 |
-
</div>
|
225 |
-
<h3 class='hndle'><span>
|
226 |
-
<?php _e ( 'Contact Person', 'dbem' ); ?>
|
227 |
-
</span></h3>
|
228 |
-
<div class="inside">
|
229 |
-
<p><?php _e('Contact','dbem'); ?>
|
230 |
-
<?php
|
231 |
-
wp_dropdown_users ( array ('name' => 'event_contactperson_id', 'show_option_none' => __ ( "Select...", 'dbem' ), 'selected' => $EM_Event->contactperson_id ) );
|
232 |
-
?>
|
233 |
-
</p>
|
234 |
-
</div>
|
235 |
-
</div>
|
236 |
-
<?php else: ?>
|
237 |
-
<input type="hidden" name="event_contactperson_id" value="<?php get_current_user_id() ?>" />
|
238 |
-
<?php endif; ?>
|
239 |
-
<div class="postbox ">
|
240 |
-
<div class="handlediv" title="Fare clic per cambiare."><br />
|
241 |
-
</div>
|
242 |
-
<h3 class='hndle'><span><?php _e('RSVP','dbem'); ?></span></h3>
|
243 |
-
<div class="inside">
|
244 |
-
<p>
|
245 |
-
<input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox' <?php echo ($EM_Event->rsvp) ? 'checked="checked"' : ''; ?> />
|
246 |
-
<?php _e ( 'Enable registration for this event', 'dbem' )?>
|
247 |
-
</p>
|
248 |
-
<div id='rsvp-data'>
|
249 |
-
<?php
|
250 |
-
if ($EM_Event->contactperson_id != NULL){
|
251 |
-
$selected = $EM_Event->contactperson_id;
|
252 |
-
}else{
|
253 |
-
$selected = '0';
|
254 |
-
}
|
255 |
-
?>
|
256 |
-
<p>
|
257 |
-
<?php _e ( 'Spaces','dbem' ); ?> :
|
258 |
-
<input id="seats-input" type="text" name="event_seats" size='5' value="<?php echo $EM_Event->seats ?>" />
|
259 |
-
</p>
|
260 |
-
<!-- START RSVP Stats -->
|
261 |
-
<?php
|
262 |
-
if ($EM_Event->rsvp ) {
|
263 |
-
$available_seats = $EM_Event->get_bookings()->get_available_seats();
|
264 |
-
$booked_seats = $EM_Event->get_bookings()->get_booked_seats();
|
265 |
-
|
266 |
-
if ( count($EM_Event->get_bookings()->bookings) > 0 ) {
|
267 |
-
?>
|
268 |
-
<div class='wrap'>
|
269 |
-
<p><strong><?php echo __('Available Spaces','dbem').': '.$EM_Event->get_bookings()->get_available_seats(); ?></strong></p>
|
270 |
-
<p><strong><?php echo __('Confirmed Spaces','dbem').': '.$EM_Event->get_bookings()->get_booked_seats(); ?></strong></p>
|
271 |
-
<p><strong><?php echo __('Pending Spaces','dbem').': '.$EM_Event->get_bookings()->get_pending_seats(); ?></strong></p>
|
272 |
-
</div>
|
273 |
-
|
274 |
-
<br class='clear'/>
|
275 |
-
|
276 |
-
<div id='major-publishing-actions'>
|
277 |
-
<div id='publishing-action'>
|
278 |
-
<a id='printable' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&event_id=".$EM_Event->id ?>'><?php _e('manage bookings','dbem')?></a><br />
|
279 |
-
<a target='_blank' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=bookings_report&event_id=".$EM_Event->id ?>'><?php _e('printable view','dbem')?></a>
|
280 |
-
<a href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=".$EM_Event->id ?>'><?php _e('export csv','dbem')?></a>
|
281 |
-
<br class='clear'/>
|
282 |
-
</div>
|
283 |
-
<br class='clear'/>
|
284 |
-
</div>
|
285 |
-
<?php
|
286 |
-
} else {
|
287 |
-
?>
|
288 |
-
<p><em><?php _e('No responses yet!')?></em></p>
|
289 |
-
<?php
|
290 |
-
}
|
291 |
-
}
|
292 |
-
?>
|
293 |
-
<!-- END RSVP Stats -->
|
294 |
-
</div>
|
295 |
-
</div>
|
296 |
-
</div>
|
297 |
-
<!-- END RSVP -->
|
298 |
-
<?php endif; ?>
|
299 |
-
<?php if(get_option('dbem_categories_enabled')) :?>
|
300 |
-
<!-- START Categories -->
|
301 |
-
<div class="postbox ">
|
302 |
-
<div class="handlediv" title="Fare clic per cambiare."><br />
|
303 |
-
</div>
|
304 |
-
<h3 class='hndle'><span>
|
305 |
-
<?php _e ( 'Category', 'dbem' ); ?>
|
306 |
-
</span></h3>
|
307 |
-
<div class="inside">
|
308 |
-
<?php $categories = EM_Categories::get(array('orderby'=>'category_name')); ?>
|
309 |
-
<?php if( count($categories) > 0 ): ?>
|
310 |
-
<p><?php _e ( 'Category:', 'dbem' ); ?>
|
311 |
-
<select name="event_category_id">
|
312 |
-
<option value="" <?php echo ($EM_Event->category_id == '') ? "selected='selected'":'' ?>><?php _e('no category','dbem') ?></option>
|
313 |
-
<?php
|
314 |
-
foreach ( $categories as $EM_Category ){
|
315 |
-
$selected = ($EM_Category->id == $EM_Event->category_id) ? "selected='selected'": '';
|
316 |
-
?>
|
317 |
-
<option value="<?php echo $EM_Category->id ?>" <?php echo $selected ?>>
|
318 |
-
<?php echo $EM_Category->name ?>
|
319 |
-
</option>
|
320 |
-
<?php
|
321 |
-
}
|
322 |
-
?>
|
323 |
-
</select>
|
324 |
-
</p>
|
325 |
-
<?php else: ?>
|
326 |
-
<p><?php sprintf(__('No categories available, <a href="%s">create one here first</a>','dbem'), get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-categories'); ?></p>
|
327 |
-
<?php endif; ?>
|
328 |
-
</div>
|
329 |
-
</div>
|
330 |
-
<!-- END Categories -->
|
331 |
-
<?php endif; ?>
|
332 |
-
</div>
|
333 |
-
</div>
|
334 |
-
<!-- END OF SIDEBAR -->
|
335 |
-
<div id="post-body">
|
336 |
-
<div id="post-body-content">
|
337 |
-
<div id="event_name" class="stuffbox">
|
338 |
-
<h3>
|
339 |
-
<?php _e ( 'Name', 'dbem' ); ?>
|
340 |
-
</h3>
|
341 |
-
<div class="inside">
|
342 |
-
<input type="text" name="event_name" id="event-name" value="<?php echo htmlspecialchars($EM_Event->name,ENT_QUOTES); ?>" />
|
343 |
-
<br />
|
344 |
-
<?php _e ( 'The event name. Example: Birthday party', 'dbem' )?>
|
345 |
-
</div>
|
346 |
-
</div>
|
347 |
-
<div id="event_start_date" class="stuffbox">
|
348 |
-
<h3 id='event-date-title'>
|
349 |
-
<?php _e ( 'Event date', 'dbem' ); ?>
|
350 |
-
</h3>
|
351 |
-
<h3 id='recurrence-dates-title'>
|
352 |
-
<?php _e ( 'Recurrence dates', 'dbem' ); ?>
|
353 |
-
</h3>
|
354 |
-
<div class="inside">
|
355 |
-
<input id="localised-date" type="text" name="localised_event_date" style="display: none;" />
|
356 |
-
<input id="date-to-submit" type="text" name="event_start_date" value="<?php echo $EM_Event->start_date ?>" style="background: #FCFFAA" />
|
357 |
-
<input id="localised-end-date" type="text" name="localised_event_end_date" style="display: none;" />
|
358 |
-
<input id="end-date-to-submit" type="text" name="event_end_date" value="<?php echo $EM_Event->end_date ?>" style="background: #FCFFAA" />
|
359 |
-
<br />
|
360 |
-
<span id='event-date-explanation'>
|
361 |
-
<?php
|
362 |
-
_e ( 'The event date.', 'dbem' );
|
363 |
-
/* Marcus Begin Edit */
|
364 |
-
echo " ";
|
365 |
-
_e ( 'When not reoccurring, this event spans between the beginning and end date.', 'dbem' );
|
366 |
-
/* Marcus End Edit */
|
367 |
-
?>
|
368 |
-
</span>
|
369 |
-
<span id='recurrence-dates-explanation'>
|
370 |
-
<?php _e ( 'The recurrence beginning and end date.', 'dbem' ); ?>
|
371 |
-
</span>
|
372 |
-
</div>
|
373 |
-
</div>
|
374 |
-
<div id="event_end_day" class="stuffbox">
|
375 |
-
<h3>
|
376 |
-
<?php _e ( 'Event time', 'dbem' ); ?>
|
377 |
-
</h3>
|
378 |
-
<div class="inside">
|
379 |
-
<input id="start-time" type="text" size="8" maxlength="8" name="event_start_time" value="<?php echo date( $hours_locale_regexp, strtotime($EM_Event->start_time) ); ?>" />
|
380 |
-
-
|
381 |
-
<input id="end-time" type="text" size="8" maxlength="8" name="event_end_time" value="<?php echo date( $hours_locale_regexp, strtotime($EM_Event->end_time) ); ?>" />
|
382 |
-
<br />
|
383 |
-
<?php _e ( 'The time of the event beginning and end', 'dbem' )?>.
|
384 |
-
</div>
|
385 |
-
</div>
|
386 |
-
<div id="location_coordinates" class="stuffbox" style='display: none;'>
|
387 |
-
<h3>
|
388 |
-
<?php _e ( 'Coordinates', 'dbem' ); ?>
|
389 |
-
</h3>
|
390 |
-
<div class="inside">
|
391 |
-
<input id='location-latitude' name='location_latitude' type='text' value='<?php echo $EM_Event->latitude; ?>' size='15' />
|
392 |
-
-
|
393 |
-
<input id='location-longitude' name='location_longitude' type='text' value='<?php echo $EM_Event->longitude; ?>' size='15' />
|
394 |
-
</div>
|
395 |
-
</div>
|
396 |
-
<div id="location_info" class="stuffbox">
|
397 |
-
<h3>
|
398 |
-
<?php _e ( 'Location', 'dbem' ); ?>
|
399 |
-
</h3>
|
400 |
-
<div class="inside">
|
401 |
-
<table id="dbem-location-data">
|
402 |
-
<tr>
|
403 |
-
<td style="padding-right:20px">
|
404 |
-
<table>
|
405 |
-
<?php if($use_select_for_locations) : ?>
|
406 |
-
<tr>
|
407 |
-
<th><?php _e('Location:','dbem') ?></th>
|
408 |
-
<td>
|
409 |
-
<select name="location-select-id" id='location-select-id' size="1">
|
410 |
-
<?php
|
411 |
-
$locations = EM_Locations::get();
|
412 |
-
foreach($locations as $location) {
|
413 |
-
$selected = "";
|
414 |
-
if( is_object($EM_Event->location) ) {
|
415 |
-
if ($EM_Event->location->id == $location->id)
|
416 |
-
$selected = "selected='selected' ";
|
417 |
-
}
|
418 |
-
?>
|
419 |
-
<option value="<?php echo $location->id ?>" title="<?php echo "{$location->latitude},{$location->longitude}" ?>" <?php echo $selected ?>><?php echo $location->name; ?></option>
|
420 |
-
<?php
|
421 |
-
}
|
422 |
-
?>
|
423 |
-
</select>
|
424 |
-
<p><?php _e ( 'The name of the location where the event takes place. You can use the name of a venue, a square, etc', 'dbem' )?></p>
|
425 |
-
</td>
|
426 |
-
</tr>
|
427 |
-
<?php else : ?>
|
428 |
-
<tr>
|
429 |
-
<th><?php _e ( 'Name:' )?></th>
|
430 |
-
<td>
|
431 |
-
<input id="location-name" type="text" name="location_name" value="<?php echo htmlspecialchars($EM_Event->location->name, ENT_QUOTES); ?>" />
|
432 |
-
<p><?php _e ( 'Select a location for your event', 'dbem' )?></p>
|
433 |
-
</td>
|
434 |
-
</tr>
|
435 |
-
<tr>
|
436 |
-
<th><?php _e ( 'Address:' )?> </th>
|
437 |
-
<td>
|
438 |
-
<input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Event->location->address, ENT_QUOTES); ; ?>" />
|
439 |
-
<p><?php _e ( 'The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem' )?></p>
|
440 |
-
</td>
|
441 |
-
</tr>
|
442 |
-
<tr>
|
443 |
-
<th><?php _e ( 'Town:' )?> </th>
|
444 |
-
<td>
|
445 |
-
<input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Event->location->town, ENT_QUOTES); ?>" />
|
446 |
-
<p><?php _e ( 'The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem' )?></p>
|
447 |
-
</td>
|
448 |
-
</tr>
|
449 |
-
<?php endif; ?>
|
450 |
-
</table>
|
451 |
-
</td>
|
452 |
-
<?php if ( get_option ( 'dbem_gmap_is_active' ) ) : ?>
|
453 |
-
<td width="400">
|
454 |
-
<div id='em-map-404' style='width: 400px; vertical-align:middle; text-align: center;'>
|
455 |
-
<p><em><?php _e ( 'Location not found', 'dbem' ); ?></em></p>
|
456 |
-
</div>
|
457 |
-
<div id='em-map' style='width: 400px; height: 300px; display: none;'></div>
|
458 |
-
</td>
|
459 |
-
<?php endif; ?>
|
460 |
-
</tr>
|
461 |
-
</table>
|
462 |
-
</div>
|
463 |
-
</div>
|
464 |
-
<div id="event_notes" class="postbox">
|
465 |
-
<h3>
|
466 |
-
<?php _e ( 'Details', 'dbem' ); ?>
|
467 |
-
</h3>
|
468 |
-
<div class="inside">
|
469 |
-
<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
470 |
-
<?php the_editor($EM_Event->notes ); ?>
|
471 |
-
</div>
|
472 |
-
<br />
|
473 |
-
<?php _e ( 'Details about the event', 'dbem' )?>
|
474 |
-
</div>
|
475 |
-
</div>
|
476 |
-
|
477 |
-
<?php if(get_option('dbem_attributes_enabled')) : ?>
|
478 |
-
<div id="event_attributes" class="postbox">
|
479 |
-
<h3>
|
480 |
-
<?php _e ( 'Attributes', 'dbem' ); ?>
|
481 |
-
</h3>
|
482 |
-
<div class="inside">
|
483 |
-
<?php
|
484 |
-
//We also get a list of attribute names and create a ddm list (since placeholders are fixed)
|
485 |
-
$formats =
|
486 |
-
get_option ( 'dbem_event_list_item_format' ).
|
487 |
-
get_option ( 'dbem_event_page_title_format' ).
|
488 |
-
get_option ( 'dbem_full_calendar_event_format' ).
|
489 |
-
get_option ( 'dbem_location_baloon_format' ).
|
490 |
-
get_option ( 'dbem_location_event_list_item_format' ).
|
491 |
-
get_option ( 'dbem_location_page_title_format' ).
|
492 |
-
get_option ( 'dbem_map_text_format' ).
|
493 |
-
get_option ( 'dbem_rss_description_format' ).
|
494 |
-
get_option ( 'dbem_rss_title_format' ).
|
495 |
-
get_option ( 'dbem_single_event_format' ).
|
496 |
-
get_option ( 'dbem_single_location_format' ).
|
497 |
-
get_option ( 'dbem_placeholders_custom' );
|
498 |
-
//We now have one long string of formats, get all the attribute placeholders
|
499 |
-
preg_match_all('/#_ATT\{.+?\}(\{.+?\})?/', $formats, $placeholders);
|
500 |
-
//Now grab all the unique attributes we can use in our event.
|
501 |
-
$attributes = array();
|
502 |
-
foreach($placeholders[0] as $result) {
|
503 |
-
$attribute = substr( substr($result, 0, strpos($result, '}')), 6 );
|
504 |
-
if( !in_array($attribute, $attributes) ){
|
505 |
-
$attributes[] = $attribute ;
|
506 |
-
}
|
507 |
-
}
|
508 |
-
?>
|
509 |
-
<div class="wrap">
|
510 |
-
<?php if( count( $attributes ) > 0 ) : ?>
|
511 |
-
<h2>Attributes</h2>
|
512 |
-
<p>Add attributes here</p>
|
513 |
-
<table class="form-table">
|
514 |
-
<thead>
|
515 |
-
<tr valign="top">
|
516 |
-
<td><strong>Attribute Name</strong></td>
|
517 |
-
<td><strong>Value</strong></td>
|
518 |
-
</tr>
|
519 |
-
</thead>
|
520 |
-
<tfoot>
|
521 |
-
<tr valign="top">
|
522 |
-
<td colspan="3"><a href="#" id="mtm_add_tag">Add new tag</a></td>
|
523 |
-
</tr>
|
524 |
-
</tfoot>
|
525 |
-
<tbody id="mtm_body">
|
526 |
-
<?php
|
527 |
-
$count = 1;
|
528 |
-
if( is_array($EM_Event->attributes) and count($EM_Event->attributes) > 0){
|
529 |
-
foreach( $EM_Event->attributes as $name => $value){
|
530 |
-
?>
|
531 |
-
<tr valign="top" id="mtm_<?php echo $count ?>">
|
532 |
-
<td scope="row">
|
533 |
-
<select name="mtm_<?php echo $count ?>_ref">
|
534 |
-
<?php
|
535 |
-
if( !in_array($name, $attributes) ){
|
536 |
-
echo "<option value='$name'>$name (".__('Not defined in templates', 'dbem').")</option>";
|
537 |
-
}
|
538 |
-
foreach( $attributes as $attribute ){
|
539 |
-
if( $attribute == $name ) {
|
540 |
-
echo "<option selected='selected'>$attribute</option>";
|
541 |
-
}else{
|
542 |
-
echo "<option>$attribute</option>";
|
543 |
-
}
|
544 |
-
}
|
545 |
-
?>
|
546 |
-
</select>
|
547 |
-
<a href="#" rel="<?php echo $count ?>">Remove</a>
|
548 |
-
</td>
|
549 |
-
<td>
|
550 |
-
<input type="text" name="mtm_<?php echo $count ?>_name" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?>" />
|
551 |
-
</td>
|
552 |
-
</tr>
|
553 |
-
<?php
|
554 |
-
$count++;
|
555 |
-
}
|
556 |
-
}else{
|
557 |
-
?>
|
558 |
-
<tr valign="top" id="mtm_<?php echo $count ?>">
|
559 |
-
<td scope="row">
|
560 |
-
<select name="mtm_<?php echo $count ?>_ref">
|
561 |
-
<?php
|
562 |
-
foreach( $attributes as $attribute ){
|
563 |
-
echo "<option>$attribute</option>";
|
564 |
-
}
|
565 |
-
?>
|
566 |
-
</select>
|
567 |
-
<a href="#" rel="<?php echo $count ?>">Remove</a>
|
568 |
-
</td>
|
569 |
-
<td>
|
570 |
-
<input type="text" name="mtm_<?php echo $count ?>_name" />
|
571 |
-
</td>
|
572 |
-
</tr>
|
573 |
-
<?php
|
574 |
-
}
|
575 |
-
?>
|
576 |
-
</tbody>
|
577 |
-
</table>
|
578 |
-
<?php else : ?>
|
579 |
-
<p>
|
580 |
-
<?php _e('In order to use attributes, you must define some in your templates, otherwise they\'ll never show. Go to Events > Settings to add attribute placeholders.', 'dbem'); ?>
|
581 |
-
</p>
|
582 |
-
<script>
|
583 |
-
jQuery(document).ready(function($){ $('#event_attributes').addClass('closed'); });
|
584 |
-
</script>
|
585 |
-
<?php endif; ?>
|
586 |
-
</div>
|
587 |
-
</div>
|
588 |
-
</div>
|
589 |
-
<?php endif; ?>
|
590 |
-
</div>
|
591 |
-
<p class="submit">
|
592 |
-
<input type="submit" name="events_update" value="<?php _e ( 'Submit Event', 'dbem' ); ?> »" />
|
593 |
-
</p>
|
594 |
-
<input type="hidden" name="p" value="<?php echo ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:''; ?>" /><a>
|
595 |
-
<input type="hidden" name="scope" value="<?php echo ( !empty($_REQUEST['scope']) ) ? $_REQUEST['scope']:'' ?>" /></a>
|
596 |
-
<input type="hidden" name="action" value="save" />
|
597 |
-
</div>
|
598 |
-
</div>
|
599 |
-
</div>
|
600 |
-
</form>
|
601 |
-
<script type="text/javascript">
|
602 |
-
jQuery(document).ready( function($) {
|
603 |
-
<?php if( $EM_Event->is_recurring() ): ?>
|
604 |
-
//Recurrence Warnings
|
605 |
-
$('#event_form').submit( function(event){
|
606 |
-
confirmation = confirm('<?php _e('Are you sure you want to reschedule this recurring event? If you do this, you will lose all booking information and the old recurring events will be deleted.', 'dbem'); ?>');
|
607 |
-
if( confirmation == false ){
|
608 |
-
event.preventDefault();
|
609 |
-
}
|
610 |
-
});
|
611 |
-
<?php endif; ?>
|
612 |
-
<?php if( $EM_Event->rsvp == 1 ): ?>
|
613 |
-
//RSVP Warning
|
614 |
-
$('#rsvp-checkbox').click( function(event){
|
615 |
-
if( !this.checked ){
|
616 |
-
confirmation = confirm('<?php _e('Are you sure you want to disable bookings? If you do this and save, you will lose all previous bookings. If you wish to prevent further bookings, reduce the number of seats available to the amount of bookings you currently have', 'dbem'); ?>');
|
617 |
-
if( confirmation == false ){
|
618 |
-
event.preventDefault();
|
619 |
-
}
|
620 |
-
}
|
621 |
-
});
|
622 |
-
<?php endif; ?>
|
623 |
-
});
|
624 |
-
</script>
|
625 |
-
<?php
|
626 |
-
}
|
627 |
-
?>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
admin/em-events.php
DELETED
@@ -1,242 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Determines whether to show event page or events page, and saves any updates to the event or events
|
5 |
-
* @return null
|
6 |
-
*/
|
7 |
-
function em_admin_events_page() {
|
8 |
-
//TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
|
9 |
-
global $wpdb;
|
10 |
-
global $EM_Event;
|
11 |
-
$action = ( !empty($_GET ['action']) ) ? $_GET ['action']:'';
|
12 |
-
$order = ( !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
|
13 |
-
$limit = ( !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
|
14 |
-
$page = ( !empty($_GET['pno']) ) ? $_GET['pno']:1;
|
15 |
-
$offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
|
16 |
-
$scope_names = array (
|
17 |
-
'past' => __ ( 'Past events', 'dbem' ),
|
18 |
-
'all' => __ ( 'All events', 'dbem' ),
|
19 |
-
'future' => __ ( 'Future events', 'dbem' )
|
20 |
-
);
|
21 |
-
$scope = ( !empty($_GET ['scope']) && array_key_exists($_GET ['scope'], $scope_names) ) ? $_GET ['scope']:'future';
|
22 |
-
$selectedEvents = ( !empty($_GET ['events']) ) ? $_GET ['events']:'';
|
23 |
-
|
24 |
-
// DELETE action
|
25 |
-
if ( $action == 'deleteEvents' && EM_Object::array_is_numeric($selectedEvents) ) {
|
26 |
-
EM_Events::delete( $selectedEvents );
|
27 |
-
}
|
28 |
-
|
29 |
-
// No action, only showing the events list
|
30 |
-
switch ($scope) {
|
31 |
-
case "past" :
|
32 |
-
$title = __ ( 'Past Events', 'dbem' );
|
33 |
-
break;
|
34 |
-
case "all" :
|
35 |
-
$title = __ ( 'All Events', 'dbem' );
|
36 |
-
break;
|
37 |
-
default :
|
38 |
-
$title = __ ( 'Future Events', 'dbem' );
|
39 |
-
$scope = "future";
|
40 |
-
}
|
41 |
-
$args = array('scope'=>$scope, 'limit'=>0, 'order'=>$order );
|
42 |
-
|
43 |
-
if( !get_option('dbem_permissions_events') && !em_verify_admin() ){
|
44 |
-
$args['owner'] = get_current_user_id();
|
45 |
-
}
|
46 |
-
|
47 |
-
$events = EM_Events::get( $args );
|
48 |
-
$events_count = count ( $events );
|
49 |
-
|
50 |
-
$use_events_end = get_option ( 'dbem_use_event_end' );
|
51 |
-
?>
|
52 |
-
<div class="wrap">
|
53 |
-
<div id="icon-events" class="icon32"><br />
|
54 |
-
</div>
|
55 |
-
<h2>
|
56 |
-
<?php echo $title; ?>
|
57 |
-
<a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php _e('Add New','dbem'); ?></a>
|
58 |
-
</h2>
|
59 |
-
<?php
|
60 |
-
$link = array ();
|
61 |
-
$link ['past'] = "<a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&scope=past&order=desc'>" . __ ( 'Past events', 'dbem' ) . "</a>";
|
62 |
-
$link ['all'] = " <a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&scope=all&order=desc'>" . __ ( 'All events', 'dbem' ) . "</a>";
|
63 |
-
$link ['future'] = " <a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&scope=future'>" . __ ( 'Future events', 'dbem' ) . "</a>";
|
64 |
-
?>
|
65 |
-
<?php if ( !empty($_GET['error']) ) : ?>
|
66 |
-
<div id='message' class='error'>
|
67 |
-
<p><?php echo $_GET['error']; ?></p>
|
68 |
-
</div>
|
69 |
-
<?php endif; ?>
|
70 |
-
<?php if ( !empty($_GET['message']) ) : ?>
|
71 |
-
<div id='message' class='updated fade'>
|
72 |
-
<p><?php echo $_GET['message']; ?></p>
|
73 |
-
</div>
|
74 |
-
<?php endif; ?>
|
75 |
-
<form id="posts-filter" action="" method="get"><input type='hidden' name='page' value='events-manager' />
|
76 |
-
<ul class="subsubsub">
|
77 |
-
<li><a href='#' class="current"><?php _e ( 'Total', 'dbem' ); ?> <span class="count">(<?php echo (count ( $events )); ?>)</span></a></li>
|
78 |
-
</ul>
|
79 |
-
<p class="search-box">
|
80 |
-
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Events','dbem'); ?>:</label>
|
81 |
-
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
|
82 |
-
<input type="submit" value="<?php _e('Search Events','dbem'); ?>" class="button" />
|
83 |
-
</p>
|
84 |
-
<div class="tablenav">
|
85 |
-
|
86 |
-
<div class="alignleft actions">
|
87 |
-
<select name="action">
|
88 |
-
<option value="-1" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
|
89 |
-
<option value="deleteEvents"><?php _e ( 'Delete selected','dbem' ); ?></option>
|
90 |
-
</select>
|
91 |
-
<input type="submit" value="<?php _e ( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
92 |
-
<select name="scope">
|
93 |
-
<?php
|
94 |
-
foreach ( $scope_names as $key => $value ) {
|
95 |
-
$selected = "";
|
96 |
-
if ($key == $scope)
|
97 |
-
$selected = "selected='selected'";
|
98 |
-
echo "<option value='$key' $selected>$value</option> ";
|
99 |
-
}
|
100 |
-
?>
|
101 |
-
</select>
|
102 |
-
<input id="post-query-submit" class="button-secondary" type="submit" value="<?php _e ( 'Filter' )?>" />
|
103 |
-
</div>
|
104 |
-
<!--
|
105 |
-
<div class="view-switch">
|
106 |
-
<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
|
107 |
-
</div>
|
108 |
-
-->
|
109 |
-
<?php
|
110 |
-
if ( $events_count >= $limit ) {
|
111 |
-
$page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%'));
|
112 |
-
$events_nav = em_admin_paginate( $page_link_template, $events_count, $limit, $page, 5);
|
113 |
-
echo $events_nav;
|
114 |
-
}
|
115 |
-
?>
|
116 |
-
<br class="clear" />
|
117 |
-
</div>
|
118 |
-
|
119 |
-
<?php
|
120 |
-
if (empty ( $events )) {
|
121 |
-
// TODO localize
|
122 |
-
_e ( 'no events','dbem' );
|
123 |
-
} else {
|
124 |
-
?>
|
125 |
-
|
126 |
-
<table class="widefat">
|
127 |
-
<thead>
|
128 |
-
<tr>
|
129 |
-
<th class='manage-column column-cb check-column' scope='col'>
|
130 |
-
<input class='select-all' type="checkbox" value='1' />
|
131 |
-
</th>
|
132 |
-
<th><?php _e ( 'Name', 'dbem' ); ?></th>
|
133 |
-
<th> </th>
|
134 |
-
<th><?php _e ( 'Location', 'dbem' ); ?></th>
|
135 |
-
<th colspan="2"><?php _e ( 'Date and time', 'dbem' ); ?></th>
|
136 |
-
</tr>
|
137 |
-
</thead>
|
138 |
-
<tbody>
|
139 |
-
<?php
|
140 |
-
$rowno = 0;
|
141 |
-
$event_count = 0;
|
142 |
-
foreach ( $events as $event ) {
|
143 |
-
/* @var $event EM_Event */
|
144 |
-
if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
|
145 |
-
$rowno++;
|
146 |
-
$class = ($rowno % 2) ? ' class="alternate"' : '';
|
147 |
-
// FIXME set to american
|
148 |
-
$localised_start_date = date_i18n('D d M Y', $event->start);
|
149 |
-
$localised_end_date = date_i18n('D d M Y', $event->end);
|
150 |
-
$style = "";
|
151 |
-
$today = date ( "Y-m-d" );
|
152 |
-
$location_summary = "<b>" . $event->location->name . "</b><br/>" . $event->location->address . " - " . $event->location->town;
|
153 |
-
$category = new EM_Category($event->category_id);
|
154 |
-
|
155 |
-
if ($event->start_date < $today && $event->end_date < $today){
|
156 |
-
$style = "style ='background-color: #FADDB7;'";
|
157 |
-
}
|
158 |
-
?>
|
159 |
-
<tr <?php echo "$class $style"; ?>>
|
160 |
-
|
161 |
-
<td>
|
162 |
-
<input type='checkbox' class='row-selector' value='<?php echo $event->id; ?>' name='events[]' />
|
163 |
-
</td>
|
164 |
-
<td>
|
165 |
-
<strong>
|
166 |
-
<a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&event_id=<?php echo $event->id ?>&scope=<?php echo $scope ?>&p=<?php echo $page ?>"><?php echo ($event->name); ?></a>
|
167 |
-
</strong>
|
168 |
-
<?php if( is_object($category) ) : ?>
|
169 |
-
<br/><span title='<?php echo __( 'Category', 'dbem' ).": ".$category->name ?>'><?php echo $category->name ?></span>
|
170 |
-
<?php endif; ?>
|
171 |
-
<?php
|
172 |
-
if( get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1 ){
|
173 |
-
?>
|
174 |
-
<br/>
|
175 |
-
<a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&event_id=<?php echo $event->id ?>"><?php echo __("Bookings",'dbem'); ?></a> –
|
176 |
-
<?php _e("Booked",'dbem'); ?>: <?php echo $event->get_bookings()->get_booked_seats()."/".$event->seats; ?>
|
177 |
-
<?php if( get_option('dbem_bookings_approval') == 1 ): ?>
|
178 |
-
| <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_seats(); ?>
|
179 |
-
<?php endif;
|
180 |
-
}
|
181 |
-
?>
|
182 |
-
</td>
|
183 |
-
<td>
|
184 |
-
<a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&action=duplicate&event_id=<?php echo $event->id; ?>&scope=<?php echo $scope ?>&p=<?php echo $page ?>" title="<?php _e ( 'Duplicate this event', 'dbem' ); ?>">
|
185 |
-
<strong>+</strong>
|
186 |
-
</a>
|
187 |
-
</td>
|
188 |
-
<td>
|
189 |
-
<?php echo $location_summary; ?>
|
190 |
-
</td>
|
191 |
-
|
192 |
-
<td>
|
193 |
-
<?php echo $localised_start_date; ?>
|
194 |
-
<?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
|
195 |
-
<br />
|
196 |
-
<?php
|
197 |
-
//TODO Should 00:00 - 00:00 be treated as an all day event?
|
198 |
-
echo substr ( $event->start_time, 0, 5 ) . " - " . substr ( $event->end_time, 0, 5 );
|
199 |
-
?>
|
200 |
-
</td>
|
201 |
-
<td>
|
202 |
-
<?php
|
203 |
-
if ( $event->is_recurrence() ) {
|
204 |
-
?>
|
205 |
-
<strong>
|
206 |
-
<?php echo $event->get_recurrence_description(); ?> <br />
|
207 |
-
<a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&event_id=<?php echo $event->recurrence_id ?>&scope=<?php echo $scope ?>&p=<?php echo $page ?>"><?php _e ( 'Reschedule', 'dbem' ); ?></a>
|
208 |
-
</strong>
|
209 |
-
<?php
|
210 |
-
}
|
211 |
-
?>
|
212 |
-
</td>
|
213 |
-
</tr>
|
214 |
-
<?php
|
215 |
-
}
|
216 |
-
$event_count++;
|
217 |
-
}
|
218 |
-
?>
|
219 |
-
</tbody>
|
220 |
-
</table>
|
221 |
-
<?php
|
222 |
-
} // end of table
|
223 |
-
?>
|
224 |
-
<div class='tablenav'>
|
225 |
-
<div class="alignleft actions">
|
226 |
-
<br class='clear' />
|
227 |
-
</div>
|
228 |
-
<?php if ( $events_count >= $limit ) : ?>
|
229 |
-
<div class="tablenav-pages">
|
230 |
-
<?php
|
231 |
-
echo $events_nav;
|
232 |
-
?>
|
233 |
-
</div>
|
234 |
-
<?php endif; ?>
|
235 |
-
<br class='clear' />
|
236 |
-
</div>
|
237 |
-
</form>
|
238 |
-
</div>
|
239 |
-
<?php
|
240 |
-
}
|
241 |
-
|
242 |
-
?>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
admin/em-help.php
CHANGED
@@ -1,52 +1,69 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Display function for the support page. here we can give links to forums and special upgrade instructions e.g. migration features
|
4 |
-
*/
|
5 |
-
function em_admin_help_page(){
|
6 |
-
global $wpdb;
|
7 |
-
?>
|
8 |
-
<div class="wrap">
|
9 |
-
<div id="icon-events" class="icon32"><br /></div>
|
10 |
-
<h2><?php _e('Getting Help for Events Manager','dbem'); ?></h2>
|
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 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Display function for the support page. here we can give links to forums and special upgrade instructions e.g. migration features
|
4 |
+
*/
|
5 |
+
function em_admin_help_page(){
|
6 |
+
global $wpdb;
|
7 |
+
?>
|
8 |
+
<div class="wrap">
|
9 |
+
<div id="icon-events" class="icon32"><br /></div>
|
10 |
+
<h2><?php _e('Getting Help for Events Manager','dbem'); ?></h2>
|
11 |
+
<div class="em-docs">
|
12 |
+
<h2>Where To Get Help</h3>
|
13 |
+
<p>
|
14 |
+
This page is only a small portion of the event documentation which is here for quick reference. If you're just starting out, we recommend you visit the following places for further support:
|
15 |
+
</p>
|
16 |
+
<ol>
|
17 |
+
<li>New users are strongly encouraged to have a look at our <a href="http://wp-events-plugin.com/documentation/getting-started/">getting started page</a>.</li>
|
18 |
+
<li>Browse the other documentation pages and <a href="http://wp-events-plugin.com/tutorials/">tutorials</a>.</li>
|
19 |
+
<li>View the <a href="http://wp-events-plugin.com/documentation/faq/">FAQ</a> for general questions and <a href="http://wp-events-plugin.com/documentation/troubleshooting/">Troubleshooting</a> for common issues. These are regularly updated with recent issues.</li>
|
20 |
+
<li>Rather than trying to contact us directly, we request you use the <a href="http://wordpress.org/tags/events-manager?forum_id=10">support forums</a> as others may be experiencing the same issues as you. For faster support via private member forums and extra features please consider <a href="http://wp-events-plugin.com/events-manager-pro/">upgrading to pro</a>.</li>
|
21 |
+
</ol>
|
22 |
+
<p>
|
23 |
+
If you can't find what you're looking for in the documentation, you may find help on our <a href="http://wp-events-plugin.com/forums/">support forums</a>.
|
24 |
+
</p>
|
25 |
+
<h2><?php _e('Placeholders for customizing event pages','dbem'); ?></h2>
|
26 |
+
<p><?php echo sprintf( __("In the <a href='%s'>settings page</a>, you'll find various textboxes where you can edit how event information looks, such as for event and location lists. Using the placeholders below, you can choose what information should be displayed.",'dbem'), EM_ADMIN_URL .'&events-manager-options'); ?></p>
|
27 |
+
<a name="event-placeholders"></a>
|
28 |
+
<h3 style="margin-top:20px;"><?php _e('Event Related Placeholders','dbem'); ?></h3>
|
29 |
+
<?php echo em_docs_placeholders( array('type'=>'events') ); ?>
|
30 |
+
<a name="category-placeholders"></a>
|
31 |
+
<h3><?php _e('Category Related Placeholders','dbem'); ?></h3>
|
32 |
+
<?php echo em_docs_placeholders( array('type'=>'categories') ); ?>
|
33 |
+
<a name="location-placeholders"></a>
|
34 |
+
<h3><?php _e('Location Related Placeholders','dbem'); ?></h3>
|
35 |
+
<?php echo em_docs_placeholders( array('type'=>'locations') ); ?>
|
36 |
+
<a name="booking-placeholders"></a>
|
37 |
+
<h3><?php _e('Booking Related Placeholders','dbem'); ?></h3>
|
38 |
+
<?php echo em_docs_placeholders( array('type'=>'bookings') ); ?>
|
39 |
+
</div>
|
40 |
+
<?php
|
41 |
+
|
42 |
+
//Is this a previously imported installation?
|
43 |
+
$old_table_name = $wpdb->prefix.'dbem_events';
|
44 |
+
if( $wpdb->get_var("SHOW TABLES LIKE '$old_table_name'") == $old_table_name ){
|
45 |
+
?>
|
46 |
+
<hr style="margin:30px 10px;" />
|
47 |
+
<div class="updated">
|
48 |
+
<h3>Troubleshooting upgrades from version 2.x to 3.x</h3>
|
49 |
+
<p>We notice that you upgraded from version 2, as we are now using new database tables, and we do not delete the old tables in case something went wrong with this upgrade.</p>
|
50 |
+
<p>If something went wrong with the update to version 3 read on:</p>
|
51 |
+
<h4>Scenario 1: the plugin is working, but for some reason the old events weren't imported</h4>
|
52 |
+
<p>You can safely reimport your old events from the previous tables without any risk of deleting them. However, if you click the link below <b>YOU WILL OVERWRITE ANY NEW EVENTS YOU CREATED IN VERSION 3</b></p>
|
53 |
+
<p><a onclick="return confirm('Are you sure you want to do this? Any new changes made since updating will be overwritten by your old ones, and this cannot be undone');" href="<?php echo wp_nonce_url( EM_ADMIN_URL .'&events-manager-help&em_reimport=1', 'em_reimport' ) ?>">Reimport Events from version 2</a></p>
|
54 |
+
<h4>Scenario 2: the plugin is not working, I want to go back to version 2!</h4>
|
55 |
+
<p>You can safely downgrade and will not lose any information.</p>
|
56 |
+
<ol>
|
57 |
+
<li>First of all, <a href='http://downloads.wordpress.org/plugin/events-manager.2.2.2.zip'>dowload a copy of version 2.2</a></li>
|
58 |
+
<li>Deactivate and delete Events Manager in the plugin page</li>
|
59 |
+
<li><a href="<?php bloginfo('wpurl'); ?>/wp-admin/plugin-install.php?tab=upload">Upload the zip file you just downloaded here</a></li>
|
60 |
+
<li>Let the developers know, of any bugs you ran into while upgrading. We'll help you out if there is a simple solution, and will fix reported bugs within days, if not quicker!</li>
|
61 |
+
</ol>
|
62 |
+
</div>
|
63 |
+
<?php
|
64 |
+
}
|
65 |
+
?>
|
66 |
+
</div>
|
67 |
+
<?php
|
68 |
+
}
|
69 |
Â
?>
|
admin/em-locations-search.php
CHANGED
@@ -3,20 +3,25 @@
|
|
3 |
Â
* This page will search for either a specific location via GET "id" variable
|
4 |
Â
* or will search for events by name via the GET "q" variable.
|
5 |
Â
*/
|
Â
|
|
6 |
Â
require_once('../../../../wp-load.php');
|
7 |
Â
global $wpdb;
|
8 |
Â
|
9 |
-
$locations_table =
|
10 |
-
$location_cond = (
|
11 |
Â
|
12 |
Â
$term = (isset($_GET['term'])) ? '%'.$_GET['term'].'%' : '%'.$_GET['q'].'%';
|
13 |
Â
$sql = $wpdb->prepare("
|
14 |
Â
SELECT
|
Â
|
|
15 |
Â
Concat( location_name, ', ', location_address, ', ', location_town) AS `label`,
|
16 |
Â
location_name AS `value`,
|
17 |
Â
location_address AS `address`,
|
18 |
Â
location_town AS `town`,
|
19 |
-
|
Â
|
|
Â
|
|
Â
|
|
20 |
Â
FROM $locations_table
|
21 |
Â
WHERE ( `location_name` LIKE %s ) $location_cond LIMIT 10
|
22 |
Â
", $term);
|
3 |
Â
* This page will search for either a specific location via GET "id" variable
|
4 |
Â
* or will search for events by name via the GET "q" variable.
|
5 |
Â
*/
|
6 |
+
//FIXME just plug loc search into ajax catcher
|
7 |
Â
require_once('../../../../wp-load.php');
|
8 |
Â
global $wpdb;
|
9 |
Â
|
10 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
11 |
+
$location_cond = ( !current_user_can('edit_others_locations') && !current_user_can('read_others_locations') ) ? "AND location_owner=".get_current_user_id() : '';
|
12 |
Â
|
13 |
Â
$term = (isset($_GET['term'])) ? '%'.$_GET['term'].'%' : '%'.$_GET['q'].'%';
|
14 |
Â
$sql = $wpdb->prepare("
|
15 |
Â
SELECT
|
16 |
+
location_id AS `id`,
|
17 |
Â
Concat( location_name, ', ', location_address, ', ', location_town) AS `label`,
|
18 |
Â
location_name AS `value`,
|
19 |
Â
location_address AS `address`,
|
20 |
Â
location_town AS `town`,
|
21 |
+
location_state AS `state`,
|
22 |
+
location_region AS `region`,
|
23 |
+
location_postcode AS `postcode`,
|
24 |
+
location_country AS `country`
|
25 |
Â
FROM $locations_table
|
26 |
Â
WHERE ( `location_name` LIKE %s ) $location_cond LIMIT 10
|
27 |
Â
", $term);
|
admin/em-locations.php
DELETED
@@ -1,268 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Looks at the request values, saves/updates and then displays the right menu in the admin
|
4 |
-
* @return null
|
5 |
-
*/
|
6 |
-
function em_admin_locations_page() {
|
7 |
-
//TODO EM_Location is globalized, use it fully here
|
8 |
-
global $EM_Location;
|
9 |
-
//Take actions
|
10 |
-
if( !empty($_REQUEST['action']) || !empty($_REQUEST['location_id']) ){
|
11 |
-
if( $_REQUEST['action'] == "edit" || $_REQUEST['action'] == "add" ) {
|
12 |
-
//edit/add location
|
13 |
-
em_admin_location();
|
14 |
-
} elseif( $_REQUEST['action'] == "delete" ){
|
15 |
-
//delelte location
|
16 |
-
$locations = $_REQUEST['locations'];
|
17 |
-
foreach($locations as $location_id) {
|
18 |
-
$EM_Location = new EM_Location($location_id);
|
19 |
-
$EM_Location->delete();
|
20 |
-
}
|
21 |
-
em_admin_locations(__('Locations Deleted', "dbem" ));
|
22 |
-
} elseif( $_REQUEST['action'] == "save") {
|
23 |
-
// save (add/update) location
|
24 |
-
if( empty($EM_Location) || !is_object($EM_Location) ){
|
25 |
-
$EM_Location = new EM_Location(); //blank location
|
26 |
-
$success_message = __('The location has been added.', 'dbem');
|
27 |
-
}else{
|
28 |
-
$success_message = __('The location has been updated.', 'dbem');
|
29 |
-
}
|
30 |
-
$EM_Location->get_post();
|
31 |
-
$validation_result = $EM_Location->validate();
|
32 |
-
if ( $validation_result ) {
|
33 |
-
$EM_Location->save(); //FIXME better handling of db write fails when saving location
|
34 |
-
em_admin_locations($success_message);
|
35 |
-
} else {
|
36 |
-
?>
|
37 |
-
<div id='message' class='error '>
|
38 |
-
<p>
|
39 |
-
<strong><?php _e( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br /><?php echo implode('<br />', $EM_Location->errors); ?>
|
40 |
-
</p>
|
41 |
-
</div>
|
42 |
-
<?php
|
43 |
-
unset($EM_Location);
|
44 |
-
em_admin_location();
|
45 |
-
}
|
46 |
-
}
|
47 |
-
} else {
|
48 |
-
// no action, just a locations list
|
49 |
-
em_admin_locations();
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
function em_admin_locations($message='', $fill_fields = false) {
|
54 |
-
$limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
|
55 |
-
$page = ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:1;
|
56 |
-
$offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
|
57 |
-
$locations = EM_Locations::get();
|
58 |
-
$locations_count = count($locations);
|
59 |
-
?>
|
60 |
-
<div class='wrap'>
|
61 |
-
<div id='icon-edit' class='icon32'>
|
62 |
-
<br/>
|
63 |
-
</div>
|
64 |
-
<h2>
|
65 |
-
<?php _e('Locations', 'dbem'); ?>
|
66 |
-
<a href="admin.php?page=events-manager-locations&action=add" class="button add-new-h2"><?php _e('Add New') ?></a>
|
67 |
-
</h2>
|
68 |
-
|
69 |
-
<?php if($message != "") : ?>
|
70 |
-
<div id='message' class='updated fade below-h2'>
|
71 |
-
<p><?php echo $message ?></p>
|
72 |
-
</div>
|
73 |
-
<?php endif; ?>
|
74 |
-
|
75 |
-
<form id='bookings-filter' method='post' action=''>
|
76 |
-
<input type='hidden' name='page' value='locations'/>
|
77 |
-
<input type='hidden' name='limit' value='<?php echo $limit ?>' />
|
78 |
-
<input type='hidden' name='p' value='<?php echo $page ?>' />
|
79 |
-
<?php if ( $locations_count > 0 ) : ?>
|
80 |
-
<div class='tablenav'>
|
81 |
-
<div class="alignleft actions">
|
82 |
-
<select name="action">
|
83 |
-
<option value="" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
|
84 |
-
<option value="delete"><?php _e ( 'Delete selected','dbem' ); ?></option>
|
85 |
-
</select>
|
86 |
-
<input type="submit" value="<?php _e ( 'Apply' ); ?>" id="doaction2" class="button-secondary action" />
|
87 |
-
<?php
|
88 |
-
//Pagination (if needed/requested)
|
89 |
-
if( $locations_count >= $limit ){
|
90 |
-
//Show the pagination links (unless there's less than 10 events
|
91 |
-
$page_link_template = preg_replace('/(&|\?)p=\d+/i','',$_SERVER['REQUEST_URI']);
|
92 |
-
$page_link_template = em_add_get_params($page_link_template, array('pno'=>'%PAGE%'));
|
93 |
-
$locations_nav = em_paginate( $page_link_template, $locations_count, $limit, $page);
|
94 |
-
echo $locations_nav;
|
95 |
-
}
|
96 |
-
?>
|
97 |
-
</div>
|
98 |
-
</div>
|
99 |
-
<table class='widefat'>
|
100 |
-
<thead>
|
101 |
-
<tr>
|
102 |
-
<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
|
103 |
-
<th><?php _e('Name', 'dbem') ?></th>
|
104 |
-
<th><?php _e('Address', 'dbem') ?></th>
|
105 |
-
<th><?php _e('Town', 'dbem') ?></th>
|
106 |
-
</tr>
|
107 |
-
</thead>
|
108 |
-
<tfoot>
|
109 |
-
<tr>
|
110 |
-
<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
|
111 |
-
<th><?php _e('Name', 'dbem') ?></th>
|
112 |
-
<th><?php _e('Address', 'dbem') ?></th>
|
113 |
-
<th><?php _e('Town', 'dbem') ?></th>
|
114 |
-
</tr>
|
115 |
-
</tfoot>
|
116 |
-
<tbody>
|
117 |
-
<?php $i = 1; ?>
|
118 |
-
<?php foreach ($locations as $EM_Location) : ?>
|
119 |
-
<?php if( $i >= $offset && $i <= $offset+$limit ): ?>
|
120 |
-
<tr>
|
121 |
-
<td><input type='checkbox' class ='row-selector' value='<?php echo $EM_Location->id ?>' name='locations[]'/></td>
|
122 |
-
<td><a href='admin.php?page=events-manager-locations&action=edit&location_id=<?php echo $EM_Location->id ?>'><?php echo $EM_Location->name ?></a></td>
|
123 |
-
<td><?php echo $EM_Location->address ?></td>
|
124 |
-
<td><?php echo $EM_Location->town ?></td>
|
125 |
-
</tr>
|
126 |
-
<?php endif; ?>
|
127 |
-
<?php $i++; ?>
|
128 |
-
<?php endforeach; ?>
|
129 |
-
</tbody>
|
130 |
-
</table>
|
131 |
-
<?php else: ?>
|
132 |
-
<p><?php _e('No venues have been inserted yet!', 'dbem') ?></p>
|
133 |
-
<?php endif; ?>
|
134 |
-
</form>
|
135 |
-
</div>
|
136 |
-
<?php
|
137 |
-
}
|
138 |
-
|
139 |
-
function em_admin_location($message = "") {
|
140 |
-
global $EM_Location, $EM_Event;
|
141 |
-
//check that user can access this page
|
142 |
-
if( is_object($EM_Location) && !$EM_Location->can_manage() ){
|
143 |
-
?>
|
144 |
-
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this location.','dbem'); ?></p></div>
|
145 |
-
<?php
|
146 |
-
return false;
|
147 |
-
}
|
148 |
-
if( empty($EM_Location) || !is_object($EM_Location) ){
|
149 |
-
$title = __('Add location', 'dbem');
|
150 |
-
$EM_Location = new EM_Location();
|
151 |
-
}else{
|
152 |
-
$title = __('Edit location', 'dbem');
|
153 |
-
}
|
154 |
-
?>
|
155 |
-
<form enctype='multipart/form-data' name='editcat' id='locationForm' method='post' action='admin.php?page=events-manager-locations' class='validate'>
|
156 |
-
<input type='hidden' name='action' value='save' />
|
157 |
-
<input type='hidden' name='location_id' value='<?php echo $EM_Location->id ?>'/>
|
158 |
-
<div class='wrap'>
|
159 |
-
<div id='icon-edit' class='icon32'>
|
160 |
-
<br/>
|
161 |
-
</div>
|
162 |
-
<h2><?php echo $title ?></h2>
|
163 |
-
|
164 |
-
<?php if($message != "") : ?>
|
165 |
-
<div id='message' class='updated fade below-h2' style='background-color: rgb(255, 251, 204);'>
|
166 |
-
<p><?php echo $message ?></p>
|
167 |
-
</div>
|
168 |
-
<?php endif; ?>
|
169 |
-
<div id='ajax-response'></div>
|
170 |
-
|
171 |
-
<div id="poststuff" class="metabox-holder">
|
172 |
-
<div id="post-body">
|
173 |
-
<div id="post-body-content">
|
174 |
-
<div id="location_name" class="stuffbox">
|
175 |
-
<h3>
|
176 |
-
<?php _e ( 'Location Name', 'dbem' ); ?>
|
177 |
-
</h3>
|
178 |
-
<div class="inside">
|
179 |
-
<input name='location_name' id='location-name' type='text' value='<?php echo htmlspecialchars($EM_Location->name, ENT_QUOTES); ?>' size='40' />
|
180 |
-
<br />
|
181 |
-
<?php _e('The name of the location', 'dbem') ?>
|
182 |
-
</div>
|
183 |
-
</div>
|
184 |
-
<div id="location_coordinates" class="stuffbox" style='display: none;'>
|
185 |
-
<h3>
|
186 |
-
<?php _e ( 'Coordinates', 'dbem' ); ?>
|
187 |
-
</h3>
|
188 |
-
<div class="inside">
|
189 |
-
<input id='location-latitude' name='location_latitude' type='text' value='<?php echo $EM_Location->latitude; ?>' size='15' />
|
190 |
-
-
|
191 |
-
<input id='location-longitude' name='location_longitude' type='text' value='<?php echo $EM_Location->longitude; ?>' size='15' />
|
192 |
-
</div>
|
193 |
-
</div>
|
194 |
-
<div id="location_info" class="stuffbox">
|
195 |
-
<h3>
|
196 |
-
<?php _e ( 'Location', 'dbem' ); ?>
|
197 |
-
</h3>
|
198 |
-
<div class="inside">
|
199 |
-
<table id="dbem-location-data">
|
200 |
-
<tr>
|
201 |
-
<td style="padding-right:20px">
|
202 |
-
<table>
|
203 |
-
<tr>
|
204 |
-
<th><?php _e ( 'Address:' )?> </th>
|
205 |
-
<td>
|
206 |
-
<input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Location->address, ENT_QUOTES); ; ?>" />
|
207 |
-
<p><?php _e ( 'The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem' )?></p>
|
208 |
-
</td>
|
209 |
-
</tr>
|
210 |
-
<tr>
|
211 |
-
<th><?php _e ( 'Town:' )?> </th>
|
212 |
-
<td>
|
213 |
-
<input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Location->town, ENT_QUOTES); ?>" />
|
214 |
-
<p><?php _e ( 'The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem' )?></p>
|
215 |
-
</td>
|
216 |
-
</tr>
|
217 |
-
</table>
|
218 |
-
</td>
|
219 |
-
<?php if ( get_option ( 'dbem_gmap_is_active' ) ) : ?>
|
220 |
-
<td width="400">
|
221 |
-
<div id='em-map-404' style='width: 400px; vertical-align:middle; text-align: center;'>
|
222 |
-
<p><em><?php _e ( 'Location not found', 'dbem' ); ?></em></p>
|
223 |
-
</div>
|
224 |
-
<div id='em-map' style='width: 400px; height: 300px; display: none;'></div>
|
225 |
-
</td>
|
226 |
-
<?php endif; ?>
|
227 |
-
</tr>
|
228 |
-
</table>
|
229 |
-
</div>
|
230 |
-
</div>
|
231 |
-
|
232 |
-
<div id="location_description" class="postbox">
|
233 |
-
<h3>
|
234 |
-
<?php _e ( 'Details', 'dbem' ); ?>
|
235 |
-
</h3>
|
236 |
-
<div class="inside">
|
237 |
-
<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
238 |
-
<?php the_editor($EM_Location->description ); ?>
|
239 |
-
</div>
|
240 |
-
<br />
|
241 |
-
<?php _e ( 'Details about the location', 'dbem' )?>
|
242 |
-
</div>
|
243 |
-
</div>
|
244 |
-
|
245 |
-
<div id="location_description" class="stuffbox">
|
246 |
-
<h3>
|
247 |
-
<?php _e ( 'Location image', 'dbem' ); ?>
|
248 |
-
</h3>
|
249 |
-
<div class="inside" style="padding:10px;">
|
250 |
-
<?php if ($EM_Location->image_url != '') : ?>
|
251 |
-
<img src='<?php echo $EM_Location->image_url; ?>' alt='<?php echo $EM_Location->name ?>'/>
|
252 |
-
<?php else : ?>
|
253 |
-
<?php _e('No image uploaded for this location yet', 'debm') ?>
|
254 |
-
<?php endif; ?>
|
255 |
-
<br /><br />
|
256 |
-
<label for='location_image'><?php _e('Upload/change picture', 'dbem') ?></label> <input id='location-image' name='location_image' id='location_image' type='file' size='40' />
|
257 |
-
</div>
|
258 |
-
</div>
|
259 |
-
</div>
|
260 |
-
</div>
|
261 |
-
</div>
|
262 |
-
<p class='submit'><input type='submit' class='button-primary' name='submit' value='<?php _e('Update location', 'dbem') ?>' /></p>
|
263 |
-
</div>
|
264 |
-
</form>
|
265 |
-
<?php
|
266 |
-
}
|
267 |
-
|
268 |
-
?>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
admin/em-ms-locations.php
ADDED
@@ -0,0 +1,52 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Looks at the request values, saves/updates and then displays the right menu in the admin
|
4 |
+
* @return null
|
5 |
+
*/
|
6 |
+
function em_admin_ms_locations() {
|
7 |
+
//TODO EM_Location is globalized, use it fully here
|
8 |
+
global $EM_Location;
|
9 |
+
//Take actions
|
10 |
+
if( !empty($_REQUEST['action']) && ($_REQUEST['action'] == "edit" || $_REQUEST['action'] == "location_save")) {
|
11 |
+
em_admin_location();
|
12 |
+
} else {
|
13 |
+
// no action, just a locations list
|
14 |
+
em_admin_locations();
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
function em_admin_locations($message='', $fill_fields = false) {
|
19 |
+
global $current_site;
|
20 |
+
?>
|
21 |
+
<div class='wrap'>
|
22 |
+
<div id='icon-edit' class='icon32'>
|
23 |
+
<br/>
|
24 |
+
</div>
|
25 |
+
<h2>
|
26 |
+
<?php _e('Locations', 'dbem'); ?>
|
27 |
+
</h2>
|
28 |
+
<?php em_locations_admin(array('url' => $_SERVER['REQUEST_URI'])); ?>
|
29 |
+
</div>
|
30 |
+
<?php
|
31 |
+
}
|
32 |
+
|
33 |
+
function em_admin_location($message = "") {
|
34 |
+
global $EM_Location;
|
35 |
+
if( empty($EM_Location) || !is_object($EM_Location) ){
|
36 |
+
$title = __('Add location', 'dbem');
|
37 |
+
$EM_Location = new EM_Location();
|
38 |
+
}else{
|
39 |
+
$title = __('Edit location', 'dbem');
|
40 |
+
}
|
41 |
+
?>
|
42 |
+
<div class='wrap'>
|
43 |
+
<div id='icon-edit' class='icon32'>
|
44 |
+
<br/>
|
45 |
+
</div>
|
46 |
+
<h2><?php echo $title ?></h2>
|
47 |
+
<?php em_location_form(); ?>
|
48 |
+
</div>
|
49 |
+
<?php
|
50 |
+
}
|
51 |
+
|
52 |
+
?>
|
admin/em-ms-options.php
ADDED
@@ -0,0 +1,205 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
function em_ms_upgrade( $blog_id ){
|
3 |
+
?>
|
4 |
+
<div class="wrap">
|
5 |
+
<div id='icon-options-general' class='icon32'><br /></div>
|
6 |
+
<h2><?php _e('Update Network','dbem'); ?></h2>
|
7 |
+
<?php
|
8 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'upgrade' && check_admin_referer('em_ms_ugrade_'.get_current_user_id()) ){
|
9 |
+
global $current_site,$wpdb;
|
10 |
+
$blog_ids = $wpdb->get_col('SELECT blog_id FROM '.$wpdb->blogs.' WHERE site_id='.$current_site->id);
|
11 |
+
foreach($blog_ids as $blog_id){
|
12 |
+
$plugin_basename = plugin_basename(dirname(dirname(__FILE__)).'/events-manager.php');
|
13 |
+
if( in_array( $plugin_basename, (array) get_blog_option($blog_id, 'active_plugins', array() ) ) || is_plugin_active_for_network($plugin_basename) ){
|
14 |
+
if( EM_VERSION > get_blog_option($blog_id, 'dbem_version', 0) ){
|
15 |
+
switch_to_blog($blog_id);
|
16 |
+
require_once( dirname(__FILE__).'/../em-install.php');
|
17 |
+
em_install();
|
18 |
+
echo "<p>Upgraded - ".get_bloginfo('blogname')."</p>";
|
19 |
+
restore_current_blog();
|
20 |
+
}else{
|
21 |
+
echo "<p>"".get_blog_option($blog_id, 'blogname')."" is up to date.</p>";
|
22 |
+
}
|
23 |
+
}else{
|
24 |
+
echo "<p>"".get_blog_option($blog_id, 'blogname')."" does not have Events Manager activated.</p>";
|
25 |
+
}
|
26 |
+
}
|
27 |
+
echo "<p>Done Upgrading</p>";
|
28 |
+
}else{
|
29 |
+
?>
|
30 |
+
<form action="" method="post">
|
31 |
+
<p><?php _e('To update your network blogs with the latest Events Manager automatically, click the update button below.','dbem'); ?></p>
|
32 |
+
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('em_ms_ugrade_'.get_current_user_id()); ?>" />
|
33 |
+
<input type="hidden" name="action" value="upgrade" />
|
34 |
+
<input type="submit" value="<?php _e('Update','dbem'); ?>" />
|
35 |
+
</form>
|
36 |
+
<?php
|
37 |
+
}
|
38 |
+
?>
|
39 |
+
</div>
|
40 |
+
<?php
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Displays network-related options in the network admin section
|
45 |
+
* @uses em_options_save() to save settings
|
46 |
+
*/
|
47 |
+
function em_ms_admin_options_page() {
|
48 |
+
global $wpdb,$EM_Notices;
|
49 |
+
//Check for uninstall/reset request
|
50 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'uninstall' ){
|
51 |
+
em_admin_options_uninstall_page();
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ){
|
55 |
+
em_admin_options_reset_page();
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
//TODO place all options into an array
|
59 |
+
$events_placeholders = '<a href="'.EM_ADMIN_URL .'&events-manager-help#event-placeholders">'. __('Event Related Placeholders','dbem') .'</a>';
|
60 |
+
$locations_placeholders = '<a href="'.EM_ADMIN_URL .'&events-manager-help#location-placeholders">'. __('Location Related Placeholders','dbem') .'</a>';
|
61 |
+
$bookings_placeholders = '<a href="'.EM_ADMIN_URL .'&events-manager-help#booking-placeholders">'. __('Booking Related Placeholders','dbem') .'</a>';
|
62 |
+
$categories_placeholders = '<a href="'.EM_ADMIN_URL .'&events-manager-help#category-placeholders">'. __('Category Related Placeholders','dbem') .'</a>';
|
63 |
+
$events_placeholder_tip = " ". sprintf(__('This accepts %s and %s placeholders.','dbem'),$events_placeholders, $locations_placeholders);
|
64 |
+
$locations_placeholder_tip = " ". sprintf(__('This accepts %s placeholders.','dbem'), $locations_placeholders);
|
65 |
+
$categories_placeholder_tip = " ". sprintf(__('This accepts %s placeholders.','dbem'), $categories_placeholders);
|
66 |
+
$bookings_placeholder_tip = " ". sprintf(__('This accepts %s, %s and %s placeholders.','dbem'), $bookings_placeholders, $events_placeholders, $locations_placeholders);
|
67 |
+
|
68 |
+
global $save_button;
|
69 |
+
$save_button = '<tr><th> </th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" id="dbem_options_submit" name="Submit" value="'. __( 'Save Changes', 'dbem') .' ('. __('All','dbem') .')" /></p></ts></td></tr>';
|
70 |
+
//Do some multisite checking here for reuse
|
71 |
+
?>
|
72 |
+
<script type="text/javascript" charset="utf-8"><?php include(EM_DIR.'/includes/js/admin-settings.js'); ?></script>
|
73 |
+
<script type="text/javascript" charset="utf-8">
|
74 |
+
jQuery(document).ready(function($){
|
75 |
+
//MS Mode selection hiders
|
76 |
+
$('input[name="dbem_ms_global_table"]').change(function(){ //global
|
77 |
+
if( $('input:radio[name="dbem_ms_global_table"]:checked').val() == 1 ){
|
78 |
+
$("tbody.em-global-options").show();
|
79 |
+
$('input:radio[name="dbem_ms_mainblog_locations"]:checked').trigger('change');
|
80 |
+
}else{
|
81 |
+
$("tbody.em-global-options").hide();
|
82 |
+
}
|
83 |
+
}).first().trigger('change');
|
84 |
+
//events
|
85 |
+
$('input[name="dbem_ms_global_events"]').change(function(){
|
86 |
+
if( $('input:radio[name="dbem_ms_global_events"]:checked').val() == 1 ){
|
87 |
+
$("tr#dbem_ms_global_events_links_row").show();
|
88 |
+
$('input:radio[name="dbem_ms_global_events_links"]:checked').trigger('change');
|
89 |
+
}else{
|
90 |
+
$("tr#dbem_ms_global_events_links_row, tr#dbem_ms_events_slug_row").hide();
|
91 |
+
}
|
92 |
+
}).first().trigger('change');
|
93 |
+
$('input[name="dbem_ms_global_events_links"]').change(function(){
|
94 |
+
if( $('input:radio[name="dbem_ms_global_events_links"]:checked').val() == 1 ){
|
95 |
+
$("tr#dbem_ms_events_slug_row").hide();
|
96 |
+
}else{
|
97 |
+
$("tr#dbem_ms_events_slug_row").show();
|
98 |
+
}
|
99 |
+
}).first().trigger('change');
|
100 |
+
//locations
|
101 |
+
$('input[name="dbem_ms_mainblog_locations"]').change(function(){
|
102 |
+
if( $('input:radio[name="dbem_ms_mainblog_locations"]:checked').val() == 1 ){
|
103 |
+
$("tbody.em-global-locations").hide();
|
104 |
+
}else{
|
105 |
+
$("tbody.em-global-locations").show();
|
106 |
+
}
|
107 |
+
}).first().trigger('change');
|
108 |
+
$('input[name="dbem_ms_global_locations"]').change(function(){
|
109 |
+
if( $('input:radio[name="dbem_ms_global_locations"]:checked').val() == 1 ){
|
110 |
+
$("tr#dbem_ms_global_locations_links_row").show();
|
111 |
+
$('input:radio[name="dbem_ms_global_locations_links"]:checked').trigger('change');
|
112 |
+
}else{
|
113 |
+
$("tr#dbem_ms_global_locations_links_row, tr#dbem_ms_locations_slug_row").hide();
|
114 |
+
}
|
115 |
+
}).first().trigger('change');
|
116 |
+
$('input[name="dbem_ms_global_locations_links"]').change(function(){
|
117 |
+
if( $('input:radio[name="dbem_ms_global_locations_links"]:checked').val() == 1 ){
|
118 |
+
$("tr#dbem_ms_locations_slug_row").hide();
|
119 |
+
}else{
|
120 |
+
$("tr#dbem_ms_locations_slug_row").show();
|
121 |
+
}
|
122 |
+
});
|
123 |
+
});
|
124 |
+
</script>
|
125 |
+
<style type="text/css">.postbox h3 { cursor:pointer; }</style>
|
126 |
+
<div class="wrap">
|
127 |
+
<div id='icon-options-general' class='icon32'><br /></div>
|
128 |
+
<h2 class="nav-tab-wrapper">
|
129 |
+
<a href="#" id="em-menu-general" class="nav-tab nav-tab-active"><?php _e('General','dbem'); ?></a>
|
130 |
+
</h2>
|
131 |
+
<h3 id="em-options-title"><?php _e ( 'Event Manager Options', 'dbem' ); ?></h3>
|
132 |
+
<?php echo $EM_Notices; ?>
|
133 |
+
<form id="em-options-form" method="post" action="">
|
134 |
+
<div class="metabox-holder">
|
135 |
+
<!-- // TODO Move style in css -->
|
136 |
+
<div class='postbox-container' style='width: 99.5%'>
|
137 |
+
<div id="">
|
138 |
+
|
139 |
+
<div class="em-menu-general em-menu-group">
|
140 |
+
<div class="postbox " id="em-opt-ms-options" >
|
141 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Multi Site Options', 'dbem' ); ?></span></h3>
|
142 |
+
<div class="inside">
|
143 |
+
<table class="form-table">
|
144 |
+
<?php
|
145 |
+
em_options_radio_binary ( __( 'Enable global tables mode?', 'dbem'), 'dbem_ms_global_table', __( 'Setting this to yes will make all events save in the main site event tables (EM must also be activated). This allows you to share events across different blogs, such as showing events in your network whilst allowing users to display and manage their events within their own blog. Bear in mind that activating this will mean old events created on the sub-blogs will not be accessible anymore, and if you switch back they will be but new events created during global events mode will only remain on the main site.','dbem' ) );
|
146 |
+
?>
|
147 |
+
<tbody class="em-global-options">
|
148 |
+
<?php
|
149 |
+
global $current_site;
|
150 |
+
$global_slug_tip = __('%s belonging to other sub-sites will have an extra slug preppended to it so that your main site can differentiate between its own %s and those belonging to other sites in your network.','dbem');
|
151 |
+
$global_link_tip = __( 'When displaying global %s on the main site you have the option of users viewing the %s details on the main site or being directed to the sub-site.','dbem' );
|
152 |
+
$global_post_tip = __( 'Displays %s from all sites on the network by default. You can still restrict %s by blog using shortcodes and template tags coupled with the <code>blog</code> attribute. Requires global tables to be turned on.','dbem');
|
153 |
+
$global_link_tip2 = __('You <strong>must</strong> have assigned a %s page in your <a href="%s">main blog settings</a> for this to work.','dbem');
|
154 |
+
$options_page_link = get_admin_url($current_site->blog_id, 'edit.php?post_type=event&page=events-manager-options#pages');
|
155 |
+
?><tr><td><strong><?php echo sprintf(__('%s Options','dbem'),__('Event','dbem')); ?></strong></td></tr><?php
|
156 |
+
em_options_radio_binary ( sprintf(__( 'Display global events on main blog?', 'dbem'), __('events','dbem')), 'dbem_ms_global_events', sprintf($global_post_tip, __('events','dbem'), __('events','dbem')) );
|
157 |
+
em_options_radio_binary ( sprintf(__( 'Link sub-site %s directly to sub-site?', 'dbem'), __('events','dbem')), 'dbem_ms_global_events_links', sprintf($global_link_tip, __('events','dbem'), __('event','dbem')).sprintf($global_link_tip2, __('event','dbem'), $options_page_link) );
|
158 |
+
em_options_input_text ( sprintf(__( 'Global %s slug', 'dbem' ),__('event','dbem')), 'dbem_ms_events_slug', sprintf($global_slug_tip, __('Events','dbem'), __('events','dbem')).__('Example:','dbem').'<code>http://yoursite.com/events/<strong>event</strong>/subsite-event-slug/', EM_EVENT_SLUG );
|
159 |
+
?><tr><td><strong><?php echo sprintf(__('%s Options','dbem'),__('Location','dbem')); ?></strong></td></tr><?php
|
160 |
+
em_options_radio_binary ( sprintf(__( 'Locations on main blog?', 'dbem'), __('locations','dbem')), 'dbem_ms_mainblog_locations', __('If you would prefer all your locations to belong to your main blog, users in sub-sites will still be able to create locations, but the actual locations are created and reside in the main blog.','dbem') );
|
161 |
+
?>
|
162 |
+
</tbody>
|
163 |
+
<tbody class="em-global-options em-global-locations">
|
164 |
+
<?php
|
165 |
+
em_options_radio_binary ( sprintf(__( 'Display global %s on main blog?', 'dbem'), __('locations','dbem')), 'dbem_ms_global_locations', sprintf($global_post_tip, __('locations','dbem'), __('locations','dbem')) );
|
166 |
+
em_options_radio_binary ( sprintf(__( 'Link sub-site %s directly to sub-site?', 'dbem'), __('locations','dbem')), 'dbem_ms_global_locations_links', sprintf($global_link_tip, __('locations','dbem'), __('location','dbem')).sprintf($global_link_tip2, __('location','dbem'), $options_page_link) );
|
167 |
+
em_options_input_text ( sprintf(__( 'Global %s slug', 'dbem' ),__('location','dbem')), 'dbem_ms_locations_slug', sprintf($global_slug_tip, __('Locations','dbem'), __('locations','dbem')).__('Example:','dbem').'<code>http://yoursite.com/locations/<strong>location</strong>/subsite-location-slug/', EM_LOCATION_SLUG );
|
168 |
+
?>
|
169 |
+
</tbody>
|
170 |
+
<?php echo $save_button; ?>
|
171 |
+
</table>
|
172 |
+
|
173 |
+
</div> <!-- . inside -->
|
174 |
+
</div> <!-- .postbox -->
|
175 |
+
|
176 |
+
<?php
|
177 |
+
//including shared MS/non-MS boxes
|
178 |
+
em_admin_option_box_caps();
|
179 |
+
em_admin_option_box_image_sizes();
|
180 |
+
em_admin_option_box_email();
|
181 |
+
em_admin_option_box_uninstall();
|
182 |
+
?>
|
183 |
+
|
184 |
+
<?php do_action('em_ms_options_page_footer'); ?>
|
185 |
+
</div> <!-- .em-menu-general -->
|
186 |
+
|
187 |
+
<div class="em-menu-pages em-menu-group" style="display:none;">
|
188 |
+
|
189 |
+
</div> <!-- .em-menu-pages -->
|
190 |
+
|
191 |
+
<p class="submit">
|
192 |
+
<input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
|
193 |
+
<input type="hidden" name="em-submitted" value="1" />
|
194 |
+
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('events-manager-options'); ?>" />
|
195 |
+
</p>
|
196 |
+
|
197 |
+
</div> <!-- .metabox-sortables -->
|
198 |
+
</div> <!-- .postbox-container -->
|
199 |
+
|
200 |
+
</div> <!-- .metabox-holder -->
|
201 |
+
</form>
|
202 |
+
</div>
|
203 |
+
<?php
|
204 |
+
}
|
205 |
+
?>
|
admin/em-options.php
CHANGED
@@ -1,444 +1,2114 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
//Function composing the options subpanel
|
4 |
-
function em_options_save(){
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
</
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
<
|
257 |
-
|
258 |
-
<
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
);
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
444 |
Â
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//Function composing the options subpanel
|
4 |
+
function em_options_save(){
|
5 |
+
global $EM_Notices;
|
6 |
+
/*
|
7 |
+
* Here's the idea, we have an array of all options that need super admin approval if in multi-site mode
|
8 |
+
* since options are only updated here, its one place fit all
|
9 |
+
*/
|
10 |
+
if( current_user_can('list_users') && !empty($_POST['em-submitted']) && check_admin_referer('events-manager-options','_wpnonce') ){
|
11 |
+
//Build the array of options here
|
12 |
+
$post = $_POST;
|
13 |
+
foreach ($_POST as $postKey => $postValue){
|
14 |
+
if( substr($postKey, 0, 5) == 'dbem_' ){
|
15 |
+
//TODO some more validation/reporting
|
16 |
+
$numeric_options = array('dbem_locations_default_limit','dbem_events_default_limit');
|
17 |
+
if( in_array($postKey, array('dbem_bookings_notify_admin','dbem_event_submitted_email_admin','dbem_js_limit_events_form','dbem_js_limit_search','dbem_js_limit_general','dbem_css_limit_include','dbem_css_limit_exclude')) ){ $postValue = str_replace(' ', '', $postValue); } //clean up comma seperated emails, no spaces needed
|
18 |
+
if( in_array($postKey,$numeric_options) && !is_numeric($postValue) ){
|
19 |
+
//Do nothing, keep old setting.
|
20 |
+
}else{
|
21 |
+
//TODO slashes being added?
|
22 |
+
if( is_array($postValue) ){
|
23 |
+
foreach($postValue as $postValue_key=>$postValue_val) $postValue[$postValue_key] = stripslashes($postValue_val);
|
24 |
+
}else{
|
25 |
+
$postValue = stripslashes($postValue);
|
26 |
+
}
|
27 |
+
update_option($postKey, $postValue);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
//set capabilities
|
32 |
+
if( !empty($_POST['em_capabilities']) && is_array($_POST['em_capabilities']) && (!is_multisite() || is_multisite() && is_super_admin()) ){
|
33 |
+
global $em_capabilities_array, $wp_roles;
|
34 |
+
if( is_multisite() && is_network_admin() && $_POST['dbem_ms_global_caps'] == 1 ){
|
35 |
+
//apply_caps_to_blog
|
36 |
+
global $current_site,$wpdb;
|
37 |
+
$blog_ids = $wpdb->get_col('SELECT blog_id FROM '.$wpdb->blogs.' WHERE site_id='.$current_site->id);
|
38 |
+
foreach($blog_ids as $blog_id){
|
39 |
+
switch_to_blog($blog_id);
|
40 |
+
//normal blog role application
|
41 |
+
foreach( $wp_roles->role_objects as $role_name => $role ){
|
42 |
+
foreach( array_keys($em_capabilities_array) as $capability){
|
43 |
+
if( !empty($_POST['em_capabilities'][$role_name][$capability]) ){
|
44 |
+
$role->add_cap($capability);
|
45 |
+
}else{
|
46 |
+
$role->remove_cap($capability);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
restore_current_blog();
|
51 |
+
}
|
52 |
+
}elseif( !is_network_admin() ){
|
53 |
+
//normal blog role application
|
54 |
+
foreach( $wp_roles->role_objects as $role_name => $role ){
|
55 |
+
foreach( array_keys($em_capabilities_array) as $capability){
|
56 |
+
if( !empty($_POST['em_capabilities'][$role_name][$capability]) ){
|
57 |
+
$role->add_cap($capability);
|
58 |
+
}else{
|
59 |
+
$role->remove_cap($capability);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
update_option('dbem_flush_needed',1);
|
66 |
+
do_action('em_options_save');
|
67 |
+
$EM_Notices->add_confirm('<strong>'.__('Changes saved.', 'dbem').'</strong>', true);
|
68 |
+
wp_redirect(wp_get_referer());
|
69 |
+
exit();
|
70 |
+
}
|
71 |
+
//Migration
|
72 |
+
if( !empty($_GET['em_migrate_images']) && check_admin_referer('em_migrate_images','_wpnonce') && get_option('dbem_migrate_images') ){
|
73 |
+
include(plugin_dir_path(__FILE__).'../em-install.php');
|
74 |
+
$result = em_migrate_uploads();
|
75 |
+
if($result){
|
76 |
+
$failed = ( $result['fail'] > 0 ) ? $result['fail'] . ' images failed to migrate.' : '';
|
77 |
+
$EM_Notices->add_confirm('<strong>'.$result['success'].' images migrated successfully. '.$failed.'</strong>');
|
78 |
+
}
|
79 |
+
wp_redirect(admin_url().'edit.php?post_type=event&page=events-manager-options&em_migrate_images');
|
80 |
+
}elseif( !empty($_GET['em_not_migrate_images']) && check_admin_referer('em_not_migrate_images','_wpnonce') ){
|
81 |
+
delete_option('dbem_migrate_images_nag');
|
82 |
+
delete_option('dbem_migrate_images');
|
83 |
+
}
|
84 |
+
//Uninstall
|
85 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'uninstall' && current_user_can('activate_plugins') && !empty($_REQUEST['confirmed']) && check_admin_referer('em_uninstall_'.get_current_user_id().'_wpnonce') && is_super_admin() ){
|
86 |
+
if( check_admin_referer('em_uninstall_'.get_current_user_id().'_confirmed','_wpnonce2') ){
|
87 |
+
//We have a go to uninstall
|
88 |
+
global $wpdb;
|
89 |
+
//delete EM posts
|
90 |
+
remove_action('before_delete_post',array('EM_Location_Post_Admin','before_delete_post'),10,1);
|
91 |
+
remove_action('before_delete_post',array('EM_Event_Post_Admin','before_delete_post'),10,1);
|
92 |
+
remove_action('before_delete_post',array('EM_Event_Recurring_Post_Admin','before_delete_post'),10,1);
|
93 |
+
$post_ids = $wpdb->get_col('SELECT ID FROM '.$wpdb->posts." WHERE post_type IN ('".EM_POST_TYPE_EVENT."','".EM_POST_TYPE_LOCATION."','event-recurring')");
|
94 |
+
foreach($post_ids as $post_id){
|
95 |
+
wp_delete_post($post_id);
|
96 |
+
}
|
97 |
+
//delete categories
|
98 |
+
$cat_terms = get_terms(EM_TAXONOMY_CATEGORY, array('hide_empty'=>false));
|
99 |
+
foreach($cat_terms as $cat_term){
|
100 |
+
wp_delete_term($cat_term->term_id, EM_TAXONOMY_CATEGORY);
|
101 |
+
}
|
102 |
+
$tag_terms = get_terms(EM_TAXONOMY_TAG, array('hide_empty'=>false));
|
103 |
+
foreach($tag_terms as $tag_term){
|
104 |
+
wp_delete_term($tag_term->term_id, EM_TAXONOMY_TAG);
|
105 |
+
}
|
106 |
+
//delete EM tables
|
107 |
+
$wpdb->query('DROP TABLE '.EM_EVENTS_TABLE);
|
108 |
+
$wpdb->query('DROP TABLE '.EM_BOOKINGS_TABLE);
|
109 |
+
$wpdb->query('DROP TABLE '.EM_LOCATIONS_TABLE);
|
110 |
+
$wpdb->query('DROP TABLE '.EM_TICKETS_TABLE);
|
111 |
+
$wpdb->query('DROP TABLE '.EM_TICKETS_BOOKINGS_TABLE);
|
112 |
+
$wpdb->query('DROP TABLE '.EM_RECURRENCE_TABLE);
|
113 |
+
$wpdb->query('DROP TABLE '.EM_CATEGORIES_TABLE);
|
114 |
+
$wpdb->query('DROP TABLE '.EM_META_TABLE);
|
115 |
+
|
116 |
+
//delete options
|
117 |
+
$wpdb->query('DELETE FROM '.$wpdb->options.' WHERE option_name LIKE \'em_%\' OR option_name LIKE \'dbem_%\'');
|
118 |
+
//deactivate and go!
|
119 |
+
deactivate_plugins(array('events-manager/events-manager.php','events-manager-pro/events-manager-pro.php'), true);
|
120 |
+
wp_redirect(admin_url('plugins.php?deactivate=true'));
|
121 |
+
exit();
|
122 |
+
}
|
123 |
+
}
|
124 |
+
//Reset
|
125 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' && !empty($_REQUEST['confirmed']) && check_admin_referer('em_reset_'.get_current_user_id().'_wpnonce') && is_super_admin() ){
|
126 |
+
if( check_admin_referer('em_reset_'.get_current_user_id().'_confirmed','_wpnonce2') ){
|
127 |
+
//We have a go to uninstall
|
128 |
+
global $wpdb;
|
129 |
+
//delete options
|
130 |
+
$wpdb->query('DELETE FROM '.$wpdb->options.' WHERE option_name LIKE \'em_%\' OR option_name LIKE \'dbem_%\'');
|
131 |
+
//reset capabilities
|
132 |
+
global $em_capabilities_array, $wp_roles;
|
133 |
+
foreach( $wp_roles->role_objects as $role_name => $role ){
|
134 |
+
foreach( array_keys($em_capabilities_array) as $capability){
|
135 |
+
$role->remove_cap($capability);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
//go back to plugin options page
|
139 |
+
$EM_Notices->add_confirm(__('Settings have been reset back to default. Your events, locations and categories have not been modified.','dbem'), true);
|
140 |
+
wp_redirect(EM_ADMIN_URL.'&page=events-manager-options');
|
141 |
+
exit();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
//Force Update Recheck - Workaround for now
|
145 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'recheck_updates' && check_admin_referer('em_recheck_updates_'.get_current_user_id().'_wpnonce') && is_super_admin() ){
|
146 |
+
//force recheck of plugin updates, to refresh dl links
|
147 |
+
delete_transient('update_plugins');
|
148 |
+
delete_site_transient('update_plugins');
|
149 |
+
$EM_Notices->add_confirm(__('If there are any new updates, you should now see them in your Plugins or Updates admin pages.','dbem'), true);
|
150 |
+
wp_redirect(wp_get_referer());
|
151 |
+
exit();
|
152 |
+
}
|
153 |
+
//Flag version checking to look at trunk, not tag
|
154 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'check_devs' && check_admin_referer('em_check_devs_wpnonce') && is_super_admin() ){
|
155 |
+
//delete transients, and add a flag to recheck dev version next time round
|
156 |
+
delete_transient('update_plugins');
|
157 |
+
delete_site_transient('update_plugins');
|
158 |
+
update_option('em_check_dev_version', true);
|
159 |
+
$EM_Notices->add_confirm(__('Checking for dev versions.','dbem').' '. __('If there are any new updates, you should now see them in your Plugins or Updates admin pages.','dbem'), true);
|
160 |
+
wp_redirect(wp_get_referer());
|
161 |
+
exit();
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
165 |
+
add_action('admin_init', 'em_options_save');
|
166 |
+
|
167 |
+
function em_admin_email_test_ajax(){
|
168 |
+
if( wp_verify_nonce($_REQUEST['_check_email_nonce'],'check_email') && current_user_can('activate_plugins') ){
|
169 |
+
$subject = __("Events Manager Test Email",'dbem');
|
170 |
+
$content = __('Congratulations! Your email settings work.','dbem');
|
171 |
+
$current_user = get_user_by('id', get_current_user_id());
|
172 |
+
$EM_Event = new EM_Event();
|
173 |
+
if( $EM_Event->email_send($subject,$content,$current_user->user_email) ){
|
174 |
+
$result = array(
|
175 |
+
'result' => true,
|
176 |
+
'message' => sprintf(__('Email sent succesfully to %s','dbem'),$current_user->user_email)
|
177 |
+
);
|
178 |
+
}else{
|
179 |
+
$result = array(
|
180 |
+
'result' => false,
|
181 |
+
'message' => __('Email not sent.','dbem')." <ul><li>".implode('</li><li>',$EM_Event->get_errors()).'</li></ul>'
|
182 |
+
);
|
183 |
+
}
|
184 |
+
echo json_encode($result);
|
185 |
+
}
|
186 |
+
exit();
|
187 |
+
}
|
188 |
+
add_action('wp_ajax_em_admin_test_email','em_admin_email_test_ajax');
|
189 |
+
|
190 |
+
function em_admin_options_reset_page(){
|
191 |
+
if( check_admin_referer('em_reset_'.get_current_user_id().'_wpnonce') && is_super_admin() ){
|
192 |
+
?>
|
193 |
+
<div class="wrap">
|
194 |
+
<div id='icon-options-general' class='icon32'><br /></div>
|
195 |
+
<h2><?php _e('Reset Events Manager','dbem'); ?></h2>
|
196 |
+
<p style="color:red; font-weight:bold;"><?php _e('Are you sure you want to reset Events Manager?','dbem')?></p>
|
197 |
+
<p style="font-weight:bold;"><?php _e('All your settings, including email templates and template formats for Events Manager will be deleted.','dbem')?></p>
|
198 |
+
<p>
|
199 |
+
<a href="<?php echo add_query_arg(array('_wpnonce2' => wp_create_nonce('em_reset_'.get_current_user_id().'_confirmed'), 'confirmed'=>1)); ?>" class="button-primary"><?php _e('Reset Events Manager','dbem'); ?></a>
|
200 |
+
<a href="<?php echo wp_get_referer(); ?>" class="button-secondary"><?php _e('Cancel','dbem'); ?></a>
|
201 |
+
</p>
|
202 |
+
</div>
|
203 |
+
<?php
|
204 |
+
}
|
205 |
+
}
|
206 |
+
function em_admin_options_uninstall_page(){
|
207 |
+
if( check_admin_referer('em_uninstall_'.get_current_user_id().'_wpnonce') && is_super_admin() ){
|
208 |
+
?>
|
209 |
+
<div class="wrap">
|
210 |
+
<div id='icon-options-general' class='icon32'><br /></div>
|
211 |
+
<h2><?php _e('Uninstall Events Manager','dbem'); ?></h2>
|
212 |
+
<p style="color:red; font-weight:bold;"><?php _e('Are you sure you want to uninstall Events Manager?','dbem')?></p>
|
213 |
+
<p style="font-weight:bold;"><?php _e('All your settings and events will be permanently deleted. This cannot be undone.','dbem')?></p>
|
214 |
+
<p><?php echo sprintf(__('If you just want to deactivate the plugin, <a href="%s">go to your plugins page</a>.','dbem'), wp_nonce_url(admin_url('plugins.php'))); ?></p>
|
215 |
+
<p>
|
216 |
+
<a href="<?php echo add_query_arg(array('_wpnonce2' => wp_create_nonce('em_uninstall_'.get_current_user_id().'_confirmed'), 'confirmed'=>1)); ?>" class="button-primary"><?php _e('Uninstall and Deactivate','dbem'); ?></a>
|
217 |
+
<a href="<?php echo wp_get_referer(); ?>" class="button-secondary"><?php _e('Cancel','dbem'); ?></a>
|
218 |
+
</p>
|
219 |
+
</div>
|
220 |
+
<?php
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
function em_admin_options_page() {
|
225 |
+
global $wpdb, $EM_Notices;
|
226 |
+
//Check for uninstall/reset request
|
227 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'uninstall' ){
|
228 |
+
em_admin_options_uninstall_page();
|
229 |
+
return;
|
230 |
+
}
|
231 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ){
|
232 |
+
em_admin_options_reset_page();
|
233 |
+
return;
|
234 |
+
}
|
235 |
+
//TODO place all options into an array
|
236 |
+
global $events_placeholder_tip, $locations_placeholder_tip, $categories_placeholder_tip, $bookings_placeholder_tip;
|
237 |
+
$events_placeholders = '<a href="'.EM_ADMIN_URL .'&page=events-manager-help#event-placeholders">'. __('Event Related Placeholders','dbem') .'</a>';
|
238 |
+
$locations_placeholders = '<a href="'.EM_ADMIN_URL .'&page=events-manager-help#location-placeholders">'. __('Location Related Placeholders','dbem') .'</a>';
|
239 |
+
$bookings_placeholders = '<a href="'.EM_ADMIN_URL .'&page=events-manager-help#booking-placeholders">'. __('Booking Related Placeholders','dbem') .'</a>';
|
240 |
+
$categories_placeholders = '<a href="'.EM_ADMIN_URL .'&page=events-manager-help#category-placeholders">'. __('Category Related Placeholders','dbem') .'</a>';
|
241 |
+
$events_placeholder_tip = " ". sprintf(__('This accepts %s and %s placeholders.','dbem'),$events_placeholders, $locations_placeholders);
|
242 |
+
$locations_placeholder_tip = " ". sprintf(__('This accepts %s placeholders.','dbem'), $locations_placeholders);
|
243 |
+
$categories_placeholder_tip = " ". sprintf(__('This accepts %s placeholders.','dbem'), $categories_placeholders);
|
244 |
+
$bookings_placeholder_tip = " ". sprintf(__('This accepts %s, %s and %s placeholders.','dbem'), $bookings_placeholders, $events_placeholders, $locations_placeholders);
|
245 |
+
|
246 |
+
global $save_button;
|
247 |
+
$save_button = '<tr><th> </th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" class="button-primary" id="dbem_options_submit" name="Submit" value="'. __( 'Save Changes', 'dbem') .' ('. __('All','dbem') .')" /></p></ts></td></tr>';
|
248 |
+
?>
|
249 |
+
<script type="text/javascript" charset="utf-8"><?php include(EM_DIR.'/includes/js/admin-settings.js'); ?></script>
|
250 |
+
<style type="text/css">.postbox h3 { cursor:pointer; }</style>
|
251 |
+
<div class="wrap">
|
252 |
+
<div id='icon-options-general' class='icon32'><br /></div>
|
253 |
+
<h2 class="nav-tab-wrapper">
|
254 |
+
<a href="#general" id="em-menu-general" class="nav-tab nav-tab-active"><?php _e('General','dbem'); ?></a>
|
255 |
+
<a href="#pages" id="em-menu-pages" class="nav-tab"><?php _e('Pages','dbem'); ?></a>
|
256 |
+
<a href="#formats" id="em-menu-formats" class="nav-tab"><?php _e('Formatting','dbem'); ?></a>
|
257 |
+
<?php if( get_option('dbem_rsvp_enabled') ): ?>
|
258 |
+
<a href="#bookings" id="em-menu-bookings" class="nav-tab"><?php _e('Bookings','dbem'); ?></a>
|
259 |
+
<?php endif; ?>
|
260 |
+
<a href="#emails" id="em-menu-emails" class="nav-tab"><?php _e('Emails','dbem'); ?></a>
|
261 |
+
</h2>
|
262 |
+
<h3 id="em-options-title"><?php _e ( 'Event Manager Options', 'dbem' ); ?></h3>
|
263 |
+
<form id="em-options-form" method="post" action="">
|
264 |
+
<div class="metabox-holder">
|
265 |
+
<!-- // TODO Move style in css -->
|
266 |
+
<div class='postbox-container' style='width: 99.5%'>
|
267 |
+
<div id="">
|
268 |
+
|
269 |
+
<div class="em-menu-general em-menu-group">
|
270 |
+
|
271 |
+
<!-- GENERAL OPTIONS -->
|
272 |
+
<div class="postbox " id="em-opt-general" >
|
273 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'General Options', 'dbem' ); ?> </span></h3>
|
274 |
+
<div class="inside">
|
275 |
+
<table class="form-table">
|
276 |
+
<?php em_options_radio_binary ( __( 'Disable thumbnails?', 'dbem' ), 'dbem_thumbnails_enabled', __( 'Select yes to disable Events Manager from enabling thumbnails (some themes may already have this enabled, which we cannot be turned off here).','dbem' ) ); ?>
|
277 |
+
<tr>
|
278 |
+
<td colspan="2">
|
279 |
+
<h4><?php echo sprintf(__('%s Settings','dbem'),__('Event','dbem')); ?></h4>
|
280 |
+
</td>
|
281 |
+
</tr>
|
282 |
+
<?php
|
283 |
+
em_options_radio_binary ( __( 'Enable recurrence?', 'dbem' ), 'dbem_recurrence_enabled', __( 'Select yes to enable the recurrence features feature','dbem' ) );
|
284 |
+
em_options_radio_binary ( __( 'Enable bookings?', 'dbem' ), 'dbem_rsvp_enabled', __( 'Select yes to allow bookings and tickets for events.','dbem' ) );
|
285 |
+
em_options_radio_binary ( __( 'Enable tags?', 'dbem' ), 'dbem_tags_enabled', __( 'Select yes to enable the tag features','dbem' ) );
|
286 |
+
if( !(EM_MS_GLOBAL && !is_main_site()) ){
|
287 |
+
em_options_radio_binary ( __( 'Enable categories?', 'dbem' ), 'dbem_categories_enabled', __( 'Select yes to enable the category features','dbem' ) );
|
288 |
+
if( get_option('dbem_categories_enabled') ){
|
289 |
+
/*default category*/
|
290 |
+
$category_options = array();
|
291 |
+
$category_options[0] = __('no default category','dbem');
|
292 |
+
$EM_Categories = EM_Categories::get();
|
293 |
+
foreach($EM_Categories as $EM_Category){
|
294 |
+
$category_options[$EM_Category->id] = $EM_Category->name;
|
295 |
+
}
|
296 |
+
echo "<tr><td>".__( 'Default Category', 'dbem' )."</td><td>";
|
297 |
+
wp_dropdown_categories(array( 'hide_empty' => 0, 'name' => 'dbem_default_category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => get_option('dbem_default_category'), 'show_option_none' => __('None','dbem'), 'class'=>''));
|
298 |
+
echo "</br><em>" .__( 'This option allows you to select the default category when adding an event.','dbem' ).' '.__('If an event does not have a category assigned when editing, this one will be assigned automatically.','dbem')."</em>";
|
299 |
+
echo "</td></tr>";
|
300 |
+
}
|
301 |
+
}
|
302 |
+
em_options_radio_binary ( sprintf(__( 'Enable %s attributes?', 'dbem' ),__('event','dbem')), 'dbem_attributes_enabled', __( 'Select yes to enable the attributes feature','dbem' ) );
|
303 |
+
em_options_radio_binary ( sprintf(__( 'Enable %s custom fields?', 'dbem' ),__('event','dbem')), 'dbem_cp_events_custom_fields', __( 'Custom fields are the same as attributes, except you cannot restrict specific values, users can add any kind of custom field name/value pair. Only available in the WordPress admin area.','dbem' ) );
|
304 |
+
if( get_option('dbem_attributes_enabled') ){
|
305 |
+
em_options_textarea ( sprintf(__( '%s Attributes', 'dbem' ),__('Event','dbem')), 'dbem_placeholders_custom', sprintf(__( "You can also add event attributes here, one per line in this format <code>#_ATT{key}</code>. They will not appear on event pages unless you insert them into another template below, but you may want to store extra information about an event for other uses. <a href='%s'>More information on placeholders.</a>", 'dbem' ), EM_ADMIN_URL .'&page=events-manager-help') );
|
306 |
+
}
|
307 |
+
if( get_option('dbem_locations_enabled') ){
|
308 |
+
/*default location*/
|
309 |
+
$location_options = array();
|
310 |
+
$location_options[0] = __('no default location','dbem');
|
311 |
+
$EM_Locations = EM_Locations::get();
|
312 |
+
foreach($EM_Locations as $EM_Location){
|
313 |
+
$location_options[$EM_Location->location_id] = $EM_Location->location_name;
|
314 |
+
}
|
315 |
+
em_options_select ( __( 'Default Location', 'dbem' ), 'dbem_default_location', $location_options, __( 'This option allows you to select the default location when adding an event.','dbem' )." ".__('(not applicable with event ownership on presently, coming soon!)','dbem') );
|
316 |
+
|
317 |
+
/*default location country*/
|
318 |
+
em_options_select ( __( 'Default Location Country', 'dbem' ), 'dbem_location_default_country', em_get_countries(__('no default country', 'dbem')), __('If you select a default country, that will be pre-selected when creating a new location.','dbem') );
|
319 |
+
}
|
320 |
+
?>
|
321 |
+
<tr>
|
322 |
+
<td colspan="2">
|
323 |
+
<h4><?php echo sprintf(__('%s Settings','dbem'),__('Location','dbem')); ?></h4>
|
324 |
+
</td>
|
325 |
+
</tr>
|
326 |
+
<?php
|
327 |
+
em_options_radio_binary ( __( 'Enable locations?', 'dbem' ), 'dbem_locations_enabled', __( 'If you disable locations, bear in mind that you should remove your location page, shortcodes and related placeholders from your <a href="#formats" class="nav-tab-link" rel="#em-menu-formats">formats</a>.','dbem' ) );
|
328 |
+
if( get_option('dbem_locations_enabled') ){
|
329 |
+
em_options_radio_binary ( __( 'Require locations for events?', 'dbem' ), 'dbem_require_location', __( 'Setting this to no will allow you to submit events without locations. You can use the <code>{no_location}...{/no_location}</code> or <code>{has_location}..{/has_location}</code> conditional placeholder to selectively display location information.','dbem' ) );
|
330 |
+
em_options_radio_binary ( __( 'Use dropdown for locations?', 'dbem' ), 'dbem_use_select_for_locations', __( 'Select yes to select location from a drow-down menu; location selection will be faster, but you will lose the ability to insert locations with events','dbem' ) );
|
331 |
+
em_options_radio_binary ( sprintf(__( 'Enable %s attributes?', 'dbem' ),__('location','dbem')), 'dbem_location_attributes_enabled', __( 'Select yes to enable the attributes feature','dbem' ) );
|
332 |
+
em_options_radio_binary ( sprintf(__( 'Enable %s custom fields?', 'dbem' ),__('location','dbem')), 'dbem_cp_locations_custom_fields', __( 'Custom fields are the same as attributes, except you cannot restrict specific values, users can add any kind of custom field name/value pair. Only available in the WordPress admin area.','dbem' ) );
|
333 |
+
if( get_option('dbem_location_attributes_enabled') ){
|
334 |
+
em_options_textarea ( sprintf(__( '%s Attributes', 'dbem' ),__('Location','dbem')), 'dbem_location_placeholders_custom', sprintf(__( "You can also add location attributes here, one per line in this format <code>#_LATT{key}</code>. They will not appear on location pages unless you insert them into another template below, but you may want to store extra information about an event for other uses. <a href='%s'>More information on placeholders.</a>", 'dbem' ), EM_ADMIN_URL .'&page=events-manager-help') );
|
335 |
+
}
|
336 |
+
}
|
337 |
+
?>
|
338 |
+
<tr>
|
339 |
+
<td colspan="2">
|
340 |
+
<h4><?php echo sprintf(__('%s Settings','dbem'),__('Other','dbem')); ?></h4>
|
341 |
+
</td>
|
342 |
+
</tr>
|
343 |
+
<?php
|
344 |
+
em_options_radio_binary ( __('Show some love?','dbem'), 'dbem_credits', __( 'Hundreds of free hours have gone into making this free plugin, show your support and add a small link to the plugin website at the bottom of your event pages.','dbem' ) );
|
345 |
+
echo $save_button;
|
346 |
+
?>
|
347 |
+
</table>
|
348 |
+
|
349 |
+
</div> <!-- . inside -->
|
350 |
+
</div> <!-- .postbox -->
|
351 |
+
|
352 |
+
<?php if ( !is_multisite() ){ em_admin_option_box_image_sizes(); } ?>
|
353 |
+
|
354 |
+
<?php if ( !is_multisite() || (is_super_admin() && !get_site_option('dbem_ms_global_caps')) ){ em_admin_option_box_caps(); } ?>
|
355 |
+
|
356 |
+
<div class="postbox" id="em-opt-event-submissions" >
|
357 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Submission Forms', 'dbem' ); ?></span></h3>
|
358 |
+
<div class="inside">
|
359 |
+
<table class="form-table">
|
360 |
+
<tr><td colspan="2">
|
361 |
+
<?php echo sprintf(__('You can allow users to publicly submit events on your blog by using the %s shortcode, and enabling anonymous submissions below.','dbem'), '<code>[event_form]</code>'); ?>
|
362 |
+
</td></tr>
|
363 |
+
<?php
|
364 |
+
em_options_radio_binary ( __( 'Use Visual Editor?', 'dbem' ), 'dbem_events_form_editor', __( 'Users can now use the WordPress editor for easy HTML entry in the submission form.', 'dbem' ) );
|
365 |
+
em_options_radio_binary ( __( 'Show form again?', 'dbem' ), 'dbem_events_form_reshow', __( 'When a user submits their event, you can display a new event form again.', 'dbem' ) );
|
366 |
+
em_options_textarea ( __( 'Success Message', 'dbem' ), 'dbem_events_form_result_success', __( 'Customize the message your user sees when they submitted their event.', 'dbem' ).$events_placeholder_tip );
|
367 |
+
em_options_textarea ( __( 'Successfully Updated Message', 'dbem' ), 'dbem_events_form_result_success_updated', __( 'Customize the message your user sees when they resubmit/update their event.', 'dbem' ).$events_placeholder_tip );
|
368 |
+
?>
|
369 |
+
<tr><td colspan="2">
|
370 |
+
<strong><?php echo sprintf(__('Anonymous event submissions','dbem'), '<code>[event_form]</code>'); ?></strong>
|
371 |
+
</td></tr>
|
372 |
+
<?php
|
373 |
+
em_options_radio_binary ( __( 'Allow anonymous event submissions?', 'dbem' ), 'dbem_events_anonymous_submissions', __( 'Would you like to allow users to submit bookings anonymously? If so, you can use the new [event_form] shortcode or <code>em_event_form()</code> template tag with this enabled.', 'dbem' ) );
|
374 |
+
em_options_select ( __('Guest Default User', 'dbem'), 'dbem_events_anonymous_user', em_get_wp_users (), __( 'Events require a user to own them. In order to allow events to be submitted anonymously you need to assign that event a specific user. We recommend you create a "Anonymous" subscriber with a very good password and use that. Guests will have the same event permissions as this user when submitting.', 'dbem' ) );
|
375 |
+
em_options_textarea ( __( 'Success Message', 'dbem' ), 'dbem_events_anonymous_result_success', __( 'Anonymous submitters cannot see or modify their event once submitted. You can customize the success message they see here.', 'dbem' ).$events_placeholder_tip );
|
376 |
+
?>
|
377 |
+
<?php echo $save_button; ?>
|
378 |
+
</table>
|
379 |
+
</div> <!-- . inside -->
|
380 |
+
</div> <!-- .postbox -->
|
381 |
+
|
382 |
+
<?php do_action('em_options_page_footer'); ?>
|
383 |
+
|
384 |
+
<?php /*
|
385 |
+
<div class="postbox" id="em-opt-geo" >
|
386 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Geo APIs', 'dbem' ); ?> <em>(Beta)</em></span></h3>
|
387 |
+
<div class="inside">
|
388 |
+
<p><?php esc_html_e('Geocoding is the process of converting addresses into geographic coordinates, which can be used to find events and locations near a specific coordinate.','dbem'); ?></p>
|
389 |
+
<table class="form-table">
|
390 |
+
<?php
|
391 |
+
em_options_radio_binary ( __( 'Enable Geocoding Features?', 'dbem' ), 'dbem_geo', '', '', '.em-settings-geocoding');
|
392 |
+
?>
|
393 |
+
</table>
|
394 |
+
<div class="em-settings-geocoding">
|
395 |
+
<h4>GeoNames API (geonames.org)</h4>
|
396 |
+
<p>We make use of the <a href="http://www.geonames.org">GeoNames</a> web service to suggest locations/addresses to users when searching, and converting these into coordinates.</p>
|
397 |
+
<p>To be able to use these services, you must <a href="http://www.geonames.org/login">register an account</a>, activate the free webservice and enter your username below. You are allowed up to 30,000 requests per day, if you require more you can purchase credits from your account.</p>
|
398 |
+
<table class="form-table">
|
399 |
+
<?php em_options_input_text ( __( 'GeoNames Username', 'dbem' ), 'dbem_geonames_username', __('If left blank, this service will not be used.','dbem')); ?>
|
400 |
+
</table>
|
401 |
+
</div>
|
402 |
+
<table class="form-table"><?php echo $save_button; ?></table>
|
403 |
+
</div> <!-- . inside -->
|
404 |
+
</div> <!-- .postbox -->
|
405 |
+
*/ ?>
|
406 |
+
|
407 |
+
<div class="postbox" id="em-opt-performance-optimization" >
|
408 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Performance Optimization', 'dbem' ); ?> (<?php _e('Advanced','dbem'); ?>)</span></h3>
|
409 |
+
<div class="inside">
|
410 |
+
<?php
|
411 |
+
$performance_opt_page_instructions = __('In the boxes below, you are expected to write the page IDs. For multiple pages, use comma-seperated values e.g. 1,2,3. Entering 0 means EVERY page, -1 means the home page.','dbem');
|
412 |
+
?>
|
413 |
+
<p><?php _e('This section allows you to configure parts of this plugin that will improve performance on your site and increase page speeds by reducing extra files from being unnecessarily included on pages as well as reducing server loads where possible. This only applies to pages outside the admin area.','dbem'); ?></p>
|
414 |
+
<p><em><strong><?php _e('Warning!','dbem'); ?></strong> <?php echo sprintf(__('This is for advanced users, you should know what you\'re doing here or things will not work properly. For more information on how these options work see our <a href="%s" target="_blank">optimization recommendations</a>','dbem'), 'http://wp-events-plugin.com/documentation/optimization-recommendations/'); ?></em></p>
|
415 |
+
<table class="form-table">
|
416 |
+
<tr><td colspan="2">
|
417 |
+
<strong><?php _e('JavaScript Files','dbem'); ?></strong>
|
418 |
+
<p><?php echo sprintf(__('If you are not using it already, we recommend you try the <a href="%s" target="_blank">Use Google Libraries</a> plugin, because without further optimization options below it already significantly reduces the number of files needed to display your Event pages and will most likely speed up your overall website loading time.' ,'dbem'),'http://wordpress.org/extend/plugins/use-google-libraries/'); ?>
|
419 |
+
</td></tr>
|
420 |
+
<?php
|
421 |
+
em_options_radio_binary ( __( 'Limit JS file loading?', 'dbem' ), 'dbem_js_limit', __( 'Prevent unnecessary loading of JavaScript files on pages where they are not needed.', 'dbem' ) );
|
422 |
+
?>
|
423 |
+
<tbody id="dbem-js-limit-options">
|
424 |
+
<tr><td colspan="2">
|
425 |
+
<?php
|
426 |
+
_e('Aside from pages we automatically generate and include certain jQuery files, if you are using Widgets, Shortcode or PHP to display specific items you may need to tell us where you are using them for them to work properly. Below are options for you to include specific jQuery dependencies only on certain pages.','dbem');
|
427 |
+
echo $performance_opt_page_instructions;
|
428 |
+
?>
|
429 |
+
</td></tr>
|
430 |
+
<?php
|
431 |
+
em_options_input_text( __( 'General JS', 'dbem' ), 'dbem_js_limit_general', __( 'Loads our own JS file if no other dependencies are already loaded, which is still needed for many items generated by EM using JavaScript such as Calendars, Maps and Booking Forms/Buttons', 'dbem' ), 0 );
|
432 |
+
em_options_input_text( __( 'Search Forms', 'dbem' ), 'dbem_js_limit_search', __( 'Include pages where you use shortcodes or widgets to display event search forms.', 'dbem' ) );
|
433 |
+
em_options_input_text( __( 'Event Edit and Submission Forms', 'dbem' ), 'dbem_js_limit_events_form', __( 'Include pages where you use shortcode or PHP to display event submission forms.', 'dbem' ) );
|
434 |
+
em_options_input_text( __( 'Booking Management Pages', 'dbem' ), 'dbem_js_limit_edit_bookings', __( 'Include pages where you use shortcode or PHP to display event submission forms.', 'dbem' ) );
|
435 |
+
?>
|
436 |
+
</tbody>
|
437 |
+
<tr><td colspan="2" style="font-weight:bold;">
|
438 |
+
<?php _e('CSS File','dbem'); ?>
|
439 |
+
</td></tr>
|
440 |
+
<?php
|
441 |
+
em_options_radio_binary ( __( 'Limit loading of our CSS files?', 'dbem' ), 'dbem_css_limit', __( 'Enabling this will prevent us from loading our CSS file on every page, and will only load on specific pages generated by Events Manager.', 'dbem' ) );
|
442 |
+
?>
|
443 |
+
<tbody id="dbem-css-limit-options">
|
444 |
+
<tr><td colspan="2">
|
445 |
+
<?php echo $performance_opt_page_instructions; ?>
|
446 |
+
</td></tr>
|
447 |
+
<?php
|
448 |
+
em_options_input_text( __( 'Include on', 'dbem' ), 'dbem_css_limit_include', __( 'Our CSS file will only be INCLUDED on all of these pages.', 'dbem' ), 0 );
|
449 |
+
em_options_input_text( __( 'Exclude on', 'dbem' ), 'dbem_css_limit_exclude', __( 'Our CSS file will be EXCLUDED on all of these pages. Takes precedence over inclusion rules.', 'dbem' ), 0 );
|
450 |
+
?>
|
451 |
+
</tbody>
|
452 |
+
<?php
|
453 |
+
?>
|
454 |
+
<tr><td colspan="2">
|
455 |
+
<strong><?php _e('Thumbnails','dbem'); ?></strong>
|
456 |
+
<p><?php _e('By default we used to use TimThumb (in some cases we still do), which is supplied with our plugin, to generate all your thumbnails, alternatively you can use the default WordPress thumbnail generator which is less resource intensive.' ,'dbem'); ?>
|
457 |
+
</td></tr>
|
458 |
+
<?php
|
459 |
+
em_options_radio_binary ( __( 'Use WordPress thumbnails?', 'dbem' ), 'dbem_disable_timthumb', __( 'Recommended you enable this, as it will speed up your site page loading times if displaying many thumbnails on your pages.', 'dbem' ) );
|
460 |
+
?>
|
461 |
+
<?php echo $save_button; ?>
|
462 |
+
</table>
|
463 |
+
<script type="text/javascript">
|
464 |
+
jQuery(document).ready(function($){
|
465 |
+
$('input:radio[name="dbem_js_limit"]').change(function(){
|
466 |
+
if( $('input:radio[name="dbem_js_limit"]:checked').val() == 1 ){
|
467 |
+
$('tbody#dbem-js-limit-options').show();
|
468 |
+
}else{
|
469 |
+
$('tbody#dbem-js-limit-options').hide();
|
470 |
+
}
|
471 |
+
}).trigger('change');
|
472 |
+
|
473 |
+
$('input:radio[name="dbem_css_limit"]').change(function(){
|
474 |
+
if( $('input:radio[name="dbem_css_limit"]:checked').val() == 1 ){
|
475 |
+
$('tbody#dbem-css-limit-options').show();
|
476 |
+
}else{
|
477 |
+
$('tbody#dbem-css-limit-options').hide();
|
478 |
+
}
|
479 |
+
}).trigger('change');
|
480 |
+
});
|
481 |
+
</script>
|
482 |
+
</div> <!-- . inside -->
|
483 |
+
</div> <!-- .postbox -->
|
484 |
+
|
485 |
+
<div class="postbox" id="em-opt-style-options" >
|
486 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Styling Options', 'dbem' ); ?> (<?php _e('Advanced','dbem'); ?>) <em>(Beta)</em></span></h3>
|
487 |
+
<div class="inside">
|
488 |
+
<p>
|
489 |
+
<?php _e('Events Manager imposes a minimal amount of styling on websites so that your themes can take over.','dbem'); ?>
|
490 |
+
<?php _e('Below are some additional options for individual pages and sections, which you can turn on to enforce custom styling provided by the plugin or off if you want to do your own custom styling.','dbem'); ?>
|
491 |
+
</p>
|
492 |
+
<table class="form-table">
|
493 |
+
<?php
|
494 |
+
em_options_radio_binary ( __( 'Search forms', 'dbem' ), 'dbem_css_search');
|
495 |
+
?>
|
496 |
+
<tr><td colspan="2"><em>The options below currently have no effect, but are there so you know what may be added in future updates. You can leave them on if you want furture styling to take effect, or turn them off to keep your current styles as is.</em></td><tr>
|
497 |
+
<?php
|
498 |
+
em_options_radio_binary ( __( 'Event/Location admin pages', 'dbem' ), 'dbem_css_editors' );
|
499 |
+
em_options_radio_binary ( __( 'Booking admin pages', 'dbem' ), 'dbem_css_rsvpadmin' );
|
500 |
+
em_options_radio_binary ( __( 'Events list page', 'dbem' ), 'dbem_css_evlist' );
|
501 |
+
em_options_radio_binary ( __( 'Locations list page', 'dbem' ), 'dbem_css_loclist' );
|
502 |
+
em_options_radio_binary ( __( 'Event booking forms', 'dbem' ), 'dbem_css_rsvp' );
|
503 |
+
em_options_radio_binary ( __( 'Categories list page', 'dbem' ), 'dbem_css_catlist' );
|
504 |
+
em_options_radio_binary ( __( 'Tags list page', 'dbem' ), 'dbem_css_taglist' );
|
505 |
+
echo $save_button;
|
506 |
+
?>
|
507 |
+
</table>
|
508 |
+
</div> <!-- . inside -->
|
509 |
+
</div> <!-- .postbox -->
|
510 |
+
|
511 |
+
<?php if ( !is_multisite() ) { em_admin_option_box_uninstall(); } ?>
|
512 |
+
|
513 |
+
<?php if( get_option('dbem_migrate_images') ): ?>
|
514 |
+
<div class="postbox " >
|
515 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span>Migrate Images From Version 4</span></h3>
|
516 |
+
<div class="inside">
|
517 |
+
<?php /* Not translating as it's temporary */ ?>
|
518 |
+
<p>You have the option of migrating images from version 4 so they become the equivalent of 'featured images' like with regular WordPress posts and pages and are also available in your media library.</p>
|
519 |
+
<p>Your event and location images will still display correctly on the front-end even if you don't migrate, but will not show up within your edit location/event pages in the admin area.</p>
|
520 |
+
<p>
|
521 |
+
<a href="<?php echo $_SERVER['REQUEST_URI'] ?>&em_migrate_images=1&_wpnonce=<?php echo wp_create_nonce('em_migrate_images'); ?>" />Migrate Images</a><br />
|
522 |
+
<a href="<?php echo $_SERVER['REQUEST_URI'] ?>&em_not_migrate_images=1&_wpnonce=<?php echo wp_create_nonce('em_not_migrate_images'); ?>" />Do Not Migrate Images</a>
|
523 |
+
</p>
|
524 |
+
</div> <!-- . inside -->
|
525 |
+
</div> <!-- .postbox -->
|
526 |
+
<?php endif; ?>
|
527 |
+
</div> <!-- .em-menu-general -->
|
528 |
+
|
529 |
+
<!-- PAGE OPTIONS -->
|
530 |
+
<div class="em-menu-pages em-menu-group" style="display:none;">
|
531 |
+
<?php
|
532 |
+
$template_page_tip = __( "Many themes display extra meta information on post pages such as 'posted by' or 'post date' information, which may not be desired. Usually, page templates contain less clutter.", 'dbem' );
|
533 |
+
$template_page_tip .= ' '. __("If you choose 'Pages' then %s will be shown using your theme default page template, alternatively choose from page templates that come with your specific theme.",'dbem');
|
534 |
+
$template_page_tip .= ' '. str_replace('#','http://codex.wordpress.org/Post_Types#Template_Files',__("Be aware that some themes will not work with this option, if so (or you want to make your own changes), you can create a file named <code>single-%s.php</code> <a href='#'>as shown on the wordpress codex</a>, and leave this set to Posts.", 'dbem'));
|
535 |
+
$body_class_tip = __('If you would like to add extra classes to your body html tag when a single %s page is displayed, enter it here. May be useful or necessary if your theme requires special class names for specific templates.','dbem');
|
536 |
+
$post_class_tip = __('Same concept as the body classes option, but some themes also use the <code>post_class()</code> function within page content to differentiate styling between post types.','dbem');
|
537 |
+
$format_override_tip = __("By using formats, you can control how your %s are displayed from within the Events Manager <a href='#formats' class='nav-tab-link' rel='#em-menu-formats'>Formatting</a> tab above without having to edit your theme files.",'dbem');
|
538 |
+
$page_templates = array(''=>__('Posts'), 'page' => __('Pages'), __('Theme Templates','dbem') => array_flip(get_page_templates()));
|
539 |
+
?>
|
540 |
+
<div class="postbox" id="em-opt-permalinks" >
|
541 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('Permalink Slugs','dbem')); ?></span></h3>
|
542 |
+
<div class="inside">
|
543 |
+
<p><?php _e('You can change the permalink structure of your events, locations, categories and tags here. Be aware that you may want to set up redirects if you change your permalink structures to maintain SEO rankings.','dbem'); ?></p>
|
544 |
+
<table class="form-table">
|
545 |
+
<?php
|
546 |
+
em_options_input_text ( __( 'Events', 'dbem' ), 'dbem_cp_events_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem' ), '<strong>'.home_url().'/<code>'.get_option('dbem_cp_events_slug',EM_POST_TYPE_EVENT_SLUG).'</code>/2012-olympics/</strong>'), EM_POST_TYPE_EVENT_SLUG );
|
547 |
+
if( get_option('dbem_locations_enabled') ){
|
548 |
+
em_options_input_text ( __( 'Locations', 'dbem' ), 'dbem_cp_locations_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem' ), '<strong>'.home_url().'/<code>'.get_option('dbem_cp_locations_slug',EM_POST_TYPE_LOCATION_SLUG).'</code>/wembley-stadium/</strong>'), EM_POST_TYPE_LOCATION_SLUG );
|
549 |
+
}
|
550 |
+
if( get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site()) ){
|
551 |
+
em_options_input_text ( __( 'Event Categories', 'dbem' ), 'dbem_taxonomy_category_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem' ), '<strong>'.home_url().'/<code>'.get_option('dbem_taxonomy_category_slug',EM_TAXONOMY_CATEGORY_SLUG).'</code>/sports/</strong>'), EM_TAXONOMY_CATEGORY_SLUG );
|
552 |
+
}
|
553 |
+
if( get_option('dbem_tags_enabled') ){
|
554 |
+
em_options_input_text ( __( 'Event Tags', 'dbem' ), 'dbem_taxonomy_tag_slug', sprintf(__('e.g. %s - you can use / Separators too', 'dbem' ), '<strong>'.home_url().'/<code>'.get_option('dbem_taxonomy_tag_slug',EM_TAXONOMY_TAG_SLUG).'</code>/running/</strong>'), EM_TAXONOMY_TAG_SLUG );
|
555 |
+
}
|
556 |
+
echo $save_button;
|
557 |
+
?>
|
558 |
+
</table>
|
559 |
+
</div> <!-- . inside -->
|
560 |
+
</div> <!-- .postbox -->
|
561 |
+
|
562 |
+
<div class="postbox " id="em-opt-event-pages" >
|
563 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s Pages','dbem'),__('Event','dbem')); ?></span></h3>
|
564 |
+
<div class="inside">
|
565 |
+
<table class="form-table">
|
566 |
+
<?php
|
567 |
+
//em_options_radio_binary ( sprintf(__( 'Display %s as', 'dbem' ),__('events','dbem')), 'dbem_cp_events_template_page', sprintf($template_page_tip, EM_POST_TYPE_EVENT), array(__('Posts'),__('Pages')) );
|
568 |
+
em_options_select( sprintf(__( 'Display %s as', 'dbem' ),__('events','dbem')), 'dbem_cp_events_template', $page_templates, sprintf($template_page_tip, __('events','dbem'), EM_POST_TYPE_EVENT) );
|
569 |
+
em_options_input_text( __('Body Classes','dbem'), 'dbem_cp_events_body_class', sprintf($body_class_tip, __('event','dbem')) );
|
570 |
+
em_options_input_text( __('Post Classes','dbem'), 'dbem_cp_events_post_class', $post_class_tip );
|
571 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_events_formats', sprintf($format_override_tip,__('events','dbem')));
|
572 |
+
em_options_radio_binary ( __( 'Enable Comments?', 'dbem' ), 'dbem_cp_events_comments', sprintf(__('If you would like to disable comments entirely, disable this, otherwise you can disable comments on each single %s. Note that %s with comments enabled will still be until you resave them.','dbem'),__('event','dbem'),__('events','dbem')));
|
573 |
+
echo $save_button;
|
574 |
+
?>
|
575 |
+
</table>
|
576 |
+
</div> <!-- . inside -->
|
577 |
+
</div> <!-- .postbox -->
|
578 |
+
|
579 |
+
<div class="postbox " id="em-opt-event-archives" >
|
580 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s List/Archives','dbem'),__('Event','dbem')); ?></span></h3>
|
581 |
+
<div class="inside">
|
582 |
+
<table class="form-table">
|
583 |
+
<tr>
|
584 |
+
<td><?php echo sprintf(__( 'Events page', 'dbem' )); ?></td>
|
585 |
+
<td>
|
586 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_events_page', 'selected'=>get_option('dbem_events_page'), 'show_option_none'=>sprintf(__('[No %s Page]', 'dbem'),__('Events','dbem')) )); ?>
|
587 |
+
<br />
|
588 |
+
<em><?php echo __( 'This option allows you to select which page to use as an events page. If you do not select an events page, to display event lists you can enable event archives or use the appropriate shortcodes and/or template tags.','dbem' ); ?></em>
|
589 |
+
</td>
|
590 |
+
</tr>
|
591 |
+
<tbody class="em-event-page-options">
|
592 |
+
<?php
|
593 |
+
em_options_radio_binary ( __( 'Show events search?', 'dbem' ), 'dbem_events_page_search_form', __( "If set to yes, a search form will appear just above your list of events.", 'dbem' ) );
|
594 |
+
em_options_radio_binary ( __( 'Display calendar in events page?', 'dbem' ), 'dbem_display_calendar_in_events_page', __( 'This options allows to display the calendar in the events page, instead of the default list. It is recommended not to display both the calendar widget and a calendar page.','dbem' ).' '.__('If you would like to show events that span over more than one day, see the Calendar section on this page.','dbem') );
|
595 |
+
em_options_radio_binary ( __( 'Disable title rewriting?', 'dbem' ), 'dbem_disable_title_rewrites', __( "Some WordPress themes don't follow best practices when generating navigation menus, and so the automatic title rewriting feature may cause problems, if your menus aren't working correctly on the event pages, try setting this to 'Yes', and provide an appropriate HTML title format below.",'dbem' ) );
|
596 |
+
em_options_input_text ( __( 'Event Manager titles', 'dbem' ), 'dbem_title_html', __( "This only setting only matters if you selected 'Yes' to above. You will notice the events page titles aren't being rewritten, and you have a new title underneath the default page name. This is where you control the HTML of this title. Make sure you keep the #_PAGETITLE placeholder here, as that's what is rewritten by events manager. To control what's rewritten in this title, see settings further down for page titles.", 'dbem' ) );
|
597 |
+
?>
|
598 |
+
</tbody>
|
599 |
+
<tr>
|
600 |
+
<td colspan="2">
|
601 |
+
<h4><?php echo sprintf(__('WordPress %s Archives','dbem'), __('Event','dbem')); ?></h4>
|
602 |
+
<p><?php echo sprintf(__('%s custom post types can have archives, just like normal WordPress posts. If enabled, should you visit your base slug url %s and you will see an post-formatted archive of previous %s', 'dbem'), __('Event','dbem'), '<code>'.home_url().'/'.get_option('dbem_cp_events_slug',EM_POST_TYPE_EVENT_SLUG).'/</code>', __('events','dbem')); ?></p>
|
603 |
+
<p><?php echo sprintf(__('Note that assigning a %s page above will override this archive if the URLs collide (which is the default setting, and is recommended for maximum plugin compatibility). You can have both at the same time, but you must ensure that your page and %s slugs are different.','dbem'), __('events','dbem'), __('event','dbem')); ?></p>
|
604 |
+
</td>
|
605 |
+
</tr>
|
606 |
+
<tbody class="em-event-archive-options">
|
607 |
+
<?php
|
608 |
+
em_options_radio_binary ( __( 'Enable Archives?', 'dbem' ), 'dbem_cp_events_has_archive', __( "Allow WordPress post-style archives.", 'dbem' ) );
|
609 |
+
?>
|
610 |
+
</tbody>
|
611 |
+
<tbody class="em-event-archive-options em-event-archive-sub-options">
|
612 |
+
<tr valign="top">
|
613 |
+
<th scope="row"><?php _e('Default event archive ordering','dbem'); ?></th>
|
614 |
+
<td>
|
615 |
+
<select name="dbem_events_default_archive_orderby" >
|
616 |
+
<?php
|
617 |
+
$event_archive_orderby_options = apply_filters('em_settings_events_default_archive_orderby_ddm', array(
|
618 |
+
'_start_ts' => __('Order by start date, start time','dbem'),
|
619 |
+
'title' => __('Order by name','dbem')
|
620 |
+
));
|
621 |
+
?>
|
622 |
+
<?php foreach($event_archive_orderby_options as $key => $value) : ?>
|
623 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
624 |
+
<?php echo $value; ?>
|
625 |
+
</option>
|
626 |
+
<?php endforeach; ?>
|
627 |
+
</select>
|
628 |
+
<select name="dbem_events_default_archive_order" >
|
629 |
+
<?php
|
630 |
+
$ascending = __('Ascending','dbem');
|
631 |
+
$descending = __('Descending','dbem');
|
632 |
+
$event_archive_order_options = apply_filters('em_settings_events_default_archive_order_ddm', array(
|
633 |
+
'ASC' => __('Ascending','dbem'),
|
634 |
+
'DESC' => __('Descending','dbem')
|
635 |
+
));
|
636 |
+
?>
|
637 |
+
<?php foreach( $event_archive_order_options as $key => $value) : ?>
|
638 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
639 |
+
<?php echo $value; ?>
|
640 |
+
</option>
|
641 |
+
<?php endforeach; ?>
|
642 |
+
</select>
|
643 |
+
<br/>
|
644 |
+
<em><?php _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.','dbem'); ?></em>
|
645 |
+
</td>
|
646 |
+
</tr>
|
647 |
+
<?php
|
648 |
+
em_options_select( __('Event archives scope','dbem'), 'dbem_events_archive_scope', em_get_scopes() );
|
649 |
+
?>
|
650 |
+
</tbody>
|
651 |
+
<tr>
|
652 |
+
<td colspan="2">
|
653 |
+
<h4><?php echo _e('General settings','dbem'); ?></h4>
|
654 |
+
</td>
|
655 |
+
</tr>
|
656 |
+
<?php
|
657 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_events_archive_formats', sprintf($format_override_tip,__('events','dbem')));
|
658 |
+
em_options_radio_binary ( __( 'Are current events past events?', 'dbem' ), 'dbem_events_current_are_past', __( "By default, events that are have an end date later than today will be included in searches, set this to yes to consider events that started 'yesterday' as past.", 'dbem' ) );
|
659 |
+
em_options_radio_binary ( __( 'Include in WordPress Searches?', 'dbem' ), 'dbem_cp_events_search_results', sprintf(__( "Allow %s to appear in the built-in search results.", 'dbem' ),__('events','dbem')) );
|
660 |
+
?>
|
661 |
+
<tr>
|
662 |
+
<td colspan="2">
|
663 |
+
<h4><?php echo sprintf(__('Default %s list options','dbem'), __('event','dbem')); ?></h4>
|
664 |
+
<p><?php _e('These can be overriden when using shortcode or template tags.','dbem'); ?></p>
|
665 |
+
</td>
|
666 |
+
</tr>
|
667 |
+
<tr valign="top" id='dbem_events_default_orderby_row'>
|
668 |
+
<th scope="row"><?php _e('Default event list ordering','dbem'); ?></th>
|
669 |
+
<td>
|
670 |
+
<select name="dbem_events_default_orderby" >
|
671 |
+
<?php
|
672 |
+
$orderby_options = apply_filters('em_settings_events_default_orderby_ddm', array(
|
673 |
+
'event_start_date,event_start_time,event_name' => __('Order by start date, start time, then event name','dbem'),
|
674 |
+
'event_name,event_start_date,event_start_time' => __('Order by name, start date, then start time','dbem'),
|
675 |
+
'event_name,event_end_date,event_end_time' => __('Order by name, end date, then end time','dbem'),
|
676 |
+
'event_end_date,event_end_time,event_name' => __('Order by end date, end time, then event name','dbem'),
|
677 |
+
));
|
678 |
+
?>
|
679 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
680 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_orderby')) ? "selected='selected'" : ''; ?>>
|
681 |
+
<?php echo $value; ?>
|
682 |
+
</option>
|
683 |
+
<?php endforeach; ?>
|
684 |
+
</select>
|
685 |
+
<select name="dbem_events_default_order" >
|
686 |
+
<?php
|
687 |
+
$ascending = __('Ascending','dbem');
|
688 |
+
$descending = __('Descending','dbem');
|
689 |
+
$order_options = apply_filters('em_settings_events_default_order_ddm', array(
|
690 |
+
'ASC' => __('All Ascending','dbem'),
|
691 |
+
'DESC,ASC,ASC' => __("$descending, $ascending, $ascending",'dbem'),
|
692 |
+
'DESC,DESC,ASC' => __("$descending, $descending, $ascending",'dbem'),
|
693 |
+
'DESC' => __('All Descending','dbem'),
|
694 |
+
'ASC,DESC,ASC' => __("$ascending, $descending, $ascending",'dbem'),
|
695 |
+
'ASC,DESC,DESC' => __("$ascending, $descending, $descending",'dbem'),
|
696 |
+
'ASC,ASC,DESC' => __("$ascending, $ascending, $descending",'dbem'),
|
697 |
+
'DESC,ASC,DESC' => __("$descending, $ascending, $descending",'dbem'),
|
698 |
+
));
|
699 |
+
?>
|
700 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
701 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_order')) ? "selected='selected'" : ''; ?>>
|
702 |
+
<?php echo $value; ?>
|
703 |
+
</option>
|
704 |
+
<?php endforeach; ?>
|
705 |
+
</select>
|
706 |
+
<br/>
|
707 |
+
<em><?php _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.','dbem'); ?></em>
|
708 |
+
</td>
|
709 |
+
</tr>
|
710 |
+
<?php
|
711 |
+
em_options_select( __('Event list scope','dbem'), 'dbem_events_page_scope', em_get_scopes(), __('Only show events starting within a certain time limit on the events page. Default is future events with no end time limit.','dbem') );
|
712 |
+
em_options_input_text ( __( 'Event List Limits', 'dbem' ), 'dbem_events_default_limit', __( "This will control how many events are shown on one list by default.", 'dbem' ) );
|
713 |
+
echo $save_button;
|
714 |
+
?>
|
715 |
+
</table>
|
716 |
+
</div> <!-- . inside -->
|
717 |
+
</div> <!-- .postbox -->
|
718 |
+
|
719 |
+
<?php if( get_option('dbem_locations_enabled') ): ?>
|
720 |
+
<div class="postbox " id="em-opt-location-pages" >
|
721 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s Pages','dbem'),__('Location','dbem')); ?></span></h3>
|
722 |
+
<div class="inside">
|
723 |
+
<table class="form-table">
|
724 |
+
<?php
|
725 |
+
//em_options_radio_binary ( sprintf(__( 'Display %s as', 'dbem' ),__('locations','dbem')), 'dbem_cp_locations_template_page', sprintf($template_page_tip, EM_POST_TYPE_LOCATION), array(__('Posts'),__('Pages')) );
|
726 |
+
em_options_select( sprintf(__( 'Display %s as', 'dbem' ),__('locations','dbem')), 'dbem_cp_locations_template', $page_templates, sprintf($template_page_tip, __('locations','dbem'), EM_POST_TYPE_LOCATION) );
|
727 |
+
em_options_input_text( __('Body Classes','dbem'), 'dbem_cp_locations_body_class', sprintf($body_class_tip, __('location','dbem')) );
|
728 |
+
em_options_input_text( __('Post Classes','dbem'), 'dbem_cp_locations_post_class', $post_class_tip );
|
729 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_locations_formats', sprintf($format_override_tip,__('locations','dbem')));
|
730 |
+
em_options_radio_binary ( __( 'Enable Comments?', 'dbem' ), 'dbem_cp_locations_comments', sprintf(__('If you would like to disable comments entirely, disable this, otherwise you can disable comments on each single %s. Note that %s with comments enabled will still be until you resave them.','dbem'),__('location','dbem'),__('locations','dbem')));
|
731 |
+
em_options_input_text ( __( 'Event List Limits', 'dbem' ), 'dbem_location_event_list_limit', sprintf(__( "Controls how many events being held at a location are shown per page when using placeholders such as %s. Leave blank for no limit.", 'dbem' ), '<code>#_LOCATIONNEXTEVENTS</code>') );
|
732 |
+
echo $save_button;
|
733 |
+
?>
|
734 |
+
</table>
|
735 |
+
</div> <!-- . inside -->
|
736 |
+
</div> <!-- .postbox -->
|
737 |
+
|
738 |
+
<div class="postbox " id="em-opt-location-archives" >
|
739 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s List/Archives','dbem'),__('Location','dbem')); ?></span></h3>
|
740 |
+
<div class="inside">
|
741 |
+
<table class="form-table">
|
742 |
+
<tr>
|
743 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Locations','dbem')); ?></td>
|
744 |
+
<td>
|
745 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_locations_page', 'selected'=>get_option('dbem_locations_page'), 'show_option_none'=>sprintf(__('[No %s Page]', 'dbem'),__('Locations','dbem')) )); ?>
|
746 |
+
<br />
|
747 |
+
<em><?php echo sprintf(__( 'This option allows you to select which page to use as the %s page. If you do not select a %s page, to display lists you can enable archives or use the appropriate shortcodes and/or template tags.','dbem' ),__('locations','dbem'),__('locations','dbem')); ?></em>
|
748 |
+
</td>
|
749 |
+
</tr>
|
750 |
+
<?php
|
751 |
+
em_options_radio_binary ( __( 'Show locations search?', 'dbem' ), 'dbem_locations_page_search_form', __( "If set to yes, a search form will appear just above your list of locations.", 'dbem' ) );
|
752 |
+
?>
|
753 |
+
<tr>
|
754 |
+
<td colspan="2">
|
755 |
+
<h4><?php echo sprintf(__('WordPress %s Archives','dbem'), __('Location','dbem')); ?></h4>
|
756 |
+
<p><?php echo sprintf(__('%s custom post types can have archives, just like normal WordPress posts. If enabled, should you visit your base slug url %s and you will see an post-formatted archive of previous %s', 'dbem'), __('Location','dbem'), '<code>'.home_url().'/'.get_option('dbem_cp_events_slug',EM_POST_TYPE_LOCATION_SLUG).'/</code>', __('locations','dbem')); ?></p>
|
757 |
+
<p><?php echo sprintf(__('Note that assigning a %s page above will override this archive if the URLs collide (which is the default settings, and is recommended for maximum plugin compatibility). You can have both at the same time, but you must ensure that your page and %s slugs are different.','dbem'), __('locations','dbem'), __('location','dbem')); ?></p>
|
758 |
+
</td>
|
759 |
+
</tr>
|
760 |
+
<tbody class="em-location-archive-options">
|
761 |
+
<?php
|
762 |
+
em_options_radio_binary ( __( 'Enable Archives?', 'dbem' ), 'dbem_cp_locations_has_archive', __( "Allow WordPress post-style archives.", 'dbem' ) );
|
763 |
+
?>
|
764 |
+
</tbody>
|
765 |
+
<tbody class="em-location-archive-options em-location-archive-sub-options">
|
766 |
+
<tr valign="top">
|
767 |
+
<th scope="row"><?php _e('Default archive ordering','dbem'); ?></th>
|
768 |
+
<td>
|
769 |
+
<select name="dbem_locations_default_archive_orderby" >
|
770 |
+
<?php
|
771 |
+
$orderby_options = apply_filters('em_settings_locations_default_archive_orderby_ddm', array(
|
772 |
+
'_country' => sprintf(__('Order by %s','dbem'),__('Country','dbem')),
|
773 |
+
'_town' => sprintf(__('Order by %s','dbem'),__('Town','dbem')),
|
774 |
+
'title' => sprintf(__('Order by %s','dbem'),__('Name','dbem'))
|
775 |
+
));
|
776 |
+
?>
|
777 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
778 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
779 |
+
<?php echo $value; ?>
|
780 |
+
</option>
|
781 |
+
<?php endforeach; ?>
|
782 |
+
</select>
|
783 |
+
<select name="dbem_locations_default_archive_order" >
|
784 |
+
<?php
|
785 |
+
$ascending = __('Ascending','dbem');
|
786 |
+
$descending = __('Descending','dbem');
|
787 |
+
$order_options = apply_filters('em_settings_locations_default_archive_order_ddm', array(
|
788 |
+
'ASC' => __('Ascending','dbem'),
|
789 |
+
'DESC' => __('Descending','dbem')
|
790 |
+
));
|
791 |
+
?>
|
792 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
793 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
794 |
+
<?php echo $value; ?>
|
795 |
+
</option>
|
796 |
+
<?php endforeach; ?>
|
797 |
+
</select>
|
798 |
+
</td>
|
799 |
+
</tr>
|
800 |
+
</tbody>
|
801 |
+
<tr>
|
802 |
+
<td colspan="2">
|
803 |
+
<h4><?php echo _e('General settings','dbem'); ?></h4>
|
804 |
+
</td>
|
805 |
+
</tr>
|
806 |
+
<?php
|
807 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_locations_archive_formats', sprintf($format_override_tip,__('locations','dbem')));
|
808 |
+
em_options_radio_binary ( __( 'Include in WordPress Searches?', 'dbem' ), 'dbem_cp_locations_search_results', sprintf(__( "Allow %s to appear in the built-in search results.", 'dbem' ),__('locations','dbem')) );
|
809 |
+
?>
|
810 |
+
<tr>
|
811 |
+
<td colspan="2">
|
812 |
+
<h4><?php echo sprintf(__('Default %s list options','dbem'), __('location','dbem')); ?></h4>
|
813 |
+
<p><?php _e('These can be overriden when using shortcode or template tags.','dbem'); ?></p>
|
814 |
+
</td>
|
815 |
+
</tr>
|
816 |
+
<tr valign="top" id='dbem_locations_default_orderby_row'>
|
817 |
+
<th scope="row"><?php _e('Default list ordering','dbem'); ?></th>
|
818 |
+
<td>
|
819 |
+
<select name="dbem_locations_default_orderby" >
|
820 |
+
<?php
|
821 |
+
$orderby_options = apply_filters('em_settings_locations_default_orderby_ddm', array(
|
822 |
+
'location_country' => sprintf(__('Order by %s','dbem'),__('Country','dbem')),
|
823 |
+
'location_town' => sprintf(__('Order by %s','dbem'),__('Town','dbem')),
|
824 |
+
'location_name' => sprintf(__('Order by %s','dbem'),__('Name','dbem'))
|
825 |
+
));
|
826 |
+
?>
|
827 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
828 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_orderby')) ? "selected='selected'" : ''; ?>>
|
829 |
+
<?php echo $value; ?>
|
830 |
+
</option>
|
831 |
+
<?php endforeach; ?>
|
832 |
+
</select>
|
833 |
+
<select name="dbem_locations_default_order" >
|
834 |
+
<?php
|
835 |
+
$ascending = __('Ascending','dbem');
|
836 |
+
$descending = __('Descending','dbem');
|
837 |
+
$order_options = apply_filters('em_settings_locations_default_order_ddm', array(
|
838 |
+
'ASC' => __('Ascending','dbem'),
|
839 |
+
'DESC' => __('Descending','dbem')
|
840 |
+
));
|
841 |
+
?>
|
842 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
843 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_order')) ? "selected='selected'" : ''; ?>>
|
844 |
+
<?php echo $value; ?>
|
845 |
+
</option>
|
846 |
+
<?php endforeach; ?>
|
847 |
+
</select>
|
848 |
+
</td>
|
849 |
+
</tr>
|
850 |
+
<?php
|
851 |
+
em_options_input_text ( __( 'List Limits', 'dbem' ), 'dbem_locations_default_limit', sprintf(__( "This will control how many %s are shown on one list by default.", 'dbem' ),__('locations','dbem')) );
|
852 |
+
echo $save_button;
|
853 |
+
?>
|
854 |
+
</table>
|
855 |
+
</div> <!-- . inside -->
|
856 |
+
</div> <!-- .postbox -->
|
857 |
+
<?php endif; ?>
|
858 |
+
|
859 |
+
<?php if( get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site()) ): ?>
|
860 |
+
<div class="postbox " id="em-opt-categories-pages" >
|
861 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo __('Event Categories','dbem'); ?></span></h3>
|
862 |
+
<div class="inside">
|
863 |
+
<p>
|
864 |
+
<?php echo sprintf(__('%s are a <a href="%s" target="_blank">WordPress custom taxonomy</a>.','dbem'), __('Event Categories','dbem'), 'http://codex.wordpress.org/Taxonomies');?>
|
865 |
+
<?php echo sprintf(__('%s can be displayed just like normal WordPress custom taxonomies in an archive-style format, however Events Manager by default allows you to completely change the standard look of these archives and use our own <a href="%s">custom formatting</a> methods.','dbem'), __('Event Categories','dbem'), EM_ADMIN_URL .'&page=events-manager-help#event-placeholders'); ?>
|
866 |
+
</p>
|
867 |
+
<p>
|
868 |
+
<?php echo sprintf(__('Due to how we change how this custom taxonomy is displayed when overriding with formats it is strongly advised that you assign a %s page below, which increases comatability with various plugins and themes.','dbem'), __('categories','dbem')); ?>
|
869 |
+
<?php sprintf(__('<a href="%s">See some more information</a> on how %s work when overriding with formats.','dbem'), '#', __('categories','dbem')); //not ready yet, but make translatable ?>
|
870 |
+
</p>
|
871 |
+
<table class="form-table">
|
872 |
+
<tr>
|
873 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Categories','dbem')); ?></td>
|
874 |
+
<td>
|
875 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_categories_page','selected'=>get_option('dbem_categories_page'), 'show_option_none'=>sprintf(__('[No %s Page]', 'dbem'),__('Categories','dbem')) )); ?>
|
876 |
+
<br />
|
877 |
+
<em><?php echo sprintf(__( 'This option allows you to select which page to use as the %s page.','dbem' ),__('categories','dbem')); ?></em>
|
878 |
+
</td>
|
879 |
+
</tr>
|
880 |
+
<tr>
|
881 |
+
<td colspan="2">
|
882 |
+
<h4><?php echo _e('General settings','dbem'); ?></h4>
|
883 |
+
</td>
|
884 |
+
</tr>
|
885 |
+
<?php
|
886 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_categories_formats', sprintf($format_override_tip,__('categories','dbem'))." ".__('Setting this to yes will make categories display as a page rather than an archive.', 'dbem'));
|
887 |
+
?>
|
888 |
+
<tr valign="top">
|
889 |
+
<th scope="row"><?php _e('Default archive ordering','dbem'); ?></th>
|
890 |
+
<td>
|
891 |
+
<select name="dbem_categories_default_archive_orderby" >
|
892 |
+
<?php foreach($event_archive_orderby_options as $key => $value) : ?>
|
893 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
894 |
+
<?php echo $value; ?>
|
895 |
+
</option>
|
896 |
+
<?php endforeach; ?>
|
897 |
+
</select>
|
898 |
+
<select name="dbem_categories_default_archive_order" >
|
899 |
+
<?php foreach( $event_archive_order_options as $key => $value) : ?>
|
900 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
901 |
+
<?php echo $value; ?>
|
902 |
+
</option>
|
903 |
+
<?php endforeach; ?>
|
904 |
+
</select>
|
905 |
+
<br /><?php echo __('When listing events for a category, this order is applied.', 'dbem'); ?>
|
906 |
+
</td>
|
907 |
+
</tr>
|
908 |
+
<tr>
|
909 |
+
<td colspan="2">
|
910 |
+
<h4><?php echo sprintf(__('Default %s list options','dbem'), __('category','dbem')); ?></h4>
|
911 |
+
<p><?php _e('These can be overriden when using shortcode or template tags.','dbem'); ?></p>
|
912 |
+
</td>
|
913 |
+
</tr>
|
914 |
+
<tr valign="top" id='dbem_categories_default_orderby_row'>
|
915 |
+
<th scope="row"><?php _e('Default list ordering','dbem'); ?></th>
|
916 |
+
<td>
|
917 |
+
<select name="dbem_categories_default_orderby" >
|
918 |
+
<?php
|
919 |
+
$orderby_options = apply_filters('em_settings_categories_default_orderby_ddm', array(
|
920 |
+
'id' => sprintf(__('Order by %s','dbem'),__('ID','dbem')),
|
921 |
+
'count' => sprintf(__('Order by %s','dbem'),__('Count','dbem')),
|
922 |
+
'name' => sprintf(__('Order by %s','dbem'),__('Name','dbem')),
|
923 |
+
'slug' => sprintf(__('Order by %s','dbem'),__('Slug','dbem')),
|
924 |
+
'term_group' => sprintf(__('Order by %s','dbem'),'term_group'),
|
925 |
+
));
|
926 |
+
?>
|
927 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
928 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_orderby')) ? "selected='selected'" : ''; ?>>
|
929 |
+
<?php echo $value; ?>
|
930 |
+
</option>
|
931 |
+
<?php endforeach; ?>
|
932 |
+
</select>
|
933 |
+
<select name="dbem_categories_default_order" >
|
934 |
+
<?php
|
935 |
+
$ascending = __('Ascending','dbem');
|
936 |
+
$descending = __('Descending','dbem');
|
937 |
+
$order_options = apply_filters('em_settings_categories_default_order_ddm', array(
|
938 |
+
'ASC' => __('Ascending','dbem'),
|
939 |
+
'DESC' => __('Descending','dbem')
|
940 |
+
));
|
941 |
+
?>
|
942 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
943 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_order')) ? "selected='selected'" : ''; ?>>
|
944 |
+
<?php echo $value; ?>
|
945 |
+
</option>
|
946 |
+
<?php endforeach; ?>
|
947 |
+
</select>
|
948 |
+
<br /><?php echo __('When listing categories, this order is applied.', 'dbem'); ?>
|
949 |
+
</td>
|
950 |
+
</tr>
|
951 |
+
<?php
|
952 |
+
em_options_input_text ( __( 'List Limits', 'dbem' ), 'dbem_categories_default_limit', sprintf(__( "This will control how many %s are shown on one list by default.", 'dbem' ),__('categories','dbem')) );
|
953 |
+
em_options_input_text ( __( 'Event List Limits', 'dbem' ), 'dbem_category_event_list_limit', sprintf(__( "Controls how many events belonging to a category are shown per page when using placeholders such as %s. Leave blank for no limit.", 'dbem' ), '<code>#_CATEGORYNEXTEVENTS</code>') );
|
954 |
+
echo $save_button;
|
955 |
+
?>
|
956 |
+
</table>
|
957 |
+
</div> <!-- . inside -->
|
958 |
+
</div> <!-- .postbox -->
|
959 |
+
<?php endif; ?>
|
960 |
+
|
961 |
+
<?php if( get_option('dbem_tags_enabled') ): //disabled for now, will add tag stuff later ?>
|
962 |
+
<div class="postbox " id="em-opt-tags-pages" >
|
963 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo __('Event Tags','dbem'); ?></span></h3>
|
964 |
+
<div class="inside">
|
965 |
+
<p>
|
966 |
+
<?php echo sprintf(__('%s are a <a href="%s" target="_blank">WordPress custom taxonomy</a>.','dbem'), __('Event Tags','dbem'), 'http://codex.wordpress.org/Taxonomies');?>
|
967 |
+
<?php echo sprintf(__('%s can be displayed just like normal WordPress custom taxonomies in an archive-style format, however Events Manager by default allows you to completely change the standard look of these archives and use our own <a href="%s">custom formatting</a> methods.','dbem'), __('Event Tags','dbem'), EM_ADMIN_URL .'&page=events-manager-help#event-placeholders'); ?>
|
968 |
+
</p>
|
969 |
+
<p>
|
970 |
+
<?php echo sprintf(__('Due to how we change how this custom taxonomy is displayed when overriding with formats it is strongly advised that you assign a %s page below, which increases comatability with various plugins and themes.','dbem'), __('tags','dbem')); ?>
|
971 |
+
<?php sprintf(__('<a href="%s">See some more information</a> on how %s work when overriding with formats.','dbem'), '#', __('tags','dbem')); //not ready yet, but make translatable ?>
|
972 |
+
</p>
|
973 |
+
<table class="form-table">
|
974 |
+
<tr>
|
975 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Tags','dbem')); ?></td>
|
976 |
+
<td>
|
977 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_tags_page','selected'=>get_option('dbem_tags_page'), 'show_option_none'=>sprintf(__('[No %s Page]', 'dbem'),__('Tags','dbem')) )); ?>
|
978 |
+
<br />
|
979 |
+
<em><?php echo sprintf(__( 'This option allows you to select which page to use as the %s page.','dbem' ),__('tags','dbem'),__('tags','dbem')); ?></em>
|
980 |
+
</td>
|
981 |
+
</tr>
|
982 |
+
<tr>
|
983 |
+
<td colspan="2">
|
984 |
+
<h4><?php echo _e('General settings','dbem'); ?></h4>
|
985 |
+
</td>
|
986 |
+
</tr>
|
987 |
+
<?php
|
988 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_tags_formats', sprintf($format_override_tip,__('tags','dbem')));
|
989 |
+
?>
|
990 |
+
<tr valign="top">
|
991 |
+
<th scope="row"><?php _e('Default archive ordering','dbem'); ?></th>
|
992 |
+
<td>
|
993 |
+
<select name="dbem_tags_default_archive_orderby" >
|
994 |
+
<?php foreach($event_archive_orderby_options as $key => $value) : ?>
|
995 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_tags_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
996 |
+
<?php echo $value; ?>
|
997 |
+
</option>
|
998 |
+
<?php endforeach; ?>
|
999 |
+
</select>
|
1000 |
+
<select name="dbem_tags_default_archive_order" >
|
1001 |
+
<?php foreach( $event_archive_order_options as $key => $value) : ?>
|
1002 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_tags_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
1003 |
+
<?php echo $value; ?>
|
1004 |
+
</option>
|
1005 |
+
<?php endforeach; ?>
|
1006 |
+
</select>
|
1007 |
+
</td>
|
1008 |
+
</tr>
|
1009 |
+
<tr>
|
1010 |
+
<td colspan="2">
|
1011 |
+
<h4><?php echo sprintf(__('Default %s list options','dbem'), __('tag','dbem')); ?></h4>
|
1012 |
+
<p><?php _e('These can be overriden when using shortcode or template tags.','dbem'); ?></p>
|
1013 |
+
</td>
|
1014 |
+
</tr>
|
1015 |
+
<tr valign="top" id='dbem_tags_default_orderby_row'>
|
1016 |
+
<th scope="row"><?php _e('Default list ordering','dbem'); ?></th>
|
1017 |
+
<td>
|
1018 |
+
<select name="dbem_tags_default_orderby" >
|
1019 |
+
<?php
|
1020 |
+
$orderby_options = apply_filters('em_settings_tags_default_orderby_ddm', array(
|
1021 |
+
'id' => sprintf(__('Order by %s','dbem'),__('ID','dbem')),
|
1022 |
+
'count' => sprintf(__('Order by %s','dbem'),__('Count','dbem')),
|
1023 |
+
'name' => sprintf(__('Order by %s','dbem'),__('Name','dbem')),
|
1024 |
+
'slug' => sprintf(__('Order by %s','dbem'),__('Slug','dbem')),
|
1025 |
+
'term_group' => sprintf(__('Order by %s','dbem'),'term_group'),
|
1026 |
+
));
|
1027 |
+
?>
|
1028 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
1029 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_tags_default_orderby')) ? "selected='selected'" : ''; ?>>
|
1030 |
+
<?php echo $value; ?>
|
1031 |
+
</option>
|
1032 |
+
<?php endforeach; ?>
|
1033 |
+
</select>
|
1034 |
+
<select name="dbem_tags_default_order" >
|
1035 |
+
<?php
|
1036 |
+
$ascending = __('Ascending','dbem');
|
1037 |
+
$descending = __('Descending','dbem');
|
1038 |
+
$order_options = apply_filters('em_settings_tags_default_order_ddm', array(
|
1039 |
+
'ASC' => __('Ascending','dbem'),
|
1040 |
+
'DESC' => __('Descending','dbem')
|
1041 |
+
));
|
1042 |
+
?>
|
1043 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
1044 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_tags_default_order')) ? "selected='selected'" : ''; ?>>
|
1045 |
+
<?php echo $value; ?>
|
1046 |
+
</option>
|
1047 |
+
<?php endforeach; ?>
|
1048 |
+
</select>
|
1049 |
+
<br /><?php echo __('When listing tags, this order is applied.', 'dbem'); ?>
|
1050 |
+
</td>
|
1051 |
+
</tr>
|
1052 |
+
<?php
|
1053 |
+
em_options_input_text ( __( 'List Limits', 'dbem' ), 'dbem_tags_default_limit', sprintf(__( "This will control how many %s are shown on one list by default.", 'dbem' ),__('tags','dbem')) );
|
1054 |
+
em_options_input_text ( __( 'Event List Limits', 'dbem' ), 'dbem_tag_event_list_limit', sprintf(__( "Controls how many events belonging to a tag are shown per page when using placeholders such as %s. Leave blank for no limit.", 'dbem' ), '<code>#_TAGNEXTEVENTS</code>') );
|
1055 |
+
echo $save_button; ?>
|
1056 |
+
</table>
|
1057 |
+
</div> <!-- . inside -->
|
1058 |
+
</div> <!-- .postbox -->
|
1059 |
+
<?php endif; ?>
|
1060 |
+
|
1061 |
+
<div class="postbox " id="em-opt-other-pages" >
|
1062 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s Pages','dbem'),__('Other','dbem')); ?></span></h3>
|
1063 |
+
<div class="inside">
|
1064 |
+
<table class="form-table">
|
1065 |
+
<tr><td colspan="2"><?php _e('These pages allow you to provide an event management interface outside the admin area on whatever page you want on your website. Bear in mind that this is overriden by BuddyPress if activated.', 'dbem'); ?></td></tr>
|
1066 |
+
<?php
|
1067 |
+
$other_pages_tip = 'Using the %s shortcode, you can allow users to manage %s outside the admin area.';
|
1068 |
+
?>
|
1069 |
+
<tr>
|
1070 |
+
<td colspan="2">
|
1071 |
+
<h4><?php _e('My Bookings','dbem'); ?></h4>
|
1072 |
+
<p><?php _e('This page is where people that have made bookings for an event can go and view their previous bookings.','dbem'); ?>
|
1073 |
+
</td>
|
1074 |
+
</tr>
|
1075 |
+
<tr>
|
1076 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('My bookings','dbem')); ?>
|
1077 |
+
</td>
|
1078 |
+
<td>
|
1079 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_my_bookings_page', 'selected'=>get_option('dbem_my_bookings_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1080 |
+
<br />
|
1081 |
+
<em><?php echo sprintf(__('Users can view their bookings for other events on this page.','dbem' ),'<code>[my_bookings]</code>',__('bookings','dbem')); ?></em>
|
1082 |
+
</td>
|
1083 |
+
</tr>
|
1084 |
+
<tr valign="top" id='dbem_bookings_default_orderby_row'>
|
1085 |
+
<th scope="row"><?php _e('Default list ordering','dbem'); ?></th>
|
1086 |
+
<td>
|
1087 |
+
<select name="dbem_bookings_default_orderby" >
|
1088 |
+
<?php
|
1089 |
+
$orderby_options = apply_filters('em_settings_bookings_default_orderby_ddm', array(
|
1090 |
+
'event_name' => sprintf(__('Order by %s','dbem'),__('Event Name','dbem')),
|
1091 |
+
'event_start_date' => sprintf(__('Order by %s','dbem'),__('Start Date','dbem')),
|
1092 |
+
'booking_date' => sprintf(__('Order by %s','dbem'),__('Booking Date','dbem'))
|
1093 |
+
));
|
1094 |
+
?>
|
1095 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
1096 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_bookings_default_orderby')) ? "selected='selected'" : ''; ?>>
|
1097 |
+
<?php echo $value; ?>
|
1098 |
+
</option>
|
1099 |
+
<?php endforeach; ?>
|
1100 |
+
</select>
|
1101 |
+
<select name="dbem_bookings_default_order" >
|
1102 |
+
<?php
|
1103 |
+
$ascending = __('Ascending','dbem');
|
1104 |
+
$descending = __('Descending','dbem');
|
1105 |
+
$order_options = apply_filters('em_settings_bookings_default_order_ddm', array(
|
1106 |
+
'ASC' => __('Ascending','dbem'),
|
1107 |
+
'DESC' => __('Descending','dbem')
|
1108 |
+
));
|
1109 |
+
?>
|
1110 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
1111 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_bookings_default_order')) ? "selected='selected'" : ''; ?>>
|
1112 |
+
<?php echo $value; ?>
|
1113 |
+
</option>
|
1114 |
+
<?php endforeach; ?>
|
1115 |
+
</select>
|
1116 |
+
</td>
|
1117 |
+
</tr>
|
1118 |
+
<tr>
|
1119 |
+
<td colspan="2">
|
1120 |
+
<h4><?php _e('Front-end management pages','dbem'); ?></h4>
|
1121 |
+
<p><?php _e('Users with the relevant permissions can manage their own events and bookings to these events on the following pages.','dbem'); ?></p>
|
1122 |
+
</td>
|
1123 |
+
</tr>
|
1124 |
+
<tr>
|
1125 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Edit events','dbem')); ?></td>
|
1126 |
+
<td>
|
1127 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_edit_events_page', 'selected'=>get_option('dbem_edit_events_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1128 |
+
<br />
|
1129 |
+
<em><?php echo sprintf(__('Users can view, add and edit their %s on this page.','dbem'),__('events','dbem')); ?></em>
|
1130 |
+
</td>
|
1131 |
+
</tr>
|
1132 |
+
<tr>
|
1133 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Edit locations','dbem')); ?></td>
|
1134 |
+
<td>
|
1135 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_edit_locations_page', 'selected'=>get_option('dbem_edit_locations_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1136 |
+
<br />
|
1137 |
+
<em><?php echo sprintf(__('Users can view, add and edit their %s on this page.','dbem'),__('locations','dbem')); ?></em>
|
1138 |
+
</td>
|
1139 |
+
</tr>
|
1140 |
+
<tr>
|
1141 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Manage bookings','dbem')); ?></td>
|
1142 |
+
<td>
|
1143 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_edit_bookings_page', 'selected'=>get_option('dbem_edit_bookings_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1144 |
+
<br />
|
1145 |
+
<em><?php _e('Users can manage bookings for their events on this page.','dbem'); ?></em>
|
1146 |
+
</td>
|
1147 |
+
</tr>
|
1148 |
+
<?php echo $save_button; ?>
|
1149 |
+
</table>
|
1150 |
+
</div> <!-- . inside -->
|
1151 |
+
</div> <!-- .postbox -->
|
1152 |
+
|
1153 |
+
<?php do_action('em_options_page_footer_pages'); ?>
|
1154 |
+
|
1155 |
+
</div> <!-- .em-menu-pages -->
|
1156 |
+
|
1157 |
+
<!-- FORMAT OPTIONS -->
|
1158 |
+
<div class="em-menu-formats em-menu-group" style="display:none;">
|
1159 |
+
<div class="postbox " id="em-opt-events-formats" >
|
1160 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Events', 'dbem' ); ?> </span></h3>
|
1161 |
+
<div class="inside">
|
1162 |
+
<table class="form-table">
|
1163 |
+
<tr><td colspan="2">
|
1164 |
+
<strong><?php echo sprintf(__('%s Page','dbem'),__('Events','dbem')); ?></strong>
|
1165 |
+
<p><?php _e('These formats will be used on your events page. This will also be used if you do not provide specified formats in other event lists, like in shortcodes.','dbem'); ?></p>
|
1166 |
+
</td></tr>
|
1167 |
+
<?php
|
1168 |
+
$grouby_modes = array(0=>__('None','dbem'), 'yearly'=>__('Yearly','dbem'), 'monthly'=>__('Monthly','dbem'), 'weekly'=>__('Weekly','dbem'), 'daily'=>__('Daily','dbem'));
|
1169 |
+
em_options_select(__('Events page grouping','dbem'), 'dbem_event_list_groupby', $grouby_modes, __('If you choose a group by mode, your events page will display events in groups of your chosen time range.','dbem'));
|
1170 |
+
em_options_input_text(__('Events page grouping','dbem'), 'dbem_event_list_groupby_format', __('Choose how to format your group headings. Leave blank for defaults.','dbem').' '. sprintf(__('Date and Time formats follow the <a href="%s">WordPress time formatting conventions</a>', 'dbem'), 'http://codex.wordpress.org/Formatting_Date_and_Time'));
|
1171 |
+
em_options_textarea ( __( 'Default event list format header', 'dbem' ), 'dbem_event_list_item_format_header', __( 'This content will appear just above your code for the default event list format. Default is blank', 'dbem' ) );
|
1172 |
+
em_options_textarea ( __( 'Default event list format', 'dbem' ), 'dbem_event_list_item_format', __( 'The format of any events in a list.', 'dbem' ).$events_placeholder_tip );
|
1173 |
+
em_options_textarea ( __( 'Default event list format footer', 'dbem' ), 'dbem_event_list_item_format_footer', __( 'This content will appear just below your code for the default event list format. Default is blank', 'dbem' ) );
|
1174 |
+
em_options_input_text ( __( 'No events message', 'dbem' ), 'dbem_no_events_message', __( 'The message displayed when no events are available.', 'dbem' ) );
|
1175 |
+
em_options_input_text ( __( 'List events by date title', 'dbem' ), 'dbem_list_date_title', __( 'If viewing a page for events on a specific date, this is the title that would show up. To insert date values, use <a href="http://www.php.net/manual/en/function.date.php">PHP time format characters</a> with a <code>#</code> symbol before them, i.e. <code>#m</code>, <code>#M</code>, <code>#j</code>, etc.<br/>', 'dbem' ) );
|
1176 |
+
?>
|
1177 |
+
<tr><td><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1178 |
+
<?php
|
1179 |
+
if( EM_MS_GLOBAL && !get_option('dbem_ms_global_events_links') ){
|
1180 |
+
em_options_input_text ( __( 'Single event page title format', 'dbem' ), 'dbem_event_page_title_format', __( 'The format of a single event page title.', 'dbem' ).' '.__( 'This is only used when showing events from other blogs.', 'dbem' ).$events_placeholder_tip );
|
1181 |
+
}
|
1182 |
+
em_options_textarea ( __( 'Default single event format', 'dbem' ), 'dbem_single_event_format', __( 'The format of a single event page.', 'dbem' ).$events_placeholder_tip );
|
1183 |
+
echo $save_button;
|
1184 |
+
?>
|
1185 |
+
</table>
|
1186 |
+
</div> <!-- . inside -->
|
1187 |
+
</div> <!-- .postbox -->
|
1188 |
+
|
1189 |
+
<div class="postbox " id="em-opt-search-form" >
|
1190 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Search Form', 'dbem' ); ?> </span></h3>
|
1191 |
+
<div class="inside">
|
1192 |
+
<h4><?php _e('Main Search Fields','dbem'); ?></h4>
|
1193 |
+
<table class="form-table em-search-form-main">
|
1194 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'Search', 'dbem' ); ?></strong></td></tr>
|
1195 |
+
<?php
|
1196 |
+
em_options_radio_binary ( __( 'Show text search?', 'dbem' ), 'dbem_search_form_text', '', '', '#dbem_search_form_text_label_row' );
|
1197 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_text_label', __('Appears within the input box.','dbem') );
|
1198 |
+
?>
|
1199 |
+
<tbody class="em-settings-geocoding">
|
1200 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'Geolocation Search', 'dbem' ); ?></strong></td></tr>
|
1201 |
+
<?php
|
1202 |
+
em_options_radio_binary ( __( 'Show geolocation search?', 'dbem' ), 'dbem_search_form_geo', '', '', '#dbem_search_form_geo_label_row' );
|
1203 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_geo_label', __('Appears within the input box.','dbem') );
|
1204 |
+
?>
|
1205 |
+
</tbody>
|
1206 |
+
</table>
|
1207 |
+
<h4><?php _e('Advanced Search Fields','dbem'); ?></h4>
|
1208 |
+
<table class="form-table">
|
1209 |
+
<?php
|
1210 |
+
em_options_radio_binary ( __( 'Enable advanced fields?', 'dbem' ), 'dbem_search_form_advanced', __('Enables additional advanced search fields such as dates, country, etc.','dbem'), '', '.em-search-form-advanced' );
|
1211 |
+
?>
|
1212 |
+
<tbody class="em-search-form-advanced">
|
1213 |
+
<?php
|
1214 |
+
em_options_input_text ( __( 'Search button text', 'dbem' ), 'dbem_serach_form_submit', __("If there's no fields to show in the main search section, this button will be used instead at the bottom of the advanced fields.",'dbem'));
|
1215 |
+
em_options_radio_binary ( __( 'Hidden by default?', 'dbem' ), 'dbem_search_form_advanced_hidden', __('If set to yes, advanced search fields will be hidden by default and can be revealed by clicking the "Advanced Search" link.','dbem'), '', '#dbem_search_form_advanced_show_row, #dbem_search_form_advanced_hide_row' );
|
1216 |
+
em_options_input_text ( __( 'Show label', 'dbem' ), 'dbem_search_form_advanced_show', __('Appears as the label for this search option.','dbem') );
|
1217 |
+
em_options_input_text ( __( 'Hide label', 'dbem' ), 'dbem_search_form_advanced_hide', __('Appears as the label for this search option.','dbem') );
|
1218 |
+
?>
|
1219 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'Dates', 'dbem' ); ?></strong></td></tr>
|
1220 |
+
<?php
|
1221 |
+
em_options_radio_binary ( __( 'Show date range?', 'dbem' ), 'dbem_search_form_dates', '', '', '#dbem_search_form_dates_label_row, #dbem_search_form_dates_separator_row' );
|
1222 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_dates_label', __('Appears as the label for this search option.','dbem') );
|
1223 |
+
em_options_input_text ( __( 'Date Separator', 'dbem' ), 'dbem_search_form_dates_separator', sprintf(__( 'For when start/end %s are present, this will seperate the two (include spaces here if necessary).', 'dbem' ), __('dates','dbem')) );
|
1224 |
+
?>
|
1225 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'Category', 'dbem' ); ?></strong></td></tr>
|
1226 |
+
<?php
|
1227 |
+
em_options_radio_binary ( __( 'Show categories?', 'dbem' ), 'dbem_search_form_categories', '', '', '#dbem_search_form_category_label_row, #dbem_search_form_categories_label_row' );
|
1228 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_category_label', __('Appears as the label for this search option.','dbem') );
|
1229 |
+
em_options_input_text ( __( 'Categories dropdown label', 'dbem' ), 'dbem_search_form_categories_label', __('Appears as the first default search option.','dbem') );
|
1230 |
+
?>
|
1231 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'Country', 'dbem' ); ?></strong></td></tr>
|
1232 |
+
<?php
|
1233 |
+
em_options_radio_binary ( __( 'Show countries?', 'dbem' ), 'dbem_search_form_countries', '', '', '#dbem_search_form_country_label_row, #dbem_search_form_countries_label_row' );
|
1234 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_country_label', __('Appears as the label for this search option.','dbem') );
|
1235 |
+
em_options_input_text ( __( 'All countries text', 'dbem' ), 'dbem_search_form_countries_label', __('Appears as the first default search option.','dbem') );
|
1236 |
+
?>
|
1237 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'Region', 'dbem' ); ?></strong></td></tr>
|
1238 |
+
<?php
|
1239 |
+
em_options_radio_binary ( __( 'Show regions?', 'dbem' ), 'dbem_search_form_regions', '', '', '#dbem_search_form_region_label_row, #dbem_search_form_regions_label_row' );
|
1240 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_region_label', __('Appears as the label for this search option.','dbem') );
|
1241 |
+
em_options_input_text ( __( 'All regions text', 'dbem' ), 'dbem_search_form_regions_label', __('Appears as the first default search option.','dbem') );
|
1242 |
+
?>
|
1243 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'State/County', 'dbem' ); ?></strong></td></tr>
|
1244 |
+
<?php
|
1245 |
+
em_options_radio_binary ( __( 'Show states?', 'dbem' ), 'dbem_search_form_states', '', '', '#dbem_search_form_state_label_row, #dbem_search_form_states_label_row' );
|
1246 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_state_label', __('Appears as the label for this search option.','dbem') );
|
1247 |
+
em_options_input_text ( __( 'All states text', 'dbem' ), 'dbem_search_form_states_label', __('Appears as the first default search option.','dbem') );
|
1248 |
+
?>
|
1249 |
+
<tr><td colspan="2"><strong><?php esc_html_e( 'City/Town', 'dbem' ); ?></strong></td></tr>
|
1250 |
+
<?php
|
1251 |
+
em_options_radio_binary ( __( 'Show towns/cities?', 'dbem' ), 'dbem_search_form_towns', '', '', '#dbem_search_form_town_label_row, #dbem_search_form_towns_label_row' );
|
1252 |
+
em_options_input_text ( __( 'Label', 'dbem' ), 'dbem_search_form_town_label', __('Appears as the label for this search option.','dbem') );
|
1253 |
+
em_options_input_text ( __( 'All towns/cities text', 'dbem' ), 'dbem_search_form_towns_label', __('Appears as the first default search option.','dbem') );
|
1254 |
+
?>
|
1255 |
+
</tbody>
|
1256 |
+
<?php echo $save_button; ?>
|
1257 |
+
</table>
|
1258 |
+
</div> <!-- . inside -->
|
1259 |
+
</div> <!-- .postbox -->
|
1260 |
+
|
1261 |
+
<div class="postbox " id="em-opt-date-time" >
|
1262 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Date/Time', 'dbem' ); ?> </span></h3>
|
1263 |
+
<div class="inside">
|
1264 |
+
<p><?php
|
1265 |
+
$date_time_format_tip = sprintf(__('Date and Time formats follow the <a href="%s">WordPress time formatting conventions</a>', 'dbem'), 'http://codex.wordpress.org/Formatting_Date_and_Time');
|
1266 |
+
echo $date_time_format_tip;
|
1267 |
+
?></p>
|
1268 |
+
<table class="form-table">
|
1269 |
+
<?php
|
1270 |
+
em_options_input_text ( __( 'Date Format', 'dbem' ), 'dbem_date_format', sprintf(__('For use with the %s placeholder','dbem'),'<code>#_EVENTDATES</code>') );
|
1271 |
+
em_options_input_text ( __( 'Date Picker Format', 'dbem' ), 'dbem_date_format_js', sprintf(__( 'Same as <em>Date Format</em>, but this is used for the datepickers used by Events Manager. This uses a slightly different format to the others on here, for a list of characters to use, visit the <a href="%s">jQuery formatDate reference</a>', 'dbem' ),'http://docs.jquery.com/UI/Datepicker/formatDate') );
|
1272 |
+
em_options_input_text ( __( 'Date Separator', 'dbem' ), 'dbem_dates_separator', sprintf(__( 'For when start/end %s are present, this will seperate the two (include spaces here if necessary).', 'dbem' ), __('dates','dbem')) );
|
1273 |
+
em_options_input_text ( __( 'Time Format', 'dbem' ), 'dbem_time_format', sprintf(__('For use with the %s placeholder','dbem'),'<code>#_EVENTTIMES</code>') );
|
1274 |
+
em_options_input_text ( __( 'Time Separator', 'dbem' ), 'dbem_times_separator', sprintf(__( 'For when start/end %s are present, this will seperate the two (include spaces here if necessary).', 'dbem' ), __('times','dbem')) );
|
1275 |
+
em_options_input_text ( __( 'All Day Message', 'dbem' ), 'dbem_event_all_day_message', sprintf(__( 'If an event lasts all day, this text will show if using the %s placeholder', 'dbem' ), '<code>#_EVENTTIMES</code>') );
|
1276 |
+
em_options_radio_binary ( __( 'Use 24h Format?', 'dbem' ), 'dbem_time_24h', __( 'When creating events, would you like your times to be shown in 24 hour format?', 'dbem' ) );
|
1277 |
+
echo $save_button;
|
1278 |
+
?>
|
1279 |
+
</table>
|
1280 |
+
</div> <!-- . inside -->
|
1281 |
+
</div> <!-- .postbox -->
|
1282 |
+
|
1283 |
+
<div class="postbox " id="em-opt-calendar-formats" >
|
1284 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Calendar', 'dbem' ); ?></span></h3>
|
1285 |
+
<div class="inside">
|
1286 |
+
<table class="form-table">
|
1287 |
+
<?php
|
1288 |
+
em_options_radio_binary ( __( 'Link directly to event on day with single event?', 'dbem' ), 'dbem_calendar_direct_links', __( "If a calendar day has only one event, you can force a direct link to the event (recommended to avoid duplicate content).",'dbem' ) );
|
1289 |
+
em_options_radio_binary ( __( 'Show list on day with single event?', 'dbem' ), 'dbem_display_calendar_day_single', __( "By default, if a calendar day only has one event, it display a single event when clicking on the link of that calendar date. If you select Yes here, you will get always see a list of events.",'dbem' ) );
|
1290 |
+
?>
|
1291 |
+
<tr><td colspan="2"><strong><?php _e('Small Calendar','dbem'); ?></strong></td></tr>
|
1292 |
+
<?php
|
1293 |
+
em_options_input_text ( __( 'Month format', 'dbem' ), 'dbem_small_calendar_month_format', __('The format of the month/year header of the calendar.','dbem').' '.$date_time_format_tip);
|
1294 |
+
em_options_input_text ( __( 'Event titles', 'dbem' ), 'dbem_small_calendar_event_title_format', __( 'The format of the title, corresponding to the text that appears when hovering on an eventful calendar day.', 'dbem' ).$events_placeholder_tip );
|
1295 |
+
em_options_input_text ( __( 'Title separator', 'dbem' ), 'dbem_small_calendar_event_title_separator', __( 'The separator appearing on the above title when more than one events are taking place on the same day.', 'dbem' ) );
|
1296 |
+
em_options_radio_binary( __( 'Abbreviated weekdays', 'dbem' ), 'dbem_small_calendar_abbreviated_weekdays', __( 'The calendar headings uses abbreviated weekdays','dbem') );
|
1297 |
+
em_options_input_text ( __( 'Initial lengths', 'dbem' ), 'dbem_small_calendar_initials_length', __( 'Shorten the calendar headings containing the days of the week, use 0 for the full name.', 'dbem' ).$events_placeholder_tip );
|
1298 |
+
?>
|
1299 |
+
<tr><td colspan="2"><strong><?php _e('Full Calendar','dbem'); ?></strong></td></tr>
|
1300 |
+
<?php
|
1301 |
+
em_options_input_text ( __( 'Month format', 'dbem' ), 'dbem_full_calendar_month_format', __('The format of the month/year header of the calendar.','dbem').' '.$date_time_format_tip);
|
1302 |
+
em_options_input_text ( __( 'Event format', 'dbem' ), 'dbem_full_calendar_event_format', __( 'The format of each event when displayed in the full calendar. Remember to include <code>li</code> tags before and after the event.', 'dbem' ).$events_placeholder_tip );
|
1303 |
+
em_options_radio_binary( __( 'Abbreviated weekdays?', 'dbem' ), 'dbem_full_calendar_abbreviated_weekdays', __( 'Use abbreviations, e.g. Friday = Fri. Useful for certain languages where abbreviations differ from full names.','dbem') );
|
1304 |
+
em_options_input_text ( __( 'Initial lengths', 'dbem' ), 'dbem_full_calendar_initials_length', __( 'Shorten the calendar headings containing the days of the week, use 0 for the full name.', 'dbem' ).$events_placeholder_tip);
|
1305 |
+
?>
|
1306 |
+
<tr><td colspan="2"><strong><?php echo __('Calendar Day Event List Settings','dbem'); ?></strong></td></tr>
|
1307 |
+
<tr valign="top" id='dbem_display_calendar_orderby_row'>
|
1308 |
+
<th scope="row"><?php _e('Default event list ordering','dbem'); ?></th>
|
1309 |
+
<td>
|
1310 |
+
<select name="dbem_display_calendar_orderby" >
|
1311 |
+
<?php
|
1312 |
+
$orderby_options = apply_filters('dbem_display_calendar_orderby_ddm', array(
|
1313 |
+
'event_name,event_start_time' => __('Order by event name, then event start time','dbem'),
|
1314 |
+
'event_start_time,event_name' => __('Order by event start time, then event name','dbem')
|
1315 |
+
));
|
1316 |
+
?>
|
1317 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
1318 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_display_calendar_orderby')) ? "selected='selected'" : ''; ?>>
|
1319 |
+
<?php echo $value; ?>
|
1320 |
+
</option>
|
1321 |
+
<?php endforeach; ?>
|
1322 |
+
</select>
|
1323 |
+
<select name="dbem_display_calendar_order" >
|
1324 |
+
<?php
|
1325 |
+
$ascending = __('Ascending','dbem');
|
1326 |
+
$descending = __('Descending','dbem');
|
1327 |
+
$order_options = apply_filters('dbem_display_calendar_order_ddm', array(
|
1328 |
+
'ASC' => __('All Ascending','dbem'),
|
1329 |
+
'DESC,ASC' => "$descending, $ascending",
|
1330 |
+
'DESC,DESC' => "$descending, $descending",
|
1331 |
+
'DESC' => __('All Descending','dbem')
|
1332 |
+
));
|
1333 |
+
?>
|
1334 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
1335 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_display_calendar_order')) ? "selected='selected'" : ''; ?>>
|
1336 |
+
<?php echo $value; ?>
|
1337 |
+
</option>
|
1338 |
+
<?php endforeach; ?>
|
1339 |
+
</select>
|
1340 |
+
<br/>
|
1341 |
+
<em><?php _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.','dbem'); ?></em>
|
1342 |
+
</td>
|
1343 |
+
</tr>
|
1344 |
+
<?php
|
1345 |
+
em_options_input_text ( __( 'Calendar events/day limit', 'dbem' ), 'dbem_display_calendar_events_limit', __( 'Limits the number of events on each calendar day. Leave blank for no limit.', 'dbem' ) );
|
1346 |
+
em_options_input_text ( __( 'More Events message', 'dbem' ), 'dbem_display_calendar_events_limit_msg', __( 'Text with link to calendar day page with all events for that day if there are more events than the limit above, leave blank for no link as the day number is also a link.', 'dbem' ) );
|
1347 |
+
?>
|
1348 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('iCal Feed Settings','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1349 |
+
<?php
|
1350 |
+
em_options_input_text ( __( 'iCal Title', 'dbem' ), 'dbem_ical_description_format', __( 'The title that will appear in the calendar.', 'dbem' ).$events_placeholder_tip );
|
1351 |
+
em_options_input_text ( __( 'iCal Description', 'dbem' ), 'dbem_ical_real_description_format', __( 'The description of the event that will appear in the calendar.', 'dbem' ).$events_placeholder_tip );
|
1352 |
+
em_options_input_text ( __( 'iCal Location', 'dbem' ), 'dbem_ical_location_format', __( 'The location information that will appear in the calendar.', 'dbem' ).$events_placeholder_tip );
|
1353 |
+
em_options_select( __('iCal Scope','dbem'), 'dbem_ical_scope', em_get_scopes(), __('Choose to show events within a specific time range.','dbem'));
|
1354 |
+
em_options_input_text ( __( 'iCal Limit', 'dbem' ), 'dbem_ical_limit', __( 'Limits the number of future events shown (0 = unlimited).', 'dbem' ) );
|
1355 |
+
echo $save_button;
|
1356 |
+
?>
|
1357 |
+
</table>
|
1358 |
+
</div> <!-- . inside -->
|
1359 |
+
</div> <!-- .postbox -->
|
1360 |
+
|
1361 |
+
<?php if( get_option('dbem_locations_enabled') ): ?>
|
1362 |
+
<div class="postbox " id="em-opt-locations-formats" >
|
1363 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Locations', 'dbem' ); ?> </span></h3>
|
1364 |
+
<div class="inside">
|
1365 |
+
<table class="form-table">
|
1366 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('%s Page','dbem'),__('Locations','dbem')); ?></strong></td></tr>
|
1367 |
+
<?php
|
1368 |
+
em_options_textarea ( sprintf(__('%s list header format','dbem'),__('Locations','dbem')), 'dbem_location_list_item_format_header', sprintf(__( 'This content will appear just above your code for the %s list format below. Default is blank', 'dbem' ), __('locations','dbem')) );
|
1369 |
+
em_options_textarea ( sprintf(__('%s list item format','dbem'),__('Locations','dbem')), 'dbem_location_list_item_format', sprintf(__( 'The format of a single %s in a list.', 'dbem' ), __('locations','dbem')).$locations_placeholder_tip );
|
1370 |
+
em_options_textarea ( sprintf(__('%s list footer format','dbem'),__('Locations','dbem')), 'dbem_location_list_item_format_footer', sprintf(__( 'This content will appear just below your code for the %s list format above. Default is blank', 'dbem' ), __('locations','dbem')) );
|
1371 |
+
em_options_input_text ( sprintf(__( 'No %s message', 'dbem' ),__('Locations','dbem')), 'dbem_no_locations_message', sprintf( __( 'The message displayed when no %s are available.', 'dbem' ), __('locations','dbem')) );
|
1372 |
+
?>
|
1373 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Location','dbem')); ?></strong></td></tr>
|
1374 |
+
<?php
|
1375 |
+
if( EM_MS_GLOBAL && get_option('dbem_ms_global_location_links') ){
|
1376 |
+
em_options_input_text (sprintf( __( 'Single %s title format', 'dbem' ),__('location','dbem')), 'dbem_location_page_title_format', __( 'The format of a single location page title.', 'dbem' ).$locations_placeholder_tip );
|
1377 |
+
}
|
1378 |
+
em_options_textarea ( sprintf(__('Single %s page format', 'dbem' ),__('location','dbem')), 'dbem_single_location_format', __( 'The format of a single location page.', 'dbem' ).$locations_placeholder_tip );
|
1379 |
+
?>
|
1380 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('%s List Formats','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1381 |
+
<?php
|
1382 |
+
em_options_input_text ( __( 'Default event list format header', 'dbem' ), 'dbem_location_event_list_item_header_format', __( 'This content will appear just above your code for the default event list format. Default is blank', 'dbem' ) );
|
1383 |
+
em_options_textarea ( sprintf(__( 'Default %s list format', 'dbem' ),__('events','dbem')), 'dbem_location_event_list_item_format', sprintf(__( 'The format of the events the list inserted in the location page through the %s element.', 'dbem' ).$events_placeholder_tip, '<code>#_LOCATIONNEXTEVENTS</code>, <code>#_LOCATIONPASTEVENTS</code>, <code>#_LOCATIONALLEVENTS</code>') );
|
1384 |
+
em_options_input_text ( __( 'Default event list format footer', 'dbem' ), 'dbem_location_event_list_item_footer_format', __( 'This content will appear just below your code for the default event list format. Default is blank', 'dbem' ) );
|
1385 |
+
em_options_textarea ( sprintf(__( 'No %s message', 'dbem' ),__('events','dbem')), 'dbem_location_no_events_message', sprintf(__( 'The message to be displayed in the list generated by %s when no events are available.', 'dbem' ), '<code>#_LOCATIONNEXTEVENTS</code>, <code>#_LOCATIONPASTEVENTS</code>, <code>#_LOCATIONALLEVENTS</code>') );
|
1386 |
+
?>
|
1387 |
+
<tr><td colspan="2">
|
1388 |
+
<strong><?php echo sprintf(__('Single %s Format','dbem'),__('Event','dbem')); ?></strong>
|
1389 |
+
<p><?php echo sprintf(__('The settings below are used when using the %s placeholder','dbem'), '<code>#_LOCATIONNEXTEVENT</code>'); ?></p>
|
1390 |
+
</td></tr>
|
1391 |
+
<?php
|
1392 |
+
em_options_input_text ( __( 'Next event format', 'dbem' ), 'dbem_location_event_single_format', sprintf(__( 'The format of the next upcoming event in this %s.', 'dbem' ),__('location','dbem')).$events_placeholder_tip );
|
1393 |
+
em_options_input_text ( sprintf(__( 'No %s message', 'dbem' ),__('events','dbem')), 'dbem_location_no_event_message', sprintf(__( 'The message to be displayed in the list generated by %s when no events are available.', 'dbem' ), '<code>#_LOCATIONNEXTEVENT</code>') );
|
1394 |
+
echo $save_button;
|
1395 |
+
?>
|
1396 |
+
</table>
|
1397 |
+
</div> <!-- . inside -->
|
1398 |
+
</div> <!-- .postbox -->
|
1399 |
+
<?php endif; ?>
|
1400 |
+
|
1401 |
+
<?php if( get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site()) ): ?>
|
1402 |
+
<div class="postbox " id="em-opt-categories-formats" >
|
1403 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Categories', 'dbem' ); ?> </span></h3>
|
1404 |
+
<div class="inside">
|
1405 |
+
<table class="form-table">
|
1406 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('%s Page','dbem'),__('Categories','dbem')); ?></strong></td></tr>
|
1407 |
+
<?php
|
1408 |
+
em_options_textarea ( sprintf(__('%s list header format','dbem'),__('Categories','dbem')), 'dbem_categories_list_item_format_header', sprintf(__( 'This content will appear just above your code for the %s list format below. Default is blank', 'dbem' ), __('categories','dbem')) );
|
1409 |
+
em_options_textarea ( sprintf(__('%s list item format','dbem'),__('Categories','dbem')), 'dbem_categories_list_item_format', sprintf(__( 'The format of a single %s in a list.', 'dbem' ), __('categories','dbem')).$categories_placeholder_tip );
|
1410 |
+
em_options_textarea ( sprintf(__('%s list footer format','dbem'),__('Categories','dbem')), 'dbem_categories_list_item_format_footer', sprintf(__( 'This content will appear just below your code for the %s list format above. Default is blank', 'dbem' ), __('categories','dbem')) );
|
1411 |
+
em_options_input_text ( sprintf(__( 'No %s message', 'dbem' ),__('Categories','dbem')), 'dbem_no_categories_message', sprintf( __( 'The message displayed when no %s are available.', 'dbem' ), __('categories','dbem')) );
|
1412 |
+
?>
|
1413 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Category','dbem')); ?></strong></td></tr>
|
1414 |
+
<?php
|
1415 |
+
em_options_input_text ( sprintf(__( 'Single %s title format', 'dbem' ),__('category','dbem')), 'dbem_category_page_title_format', __( 'The format of a single category page title.', 'dbem' ).$categories_placeholder_tip );
|
1416 |
+
em_options_textarea ( sprintf(__('Single %s page format', 'dbem' ),__('category','dbem')), 'dbem_category_page_format', __( 'The format of a single category page.', 'dbem' ).$categories_placeholder_tip );
|
1417 |
+
?>
|
1418 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('%s List Formats','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1419 |
+
<?php
|
1420 |
+
em_options_input_text ( __( 'Default event list format header', 'dbem' ), 'dbem_category_event_list_item_header_format', __( 'This content will appear just above your code for the default event list format. Default is blank', 'dbem' ) );
|
1421 |
+
em_options_textarea ( sprintf(__( 'Default %s list format', 'dbem' ),__('events','dbem')), 'dbem_category_event_list_item_format', sprintf(__( 'The format of the events the list inserted in the category page through the %s element.', 'dbem' ).$events_placeholder_tip, '<code>#_CATEGORYPASTEVENTS</code>, <code>#_CATEGORYNEXTEVENTS</code>, <code>#_CATEGORYALLEVENTS</code>') );
|
1422 |
+
em_options_input_text ( __( 'Default event list format footer', 'dbem' ), 'dbem_category_event_list_item_footer_format', __( 'This content will appear just below your code for the default event list format. Default is blank', 'dbem' ) );
|
1423 |
+
em_options_textarea ( sprintf(__( 'No %s message', 'dbem' ),__('events','dbem')), 'dbem_category_no_events_message', sprintf(__( 'The message to be displayed in the list generated by %s when no events are available.', 'dbem' ), '<code>#_CATEGORYPASTEVENTS</code>, <code>#_CATEGORYNEXTEVENTS</code>, <code>#_CATEGORYALLEVENTS</code>') );
|
1424 |
+
?>
|
1425 |
+
<tr><td colspan="2">
|
1426 |
+
<strong><?php echo sprintf(__('Single %s Format','dbem'),__('Event','dbem')); ?></strong>
|
1427 |
+
<p><?php echo sprintf(__('The settings below are used when using the %s placeholder','dbem'), '<code>#_CATEGORYNEXTEVENT</code>'); ?></p>
|
1428 |
+
</td></tr>
|
1429 |
+
<?php
|
1430 |
+
em_options_input_text ( __( 'Next event format', 'dbem' ), 'dbem_category_event_single_format', sprintf(__( 'The format of the next upcoming event in this %s.', 'dbem' ),__('category','dbem')).$events_placeholder_tip );
|
1431 |
+
em_options_input_text ( sprintf(__( 'No %s message', 'dbem' ),__('events','dbem')), 'dbem_category_no_event_message', sprintf(__( 'The message to be displayed in the list generated by %s when no events are available.', 'dbem' ), '<code>#_CATEGORYNEXTEVENT</code>') );
|
1432 |
+
echo $save_button;
|
1433 |
+
?>
|
1434 |
+
</table>
|
1435 |
+
</div> <!-- . inside -->
|
1436 |
+
</div> <!-- .postbox -->
|
1437 |
+
<?php endif; ?>
|
1438 |
+
|
1439 |
+
<?php if( get_option('dbem_tags_enabled') ): ?>
|
1440 |
+
<div class="postbox " id="em-opt-tags-formats" >
|
1441 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Tags', 'dbem' ); ?> </span></h3>
|
1442 |
+
<div class="inside">
|
1443 |
+
<table class="form-table">
|
1444 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('%s Page','dbem'),__('Tags','dbem')); ?></strong></td></tr>
|
1445 |
+
<?php
|
1446 |
+
em_options_textarea ( sprintf(__('%s list header format','dbem'),__('Tags','dbem')), 'dbem_tags_list_item_format_header', sprintf(__( 'This content will appear just above your code for the %s list format below. Default is blank', 'dbem' ), __('tags','dbem')) );
|
1447 |
+
em_options_textarea ( sprintf(__('%s list item format','dbem'),__('Tags','dbem')), 'dbem_tags_list_item_format', sprintf(__( 'The format of a single %s in a list.', 'dbem' ), __('tags','dbem')).$categories_placeholder_tip );
|
1448 |
+
em_options_textarea ( sprintf(__('%s list footer format','dbem'),__('Tags','dbem')), 'dbem_tags_list_item_format_footer', sprintf(__( 'This content will appear just below your code for the %s list format above. Default is blank', 'dbem' ), __('tags','dbem')) );
|
1449 |
+
em_options_input_text ( sprintf(__( 'No %s message', 'dbem' ),__('Tags','dbem')), 'dbem_no_tags_message', sprintf( __( 'The message displayed when no %s are available.', 'dbem' ), __('tags','dbem')) );
|
1450 |
+
?>
|
1451 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Tag','dbem')); ?></strong></td></tr>
|
1452 |
+
<?php
|
1453 |
+
em_options_input_text ( sprintf(__( 'Single %s title format', 'dbem' ),__('tag','dbem')), 'dbem_tag_page_title_format', __( 'The format of a single tag page title.', 'dbem' ).$categories_placeholder_tip );
|
1454 |
+
em_options_textarea ( sprintf(__('Single %s page format', 'dbem' ),__('tag','dbem')), 'dbem_tag_page_format', __( 'The format of a single tag page.', 'dbem' ).$categories_placeholder_tip );
|
1455 |
+
?>
|
1456 |
+
<tr><td colspan="2"><strong><?php echo sprintf(__('%s List Formats','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1457 |
+
<?php
|
1458 |
+
em_options_input_text ( __( 'Default event list format header', 'dbem' ), 'dbem_tag_event_list_item_header_format', __( 'This content will appear just above your code for the default event list format. Default is blank', 'dbem' ) );
|
1459 |
+
em_options_textarea ( sprintf(__( 'Default %s list format', 'dbem' ),__('events','dbem')), 'dbem_tag_event_list_item_format', __( 'The format of the events the list inserted in the tag page through the <code>#_TAGNEXTEVENTS</code>, <code>#_TAGNEXTEVENTS</code> and <code>#_TAGALLEVENTS</code> element.', 'dbem' ).$categories_placeholder_tip );
|
1460 |
+
em_options_input_text ( __( 'Default event list format footer', 'dbem' ), 'dbem_tag_event_list_item_footer_format', __( 'This content will appear just below your code for the default event list format. Default is blank', 'dbem' ) );
|
1461 |
+
em_options_textarea ( sprintf(__( 'No %s message', 'dbem' ),__('events','dbem')), 'dbem_tag_no_events_message', __( 'The message to be displayed in the list generated by <code>#_TAGNEXTEVENTS</code>, <code>#_TAGNEXTEVENTS</code> and <code>#_TAGALLEVENTS</code> when no events are available.', 'dbem' ) );
|
1462 |
+
?>
|
1463 |
+
<tr><td colspan="2">
|
1464 |
+
<strong><?php echo sprintf(__('Single %s Format','dbem'),__('Event','dbem')); ?></strong>
|
1465 |
+
<p><?php echo sprintf(__('The settings below are used when using the %s placeholder','dbem'), '<code>#_TAGNEXTEVENT</code>'); ?></p>
|
1466 |
+
</td></tr>
|
1467 |
+
<?php
|
1468 |
+
em_options_input_text ( __( 'Next event format', 'dbem' ), 'dbem_tag_event_single_format', sprintf(__( 'The format of the next upcoming event in this %s.', 'dbem' ),__('tag','dbem')).$events_placeholder_tip );
|
1469 |
+
em_options_input_text ( sprintf(__( 'No %s message', 'dbem' ),__('events','dbem')), 'dbem_tag_no_event_message', sprintf(__( 'The message to be displayed in the list generated by %s when no events are available.', 'dbem' ), '<code>#_CATEGORYNEXTEVENT</code>') );
|
1470 |
+
echo $save_button;
|
1471 |
+
?>
|
1472 |
+
</table>
|
1473 |
+
</div> <!-- . inside -->
|
1474 |
+
</div> <!-- .postbox -->
|
1475 |
+
<?php endif; ?>
|
1476 |
+
|
1477 |
+
<div class="postbox " id="em-opt-rss-formats" >
|
1478 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'RSS', 'dbem' ); ?> </span></h3>
|
1479 |
+
<div class="inside">
|
1480 |
+
<table class="form-table">
|
1481 |
+
<?php
|
1482 |
+
em_options_input_text ( __( 'RSS main title', 'dbem' ), 'dbem_rss_main_title', __( 'The main title of your RSS events feed.', 'dbem' ).$events_placeholder_tip );
|
1483 |
+
em_options_input_text ( __( 'RSS main description', 'dbem' ), 'dbem_rss_main_description', __( 'The main description of your RSS events feed.', 'dbem' ) );
|
1484 |
+
em_options_input_text ( __( 'RSS title format', 'dbem' ), 'dbem_rss_title_format', __( 'The format of the title of each item in the events RSS feed.', 'dbem' ).$events_placeholder_tip );
|
1485 |
+
em_options_input_text ( __( 'RSS description format', 'dbem' ), 'dbem_rss_description_format', __( 'The format of the description of each item in the events RSS feed.', 'dbem' ).$events_placeholder_tip );
|
1486 |
+
em_options_input_text ( __( 'RSS limit', 'dbem' ), 'dbem_rss_limit', __( 'Limits the number of future events shown (0 = unlimited).', 'dbem' ) );
|
1487 |
+
echo $save_button;
|
1488 |
+
?>
|
1489 |
+
</table>
|
1490 |
+
</div> <!-- . inside -->
|
1491 |
+
</div> <!-- .postbox -->
|
1492 |
+
|
1493 |
+
<div class="postbox " id="em-opt-maps-formats" >
|
1494 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Maps', 'dbem' ); ?> </span></h3>
|
1495 |
+
<div class="inside">
|
1496 |
+
<p><?php echo sprintf(__('You can use Google Maps to show where your events are located. For more information on using maps, <a href="%s">see our documentation</a>.','dbem'),'http://wp-events-plugin.com/documentation/google-maps/'); ?>
|
1497 |
+
<table class='form-table'>
|
1498 |
+
<?php $gmap_is_active = get_option ( 'dbem_gmap_is_active' ); ?>
|
1499 |
+
<tr valign="top">
|
1500 |
+
<th scope="row"><?php _e ( 'Enable Google Maps integration?', 'dbem' ); ?></th>
|
1501 |
+
<td>
|
1502 |
+
<?php _e ( 'Yes' ); ?> <input id="dbem_gmap_is_active_yes" name="dbem_gmap_is_active" type="radio" value="1" <?php echo ($gmap_is_active) ? "checked='checked'":''; ?> />
|
1503 |
+
<?php _e ( 'No' ); ?> <input name="dbem_gmap_is_active" type="radio" value="0" <?php echo ($gmap_is_active) ? '':"checked='checked'"; ?> /><br />
|
1504 |
+
<em><?php _e ( 'Check this option to enable Goggle Map integration.', 'dbem' )?></em>
|
1505 |
+
</td>
|
1506 |
+
<?php em_options_input_text(__('Default map width','dbem'), 'dbem_map_default_width', sprintf(__('Can be in form of pixels or a percentage such as %s or %s.', 'dbem'), '<code>100%</code>', '<code>100px</code>')); ?>
|
1507 |
+
<?php em_options_input_text(__('Default map height','dbem'), 'dbem_map_default_height', sprintf(__('Can be in form of pixels or a percentage such as %s or %s.', 'dbem'), '<code>100%</code>', '<code>100px</code>')); ?>
|
1508 |
+
</tr>
|
1509 |
+
<tr><td colspan="2">
|
1510 |
+
<strong><?php _e('Global Map Format','dbem'); ?></strong>
|
1511 |
+
<p><?php echo sprintf(__('If you use the %s <a href="%s">shortcode</a>, you can display a map of all your locations and events, the settings below will be used.','dbem'), '<code>[locations_map]</code>','http://wp-events-plugin.com/documentation/shortcodes/'); ?></p>
|
1512 |
+
</td></tr>
|
1513 |
+
<?php
|
1514 |
+
em_options_textarea ( __( 'Location balloon format', 'dbem' ), 'dbem_map_text_format', __( 'The format of of the text appearing in the balloon describing the location.', 'dbem' ).' '.__( 'Event.', 'dbem' ).$locations_placeholder_tip );
|
1515 |
+
?>
|
1516 |
+
<tr><td colspan="2">
|
1517 |
+
<strong><?php _e('Single Location/Event Map Format','dbem'); ?></strong>
|
1518 |
+
<p><?php echo sprintf(_e('If you use the <code>#_LOCATIONMAP</code> <a href="%s">placeholder</a> when displaying individual event and location information, the settings below will be used.','dbem'), '<code>[locations_map]</code>','http://wp-events-plugin.com/documentation/placeholders/'); ?></p>
|
1519 |
+
</td></tr>
|
1520 |
+
<?php
|
1521 |
+
em_options_textarea ( __( 'Location balloon format', 'dbem' ), 'dbem_location_baloon_format', __( 'The format of of the text appearing in the balloon describing the location.', 'dbem' ).$events_placeholder_tip );
|
1522 |
+
echo $save_button;
|
1523 |
+
?>
|
1524 |
+
</table>
|
1525 |
+
</div> <!-- . inside -->
|
1526 |
+
</div> <!-- .postbox -->
|
1527 |
+
|
1528 |
+
<?php do_action('em_options_page_footer_formats'); ?>
|
1529 |
+
|
1530 |
+
</div> <!-- .em-menu-formats -->
|
1531 |
+
|
1532 |
+
<?php if( get_option('dbem_rsvp_enabled') ): ?>
|
1533 |
+
<!-- BOOKING OPTIONS -->
|
1534 |
+
<div class="em-menu-bookings em-menu-group" style="display:none;">
|
1535 |
+
|
1536 |
+
<div class="postbox " id="em-opt-bookings-general" >
|
1537 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('General','dbem')); ?> </span></h3>
|
1538 |
+
<div class="inside">
|
1539 |
+
<table class='form-table'>
|
1540 |
+
<?php
|
1541 |
+
em_options_radio_binary ( __( 'Allow guest bookings?', 'dbem' ), 'dbem_bookings_anonymous', __( 'If enabled, guest visitors can supply an email address and a user account will automatically be created for them along with their booking. They will be also be able to log back in with that newly created account.', 'dbem' ) );
|
1542 |
+
em_options_radio_binary ( __( 'Approval Required?', 'dbem' ), 'dbem_bookings_approval', __( 'Bookings will not be confirmed until the event administrator approves it.', 'dbem' ).' '.__( 'This setting is overriden by individual payment gateways.', 'dbem' ));
|
1543 |
+
em_options_radio_binary ( __( 'Reserved unconfirmed spaces?', 'dbem' ), 'dbem_bookings_approval_reserved', __( 'By default, event spaces become unavailable once there are enough CONFIRMED bookings. To reserve spaces even if unnapproved, choose yes.', 'dbem' ) );
|
1544 |
+
em_options_radio_binary ( __( 'Can users cancel their booking?', 'dbem' ), 'dbem_bookings_user_cancellation', __( 'If enabled, users can cancel their bookings themselves from their bookings page.', 'dbem' ) );
|
1545 |
+
em_options_radio_binary ( __( 'Allow overbooking when approving?', 'dbem' ), 'dbem_bookings_approval_overbooking', __( 'If you get a lot of pending bookings and you decide to allow more bookings than spaces allow, setting this to yes will allow you to override the event space limit when manually approving.', 'dbem' ) );
|
1546 |
+
em_options_radio_binary ( __( 'Allow double bookings?', 'dbem' ), 'dbem_bookings_double', __( 'If enabled, users can book an event more than once.', 'dbem' ) );
|
1547 |
+
echo $save_button;
|
1548 |
+
?>
|
1549 |
+
</table>
|
1550 |
+
</div> <!-- . inside -->
|
1551 |
+
</div> <!-- .postbox -->
|
1552 |
+
|
1553 |
+
<div class="postbox " id="em-opt-pricing-options" >
|
1554 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('Pricing','dbem')); ?> </span></h3>
|
1555 |
+
<div class="inside">
|
1556 |
+
<table class='form-table'>
|
1557 |
+
<?php
|
1558 |
+
/* Tax & Currency */
|
1559 |
+
em_options_select ( __( 'Currency', 'dbem' ), 'dbem_bookings_currency', em_get_currencies()->names, __( 'Choose your currency for displaying event pricing.', 'dbem' ) );
|
1560 |
+
em_options_input_text ( __( 'Thousands Separator', 'dbem' ), 'dbem_bookings_currency_thousands_sep', '<code>'.get_option('dbem_bookings_currency_thousands_sep')." = ".em_get_currency_symbol().'100<strong>'.get_option('dbem_bookings_currency_thousands_sep').'</strong>000<strong>'.get_option('dbem_bookings_currency_decimal_point').'</strong>00</code>' );
|
1561 |
+
em_options_input_text ( __( 'Decimal Point', 'dbem' ), 'dbem_bookings_currency_decimal_point', '<code>'.get_option('dbem_bookings_currency_decimal_point')." = ".em_get_currency_symbol().'100<strong>'.get_option('dbem_bookings_currency_decimal_point').'</strong>00</code>' );
|
1562 |
+
em_options_input_text ( __( 'Currency Format', 'dbem' ), 'dbem_bookings_currency_format', __('Choose how prices are displayed. <code>@</code> will be replaced by the currency symbol, and <code>#</code> will be replaced by the number.','dbem').' <code>'.get_option('dbem_bookings_currency_format')." = ".em_get_currency_formatted('10000000').'</code>');
|
1563 |
+
em_options_input_text ( __( 'Tax Rate', 'dbem' ), 'dbem_bookings_tax', __( 'Add a tax rate to your ticket prices (entering 10 will add 10% to the ticket price).', 'dbem' ) );
|
1564 |
+
em_options_radio_binary ( __( 'Add tax to ticket price?', 'dbem' ), 'dbem_bookings_tax_auto_add', __( 'When displaying ticket prices and booking totals, include the tax automatically?', 'dbem' ) );
|
1565 |
+
echo $save_button;
|
1566 |
+
?>
|
1567 |
+
</table>
|
1568 |
+
</div> <!-- . inside -->
|
1569 |
+
</div> <!-- .postbox -->
|
1570 |
+
|
1571 |
+
<div class="postbox " id="em-opt-booking-feedbacks" >
|
1572 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e( 'Customize Feedback Messages', 'dbem' ); ?> </span></h3>
|
1573 |
+
<div class="inside">
|
1574 |
+
<p><?php _e('Below you will find texts that will be displayed to users in various areas during the bookings process, particularly on booking forms.','dbem'); ?></p>
|
1575 |
+
<table class='form-table'>
|
1576 |
+
<tr><td colspan='2'><h4><?php _e('My Bookings messages','dbem') ?></h4></td></tr>
|
1577 |
+
<?php
|
1578 |
+
em_options_input_text ( __( 'Booking Cancelled', 'dbem' ), 'dbem_booking_feedback_cancelled', __( 'When a user cancels their booking, this message will be displayed confirming the cancellation.', 'dbem' ) );
|
1579 |
+
em_options_input_text ( __( 'Booking Cancellation Warning', 'dbem' ), 'dbem_booking_warning_cancel', __( 'When a user chooses to cancel a booking, this warning is displayed for them to confirm.', 'dbem' ) );
|
1580 |
+
?>
|
1581 |
+
<tr><td colspan='2'><h4><?php _e('Booking form texts/messages','dbem') ?></h4></td></tr>
|
1582 |
+
<?php
|
1583 |
+
em_options_input_text ( __( 'Bookings disabled', 'dbem' ), 'dbem_bookings_form_msg_disabled', __( 'An event with no bookings.', 'dbem' ) );
|
1584 |
+
em_options_input_text ( __( 'Bookings closed', 'dbem' ), 'dbem_bookings_form_msg_closed', __( 'Bookings have closed (e.g. event has started).', 'dbem' ) );
|
1585 |
+
em_options_input_text ( __( 'Fully booked', 'dbem' ), 'dbem_bookings_form_msg_full', __( 'Event is fully booked.', 'dbem' ) );
|
1586 |
+
em_options_input_text ( __( 'Already attending', 'dbem' ), 'dbem_bookings_form_msg_attending', __( 'If already attending and double bookings are disabled, this message will be displayed, followed by a link to the users booking page.', 'dbem' ) );
|
1587 |
+
em_options_input_text ( __( 'Manage bookings link text', 'dbem' ), 'dbem_bookings_form_msg_bookings_link', __( 'Link text used for link to user bookings.', 'dbem' ) );
|
1588 |
+
?>
|
1589 |
+
<tr><td colspan='2'><h4><?php _e('Booking form feedback messages','dbem') ?></h4></td></tr>
|
1590 |
+
<tr><td colspan='2'><?php _e('When a booking is made by a user, a feedback message is shown depending on the result, which can be customized below.','dbem'); ?></td></tr>
|
1591 |
+
<?php
|
1592 |
+
em_options_input_text ( __( 'Successful booking', 'dbem' ), 'dbem_booking_feedback', __( 'When a booking is registered and confirmed.', 'dbem' ) );
|
1593 |
+
em_options_input_text ( __( 'Successful pending booking', 'dbem' ), 'dbem_booking_feedback_pending', __( 'When a booking is registered but pending.', 'dbem' ) );
|
1594 |
+
em_options_input_text ( __( 'Not enough spaces', 'dbem' ), 'dbem_booking_feedback_full', __( 'When a booking cannot be made due to lack of spaces.', 'dbem' ) );
|
1595 |
+
em_options_input_text ( __( 'Errors', 'dbem' ), 'dbem_booking_feedback_error', __( 'When a booking cannot be made due to an error when filling the form. Below this, there will be a dynamic list of errors.', 'dbem' ) );
|
1596 |
+
em_options_input_text ( __( 'Email Exists', 'dbem' ), 'dbem_booking_feedback_email_exists', __( 'When a guest tries to book using an email registered with a user account.', 'dbem' ) );
|
1597 |
+
em_options_input_text ( __( 'User must log in', 'dbem' ), 'dbem_booking_feedback_log_in', __( 'When a user must log in before making a booking.', 'dbem' ) );
|
1598 |
+
em_options_input_text ( __( 'Error mailing user', 'dbem' ), 'dbem_booking_feedback_nomail', __( 'If a booking is made and an email cannot be sent, this is added to the success message.', 'dbem' ) );
|
1599 |
+
em_options_input_text ( __( 'Already booked', 'dbem' ), 'dbem_booking_feedback_already_booked', __( 'If the user made a previous booking and cannot double-book.', 'dbem' ) );
|
1600 |
+
em_options_input_text ( __( 'No spaces booked', 'dbem' ), 'dbem_booking_feedback_min_space', __( 'If the user tries to make a booking without requesting any spaces.', 'dbem' ) );$notice_full = __('Sold Out', 'dbem');
|
1601 |
+
em_options_input_text ( __( 'Maximum spaces per booking', 'dbem' ), 'dbem_booking_feedback_spaces_limit', __( 'If the user tries to make a booking with spaces that exceeds the maximum number of spaces per booking.', 'dbem' ).' '. __('%d will be replaced by a number.','dbem') );
|
1602 |
+
?>
|
1603 |
+
<tr><td colspan='2'><h4><?php _e('Booking button feedback messages','dbem') ?></h4></td></tr>
|
1604 |
+
<tr><td colspan='2'><?php echo sprintf(__('When the %s placeholder, the below texts will be used.','dbem'),'<code>#_BOOKINGBUTTON</code>'); ?></td></tr>
|
1605 |
+
<?php
|
1606 |
+
em_options_input_text ( __( 'User can book', 'dbem' ), 'dbem_booking_button_msg_book', '');
|
1607 |
+
em_options_input_text ( __( 'Booking in progress', 'dbem' ), 'dbem_booking_button_msg_booking', '');
|
1608 |
+
em_options_input_text ( __( 'Booking complete', 'dbem' ), 'dbem_booking_button_msg_booked', '');
|
1609 |
+
em_options_input_text ( __( 'Booking already made', 'dbem' ), 'dbem_booking_button_msg_already_booked', '');
|
1610 |
+
em_options_input_text ( __( 'Booking error', 'dbem' ), 'dbem_booking_button_msg_error', '');
|
1611 |
+
em_options_input_text ( __( 'Event fully booked', 'dbem' ), 'dbem_booking_button_msg_full', '');
|
1612 |
+
em_options_input_text ( __( 'Cancel', 'dbem' ), 'dbem_booking_button_msg_cancel', '');
|
1613 |
+
em_options_input_text ( __( 'Cancelation in progress', 'dbem' ), 'dbem_booking_button_msg_canceling', '');
|
1614 |
+
em_options_input_text ( __( 'Cancelation complete', 'dbem' ), 'dbem_booking_button_msg_cancelled', '');
|
1615 |
+
em_options_input_text ( __( 'Cancelation error', 'dbem' ), 'dbem_booking_button_msg_cancel_error', '');
|
1616 |
+
|
1617 |
+
echo $save_button;
|
1618 |
+
?>
|
1619 |
+
</table>
|
1620 |
+
</div> <!-- . inside -->
|
1621 |
+
</div> <!-- .postbox -->
|
1622 |
+
|
1623 |
+
<div class="postbox " id="em-opt-booking-form-options" >
|
1624 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('Booking Form','dbem')); ?> </span></h3>
|
1625 |
+
<div class="inside">
|
1626 |
+
<table class='form-table'>
|
1627 |
+
<?php
|
1628 |
+
em_options_radio_binary ( __( 'Display login form?', 'dbem' ), 'dbem_bookings_login_form', __( 'Choose whether or not to display a login form in the booking form area to remind your members to log in before booking.', 'dbem' ) );
|
1629 |
+
em_options_input_text ( __( 'Submit button text', 'dbem' ), 'dbem_bookings_submit_button', sprintf(__( 'The text used by the submit button. To use an image instead, enter the full url starting with %s or %s.', 'dbem' ), '<code>http://</code>','<code>https://</code>') );
|
1630 |
+
do_action('em_options_booking_form_options');
|
1631 |
+
echo $save_button;
|
1632 |
+
?>
|
1633 |
+
</table>
|
1634 |
+
</div> <!-- . inside -->
|
1635 |
+
</div> <!-- .postbox -->
|
1636 |
+
|
1637 |
+
<div class="postbox " id="em-opt-ticket-options" >
|
1638 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('Ticket','dbem')); ?> </span></h3>
|
1639 |
+
<div class="inside">
|
1640 |
+
<table class='form-table'>
|
1641 |
+
<?php
|
1642 |
+
em_options_radio_binary ( __( 'Single ticket mode?', 'dbem' ), 'dbem_bookings_tickets_single', __( 'In single ticket mode, users can only create one ticket per booking (and will not see options to add more tickets).', 'dbem' ) );
|
1643 |
+
em_options_radio_binary ( __( 'Show ticket table in single ticket mode?', 'dbem' ), 'dbem_bookings_tickets_single_form', __( 'If you prefer a ticket table like with multiple tickets, even for single ticket events, enable this.', 'dbem' ) );
|
1644 |
+
em_options_radio_binary ( __( 'Show unavailable tickets?', 'dbem' ), 'dbem_bookings_tickets_show_unavailable', __( 'You can choose whether or not to show unavailable tickets to visitors.', 'dbem' ) );
|
1645 |
+
em_options_radio_binary ( __( 'Show member-only tickets?', 'dbem' ), 'dbem_bookings_tickets_show_member_tickets', sprintf(__('%s must be set to yes for this to work.', 'dbem' ), '<strong>'.__( 'Show unavailable tickets?', 'dbem' ).'</strong>').' '.__( 'If there are member-only tickets, you can choose whether or not to show these tickets to guests.','dbem') );
|
1646 |
+
|
1647 |
+
em_options_radio_binary ( __( 'Show multiple tickets if logged out?', 'dbem' ), 'dbem_bookings_tickets_show_loggedout', __( 'If guests cannot make bookings, they will be asked to register in order to book. However, enabling this will still show available tickets.', 'dbem' ) );
|
1648 |
+
$ticket_orders = array(
|
1649 |
+
'ticket_price DESC, ticket_name ASC'=>__('Ticket Price (Descending)','dbem'),
|
1650 |
+
'ticket_price ASC, ticket_name ASC'=>__('Ticket Price (Ascending)','dbem'),
|
1651 |
+
'ticket_name ASC, ticket_price DESC'=>__('Ticket Name (Ascending)','dbem'),
|
1652 |
+
'ticket_name DESC, ticket_price DESC'=>__('Ticket Name (Descending)','dbem')
|
1653 |
+
);
|
1654 |
+
em_options_select ( __( 'Order Tickets By', 'dbem' ), 'dbem_bookings_tickets_orderby', $ticket_orders, __( 'Choose which order your tickets appear.', 'dbem' ) );
|
1655 |
+
echo $save_button;
|
1656 |
+
?>
|
1657 |
+
</table>
|
1658 |
+
</div> <!-- . inside -->
|
1659 |
+
</div> <!-- .postbox -->
|
1660 |
+
|
1661 |
+
<div class="postbox " id="em-opt-no-user-bookings" >
|
1662 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e('No-User Booking Mode','dbem'); ?> </span></h3>
|
1663 |
+
<div class="inside">
|
1664 |
+
<table class='form-table'>
|
1665 |
+
<tr><td colspan='2'>
|
1666 |
+
<p><?php _e('By default, when a booking is made by a user, this booking is tied to a user account, if the user is not registered nor logged in and guest bookings are enabled, an account will be created for them.','dbem'); ?></p>
|
1667 |
+
<p><?php _e('The option below allows you to disable user accounts and assign all bookings to a parent user, yet you will still see the supplied booking personal information for each booking. When this mode is enabled, extra booking information about the person is stored alongside the booking record rather than as a WordPress user.','dbem'); ?></p>
|
1668 |
+
<p><?php _e('Users with accounts (which would be created by other means when this mode is enabled) will still be able to log in and make bookings linked to their account as normal.','dbem'); ?></p>
|
1669 |
+
<p><?php _e('<strong>Warning : </strong> Various features afforded to users with an account will not be available, e.g. viewing bookings. Once you enable this and select a user, modifying these values will prevent older non-user bookings from displaying the correct information.','dbem'); ?></p>
|
1670 |
+
</td></tr>
|
1671 |
+
<?php
|
1672 |
+
em_options_radio_binary ( __( 'Enable No-User Booking Mode?', 'dbem' ), 'dbem_bookings_registration_disable', __( 'This disables user registrations for bookings.', 'dbem' ) );
|
1673 |
+
em_options_radio_binary ( __( 'Allow bookings with registered emails?', 'dbem' ), 'dbem_bookings_registration_disable_user_emails', __( 'By default, if a guest tries to book an event using the email of a user account on your site they will be asked to log in, selecting yes will bypass this security measure.', 'dbem' ).'<br />'.__('<strong>Warning : </strong> By enabling this, registered users will not be able to see bookings they make as guests in their "My Bookings" page.','dbem') );
|
1674 |
+
$current_user = array();
|
1675 |
+
if( get_option('dbem_bookings_registration_user') ){
|
1676 |
+
$user = get_user_by('id',get_option('dbem_bookings_registration_user'));
|
1677 |
+
$current_user[$user->ID] = $user->display_name;
|
1678 |
+
}
|
1679 |
+
em_options_select ( __( 'Assign bookings to', 'dbem' ), 'dbem_bookings_registration_user', em_get_wp_users(array('role' => 'subscriber'), $current_user), __( 'Choose a parent user to assign bookings to. People making their booking will be unaware of this and will never have access to those user details. This should be a subscriber user you do not use to log in with yourself.', 'dbem' ) );
|
1680 |
+
echo $save_button;
|
1681 |
+
?>
|
1682 |
+
</table>
|
1683 |
+
</div> <!-- . inside -->
|
1684 |
+
</div> <!-- .postbox -->
|
1685 |
+
|
1686 |
+
<?php do_action('em_options_page_footer_bookings'); ?>
|
1687 |
+
|
1688 |
+
</div> <!-- .em-menu-bookings -->
|
1689 |
+
<?php endif; ?>
|
1690 |
+
|
1691 |
+
<!-- EMAIL OPTIONS -->
|
1692 |
+
<div class="em-menu-emails em-menu-group" style="display:none;">
|
1693 |
+
|
1694 |
+
<?php if ( !is_multisite() ) { em_admin_option_box_email(); } ?>
|
1695 |
+
|
1696 |
+
<?php if( get_option('dbem_rsvp_enabled') ): ?>
|
1697 |
+
<div class="postbox " id="em-opt-booking-emails">
|
1698 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Booking Email Templates', 'dbem' ); ?> </span></h3>
|
1699 |
+
<div class="inside">
|
1700 |
+
<?php do_action('em_options_page_booking_email_templates_options_top'); ?>
|
1701 |
+
<table class='form-table'>
|
1702 |
+
<?php
|
1703 |
+
$email_subject_tip = __('You can disable this email by leaving the subject blank.','dbem');
|
1704 |
+
em_options_input_text ( __( 'Email events admin?', 'dbem' ), 'dbem_bookings_notify_admin', __( "If you would like every event booking confirmation email sent to an administrator write their email here (leave blank to not send an email).", 'dbem' ).' '.__('For multiple emails, seperate by commas (e.g. email1@test.com,email2@test.com,etc.)','dbem') );
|
1705 |
+
em_options_radio_binary ( __( 'Email event owner?', 'dbem' ), 'dbem_bookings_contact_email', __( 'Check this option if you want the event contact to receive an email when someone books places. An email will be sent when a booking is first made (regardless if confirmed or pending)', 'dbem' ) );
|
1706 |
+
?>
|
1707 |
+
<tr><td colspan='2'><strong style="font-size:1.2em"><?php _e('Event Admin/Owner Emails', 'dbem'); ?></strong></td></tr>
|
1708 |
+
<tr><td colspan='2'>
|
1709 |
+
<p><strong><?php _e('Contact person booking confirmed','dbem') ?></strong></p>
|
1710 |
+
<em><?php echo __('An email will be sent to the event contact when a booking is first made.','dbem').$bookings_placeholder_tip ?></em>
|
1711 |
+
</td></tr>
|
1712 |
+
<?php
|
1713 |
+
em_options_input_text ( __( 'Contact person email subject', 'dbem' ), 'dbem_bookings_contact_email_subject', $email_subject_tip );
|
1714 |
+
em_options_textarea ( __( 'Contact person email', 'dbem' ), 'dbem_bookings_contact_email_body', '' );
|
1715 |
+
?>
|
1716 |
+
<tr><td colspan='2'>
|
1717 |
+
<p><strong><?php _e('Contact person booking cancelled','dbem') ?></strong></p>
|
1718 |
+
<em><?php echo __('An email will be sent to the event contact if someone cancels their booking.','dbem').$bookings_placeholder_tip ?></em>
|
1719 |
+
</td></tr>
|
1720 |
+
<?php
|
1721 |
+
em_options_input_text ( __( 'Contact person cancellation subject', 'dbem' ), 'dbem_contactperson_email_cancelled_subject', $email_subject_tip );
|
1722 |
+
em_options_textarea ( __( 'Contact person cancellation email', 'dbem' ), 'dbem_contactperson_email_cancelled_body', '' );
|
1723 |
+
?>
|
1724 |
+
<tr><td colspan='2'><strong style="font-size:1.2em"><?php _e('Booked User Emails', 'dbem'); ?></strong></td></tr>
|
1725 |
+
<tr><td colspan='2'>
|
1726 |
+
<p><strong><?php _e('Confirmed booking email','dbem') ?></strong></p>
|
1727 |
+
<em><?php echo __('This is sent when a person\'s booking is confirmed. This will be sent automatically if approvals are required and the booking is approved. If approvals are disabled, this is sent out when a user first submits their booking.','dbem').$bookings_placeholder_tip ?></em>
|
1728 |
+
</td></tr>
|
1729 |
+
<?php
|
1730 |
+
em_options_input_text ( __( 'Booking confirmed email subject', 'dbem' ), 'dbem_bookings_email_confirmed_subject', $email_subject_tip );
|
1731 |
+
em_options_textarea ( __( 'Booking confirmed email', 'dbem' ), 'dbem_bookings_email_confirmed_body', '' );
|
1732 |
+
?>
|
1733 |
+
<tr><td colspan='2'>
|
1734 |
+
<p><strong><?php _e('Pending booking email','dbem') ?></strong></p>
|
1735 |
+
<em><?php echo __( 'This will be sent to the person when they first submit their booking. Not relevant if bookings don\'t require approval.', 'dbem' ).$bookings_placeholder_tip ?></em>
|
1736 |
+
</td></tr>
|
1737 |
+
<?php
|
1738 |
+
em_options_input_text ( __( 'Booking pending email subject', 'dbem' ), 'dbem_bookings_email_pending_subject', $email_subject_tip);
|
1739 |
+
em_options_textarea ( __( 'Booking pending email', 'dbem' ), 'dbem_bookings_email_pending_body','') ;
|
1740 |
+
?>
|
1741 |
+
<tr><td colspan='2'>
|
1742 |
+
<p><strong><?php _e('Rejected booking email','dbem') ?></strong></p>
|
1743 |
+
<em><?php echo __( 'This will be sent automatically when a booking is rejected. Not relevant if bookings don\'t require approval.', 'dbem' ).$bookings_placeholder_tip ?></em>
|
1744 |
+
</td></tr>
|
1745 |
+
<?php
|
1746 |
+
em_options_input_text ( __( 'Booking rejected email subject', 'dbem' ), 'dbem_bookings_email_rejected_subject', $email_subject_tip );
|
1747 |
+
em_options_textarea ( __( 'Booking rejected email', 'dbem' ), 'dbem_bookings_email_rejected_body', '' );
|
1748 |
+
?>
|
1749 |
+
<tr><td colspan='2'>
|
1750 |
+
<p><strong><?php _e('Booking cancelled','dbem') ?></strong></p>
|
1751 |
+
<em><?php echo __('This will be sent when a user cancels their booking.','dbem').$bookings_placeholder_tip ?></em>
|
1752 |
+
</td></tr>
|
1753 |
+
<?php
|
1754 |
+
em_options_input_text ( __( 'Booking cancelled email subject', 'dbem' ), 'dbem_bookings_email_cancelled_subject', $email_subject_tip );
|
1755 |
+
em_options_textarea ( __( 'Booking cancelled email', 'dbem' ), 'dbem_bookings_email_cancelled_body', '' );
|
1756 |
+
?>
|
1757 |
+
<?php do_action('em_options_page_booking_email_templates_options_bottom'); ?>
|
1758 |
+
<?php echo $save_button; ?>
|
1759 |
+
</table>
|
1760 |
+
</div> <!-- . inside -->
|
1761 |
+
</div> <!-- .postbox -->
|
1762 |
+
<?php endif; ?>
|
1763 |
+
|
1764 |
+
<?php if( get_option('dbem_rsvp_enabled') ): ?>
|
1765 |
+
<div class="postbox " id="em-opt-registration-emails">
|
1766 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Registration Email Templates', 'dbem' ); ?> </span></h3>
|
1767 |
+
<div class="inside">
|
1768 |
+
<p>
|
1769 |
+
<?php echo sprintf(__('This is only applicable when %s is not active.','dbem'), '<em>'.__('No-User Booking Mode','dbem').'</em>'); ?>
|
1770 |
+
<?php _e('When a guest user makes a booking for the first time in Events Manager, a new user account is created for them and they are sent their credentials in a seperate email, which can be modified below.','dbem'); ?>
|
1771 |
+
</p>
|
1772 |
+
<table class='form-table'>
|
1773 |
+
<?php
|
1774 |
+
em_options_radio_binary ( __( 'Disable new registration email?', 'dbem' ), 'dbem_email_disable_registration', __( 'Check this option if you want to prevent the WordPress registration email from going out when a user anonymously books an event.', 'dbem' ) );
|
1775 |
+
|
1776 |
+
em_options_input_text ( __( 'Registration email subject', 'dbem' ), 'dbem_bookings_email_registration_subject' );
|
1777 |
+
em_options_textarea ( __( 'Registration email', 'dbem' ), 'dbem_bookings_email_registration_body', sprintf(__('%s is replaced by username and %s is replaced by the user password.','dbem'),'<code>%username%</code>','<code>%password%</code>') );
|
1778 |
+
echo $save_button;
|
1779 |
+
?>
|
1780 |
+
</table>
|
1781 |
+
</div> <!-- . inside -->
|
1782 |
+
</div> <!-- .postbox -->
|
1783 |
+
<?php endif; ?>
|
1784 |
+
|
1785 |
+
<div class="postbox " id="em-opt-event-submission-emails" >
|
1786 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Submission Templates', 'dbem' ); ?> </span></h3>
|
1787 |
+
<div class="inside">
|
1788 |
+
<table class='form-table'>
|
1789 |
+
<tr><td colspan='2'><strong style="font-size:1.2em"><?php _e('Event Admin Emails', 'dbem'); ?></strong></td></tr>
|
1790 |
+
<?php
|
1791 |
+
em_options_input_text ( __( 'Administrator Email', 'dbem' ), 'dbem_event_submitted_email_admin', __('Event submission notifications will be sent to emails added here.','dbem').' '.__('If left blank, no emails will be sent. Seperate emails with commas for more than one email.','dbem') );
|
1792 |
+
?>
|
1793 |
+
<tr><td colspan='2'>
|
1794 |
+
<p><strong><?php _e('Event Submitted','dbem') ?></strong></p>
|
1795 |
+
<em><?php echo __('An email will be sent to your administrator emails when an event is submitted and pending approval.','dbem').$bookings_placeholder_tip ?></em>
|
1796 |
+
</td></tr>
|
1797 |
+
<?php
|
1798 |
+
em_options_input_text ( __( 'Event submitted subject', 'dbem' ), 'dbem_event_submitted_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1799 |
+
em_options_textarea ( __( 'Event submitted email', 'dbem' ), 'dbem_event_submitted_email_body', '' );
|
1800 |
+
?>
|
1801 |
+
<tr><td colspan='2'>
|
1802 |
+
<p><strong><?php _e('Event Re-Submitted','dbem') ?></strong></p>
|
1803 |
+
<em><?php echo __('When a user modifies a previously published event, it will be put back into pending review status and will not be publisehd until you re-approve it.','dbem').$bookings_placeholder_tip ?></em>
|
1804 |
+
</td></tr>
|
1805 |
+
<?php
|
1806 |
+
em_options_input_text ( __( 'Event resubmitted subject', 'dbem' ), 'dbem_event_resubmitted_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1807 |
+
em_options_textarea ( __( 'Event resubmitted email', 'dbem' ), 'dbem_event_resubmitted_email_body', '' );
|
1808 |
+
?>
|
1809 |
+
<tr><td colspan='2'>
|
1810 |
+
<p><strong><?php _e('Event Published','dbem') ?></strong></p>
|
1811 |
+
<em><?php echo __('An email will be sent to an administrator of your choice when an event is published by users who are not administrators.','dbem').$bookings_placeholder_tip ?>
|
1812 |
+
</td></tr>
|
1813 |
+
<?php
|
1814 |
+
em_options_input_text ( __( 'Event published subject', 'dbem' ), 'dbem_event_published_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1815 |
+
em_options_textarea ( __( 'Event published email', 'dbem' ), 'dbem_event_published_email_body', '' );
|
1816 |
+
?>
|
1817 |
+
<tr><td colspan='2'><strong style="font-size:1.2em"><?php _e('Event Submitter Emails', 'dbem'); ?></strong></td></tr>
|
1818 |
+
<tr><td colspan='2'>
|
1819 |
+
<p><strong><?php _e('Event Approved','dbem') ?></strong></p>
|
1820 |
+
<em><?php echo __('An email will be sent to the event owner when their event is approved. Users requiring event approval do not have the <code>publish_events</code> capability.','dbem').$bookings_placeholder_tip ?>
|
1821 |
+
</td></tr>
|
1822 |
+
<?php
|
1823 |
+
em_options_input_text ( __( 'Event approved subject', 'dbem' ), 'dbem_event_approved_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1824 |
+
em_options_textarea ( __( 'Event approved email', 'dbem' ), 'dbem_event_approved_email_body', '' );
|
1825 |
+
?>
|
1826 |
+
<tr><td colspan='2'><?php echo __('When a user modifies a previously published event, it will be put back into pending review status and will not be publisehd until you re-approve it.','dbem').$bookings_placeholder_tip ?></td></tr>
|
1827 |
+
<?php
|
1828 |
+
em_options_input_text ( __( 'Event reapproved subject', 'dbem' ), 'dbem_event_reapproved_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1829 |
+
em_options_textarea ( __( 'Event reapproved email', 'dbem' ), 'dbem_event_reapproved_email_body', '' );
|
1830 |
+
?>
|
1831 |
+
<?php echo $save_button; ?>
|
1832 |
+
</table>
|
1833 |
+
</div> <!-- . inside -->
|
1834 |
+
</div> <!-- .postbox -->
|
1835 |
+
|
1836 |
+
<?php do_action('em_options_page_footer_emails'); ?>
|
1837 |
+
|
1838 |
+
</div><!-- .em-group-emails -->
|
1839 |
+
<?php /*
|
1840 |
+
<div class="postbox " >
|
1841 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Debug Modes', 'dbem' ); ?> </span></h3>
|
1842 |
+
<div class="inside">
|
1843 |
+
<table class='form-table'>
|
1844 |
+
<?php
|
1845 |
+
em_options_radio_binary ( __( 'EM Debug Mode?', 'dbem' ), 'dbem_debug', __( 'Setting this to yes will display different content to admins for event pages and emails so you can see all the available placeholders and their values.', 'dbem' ) );
|
1846 |
+
em_options_radio_binary ( __( 'WP Debug Mode?', 'dbem' ), 'dbem_wp_debug', __( 'This will turn WP_DEBUG mode on. Useful if you want to troubleshoot php errors without looking at your logs.', 'dbem' ) );
|
1847 |
+
?>
|
1848 |
+
</table>
|
1849 |
+
</div> <!-- . inside -->
|
1850 |
+
</div> <!-- .postbox -->
|
1851 |
+
*/ ?>
|
1852 |
+
|
1853 |
+
<p class="submit">
|
1854 |
+
<input type="submit" id="dbem_options_submit" class="button-primary" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
|
1855 |
+
<input type="hidden" name="em-submitted" value="1" />
|
1856 |
+
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('events-manager-options'); ?>" />
|
1857 |
+
</p>
|
1858 |
+
|
1859 |
+
</div> <!-- .metabox-sortables -->
|
1860 |
+
</div> <!-- .postbox-container -->
|
1861 |
+
|
1862 |
+
</div> <!-- .metabox-holder -->
|
1863 |
+
</form>
|
1864 |
+
</div>
|
1865 |
+
<?php
|
1866 |
+
}
|
1867 |
+
|
1868 |
+
/**
|
1869 |
+
* Meta options box for image sizes. Shared in both MS and Normal options page, hence it's own function
|
1870 |
+
*/
|
1871 |
+
function em_admin_option_box_image_sizes(){
|
1872 |
+
global $save_button;
|
1873 |
+
?>
|
1874 |
+
<div class="postbox " id="em-opt-image-sizes" >
|
1875 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Image Sizes', 'dbem' ); ?> </span></h3>
|
1876 |
+
<div class="inside">
|
1877 |
+
<p><?php _e('These settings will only apply to the image uploading if using our front-end forms. In your WP admin area, images are handled by WordPress.','dbem'); ?>
|
1878 |
+
<table class='form-table'>
|
1879 |
+
<?php
|
1880 |
+
em_options_input_text ( __( 'Maximum width (px)', 'dbem' ), 'dbem_image_max_width', __( 'The maximum allowed width for images uploades', 'dbem' ) );
|
1881 |
+
em_options_input_text ( __( 'Minimum width (px)', 'dbem' ), 'dbem_image_min_width', __( 'The minimum allowed width for images uploades', 'dbem' ) );
|
1882 |
+
em_options_input_text ( __( 'Maximum height (px)', 'dbem' ), 'dbem_image_max_height', __( "The maximum allowed height for images uploaded, in pixels", 'dbem' ) );
|
1883 |
+
em_options_input_text ( __( 'Minimum height (px)', 'dbem' ), 'dbem_image_min_height', __( "The minimum allowed height for images uploaded, in pixels", 'dbem' ) );
|
1884 |
+
em_options_input_text ( __( 'Maximum size (bytes)', 'dbem' ), 'dbem_image_max_size', __( "The maximum allowed size for images uploaded, in bytes", 'dbem' ) );
|
1885 |
+
echo $save_button;
|
1886 |
+
?>
|
1887 |
+
</table>
|
1888 |
+
</div> <!-- . inside -->
|
1889 |
+
</div> <!-- .postbox -->
|
1890 |
+
<?php
|
1891 |
+
}
|
1892 |
+
|
1893 |
+
/**
|
1894 |
+
* Meta options box for email settings. Shared in both MS and Normal options page, hence it's own function
|
1895 |
+
*/
|
1896 |
+
function em_admin_option_box_email(){
|
1897 |
+
global $save_button;
|
1898 |
+
$current_user = get_user_by('id', get_current_user_id());
|
1899 |
+
?>
|
1900 |
+
<div class="postbox " id="em-opt-email-settings">
|
1901 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Email Settings', 'dbem' ); ?></span></h3>
|
1902 |
+
<div class="inside em-email-form">
|
1903 |
+
<p class="em-email-settings-check">
|
1904 |
+
<em><?php _e('Before you save your changes, you can quickly send yourself a test email by clicking this button.','dbem'); ?>
|
1905 |
+
<?php echo sprintf(__('A test email will be sent to your account email - %s','dbem'), $current_user->user_email . ' <a href="'.admin_url( 'profile.php' ).'">'.__('edit','dbem').'</a>'); ?></em><br />
|
1906 |
+
<input type="button" id="em-admin-check-email" class="secondary-button" value="<?php _e('Test Email Settings','dbem'); ?>" />
|
1907 |
+
<input type="hidden" name="_check_email_nonce" value="<?php echo wp_create_nonce('check_email'); ?>" />
|
1908 |
+
<span id="em-email-settings-check-status"></span>
|
1909 |
+
</p>
|
1910 |
+
<table class="form-table">
|
1911 |
+
<?php
|
1912 |
+
em_options_input_text ( __( 'Notification sender name', 'dbem' ), 'dbem_mail_sender_name', __( "Insert the display name of the notification sender.", 'dbem' ) );
|
1913 |
+
em_options_input_text ( __( 'Notification sender address', 'dbem' ), 'dbem_mail_sender_address', __( "Insert the address of the notification sender.", 'dbem' ) );
|
1914 |
+
em_options_select ( __( 'Mail sending method', 'dbem' ), 'dbem_rsvp_mail_send_method', array ('smtp' => 'SMTP', 'mail' => __( 'PHP mail function', 'dbem' ), 'sendmail' => 'Sendmail', 'qmail' => 'Qmail', 'wp_mail' => 'WP Mail' ), __( 'Select the method to send email notification.', 'dbem' ) );
|
1915 |
+
em_options_radio_binary ( __( 'Send HTML Emails?', 'dbem' ), 'dbem_smtp_html', __( 'If set to yes, your emails will be sent in HTML format, otherwise plaintext.', 'dbem' ).' '.__( 'Depending on server settings, some sending methods may ignore this settings.', 'dbem' ) );
|
1916 |
+
em_options_radio_binary ( __( 'Add br tags to HTML emails?', 'dbem' ), 'dbem_smtp_html_br', __( 'If HTML emails are enabled, br tags will automatically be added for new lines.', 'dbem' ) );
|
1917 |
+
?>
|
1918 |
+
<tbody class="em-email-settings-smtp">
|
1919 |
+
<?php
|
1920 |
+
em_options_input_text ( 'Mail sending port', 'dbem_rsvp_mail_port', __( "The port through which you e-mail notifications will be sent. Make sure the firewall doesn't block this port", 'dbem' ) );
|
1921 |
+
em_options_radio_binary ( __( 'Use SMTP authentication?', 'dbem' ), 'dbem_rsvp_mail_SMTPAuth', __( 'SMTP authentication is often needed. If you use GMail, make sure to set this parameter to Yes', 'dbem' ) );
|
1922 |
+
em_options_input_text ( 'SMTP host', 'dbem_smtp_host', __( "The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set this value to 'ssl://smtp.gmail.com:465'.", 'dbem' ) );
|
1923 |
+
em_options_input_text ( __( 'SMTP username', 'dbem' ), 'dbem_smtp_username', __( "Insert the username to be used to access your SMTP server.", 'dbem' ) );
|
1924 |
+
em_options_input_password ( __( 'SMTP password', 'dbem' ), "dbem_smtp_password", __( "Insert the password to be used to access your SMTP server", 'dbem' ) );
|
1925 |
+
?>
|
1926 |
+
</tbody>
|
1927 |
+
<?php
|
1928 |
+
echo $save_button;
|
1929 |
+
?>
|
1930 |
+
</table>
|
1931 |
+
<script type="text/javascript" charset="utf-8">
|
1932 |
+
jQuery(document).ready(function($){
|
1933 |
+
$('#dbem_rsvp_mail_send_method_row select').change(function(){
|
1934 |
+
el = $(this);
|
1935 |
+
if( el.find(':selected').val() == 'smtp' ){
|
1936 |
+
$('.em-email-settings-smtp').show();
|
1937 |
+
}else{
|
1938 |
+
$('.em-email-settings-smtp').hide();
|
1939 |
+
}
|
1940 |
+
}).trigger('change');
|
1941 |
+
$('input#em-admin-check-email').click(function(e,el){
|
1942 |
+
var email_data = $('.em-email-form input').serialize();
|
1943 |
+
$.ajax({
|
1944 |
+
url: EM.ajaxurl,
|
1945 |
+
dataType: 'json',
|
1946 |
+
data: email_data+"&action=em_admin_test_email",
|
1947 |
+
success: function(data){
|
1948 |
+
if(data.result && data.message){
|
1949 |
+
$('#em-email-settings-check-status').css({'color':'green','display':'block'}).html(data.message);
|
1950 |
+
}else{
|
1951 |
+
var msg = (data.message) ? data.message:'Email not sent';
|
1952 |
+
$('#em-email-settings-check-status').css({'color':'red','display':'block'}).html(msg);
|
1953 |
+
}
|
1954 |
+
},
|
1955 |
+
error: function(){ $('#em-email-settings-check-status').css({'color':'red','display':'block'}).html('Server Error'); },
|
1956 |
+
beforeSend: function(){ $('input#em-admin-check-email').val('<?php _e('Checking...','dbem') ?>'); },
|
1957 |
+
complete: function(){ $('input#em-admin-check-email').val('<?php _e('Test Email Settings','dbem'); ?>'); }
|
1958 |
+
});
|
1959 |
+
});
|
1960 |
+
});
|
1961 |
+
</script>
|
1962 |
+
</div> <!-- . inside -->
|
1963 |
+
</div> <!-- .postbox -->
|
1964 |
+
<?php
|
1965 |
+
}
|
1966 |
+
|
1967 |
+
/**
|
1968 |
+
* Meta options box for user capabilities. Shared in both MS and Normal options page, hence it's own function
|
1969 |
+
*/
|
1970 |
+
function em_admin_option_box_caps(){
|
1971 |
+
global $save_button, $wpdb;
|
1972 |
+
?>
|
1973 |
+
<div class="postbox" id="em-opt-user-caps" >
|
1974 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'User Capabilities', 'dbem' ); ?></span></h3>
|
1975 |
+
<div class="inside">
|
1976 |
+
<table class="form-table">
|
1977 |
+
<tr><td colspan="2">
|
1978 |
+
<strong><?php _e('Warning: Changing these values may result in exposing previously hidden information to all users.', 'dbem')?></strong><br />
|
1979 |
+
</td></tr>
|
1980 |
+
<?php
|
1981 |
+
global $wp_roles;
|
1982 |
+
$cap_docs = array(
|
1983 |
+
sprintf(__('%s Capabilities','dbem'),__('Event','dbem')) => array(
|
1984 |
+
/* Event Capabilities */
|
1985 |
+
'publish_events' => sprintf(__('Users can publish %s and skip any admin approval','dbem'),__('events','dbem')),
|
1986 |
+
'delete_others_events' => sprintf(__('User can delete other users %s','dbem'),__('events','dbem')),
|
1987 |
+
'edit_others_events' => sprintf(__('User can edit other users %s','dbem'),__('events','dbem')),
|
1988 |
+
'delete_events' => sprintf(__('User can delete their own %s','dbem'),__('events','dbem')),
|
1989 |
+
'edit_events' => sprintf(__('User can create and edit %s','dbem'),__('events','dbem')),
|
1990 |
+
'read_private_events' => sprintf(__('User can view private %s','dbem'),__('events','dbem')),
|
1991 |
+
/*'read_events' => sprintf(__('User can view %s','dbem'),__('events','dbem')),*/
|
1992 |
+
),
|
1993 |
+
sprintf(__('%s Capabilities','dbem'),__('Recurring Event','dbem')) => array(
|
1994 |
+
/* Recurring Event Capabilties */
|
1995 |
+
'publish_recurring_events' => sprintf(__('Users can publish %s and skip any admin approval','dbem'),__('recurring events','dbem')),
|
1996 |
+
'delete_others_recurring_events' => sprintf(__('User can delete other users %s','dbem'),__('recurring events','dbem')),
|
1997 |
+
'edit_others_recurring_events' => sprintf(__('User can edit other users %s','dbem'),__('recurring events','dbem')),
|
1998 |
+
'delete_recurring_events' => sprintf(__('User can delete their own %s','dbem'),__('recurring events','dbem')),
|
1999 |
+
'edit_recurring_events' => sprintf(__('User can create and edit %s','dbem'),__('recurring events','dbem'))
|
2000 |
+
),
|
2001 |
+
sprintf(__('%s Capabilities','dbem'),__('Location','dbem')) => array(
|
2002 |
+
/* Location Capabilities */
|
2003 |
+
'publish_locations' => sprintf(__('Users can publish %s and skip any admin approval','dbem'),__('locations','dbem')),
|
2004 |
+
'delete_others_locations' => sprintf(__('User can delete other users %s','dbem'),__('locations','dbem')),
|
2005 |
+
'edit_others_locations' => sprintf(__('User can edit other users %s','dbem'),__('locations','dbem')),
|
2006 |
+
'delete_locations' => sprintf(__('User can delete their own %s','dbem'),__('locations','dbem')),
|
2007 |
+
'edit_locations' => sprintf(__('User can create and edit %s','dbem'),__('locations','dbem')),
|
2008 |
+
'read_private_locations' => sprintf(__('User can view private %s','dbem'),__('locations','dbem')),
|
2009 |
+
'read_others_locations' => __('User can use other user locations for their events.','dbem'),
|
2010 |
+
/*'read_locations' => sprintf(__('User can view %s','dbem'),__('locations','dbem')),*/
|
2011 |
+
),
|
2012 |
+
sprintf(__('%s Capabilities','dbem'),__('Other','dbem')) => array(
|
2013 |
+
/* Category Capabilities */
|
2014 |
+
'delete_event_categories' => sprintf(__('User can delete %s categories and tags.','dbem'),__('event','dbem')),
|
2015 |
+
'edit_event_categories' => sprintf(__('User can edit %s categories and tags.','dbem'),__('event','dbem')),
|
2016 |
+
/* Booking Capabilities */
|
2017 |
+
'manage_others_bookings' => __('User can manage other users individual bookings and event booking settings.','dbem'),
|
2018 |
+
'manage_bookings' => __('User can use and manage bookings with their events.','dbem'),
|
2019 |
+
'upload_event_images' => __('User can upload images along with their events and locations.','dbem')
|
2020 |
+
)
|
2021 |
+
);
|
2022 |
+
?>
|
2023 |
+
<tr><td colspan="2">
|
2024 |
+
<p><em><?php _e('You can now give fine grained control with regards to what your users can do with events. Each user role can have perform different sets of actions.','dbem'); ?></em></p>
|
2025 |
+
</td></tr>
|
2026 |
+
<tr><td colspan="2">
|
2027 |
+
<?php
|
2028 |
+
if( is_multisite() && is_network_admin() ){
|
2029 |
+
echo em_options_radio_binary(__('Apply global capabilities?','dbem'), 'dbem_ms_global_caps', __('If set to yes the capabilities will be applied all your network blogs and you will not be able to set custom capabilities each blog. You can select no later and visit specific blog settings pages to add/remove capabilities.','dbem') );
|
2030 |
+
}
|
2031 |
+
?>
|
2032 |
+
</td></tr>
|
2033 |
+
<tr><td colspan="2">
|
2034 |
+
<table class="em-caps-table" style="width:auto;" cellspacing="0" cellpadding="0">
|
2035 |
+
<thead>
|
2036 |
+
<tr>
|
2037 |
+
<td> </td>
|
2038 |
+
<?php
|
2039 |
+
$odd = 0;
|
2040 |
+
foreach(array_keys($cap_docs) as $capability_group){
|
2041 |
+
?><th class="<?php echo ( !is_int($odd/2) ) ? 'odd':''; ?>"><?php echo $capability_group ?></th><?php
|
2042 |
+
$odd++;
|
2043 |
+
}
|
2044 |
+
?>
|
2045 |
+
</tr>
|
2046 |
+
</thead>
|
2047 |
+
<tbody>
|
2048 |
+
<?php foreach($wp_roles->role_objects as $role): ?>
|
2049 |
+
<tr>
|
2050 |
+
<td class="cap"><strong><?php echo $role->name; ?></strong></td>
|
2051 |
+
<?php
|
2052 |
+
$odd = 0;
|
2053 |
+
foreach($cap_docs as $capability_group){
|
2054 |
+
?>
|
2055 |
+
<td class="<?php echo ( !is_int($odd/2) ) ? 'odd':''; ?>">
|
2056 |
+
<?php foreach($capability_group as $cap => $cap_help){ ?>
|
2057 |
+
<input type="checkbox" name="em_capabilities[<?php echo $role->name; ?>][<?php echo $cap ?>]" value="1" id="<?php echo $role->name.'_'.$cap; ?>" <?php echo $role->has_cap($cap) ? 'checked="checked"':''; ?> />
|
2058 |
+
<label for="<?php echo $role->name.'_'.$cap; ?>"><?php echo $cap; ?></label> <a href="#" title="<?php echo $cap_help; ?>">?</a>
|
2059 |
+
<br />
|
2060 |
+
<?php } ?>
|
2061 |
+
</td>
|
2062 |
+
<?php
|
2063 |
+
$odd++;
|
2064 |
+
}
|
2065 |
+
?>
|
2066 |
+
</tr>
|
2067 |
+
<?php endforeach; ?>
|
2068 |
+
</tbody>
|
2069 |
+
</table>
|
2070 |
+
</td></tr>
|
2071 |
+
<?php echo $save_button; ?>
|
2072 |
+
</table>
|
2073 |
+
</div> <!-- . inside -->
|
2074 |
+
</div> <!-- .postbox -->
|
2075 |
+
<?php
|
2076 |
+
}
|
2077 |
+
|
2078 |
+
function em_admin_option_box_uninstall(){
|
2079 |
+
global $save_button;
|
2080 |
+
if( is_multisite() ){
|
2081 |
+
$uninstall_url = admin_url().'network/admin.php?page=events-manager-options&action=uninstall&_wpnonce='.wp_create_nonce('em_uninstall_'.get_current_user_id().'_wpnonce');
|
2082 |
+
$reset_url = admin_url().'network/admin.php?page=events-manager-options&action=reset&_wpnonce='.wp_create_nonce('em_reset_'.get_current_user_id().'_wpnonce');
|
2083 |
+
$recheck_updates_url = admin_url().'network/admin.php?page=events-manager-options&action=recheck_updates&_wpnonce='.wp_create_nonce('em_recheck_updates_'.get_current_user_id().'_wpnonce');
|
2084 |
+
$check_devs = admin_url().'network/admin.php?page=events-manager-options&action=check_devs&_wpnonce='.wp_create_nonce('em_check_devs_wpnonce');
|
2085 |
+
}else{
|
2086 |
+
$uninstall_url = EM_ADMIN_URL.'&page=events-manager-options&action=uninstall&_wpnonce='.wp_create_nonce('em_uninstall_'.get_current_user_id().'_wpnonce');
|
2087 |
+
$reset_url = EM_ADMIN_URL.'&page=events-manager-options&action=reset&_wpnonce='.wp_create_nonce('em_reset_'.get_current_user_id().'_wpnonce');
|
2088 |
+
$recheck_updates_url = EM_ADMIN_URL.'&page=events-manager-options&action=recheck_updates&_wpnonce='.wp_create_nonce('em_recheck_updates_'.get_current_user_id().'_wpnonce');
|
2089 |
+
$check_devs = EM_ADMIN_URL.'&page=events-manager-options&action=check_devs&_wpnonce='.wp_create_nonce('em_check_devs_wpnonce');
|
2090 |
+
}
|
2091 |
+
?>
|
2092 |
+
<div class="postbox" id="em-opt-admin-tools" >
|
2093 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Admin Tools', 'dbem' ); ?> (<?php _e ( 'Advanced', 'dbem' ); ?>)</span></h3>
|
2094 |
+
<div class="inside">
|
2095 |
+
<h4 style="font-size:1.1em;"><?php _e ( 'Development Versions & Updates', 'dbem' ); ?></h4>
|
2096 |
+
<p><?php _e('We\'re always making improvements, adding features and fixing bugs between releases. We incrementally make these changes in between updates and make it available as a development version. You can download these manually, but we\'ve made it easy for you. <strong>Warning:</strong> Development versions are not always fully tested before release, use wisely!','dbem'); ?></p>
|
2097 |
+
<table class="form-table">
|
2098 |
+
<?php em_options_radio_binary ( __( 'Enable Dev Updates?', 'dbem' ), 'dbem_pro_dev_updates', __('If enabled, the latest dev version will always be checked instead of the latest stable version of the plugin.', 'dbem') ); ?>
|
2099 |
+
</table>
|
2100 |
+
<p><a href="<?php echo $recheck_updates_url; ?>" class="button-secondary"><?php _e('Re-Check Updates','dbem'); ?></a> - <?php _e('If you would like to check and see if there is a new stable update.','dbem'); ?></p>
|
2101 |
+
<p><a href="<?php echo $check_devs; ?>" class="button-secondary"><?php _e('Check Dev Versions','dbem'); ?></a> - <?php _e('If you would like to download a dev version, but just as a one-off, you can force a dev version check by clicking the button below. If there is one available, it should appear in your plugin updates page as a regular update.','dbem'); ?></p>
|
2102 |
+
|
2103 |
+
<h4 style="font-size:1.1em;"><?php _e ( 'Uninstall/Reset', 'dbem' ); ?></h4>
|
2104 |
+
<p><?php _e('Use the buttons below to uninstall Events Manager completely from your system or reset Events Manager to original settings and keep your event data.','dbem'); ?></p>
|
2105 |
+
<a href="<?php echo $uninstall_url; ?>" class="button-secondary"><?php _e('Uninstall','dbem'); ?></a>
|
2106 |
+
<a href="<?php echo $reset_url; ?>" class="button-secondary"><?php _e('Reset','dbem'); ?></a>
|
2107 |
+
|
2108 |
+
<?php do_action('em_options_page_panel_admin_tools'); ?>
|
2109 |
+
<?php echo $save_button; ?>
|
2110 |
+
</div>
|
2111 |
+
</div>
|
2112 |
+
<?php
|
2113 |
+
}
|
2114 |
Â
?>
|
admin/em-people.php
DELETED
@@ -1,192 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Check for flags to save personal data
|
4 |
-
*/
|
5 |
-
function em_person_actions(){
|
6 |
-
global $EM_Person;
|
7 |
-
if( !empty($_REQUEST['action']) && is_object($EM_Person) ){
|
8 |
-
if( $_REQUEST['action'] == 'edit_person' ){
|
9 |
-
$validation = $EM_Person->get_post();
|
10 |
-
if ( $validation ) { //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
|
11 |
-
//Save
|
12 |
-
if( $EM_Person->save() ) {
|
13 |
-
function em_person_save_notification(){
|
14 |
-
global $EM_Person;
|
15 |
-
?><div class="updated"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
|
16 |
-
}
|
17 |
-
}else{
|
18 |
-
function em_person_save_notification(){
|
19 |
-
global $EM_Person;
|
20 |
-
?><div class="error"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
|
21 |
-
}
|
22 |
-
}
|
23 |
-
}else{
|
24 |
-
//TODO make errors clearer when saving person
|
25 |
-
function em_person_save_notification(){
|
26 |
-
global $EM_Person;
|
27 |
-
?><div class="error"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
|
28 |
-
}
|
29 |
-
}
|
30 |
-
add_action ( 'admin_notices', 'em_person_save_notification' );
|
31 |
-
}
|
32 |
-
if( $_REQUEST['action'] == 'person_delete' ){
|
33 |
-
if( $EM_Person->delete() ){
|
34 |
-
//TODO delete person needs confirmation
|
35 |
-
wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-bookings');
|
36 |
-
exit();
|
37 |
-
}else{
|
38 |
-
function em_person_delete_notification(){
|
39 |
-
global $EM_Person;
|
40 |
-
?><div class="error"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
|
41 |
-
}
|
42 |
-
}
|
43 |
-
add_action ( 'admin_notices', 'em_person_delete_notification' );
|
44 |
-
}
|
45 |
-
}
|
46 |
-
}
|
47 |
-
add_action('admin_init','em_person_actions');
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Generate an edit form for person details.
|
51 |
-
*/
|
52 |
-
function em_person_edit_form(){
|
53 |
-
global $EM_Person;
|
54 |
-
?>
|
55 |
-
<form action="" method="post" id="em-person-form">
|
56 |
-
<table>
|
57 |
-
<tr><td><strong><?php _e('Name','dbem'); ?></strong></td><td><input type="text" name="person_name" size="60" value="<?php echo $EM_Person->name; ?>" /></td></tr>
|
58 |
-
<tr><td><strong><?php _e('Phone','dbem'); ?></strong></td><td><input type="text" name="person_phone" size="60" value="<?php echo $EM_Person->phone; ?>" /></td></tr>
|
59 |
-
<tr><td><strong><?php _e('E-mail','dbem'); ?></strong></td><td><input type="text" name="person_email" size="60" value="<?php echo $EM_Person->email; ?>" /></td></tr>
|
60 |
-
</table>
|
61 |
-
<p class="submit">
|
62 |
-
<input type="submit" name="events_update" value="<?php _e ( 'Save' ); ?> »" />
|
63 |
-
</p>
|
64 |
-
<input type="hidden" name="action" value="person_edit" />
|
65 |
-
<input type="hidden" name="person_id" value="<?php echo $EM_Person->id; ?>" />
|
66 |
-
</form>
|
67 |
-
<?php
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Depreciated page... for now at least.
|
72 |
-
*/
|
73 |
-
function em_admin_people_page() {
|
74 |
-
?>
|
75 |
-
<div class='wrap'>
|
76 |
-
<div id="icon-users" class="icon32"><br/></div>
|
77 |
-
<h2>People</h2>
|
78 |
-
<?php
|
79 |
-
$EM_People = EM_People::get();
|
80 |
-
if (count($EM_People) < 1 ) {
|
81 |
-
_e("No people have responded to your events yet!", 'dbem');
|
82 |
-
} else {
|
83 |
-
?>
|
84 |
-
<p><?php _e('This table collects the data about the people who responded to your events', 'dbem') ?></p>
|
85 |
-
<table id='dbem-people-table' class='widefat post fixed'>
|
86 |
-
<thead>
|
87 |
-
<tr>
|
88 |
-
<th class='manage-column column-cb check-column' scope='col'> </th>
|
89 |
-
<th class='manage-column ' scope='col'>Name</th>
|
90 |
-
<th scope='col'>E-mail</th>
|
91 |
-
<th scope='col'>Phone number</th>
|
92 |
-
</tr>
|
93 |
-
</thead>
|
94 |
-
<tfoot>
|
95 |
-
<tr>
|
96 |
-
<th class='manage-column column-cb check-column' scope='col'> </th>
|
97 |
-
<th class='manage-column ' scope='col'>Name</th>
|
98 |
-
<th scope='col'>E-mail</th>
|
99 |
-
<th scope='col'>Phone number</th>
|
100 |
-
</tr>
|
101 |
-
</tfoot>
|
102 |
-
<?php foreach ($EM_People as $EM_Person): ?>
|
103 |
-
<tr>
|
104 |
-
<td> </td>
|
105 |
-
<td><?php echo $EM_Person->name ?></td>
|
106 |
-
<td><?php echo $EM_Person->email ?></td>
|
107 |
-
<td><?php echo $EM_Person->phone ?></td>
|
108 |
-
</tr>
|
109 |
-
<?php endforeach; ?>
|
110 |
-
</table>
|
111 |
-
<?php
|
112 |
-
}
|
113 |
-
?>
|
114 |
-
</div>
|
115 |
-
<?php
|
116 |
-
}
|
117 |
-
|
118 |
-
function em_printable_booking_report() {
|
119 |
-
global $EM_Event;
|
120 |
-
//check that user can access this page
|
121 |
-
if( isset($_GET['page']) && $_GET['page']=='events-manager-bookings' && isset($_GET['action']) && $_GET['action'] == 'bookings_report' && is_object($EM_Event)){
|
122 |
-
if( is_object($EM_Event) && !$EM_Event->can_manage() ){
|
123 |
-
?>
|
124 |
-
<div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
|
125 |
-
<?php
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
?>
|
129 |
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
130 |
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
131 |
-
<html>
|
132 |
-
<head>
|
133 |
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
134 |
-
<title>Bookings for <?php echo $EM_Event->name; ?></title>
|
135 |
-
<link rel="stylesheet" href="<?php echo bloginfo('wpurl') ?>/wp-content/plugins/events-manager/includes/css/events_manager.css" type="text/css" media="screen" />
|
136 |
-
</head>
|
137 |
-
<body id="printable">
|
138 |
-
<div id="container">
|
139 |
-
<h1>Bookings for <?php echo $EM_Event->name; ?></h1>
|
140 |
-
<p><?php echo $EM_Event->output("#d #M #Y"); ?></p>
|
141 |
-
<p><?php echo $EM_Event->output("#_LOCATION, #_ADDRESS, #_TOWN"); ?></p>
|
142 |
-
<h2><?php _e('Bookings data', 'dbem');?></h2>
|
143 |
-
<table id="bookings-table">
|
144 |
-
<tr>
|
145 |
-
<th scope='col'><?php _e('Name', 'dbem')?></th>
|
146 |
-
<th scope='col'><?php _e('E-mail', 'dbem')?></th>
|
147 |
-
<th scope='col'><?php _e('Phone number', 'dbem')?></th>
|
148 |
-
<th scope='col'><?php _e('Seats', 'dbem')?></th>
|
149 |
-
<th scope='col'><?php _e('Comment', 'dbem')?></th>
|
150 |
-
</tr>
|
151 |
-
<?php foreach($EM_Event->get_bookings()->bookings as $EM_Booking) { ?>
|
152 |
-
<tr>
|
153 |
-
|
154 |
-
<td><?php echo $EM_Booking->person->name ?></td>
|
155 |
-
<td><?php echo $EM_Booking->person->email ?></td>
|
156 |
-
<td><?php echo $EM_Booking->person->phone ?></td>
|
157 |
-
<td class='seats-number'><?php echo $EM_Booking->seats ?></td>
|
158 |
-
<td><?php echo $EM_Booking->comment ?></td>
|
159 |
-
</tr>
|
160 |
-
<?php } ?>
|
161 |
-
<tr id='booked-seats'>
|
162 |
-
<td colspan='3'> </td>
|
163 |
-
<td class='total-label'><?php _e('Booked', 'dbem')?>:</td>
|
164 |
-
<td class='seats-number'><?php echo $EM_Event->get_bookings()->get_booked_seats(); ?></td>
|
165 |
-
</tr>
|
166 |
-
<tr id='available-seats'>
|
167 |
-
<td colspan='3'> </td>
|
168 |
-
<td class='total-label'><?php _e('Available', 'dbem')?>:</td>
|
169 |
-
<td class='seats-number'><?php echo $EM_Event->get_bookings()->get_available_seats(); ?></td>
|
170 |
-
</tr>
|
171 |
-
</table>
|
172 |
-
</div>
|
173 |
-
</body>
|
174 |
-
</html>
|
175 |
-
<?php
|
176 |
-
die();
|
177 |
-
}
|
178 |
-
}
|
179 |
-
add_action('admin_init', 'em_printable_booking_report');
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Adds phone number to contact info of users, compatible with previous phone field method
|
183 |
-
* @param $array
|
184 |
-
* @return array
|
185 |
-
*/
|
186 |
-
function em_contact_methods($array){
|
187 |
-
$array['dbem_phone'] = __('Phone','dbem') . ' <span class="description">('. __('Events Manager','dbem') .')</span>';
|
188 |
-
return $array;
|
189 |
-
}
|
190 |
-
add_filter( 'user_contactmethods' , 'em_contact_methods' , 10 , 1 );
|
191 |
-
|
192 |
-
?>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
admin/wpfc-admin.php
ADDED
@@ -0,0 +1,47 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Adds a note to the event post type in the admin area, so it's obvious EM is interfering.
|
4 |
+
*/
|
5 |
+
function wpfc_admin_options_post_type_event(){
|
6 |
+
echo " - <i>powered by Events Manager</i>";
|
7 |
+
}
|
8 |
+
add_action('wpfc_admin_options_post_type_event','wpfc_admin_options_post_type_event');
|
9 |
+
|
10 |
+
function wpfc_em_admin_notice(){
|
11 |
+
if( !empty($_REQUEST['page']) && $_REQUEST['page'] == 'wp-fullcalendar'){
|
12 |
+
?>
|
13 |
+
<div class="updated"><p><?php echo sprintf(__('If you choose the Event post type whilst Events Manager is activated, you can also visit the <a href="%s">Events Manager settings page</a> for a few more options when displaying event information on your calendar.','dbem'), admin_url('edit.php?post_type='.EM_POST_TYPE_EVENT.'&page=events-manager-options')); ?></p></div>
|
14 |
+
<?php
|
15 |
+
}
|
16 |
+
}
|
17 |
+
add_action('admin_notices', 'wpfc_em_admin_notice');
|
18 |
+
|
19 |
+
function wpfc_em_admin_options(){
|
20 |
+
?>
|
21 |
+
<div class="postbox " >
|
22 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Full Calendar Options', 'dbem' ); ?> </span></h3>
|
23 |
+
<div class="inside">
|
24 |
+
<p><?php echo sprintf(__('Looking for the rest of the FullCalendar Options? They\'ve moved <a href="%s">here</a>, the options below are for overriding specific bits relevant to Events Manager.','dbem'), admin_url('options-general.php?page=wp-fullcalendar')); ?></p>
|
25 |
+
<table class='form-table'>
|
26 |
+
<?php
|
27 |
+
global $events_placeholder_tip, $save_button;
|
28 |
+
em_options_radio_binary ( __( 'Override calendar on events page?', 'dbem' ), 'dbem_emfc_override_calendar', __( 'If set to yes, the FullCalendar will be used instead of the standard calendar on the events page.', 'dbem' ) );
|
29 |
+
em_options_radio_binary ( __( 'Override calendar shortcode?', 'dbem' ), 'dbem_emfc_override_shortcode', __( 'Overrides the default calendar shortcode. You can also use [events_fullcalendar] instead.','dbem' ) );
|
30 |
+
em_options_input_text ( __( 'Event title format', 'wpfc' ), 'dbem_emfc_full_calendar_event_format', __('HTML is not accepted.','wpfc').' '.$events_placeholder_tip, '#_EVENTNAME' );
|
31 |
+
em_options_textarea( __( 'Event tooltips format', 'wpfc' ), 'dbem_emfc_qtips_format', __('If you enable tips, this information will be shwon, which can include HTML.','wpfc').' '.$events_placeholder_tip, '#_EVENTNAME' );$positions_options = array();
|
32 |
+
?>
|
33 |
+
</table>
|
34 |
+
<?php echo $save_button; ?>
|
35 |
+
</div> <!-- . inside -->
|
36 |
+
</div> <!-- .postbox -->
|
37 |
+
<?php
|
38 |
+
}
|
39 |
+
add_action('em_options_page_footer', 'wpfc_em_admin_options');
|
40 |
+
|
41 |
+
function wpfc_em_install(){
|
42 |
+
//check for updates - try adding one option, if it works then it's a first time install so add more
|
43 |
+
if( current_user_can('list_users') && add_option('dbem_emfc_full_calendar_event_format','#_EVENTTIMES - #_EVENTNAME') ){
|
44 |
+
add_option('dbem_emfc_qtips_format', '{has_image}<div style="float:left; margin:0px 5px 5px 0px;">#_EVENTIMAGE{75,75}</div>{/has_image}#_EVENTEXCERPT');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
add_action('init', 'wpfc_em_install');
|
buddypress/bp-em-activity.php
ADDED
@@ -0,0 +1,128 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
// This file handles hooks/filter requiring activity stream publications
|
3 |
+
|
4 |
+
/**
|
5 |
+
* bp_em_record_activity()
|
6 |
+
*
|
7 |
+
* If the activity stream component is installed, this function will record activity items for your
|
8 |
+
* component.
|
9 |
+
*/
|
10 |
+
function bp_em_record_activity( $args = '' ) {
|
11 |
+
if ( !function_exists( 'bp_activity_add' ) )
|
12 |
+
return false;
|
13 |
+
|
14 |
+
$defaults = array(
|
15 |
+
'id' => false,
|
16 |
+
'user_id' => '',
|
17 |
+
'action' => '',
|
18 |
+
'content' => '',
|
19 |
+
'primary_link' => '',
|
20 |
+
'component' => 'events-manager',
|
21 |
+
'type' => false,
|
22 |
+
'item_id' => false,
|
23 |
+
'secondary_item_id' => false,
|
24 |
+
'recorded_time' => gmdate( "Y-m-d H:i:s" ),
|
25 |
+
'hide_sitewide' => false
|
26 |
+
);
|
27 |
+
|
28 |
+
$r = wp_parse_args( $args, $defaults );
|
29 |
+
extract( $r );
|
30 |
+
return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Records new events to the activity stream.
|
35 |
+
* @param unknown_type $result
|
36 |
+
* @param unknown_type $EM_Event
|
37 |
+
* @return unknown
|
38 |
+
*/
|
39 |
+
function bp_em_record_activity_event_save( $result, $EM_Event ){
|
40 |
+
if( $result && $EM_Event->event_status == 1 && $EM_Event->get_previous_status() != 1 ){
|
41 |
+
$user = get_userdata($EM_Event->event_owner);
|
42 |
+
$member_link = bp_core_get_user_domain($user->ID);
|
43 |
+
if( empty($EM_Event->group_id) ){
|
44 |
+
bp_em_record_activity( array(
|
45 |
+
'user_id' => $user->ID,
|
46 |
+
'action' => sprintf(__('%s added the event %s','dbem'), "<a href='".$member_link."'>".$user->display_name."</a>", $EM_Event->output('#_EVENTLINK') ),
|
47 |
+
'primary_link' => $EM_Event->output('#_EVENTURL'),
|
48 |
+
'type' => 'new_event',
|
49 |
+
'item_id' => $EM_Event->event_id,
|
50 |
+
'hide_sitewide' => $EM_Event->event_private
|
51 |
+
));
|
52 |
+
}else{
|
53 |
+
//tis a group event
|
54 |
+
$group = new BP_Groups_Group($EM_Event->group_id);
|
55 |
+
bp_em_record_activity( array(
|
56 |
+
'user_id' => $user->ID,
|
57 |
+
'action' => sprintf(__('%s added the event %s to %s.','dbem'), "<a href='".$member_link."'>".$user->display_name."</a>", $EM_Event->output('#_EVENTLINK'), '<a href="'.bp_get_group_permalink($group).'">'.bp_get_group_name($group).'</a>' ),
|
58 |
+
'component' => 'groups',
|
59 |
+
'type' => 'new_event',
|
60 |
+
'item_id' => $EM_Event->group_id,
|
61 |
+
'hide_sitewide' => $EM_Event->event_private
|
62 |
+
));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return $result;
|
66 |
+
}
|
67 |
+
add_filter('em_event_save','bp_em_record_activity_event_save', 10, 2);
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param boolean $result
|
71 |
+
* @param EM_Booking $EM_Booking
|
72 |
+
* @return boolean
|
73 |
+
*/
|
74 |
+
function bp_em_record_activity_booking_save( $result, $EM_Booking ){
|
75 |
+
if( $result ){
|
76 |
+
$rejected_statuses = array(0,2,3); //these statuses apply to rejected/cancelled bookings
|
77 |
+
$user = $EM_Booking->get_person();
|
78 |
+
$member_link = bp_core_get_user_domain($user->ID);
|
79 |
+
$user_link = "<a href='".$member_link."/'>".$user->display_name."</a>";
|
80 |
+
$event_link = $EM_Booking->get_event()->output('#_EVENTLINK');
|
81 |
+
$status = $EM_Booking->booking_status;
|
82 |
+
$EM_Event = $EM_Booking->get_event();
|
83 |
+
if( empty($EM_Event->group_id) ){
|
84 |
+
if( $status == 1 || (!get_option('dbem_bookings_approval') && $status < 2) ){
|
85 |
+
$action = sprintf(__('%s is attending %s.','dbem'), $user_link, $event_link );
|
86 |
+
}elseif( ($EM_Booking->previous_status == 1 || (!get_option('dbem_bookings_approval') && $EM_Booking->previous_status < 2)) && in_array($status, $rejected_statuses) ){
|
87 |
+
$action = sprintf(__('%s will not be attending %s anymore.','dbem'), $user_link, $event_link );
|
88 |
+
}
|
89 |
+
}else{
|
90 |
+
$group = new BP_Groups_Group($EM_Event->group_id);
|
91 |
+
$group_link = '<a href="'.bp_get_group_permalink($group).'">'.bp_get_group_name($group).'</a>';
|
92 |
+
if( $status == 1 || (!get_option('dbem_bookings_approval') && $status < 2) ){
|
93 |
+
$action = sprintf(__('%s is attending %s of the group %s.','dbem'), $user_link, $event_link, $group_link );
|
94 |
+
}elseif( ($EM_Booking->previous_status == 1 || (!get_option('dbem_bookings_approval') && $EM_Booking->previous_status < 2)) && in_array($status, $rejected_statuses) ){
|
95 |
+
$action = sprintf(__('%s will not be attending %s of group %s anymore.','dbem'), $user_link, $event_link, $group_link );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
if( !empty($action) ){
|
99 |
+
if( empty($EM_Event->group_id) ){
|
100 |
+
bp_em_record_activity( array(
|
101 |
+
'user_id' => $EM_Booking->person->ID,
|
102 |
+
'action' => $action,
|
103 |
+
'primary_link' => $EM_Event->output('#_EVENTURL'),
|
104 |
+
'type' => 'new_booking',
|
105 |
+
'item_id' => $EM_Event->event_id,
|
106 |
+
'secondary_item_id' => $EM_Booking->booking_id,
|
107 |
+
'hide_sitewide' => $EM_Event->event_private
|
108 |
+
));
|
109 |
+
}else{
|
110 |
+
//tis a group event
|
111 |
+
bp_em_record_activity( array(
|
112 |
+
'component' => 'groups',
|
113 |
+
'item_id' => $EM_Event->group_id,
|
114 |
+
'user_id' => $EM_Booking->person->ID,
|
115 |
+
'action' => $action,
|
116 |
+
'primary_link' => $EM_Event->output('#_EVENTURL'),
|
117 |
+
'type' => 'new_booking',
|
118 |
+
'secondary_item_id' => $EM_Booking->booking_id,
|
119 |
+
'hide_sitewide' => $EM_Event->event_private
|
120 |
+
));
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
return $result;
|
125 |
+
}
|
126 |
+
add_filter('em_booking_set_status','bp_em_record_activity_booking_save', 100, 2);
|
127 |
+
add_filter('em_booking_save','bp_em_record_activity_booking_save', 100, 2);
|
128 |
+
add_filter('em_booking_delete','bp_em_record_activity_booking_save', 100, 2);
|
buddypress/bp-em-core.php
ADDED
@@ -0,0 +1,340 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
//Main loader for buddypress
|
3 |
+
/**
|
4 |
+
* Events Manager component for BuddyPress
|
5 |
+
* @author marcus
|
6 |
+
* @since 5.0
|
7 |
+
*/
|
8 |
+
class BP_EM_Component extends BP_Component {
|
9 |
+
|
10 |
+
function __construct() {
|
11 |
+
global $bp;
|
12 |
+
parent::start('events', __('Events', 'dbem'), EM_DIR);
|
13 |
+
$this->includes();
|
14 |
+
//TODO make BP component optional
|
15 |
+
$bp->active_components[$this->id] = '1';
|
16 |
+
}
|
17 |
+
|
18 |
+
function includes() {
|
19 |
+
// Files to include
|
20 |
+
$includes = array(
|
21 |
+
'buddypress/bp-em-activity.php',
|
22 |
+
'buddypress/bp-em-templatetags.php',
|
23 |
+
'buddypress/bp-em-notifications.php',
|
24 |
+
'buddypress/screens/profile.php',
|
25 |
+
'buddypress/screens/my-events.php',
|
26 |
+
'buddypress/screens/my-locations.php',
|
27 |
+
'buddypress/screens/attending.php',
|
28 |
+
'buddypress/screens/my-bookings.php',
|
29 |
+
'buddypress/screens/my-group-events.php'
|
30 |
+
);
|
31 |
+
if( bp_is_active('groups') ){
|
32 |
+
$includes[] = 'buddypress/screens/group-events.php';
|
33 |
+
$includes[] = 'buddypress/bp-em-groups.php';
|
34 |
+
}
|
35 |
+
parent::includes( $includes );
|
36 |
+
//TODO add admin pages for extra BP specific settings
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Sets up the global Events Manager BuddyPress Components
|
41 |
+
*/
|
42 |
+
function setup_globals() {
|
43 |
+
global $bp, $wpdb;
|
44 |
+
// Define a slug constant that will be used to view this components pages
|
45 |
+
if ( !defined( 'BP_EM_SLUG' ) )
|
46 |
+
define ( 'BP_EM_SLUG', str_replace('/','-', EM_POST_TYPE_EVENT_SLUG) );
|
47 |
+
|
48 |
+
// Set up the $globals array to be passed along to parent::setup_globals()
|
49 |
+
$globals = array(
|
50 |
+
'slug' => BP_EM_SLUG,
|
51 |
+
'has_directory' => false, //already done by EM
|
52 |
+
'notification_callback' => 'bp_em_format_notifications',
|
53 |
+
'search_string' => sprintf(__( 'Search %s...', 'dbem' ),__('Events','dbem')),
|
54 |
+
);
|
55 |
+
|
56 |
+
// Let BP_Component::setup_globals() do its work.
|
57 |
+
parent::setup_globals( $globals );
|
58 |
+
|
59 |
+
//quick link shortcut - may need to revisit this
|
60 |
+
$bp->{$this->id}->link = trailingslashit($bp->loggedin_user->domain).BP_EM_SLUG.'/';
|
61 |
+
}
|
62 |
+
|
63 |
+
function setup_nav() {
|
64 |
+
global $blog_id;
|
65 |
+
//check multisite or normal mode for correct permission checking
|
66 |
+
if(is_multisite() && $blog_id != BP_ROOT_BLOG){
|
67 |
+
//FIXME MS mode doesn't seem to recognize cross subsite caps, using the proper functions, for now we use switch_blog.
|
68 |
+
$current_blog = $blog_id;
|
69 |
+
switch_to_blog(BP_ROOT_BLOG);
|
70 |
+
$can_manage_events = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_events');
|
71 |
+
$can_manage_locations = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_locations');
|
72 |
+
$can_manage_bookings = current_user_can_for_blog(BP_ROOT_BLOG, 'manage_bookings');
|
73 |
+
switch_to_blog($current_blog);
|
74 |
+
}else{
|
75 |
+
$can_manage_events = current_user_can('edit_events');
|
76 |
+
$can_manage_locations = current_user_can('edit_locations');
|
77 |
+
$can_manage_bookings = current_user_can('manage_bookings');
|
78 |
+
}
|
79 |
+
/* Add 'Events' to the main user profile navigation */
|
80 |
+
$main_nav = array(
|
81 |
+
'name' => __( 'Events', 'dbem' ),
|
82 |
+
'slug' => em_bp_get_slug(),
|
83 |
+
'position' => 80,
|
84 |
+
'screen_function' => 'bp_em_events',
|
85 |
+
'default_subnav_slug' => 'profile'
|
86 |
+
);
|
87 |
+
|
88 |
+
$em_link = trailingslashit( bp_loggedin_user_domain() . em_bp_get_slug() );
|
89 |
+
|
90 |
+
/* Create SubNav Items */
|
91 |
+
$sub_nav[] = array(
|
92 |
+
'name' => __( 'My Profile', 'dbem' ),
|
93 |
+
'slug' => 'profile',
|
94 |
+
'parent_slug' => em_bp_get_slug(),
|
95 |
+
'parent_url' => $em_link,
|
96 |
+
'screen_function' => 'bp_em_events',
|
97 |
+
'position' => 10
|
98 |
+
);
|
99 |
+
|
100 |
+
$sub_nav[] = array(
|
101 |
+
'name' => __( 'Events I\'m Attending', 'dbem' ),
|
102 |
+
'slug' => 'attending',
|
103 |
+
'parent_slug' => em_bp_get_slug(),
|
104 |
+
'parent_url' => $em_link,
|
105 |
+
'screen_function' => 'bp_em_attending',
|
106 |
+
'position' => 20,
|
107 |
+
'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
|
108 |
+
);
|
109 |
+
|
110 |
+
if( $can_manage_events ){
|
111 |
+
$sub_nav[] = array(
|
112 |
+
'name' => __( 'My Events', 'dbem' ),
|
113 |
+
'slug' => 'my-events',
|
114 |
+
'parent_slug' => em_bp_get_slug(),
|
115 |
+
'parent_url' => $em_link,
|
116 |
+
'screen_function' => 'bp_em_my_events',
|
117 |
+
'position' => 30,
|
118 |
+
'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
if( $can_manage_locations && get_option('dbem_locations_enabled') ){
|
123 |
+
$sub_nav[] = array(
|
124 |
+
'name' => __( 'My Locations', 'dbem' ),
|
125 |
+
'slug' => 'my-locations',
|
126 |
+
'parent_slug' => em_bp_get_slug(),
|
127 |
+
'parent_url' => $em_link,
|
128 |
+
'screen_function' => 'bp_em_my_locations',
|
129 |
+
'position' => 40,
|
130 |
+
'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
if( $can_manage_bookings && get_option('dbem_rsvp_enabled') ){
|
135 |
+
$sub_nav[] = array(
|
136 |
+
'name' => __( 'My Event Bookings', 'dbem' ),
|
137 |
+
'slug' => 'my-bookings',
|
138 |
+
'parent_slug' => em_bp_get_slug(),
|
139 |
+
'parent_url' => $em_link,
|
140 |
+
'screen_function' => 'bp_em_my_bookings',
|
141 |
+
'position' => 50,
|
142 |
+
'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
|
143 |
+
);
|
144 |
+
}
|
145 |
+
|
146 |
+
if( bp_is_active('groups') ){
|
147 |
+
/* Create Profile Group Sub-Nav */
|
148 |
+
$sub_nav[] = array(
|
149 |
+
'name' => __( 'Events', 'dbem' ),
|
150 |
+
'slug' => 'group-events',
|
151 |
+
'parent_slug' => bp_get_groups_slug(),
|
152 |
+
'parent_url' =>trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ),
|
153 |
+
'screen_function' => 'bp_em_my_group_events',
|
154 |
+
'position' => 60,
|
155 |
+
'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
parent::setup_nav( $main_nav, $sub_nav );
|
160 |
+
add_action( 'bp_init', array(&$this, 'setup_group_nav') );
|
161 |
+
}
|
162 |
+
|
163 |
+
function setup_admin_bar() {
|
164 |
+
global $bp, $blog_id;
|
165 |
+
|
166 |
+
// Prevent debug notices
|
167 |
+
$wp_admin_nav = array();
|
168 |
+
|
169 |
+
// Menus for logged in user
|
170 |
+
if ( is_user_logged_in() ) {
|
171 |
+
//check multisite or normal mode for correct permission checking
|
172 |
+
if(is_multisite() && $blog_id != BP_ROOT_BLOG){
|
173 |
+
//FIXME MS mode doesn't seem to recognize cross subsite caps, using the proper functions, for now we use switch_blog.
|
174 |
+
$current_blog = $blog_id;
|
175 |
+
switch_to_blog(BP_ROOT_BLOG);
|
176 |
+
$can_manage_events = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_events');
|
177 |
+
$can_manage_locations = current_user_can_for_blog(BP_ROOT_BLOG, 'edit_locations');
|
178 |
+
$can_manage_bookings = current_user_can_for_blog(BP_ROOT_BLOG, 'manage_bookings');
|
179 |
+
switch_to_blog($current_blog);
|
180 |
+
}else{
|
181 |
+
$can_manage_events = current_user_can('edit_events');
|
182 |
+
$can_manage_locations = current_user_can('edit_locations');
|
183 |
+
$can_manage_bookings = current_user_can('manage_bookings');
|
184 |
+
}
|
185 |
+
|
186 |
+
$em_link = trailingslashit( bp_loggedin_user_domain() . em_bp_get_slug() );
|
187 |
+
|
188 |
+
/* Add 'Events' to the main user profile navigation */
|
189 |
+
$wp_admin_nav[] = array(
|
190 |
+
'parent' => $bp->my_account_menu_id,
|
191 |
+
'id' => 'my-em-' . $this->id,
|
192 |
+
'title' => __( 'Events', 'dbem' ),
|
193 |
+
'href' => $em_link
|
194 |
+
);
|
195 |
+
|
196 |
+
/* Create SubNav Items */
|
197 |
+
$wp_admin_nav[] = array(
|
198 |
+
'parent' => 'my-em-' . $this->id,
|
199 |
+
'id' => 'my-em-' . $this->id .'-profile',
|
200 |
+
'title' => __( 'My Profile', 'dbem' ),
|
201 |
+
'href' => $em_link.'profile/'
|
202 |
+
);
|
203 |
+
|
204 |
+
$wp_admin_nav[] = array(
|
205 |
+
'parent' => 'my-em-' . $this->id,
|
206 |
+
'id' => 'my-em-' . $this->id .'-attending',
|
207 |
+
'title' => __( 'Events I\'m Attending', 'dbem' ),
|
208 |
+
'href' => $em_link.'attending/'
|
209 |
+
);
|
210 |
+
|
211 |
+
if( $can_manage_events ){
|
212 |
+
$wp_admin_nav[] = array(
|
213 |
+
'parent' => 'my-em-' . $this->id,
|
214 |
+
'id' => 'my-em-' . $this->id .'-my-events',
|
215 |
+
'title' => __( 'My Events', 'dbem' ),
|
216 |
+
'href' => $em_link.'my-events/'
|
217 |
+
);
|
218 |
+
}
|
219 |
+
|
220 |
+
if( $can_manage_locations && get_option('dbem_locations_enabled') ){
|
221 |
+
$wp_admin_nav[] = array(
|
222 |
+
'parent' => 'my-em-' . $this->id,
|
223 |
+
'id' => 'my-em-' . $this->id .'-my-locations',
|
224 |
+
'title' => __( 'My Locations', 'dbem' ),
|
225 |
+
'href' => $em_link.'my-locations/'
|
226 |
+
);
|
227 |
+
}
|
228 |
+
|
229 |
+
if( $can_manage_bookings && get_option('dbem_rsvp_enabled') ){
|
230 |
+
$wp_admin_nav[] = array(
|
231 |
+
'parent' => 'my-em-' . $this->id,
|
232 |
+
'id' => 'my-em-' . $this->id .'-my-bookings',
|
233 |
+
'title' => __( 'My Event Bookings', 'dbem' ),
|
234 |
+
'href' => $em_link.'my-bookings/'
|
235 |
+
);
|
236 |
+
}
|
237 |
+
|
238 |
+
if( bp_is_active('groups') ){
|
239 |
+
/* Create Profile Group Sub-Nav */
|
240 |
+
$wp_admin_nav[] = array(
|
241 |
+
'parent' => 'my-account-groups',
|
242 |
+
'id' => 'my-account-groups-' . $this->id ,
|
243 |
+
'title' => __( 'Events', 'dbem' ),
|
244 |
+
'href' => trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . 'group-events/'
|
245 |
+
);
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
parent::setup_admin_bar( $wp_admin_nav );
|
250 |
+
}
|
251 |
+
|
252 |
+
function setup_group_nav(){
|
253 |
+
global $bp;
|
254 |
+
/* Add some group subnav items */
|
255 |
+
$user_access = false;
|
256 |
+
$group_link = '';
|
257 |
+
if( bp_is_active('groups') && !empty($bp->groups->current_group) ){
|
258 |
+
$group_link = $bp->root_domain . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/';
|
259 |
+
$user_access = $bp->groups->current_group->user_has_access;
|
260 |
+
if( !empty($bp->current_component) && $bp->current_component == 'groups' ){
|
261 |
+
$count = EM_Events::count(array('group'=>$bp->groups->current_group->id));
|
262 |
+
if( empty($count) ) $count = 0;
|
263 |
+
}
|
264 |
+
bp_core_new_subnav_item( array(
|
265 |
+
'name' => __( 'Events', 'dbem' ) . " <span>$count</span>",
|
266 |
+
'slug' => 'events',
|
267 |
+
'parent_url' => $group_link,
|
268 |
+
'parent_slug' => $bp->groups->current_group->slug,
|
269 |
+
'screen_function' => 'bp_em_group_events',
|
270 |
+
'position' => 50,
|
271 |
+
'user_has_access' => $user_access,
|
272 |
+
'item_css_id' => 'forums'
|
273 |
+
));
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
function bp_em_load_core_component() {
|
278 |
+
global $bp;
|
279 |
+
$bp->events = new BP_EM_Component();
|
280 |
+
}
|
281 |
+
add_action( 'bp_loaded', 'bp_em_load_core_component' );
|
282 |
+
|
283 |
+
if( !is_admin() || ( defined('DOING_AJAX') && !empty($_REQUEST['is_public'])) ){
|
284 |
+
/*
|
285 |
+
* Links and URL Rewriting
|
286 |
+
*/
|
287 |
+
function em_bp_rewrite_edit_url($url, $EM_Event){
|
288 |
+
global $bp;
|
289 |
+
return $bp->events->link.'my-events/?action=edit&event_id='.$EM_Event->event_id;
|
290 |
+
}
|
291 |
+
if( !get_option('dbem_edit_events_page') ){
|
292 |
+
add_filter('em_event_get_edit_url','em_bp_rewrite_edit_url',10,2);
|
293 |
+
}
|
294 |
+
|
295 |
+
function em_bp_rewrite_bookings_url($url, $EM_Event){
|
296 |
+
global $bp;
|
297 |
+
return $bp->events->link.'my-bookings/?event_id='.$EM_Event->event_id;
|
298 |
+
}
|
299 |
+
if( !get_option('dbem_edit_bookings_page') ){
|
300 |
+
add_filter('em_event_get_bookings_url','em_bp_rewrite_bookings_url',10,2);
|
301 |
+
}
|
302 |
+
|
303 |
+
function em_bp_rewrite_edit_location_url($url, $EM_Location){
|
304 |
+
global $bp;
|
305 |
+
return $bp->events->link.'my-locations/?action=edit&location_id='.$EM_Location->location_id;
|
306 |
+
}
|
307 |
+
if( !get_option('dbem_edit_locations_page') ){
|
308 |
+
add_filter('em_location_get_edit_url','em_bp_rewrite_edit_location_url',10,2);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
//CSS and JS Loading
|
313 |
+
function bp_em_enqueue_scripts( ){
|
314 |
+
if( bp_is_current_component('events') || (bp_is_current_component('groups') && bp_is_current_action('group-events')) ){
|
315 |
+
add_filter('option_dbem_js_limit', create_function('$args','return false;'));
|
316 |
+
add_filter('option_dbem_css_limit', create_function('$args','return false;'));
|
317 |
+
}
|
318 |
+
|
319 |
+
}
|
320 |
+
add_action('wp_enqueue_scripts','bp_em_enqueue_scripts',1);
|
321 |
+
|
322 |
+
function bp_em_messages_js_compat() {
|
323 |
+
if(bp_is_messages_compose_screen()){
|
324 |
+
wp_deregister_script( 'events-manager' );
|
325 |
+
}
|
326 |
+
}
|
327 |
+
add_action( 'wp_print_scripts', 'bp_em_messages_js_compat', 100 );
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Delete events when you delete a user.
|
331 |
+
*/
|
332 |
+
function bp_em_remove_data( $user_id ) {
|
333 |
+
$EM_Events = EM_Events::get(array('scope'=>'all','owner'=>$user_id, 'status'=>false));
|
334 |
+
EM_Events::delete($EM_Events);
|
335 |
+
}
|
336 |
+
add_action( 'wpmu_delete_user', 'bp_em_remove_data', 1 );
|
337 |
+
add_action( 'delete_user', 'bp_em_remove_data', 1 );
|
338 |
+
|
339 |
+
define('EM_BP_LOADED',true); //so we know
|
340 |
+
?>
|
buddypress/bp-em-groups.php
ADDED
@@ -0,0 +1,140 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @param EM_Event $EM_Event
|
4 |
+
*/
|
5 |
+
function bp_em_group_event_save($result, $EM_Event){
|
6 |
+
if( is_object($EM_Event) && !empty($EM_Event->event_id) ){
|
7 |
+
if( !empty($_REQUEST['group_id']) && is_numeric($_REQUEST['group_id']) && bp_is_active('groups') ){
|
8 |
+
//we have been requested an event creation tied to a group, so does this group exist, and does this person have admin rights to it?
|
9 |
+
if( groups_is_user_admin(get_current_user_id(), $_REQUEST['group_id']) ){
|
10 |
+
$EM_Event->group_id = $_REQUEST['group_id'];
|
11 |
+
}
|
12 |
+
if( !empty($EM_Event->group_id) ){
|
13 |
+
//if group is private, make it private
|
14 |
+
$group = groups_get_group(array('group_id'=>$EM_Event->group_id));
|
15 |
+
$is_member = groups_is_user_member(get_current_user_id(), $EM_Event->group_id) || groups_is_user_admin(get_current_user_id(), $EM_Event->group_id) || groups_is_user_mod(get_current_user_id(), $EM_Event->group_id);
|
16 |
+
if( $group->status != 'public' && $is_member ){
|
17 |
+
//Make sure event status is private and set post status to private
|
18 |
+
global $wpdb;
|
19 |
+
$EM_Event->event_private = 1;
|
20 |
+
$wpdb->update($wpdb->posts, array('post_status'=>'private'), array('ID'=>$EM_Event->post_id));
|
21 |
+
$wpdb->update(EM_EVENTS_TABLE, array('event_private'=>1), array('event_id'=>$EM_Event->event_id));
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}else{
|
25 |
+
$EM_Event->group_id = null;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
return $result;
|
29 |
+
}
|
30 |
+
add_action('em_event_save','bp_em_group_event_save',1,2);
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param boolean $result
|
34 |
+
* @param EM_Event $EM_Event
|
35 |
+
*/
|
36 |
+
function bp_em_group_event_can_manage( $result, $EM_Event){
|
37 |
+
if( !$result && !empty($EM_Event->group_id) && bp_is_active('groups') ){ //only override if already false, incase it's true
|
38 |
+
if( groups_is_user_admin(get_current_user_id(),$EM_Event->group_id) && current_user_can('edit_events') ){
|
39 |
+
//This user is an admin of the owner's group, so they can edit this event.
|
40 |
+
return true;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
return $result;
|
44 |
+
}
|
45 |
+
add_filter('em_event_can_manage','bp_em_group_event_can_manage',1,2);
|
46 |
+
|
47 |
+
|
48 |
+
function bp_em_group_events_accepted_searches($searches){
|
49 |
+
if( bp_is_active('groups') ){
|
50 |
+
$searches[] = 'group';
|
51 |
+
}
|
52 |
+
return $searches;
|
53 |
+
}
|
54 |
+
add_filter('em_accepted_searches','bp_em_group_events_accepted_searches',1,1);
|
55 |
+
|
56 |
+
function bp_em_group_events_get_default_search($searches, $array){
|
57 |
+
if( !empty($array['group']) && (is_numeric($array['group']) || $array['group'] == 'my' || $array['group'] == 'this') && bp_is_active('groups') ){
|
58 |
+
if($array['group'] == 'this'){ //shows current group, if applicable
|
59 |
+
if( is_numeric(bp_get_current_group_id()) ){
|
60 |
+
$searches['group'] = bp_get_current_group_id();
|
61 |
+
}
|
62 |
+
}else{
|
63 |
+
$searches['group'] = $array['group'];
|
64 |
+
}
|
65 |
+
}
|
66 |
+
return $searches;
|
67 |
+
}
|
68 |
+
add_filter('em_events_get_default_search','bp_em_group_events_get_default_search',1,2);
|
69 |
+
|
70 |
+
/*
|
71 |
+
* Privacy Functions
|
72 |
+
*/
|
73 |
+
function bp_em_group_events_build_sql_conditions( $conditions, $args ){
|
74 |
+
if( !empty($args['group']) && is_numeric($args['group']) ){
|
75 |
+
$conditions['group'] = "( `group_id`={$args['group']} )";
|
76 |
+
}elseif( !empty($args['group']) && $args['group'] == 'my' ){
|
77 |
+
$groups = groups_get_user_groups(get_current_user_id());
|
78 |
+
if( count($groups) > 0 ){
|
79 |
+
$conditions['group'] = "( `group_id` IN (".implode(',',$groups['groups']).") )";
|
80 |
+
}
|
81 |
+
}
|
82 |
+
//deal with private groups and events
|
83 |
+
if( is_user_logged_in() ){
|
84 |
+
global $wpdb;
|
85 |
+
//find out what private groups they belong to, and don't show private group events not in their memberships
|
86 |
+
$group_ids = BP_Groups_Member::get_group_ids(get_current_user_id());
|
87 |
+
if( $group_ids['total'] > 0){
|
88 |
+
$conditions['group_privacy'] = "(`event_private`=0 OR (`event_private`=1 AND (`group_id` IS NULL OR `group_id` = 0)) OR (`event_private`=1 AND `group_id` IN (".implode(',',$group_ids['groups']).")))";
|
89 |
+
}else{
|
90 |
+
//find out what private groups they belong to, and don't show private group events not in their memberships
|
91 |
+
$conditions['group_privacy'] = "(`event_private`=0 OR (`event_private`=1 AND (`group_id` IS NULL OR `group_id` = 0)))";
|
92 |
+
}
|
93 |
+
}
|
94 |
+
return $conditions;
|
95 |
+
}
|
96 |
+
add_filter('em_events_build_sql_conditions','bp_em_group_events_build_sql_conditions',1,2);
|
97 |
+
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Overrides the default post format of an event and can display an event as a page, which uses the page.php template.
|
101 |
+
* @param string $template
|
102 |
+
* @return string
|
103 |
+
*/
|
104 |
+
function bp_em_private_event_check($template){
|
105 |
+
global $post, $wpdb, $wp_query, $bp;
|
106 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
107 |
+
$EM_Event = em_get_event($post);
|
108 |
+
//echo "<pre>"; print_r($EM_Event); echo "</pre>"; die();
|
109 |
+
if( !empty($EM_Event->event_private) && !empty($EM_Event->group_id) ){
|
110 |
+
if( is_user_logged_in() ){
|
111 |
+
//make sure user is a member of this group, whether private or not, private groups just aren't shown to non-members of a group
|
112 |
+
$id_lookup = $wpdb->get_var( $wpdb->prepare( "SELECT m.group_id FROM {$bp->groups->table_name_members} m WHERE m.group_id = %s AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $EM_Event->group_id, get_current_user_id() ) );
|
113 |
+
if($id_lookup != $EM_Event->group_id){
|
114 |
+
unset($post);
|
115 |
+
$wp_query->set_404();
|
116 |
+
$template = locate_template(array('404.php'),false);
|
117 |
+
}
|
118 |
+
}else{
|
119 |
+
unset($post);
|
120 |
+
$wp_query->set_404();
|
121 |
+
$template = locate_template(array('404.php'),false);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
return $template;
|
126 |
+
}
|
127 |
+
add_filter('single_template','bp_em_private_event_check',20);
|
128 |
+
|
129 |
+
/*
|
130 |
+
* Admin Meta Boxes
|
131 |
+
*/
|
132 |
+
function bp_em_meta_boxes(){
|
133 |
+
add_meta_box('em-event-group', __('Group Ownership','dbem'), 'bp_em_meta_box_group',EM_POST_TYPE_EVENT, 'side','low');
|
134 |
+
add_meta_box('em-event-group', __('Group Ownership','dbem'), 'bp_em_meta_box_group','event-recurring', 'side','low');
|
135 |
+
}
|
136 |
+
add_action('add_meta_boxes', 'bp_em_meta_boxes');
|
137 |
+
|
138 |
+
function bp_em_meta_box_group(){
|
139 |
+
em_locate_template('forms/event/group.php',true);
|
140 |
+
}
|
buddypress/bp-em-notifications.php
ADDED
@@ -0,0 +1,82 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
//This file handles hooks requiring notifications
|
3 |
+
|
4 |
+
/**
|
5 |
+
* bp_em_format_notifications()
|
6 |
+
*
|
7 |
+
* The format notification function will take DB entries for notifications and format them
|
8 |
+
* so that they can be displayed and read on the screen.
|
9 |
+
*
|
10 |
+
* Notifications are "screen" notifications, that is, they appear on the notifications menu
|
11 |
+
* in the site wide navigation bar. They are not for email notifications.
|
12 |
+
*
|
13 |
+
*
|
14 |
+
* The recording is done by using bp_core_add_notification() which you can search for in this file for
|
15 |
+
* ems of usage.
|
16 |
+
*/
|
17 |
+
function bp_em_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
|
18 |
+
global $bp;
|
19 |
+
switch ( $action ) {
|
20 |
+
case 'pending_booking':
|
21 |
+
//Count pending bookings
|
22 |
+
if( get_option('dbem_bookings_approval')){
|
23 |
+
if ( $total_items > 1 ) {
|
24 |
+
return '<a href="' . $bp->loggedin_user->domain . $bp->events->slug . '/my-bookings/" title="' . __( 'My Bookings', 'dbem' ) . '">' . __('You have a pending booking','dbem'). '</a>';
|
25 |
+
} else {
|
26 |
+
return apply_filters( 'bp_em_format_new_booking_notification', '<a href="' . $bp->loggedin_user->domain . $bp->events->slug . '/my-bookings/" title="' . __( 'My Bookings', 'dbem' ) . '">' . sprintf(__('You have %s pending bookings','dbem'), $total_items). '</a>' );
|
27 |
+
}
|
28 |
+
}
|
29 |
+
break;
|
30 |
+
case 'confirmed_booking':
|
31 |
+
//Count pending bookings
|
32 |
+
if ( $total_items > 1 ) {
|
33 |
+
return apply_filters( 'bp_em_format_confirmed_booking_notifications', '<a href="' . $bp->loggedin_user->domain . $bp->events->slug . '/my-bookings/" title="' . __( 'My Bookings', 'dbem' ) . '">' . __('You have a confirmed booking','dbem'). '</a>' );
|
34 |
+
} else {
|
35 |
+
return apply_filters( 'bp_em_format_confirmed_booking_notification', '<a href="' . $bp->loggedin_user->domain . $bp->events->slug . '/my-bookings/" title="' . __( 'My Bookings', 'dbem' ) . '">' . sprintf(__('You have %s confirmed bookings','dbem'), $total_items). '</a>' );
|
36 |
+
}
|
37 |
+
break;
|
38 |
+
case 'cancelled_booking':
|
39 |
+
//Count pending bookings
|
40 |
+
if ( $total_items > 1 ) {
|
41 |
+
return apply_filters( 'bp_em_format_cancelled_booking_notifications', '<a href="' . $bp->loggedin_user->domain . $bp->events->slug . '/my-bookings/" title="' . __( 'My Bookings', 'dbem' ) . '">' . __('A user cancelled a booking','dbem'). '</a>' );
|
42 |
+
} else {
|
43 |
+
return apply_filters( 'bp_em_format_cancelled_booking_notification', '<a href="' . $bp->loggedin_user->domain . $bp->events->slug . '/my-bookings/" title="' . __( 'My Bookings', 'dbem' ) . '">' . sprintf(__('%s users cancelled bookings.','dbem'), $total_items). '</a>' );
|
44 |
+
}
|
45 |
+
break;
|
46 |
+
}
|
47 |
+
do_action( 'bp_em_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
48 |
+
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Remove a screen notification for a user.
|
54 |
+
*/
|
55 |
+
function bp_em_remove_screen_notifications() {
|
56 |
+
global $bp;
|
57 |
+
bp_core_delete_notifications_by_type( $bp->loggedin_user->id, $bp->events->slug, 'attending' );
|
58 |
+
}
|
59 |
+
add_action( 'bp_em_my_events', 'bp_em_remove_screen_notifications' );
|
60 |
+
add_action( 'xprofile_screen_display_profile', 'bp_em_remove_screen_notifications' );
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Catch booking saves and add a BP notification.
|
64 |
+
* @param boolean $result
|
65 |
+
* @param EM_Booking $EM_Booking
|
66 |
+
* @return boolean
|
67 |
+
*/
|
68 |
+
function bp_em_add_booking_notification($result, $EM_Booking){
|
69 |
+
global $bp;
|
70 |
+
if( get_option('dbem_bookings_approval') && $EM_Booking->get_status() == 0 ){
|
71 |
+
$action = 'pending_booking';
|
72 |
+
}elseif( $EM_Booking->get_status() == 1 || (get_option('dbem_bookings_approval') && $EM_Booking->get_status() == 0) ){
|
73 |
+
$action = 'confirmed_booking';
|
74 |
+
}elseif( $EM_Booking->get_status() == 3 ){
|
75 |
+
$action = 'cancelled_booking';
|
76 |
+
}
|
77 |
+
if( !empty($action) ){
|
78 |
+
bp_core_add_notification( $EM_Booking->booking_id, $EM_Booking->get_event()->get_contact()->ID, 'events', $action );
|
79 |
+
}
|
80 |
+
return $result;
|
81 |
+
}
|
82 |
+
add_filter('em_booking_save','bp_em_add_booking_notification',1,2);
|
buddypress/bp-em-templatetags.php
ADDED
@@ -0,0 +1,21 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Echo the Events Manager BuddyPresss component's slug
|
4 |
+
* @since 5.0
|
5 |
+
*/
|
6 |
+
function em_bp_slug() {
|
7 |
+
echo em_bp_get_slug();
|
8 |
+
}
|
9 |
+
/**
|
10 |
+
* Return the Events Manager BuddyPresss component's slug
|
11 |
+
*
|
12 |
+
* @since 5.0
|
13 |
+
* @uses apply_filters() Filter 'em_bp_get_slug' to change the output
|
14 |
+
* @return str $slug The slug from $bp->events->slug, if it exists
|
15 |
+
*/
|
16 |
+
function em_bp_get_slug() {
|
17 |
+
global $bp;
|
18 |
+
// Avoid PHP warnings, in case the value is not set for some reason
|
19 |
+
$slug = !empty( $bp->events->slug ) ? $bp->events->slug : BP_EM_SLUG;
|
20 |
+
return apply_filters( 'em_bp_get_slug', $slug );
|
21 |
+
}
|
buddypress/screens/attending.php
ADDED
@@ -0,0 +1,29 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* bp_em_screen_two()
|
4 |
+
*
|
5 |
+
* Sets up and displays the screen output for the sub nav item "em/screen-two"
|
6 |
+
*/
|
7 |
+
function bp_em_attending() {
|
8 |
+
global $bp;
|
9 |
+
/**
|
10 |
+
* If the user has not Accepted or Rejected anything, then the code above will not run,
|
11 |
+
* we can continue and load the template.
|
12 |
+
*/
|
13 |
+
do_action( 'bp_em_attending' );
|
14 |
+
|
15 |
+
add_action( 'bp_template_title', 'bp_em_attending_title' );
|
16 |
+
add_action( 'bp_template_content', 'bp_em_attending_content' );
|
17 |
+
|
18 |
+
/* Finally load the plugin template file. */
|
19 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
function bp_em_attending_title() {
|
23 |
+
_e( 'Events I\'m Attending', 'dbem' );
|
24 |
+
}
|
25 |
+
|
26 |
+
function bp_em_attending_content() {
|
27 |
+
//We can use the same template as the public user interface for non bp sites
|
28 |
+
em_my_bookings();
|
29 |
+
}
|
buddypress/screens/group-events.php
ADDED
@@ -0,0 +1,30 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Controller for the event views in BP (using mvc terms here)
|
4 |
+
*/
|
5 |
+
function bp_em_group_events() {
|
6 |
+
global $bp;
|
7 |
+
do_action( 'bp_em_group_events' );
|
8 |
+
|
9 |
+
//plug into EM admin code (at least for now)
|
10 |
+
include_once(EM_DIR.'/admin/em-admin.php');
|
11 |
+
|
12 |
+
add_action( 'bp_template_title', 'bp_em_group_events_title' );
|
13 |
+
add_action( 'bp_template_content', 'bp_em_group_events_content' );
|
14 |
+
|
15 |
+
/* Finally load the plugin template file. */
|
16 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'groups/single/plugins' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
function bp_em_group_events_title() {
|
20 |
+
_e( 'Group Events', 'dbem' );
|
21 |
+
}
|
22 |
+
/**
|
23 |
+
* Determines whether to show event page or events page, and saves any updates to the event or events
|
24 |
+
* @return null
|
25 |
+
*/
|
26 |
+
function bp_em_group_events_content() {
|
27 |
+
em_locate_template('buddypress/group-events.php', true);
|
28 |
+
}
|
29 |
+
|
30 |
+
?>
|
buddypress/screens/my-bookings.php
ADDED
@@ -0,0 +1,35 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* bp_em_screen_two()
|
4 |
+
*
|
5 |
+
* Sets up and displays the screen output for the sub nav item "em/screen-two"
|
6 |
+
*/
|
7 |
+
function bp_em_my_bookings() {
|
8 |
+
global $bp, $EM_Event;
|
9 |
+
|
10 |
+
//assume any notifications here are considered viewed via this page
|
11 |
+
bp_core_delete_notifications_by_type(get_current_user_id(), 'events','pending_booking');
|
12 |
+
bp_core_delete_notifications_by_type(get_current_user_id(), 'events','confirmed_booking');
|
13 |
+
bp_core_delete_notifications_by_type(get_current_user_id(), 'events','cancelled_booking');
|
14 |
+
|
15 |
+
em_load_event();
|
16 |
+
/**
|
17 |
+
* If the user has not Accepted or Rejected anything, then the code above will not run,
|
18 |
+
* we can continue and load the template.
|
19 |
+
*/
|
20 |
+
do_action( 'bp_em_my_bookings' );
|
21 |
+
|
22 |
+
add_action( 'bp_template_title', 'bp_em_my_bookings_title' );
|
23 |
+
add_action( 'bp_template_content', 'bp_em_my_bookings_content' );
|
24 |
+
|
25 |
+
/* Finally load the plugin template file. */
|
26 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
27 |
+
}
|
28 |
+
|
29 |
+
function bp_em_my_bookings_title() {
|
30 |
+
_e( 'My Event Bookings', 'dbem' );
|
31 |
+
}
|
32 |
+
|
33 |
+
function bp_em_my_bookings_content() {
|
34 |
+
em_locate_template('buddypress/my-bookings.php',true);
|
35 |
+
}
|
buddypress/screens/my-events.php
ADDED
@@ -0,0 +1,55 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Controller for the event views in BP (using mvc terms here)
|
4 |
+
*/
|
5 |
+
function bp_em_my_events() {
|
6 |
+
global $bp, $EM_Event;
|
7 |
+
if( !is_object($EM_Event) && !empty($_REQUEST['event_id']) ){
|
8 |
+
$EM_Event = new EM_Event($_REQUEST['event_id']);
|
9 |
+
}
|
10 |
+
|
11 |
+
do_action( 'bp_em_my_events' );
|
12 |
+
|
13 |
+
$template_title = 'bp_em_my_events_title';
|
14 |
+
$template_content = 'bp_em_my_events_content';
|
15 |
+
|
16 |
+
if( !empty($_GET['action']) ){
|
17 |
+
switch($_GET['action']){
|
18 |
+
case 'edit':
|
19 |
+
$template_title = 'bp_em_my_events_editor_title';
|
20 |
+
break;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
add_action( 'bp_template_title', $template_title );
|
25 |
+
add_action( 'bp_template_content', $template_content );
|
26 |
+
|
27 |
+
/* Finally load the plugin template file. */
|
28 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
function bp_em_my_events_title() {
|
32 |
+
_e( 'My Events', 'dbem' );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Determines whether to show event page or events page, and saves any updates to the event or events
|
37 |
+
* @return null
|
38 |
+
*/
|
39 |
+
function bp_em_my_events_content() {
|
40 |
+
em_locate_template('buddypress/my-events.php', true);
|
41 |
+
}
|
42 |
+
|
43 |
+
function bp_em_my_events_editor_title() {
|
44 |
+
global $EM_Event;
|
45 |
+
if( is_object($EM_Event) ){
|
46 |
+
if($EM_Event->is_recurring()){
|
47 |
+
echo __( "Reschedule Events", 'dbem' )." '{$EM_Event->event_name}'";
|
48 |
+
}else{
|
49 |
+
echo __( "Edit Event", 'dbem' ) . " '" . $EM_Event->event_name . "'";
|
50 |
+
}
|
51 |
+
}else{
|
52 |
+
_e( 'Add Event', 'dbem' );
|
53 |
+
}
|
54 |
+
}
|
55 |
+
?>
|
buddypress/screens/my-group-events.php
ADDED
@@ -0,0 +1,27 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Controller for the event views in BP (using mvc terms here)
|
4 |
+
*/
|
5 |
+
function bp_em_my_group_events() {
|
6 |
+
global $bp;
|
7 |
+
do_action( 'bp_em_my_group_events' );
|
8 |
+
|
9 |
+
//plug into EM admin code (at least for now)
|
10 |
+
include_once(EM_DIR.'/admin/em-admin.php');
|
11 |
+
|
12 |
+
add_action( 'bp_template_title', 'bp_em_my_group_events_title' );
|
13 |
+
add_action( 'bp_template_content', 'bp_em_my_group_events_content' );
|
14 |
+
|
15 |
+
/* Finally load the plugin template file. */
|
16 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
function bp_em_my_group_events_title() {
|
20 |
+
_e( 'Group Events', 'dbem' );
|
21 |
+
}
|
22 |
+
|
23 |
+
function bp_em_my_group_events_content(){
|
24 |
+
em_locate_template('buddypress/my-group-events.php', true);
|
25 |
+
}
|
26 |
+
|
27 |
+
?>
|
buddypress/screens/my-locations.php
ADDED
@@ -0,0 +1,51 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Controller for the location views in BP (using mvc terms here)
|
4 |
+
*/
|
5 |
+
function bp_em_my_locations() {
|
6 |
+
global $bp, $EM_Location;
|
7 |
+
if( !is_object($EM_Location) && !empty($_REQUEST['location_id']) ){
|
8 |
+
$EM_Location = new EM_Location($_REQUEST['location_id']);
|
9 |
+
}
|
10 |
+
|
11 |
+
do_action( 'bp_em_my_locations' );
|
12 |
+
|
13 |
+
$template_title = 'bp_em_my_locations_title';
|
14 |
+
$template_content = 'bp_em_my_locations_content';
|
15 |
+
|
16 |
+
if( !empty($_GET['action']) ){
|
17 |
+
switch($_GET['action']){
|
18 |
+
case 'edit':
|
19 |
+
$template_title = 'bp_em_my_locations_editor_title';
|
20 |
+
break;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
add_action( 'bp_template_title', $template_title );
|
25 |
+
add_action( 'bp_template_content', $template_content );
|
26 |
+
|
27 |
+
/* Finally load the plugin template file. */
|
28 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
function bp_em_my_locations_title() {
|
32 |
+
_e( 'My Locations', 'dbem' );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Determines whether to show location page or locations page, and saves any updates to the location or locations
|
37 |
+
* @return null
|
38 |
+
*/
|
39 |
+
function bp_em_my_locations_content() {
|
40 |
+
em_locate_template('buddypress/my-locations.php', true);
|
41 |
+
}
|
42 |
+
|
43 |
+
function bp_em_my_locations_editor_title() {
|
44 |
+
global $EM_Location;
|
45 |
+
if( empty($EM_Location) || !is_object($EM_Location) ){
|
46 |
+
$title = __('Add Location', 'dbem');
|
47 |
+
}else{
|
48 |
+
$title = __('Edit Location', 'dbem');
|
49 |
+
}
|
50 |
+
}
|
51 |
+
?>
|
buddypress/screens/profile.php
ADDED
@@ -0,0 +1,32 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* bp_em_screen_one()
|
4 |
+
*
|
5 |
+
* Sets up and displays the screen output for the sub nav item "em/screen-one"
|
6 |
+
*/
|
7 |
+
function bp_em_events() {
|
8 |
+
global $bp, $EM_Notices;
|
9 |
+
|
10 |
+
if( bp_is_my_profile() ){
|
11 |
+
$EM_Notices->add_info( __('You are currently viewing your public page, this is what other users will see.', 'dbem') );
|
12 |
+
}
|
13 |
+
|
14 |
+
/* Add a do action here, so your component can be extended by others. */
|
15 |
+
do_action( 'bp_em_events' );
|
16 |
+
|
17 |
+
add_action( 'bp_template_title', 'bp_em_events_title' );
|
18 |
+
add_action( 'bp_template_content', 'bp_em_events_content' );
|
19 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
20 |
+
//bp_core_load_template( apply_filters( 'bp_em_template_screen_one', 'em/screen-one' ) );
|
21 |
+
}
|
22 |
+
/***
|
23 |
+
* The second argument of each of the above add_action() calls is a function that will
|
24 |
+
* display the corresponding information. The functions are presented below:
|
25 |
+
*/
|
26 |
+
function bp_em_events_title() {
|
27 |
+
_e( 'Events', 'dbem' );
|
28 |
+
}
|
29 |
+
|
30 |
+
function bp_em_events_content() {
|
31 |
+
em_locate_template('buddypress/profile.php',true);
|
32 |
+
}
|
classes/em-booking.php
CHANGED
@@ -1,379 +1,1072 @@
|
|
1 |
-
<?php
|
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 |
-
var $
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
$
|
142 |
-
if($
|
143 |
-
$this->
|
144 |
-
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
$
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
$
|
282 |
-
|
283 |
-
$
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
$
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
*
|
365 |
-
* @return
|
366 |
-
*/
|
367 |
-
function
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
379 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* gets a booking in a more db-friendly manner, allows hooking into booking object right after instantiation
|
4 |
+
* @param mixed $id
|
5 |
+
* @param mixed $search_by
|
6 |
+
* @return EM_Booking
|
7 |
+
*/
|
8 |
+
function em_get_booking($id = false) {
|
9 |
+
global $EM_Booking;
|
10 |
+
//check if it's not already global so we don't instantiate again
|
11 |
+
if( is_object($EM_Booking) && get_class($EM_Booking) == 'EM_Booking' ){
|
12 |
+
if( is_object($id) && $EM_Booking->booking_id == $id->booking_id ){
|
13 |
+
return apply_filters('em_get_booking', $EM_Booking);
|
14 |
+
}else{
|
15 |
+
if( is_numeric($id) && $EM_Booking->booking_id == $id ){
|
16 |
+
return apply_filters('em_get_booking', $EM_Booking);
|
17 |
+
}elseif( is_array($id) && !empty($id['booking_id']) && $EM_Booking->booking_id == $id['booking_id'] ){
|
18 |
+
return apply_filters('em_get_booking', $EM_Booking);
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
if( is_object($id) && get_class($id) == 'EM_Booking' ){
|
23 |
+
return apply_filters('em_get_booking', $id);
|
24 |
+
}else{
|
25 |
+
return apply_filters('em_get_booking', new EM_Booking($id));
|
26 |
+
}
|
27 |
+
}
|
28 |
+
/**
|
29 |
+
* Contains all information and relevant functions surrounding a single booking made with Events Manager
|
30 |
+
*/
|
31 |
+
class EM_Booking extends EM_Object{
|
32 |
+
//DB Fields
|
33 |
+
var $booking_id;
|
34 |
+
var $event_id;
|
35 |
+
var $person_id;
|
36 |
+
var $booking_price = null;
|
37 |
+
var $booking_spaces;
|
38 |
+
var $booking_comment;
|
39 |
+
var $booking_status = false;
|
40 |
+
var $booking_tax_rate = null;
|
41 |
+
var $booking_taxes = null;
|
42 |
+
var $booking_meta = array();
|
43 |
+
var $fields = array(
|
44 |
+
'booking_id' => array('name'=>'id','type'=>'%d'),
|
45 |
+
'event_id' => array('name'=>'event_id','type'=>'%d'),
|
46 |
+
'person_id' => array('name'=>'person_id','type'=>'%d'),
|
47 |
+
'booking_price' => array('name'=>'price','type'=>'%f'),
|
48 |
+
'booking_spaces' => array('name'=>'spaces','type'=>'%d'),
|
49 |
+
'booking_comment' => array('name'=>'comment','type'=>'%s'),
|
50 |
+
'booking_status' => array('name'=>'status','type'=>'%d'),
|
51 |
+
'booking_tax_rate' => array('name'=>'tax_rate','type'=>'%f','null'=>1),
|
52 |
+
'booking_taxes' => array('name'=>'taxes','type'=>'%f','null'=>1),
|
53 |
+
'booking_meta' => array('name'=>'meta','type'=>'%s')
|
54 |
+
);
|
55 |
+
//Other Vars
|
56 |
+
/**
|
57 |
+
* array of notes by admins on this booking. loaded from em_meta table in construct
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
var $notes;
|
61 |
+
var $timestamp;
|
62 |
+
var $person;
|
63 |
+
var $required_fields = array('booking_id', 'event_id', 'person_id', 'booking_spaces');
|
64 |
+
var $feedback_message = "";
|
65 |
+
var $errors = array();
|
66 |
+
/**
|
67 |
+
* when using EM_Booking::email_send(), this number is updated with sent emails
|
68 |
+
* @var int
|
69 |
+
*/
|
70 |
+
var $mails_sent = 0;
|
71 |
+
/**
|
72 |
+
* Contains an array of custom fields for a booking. This is loaded from em_meta, where the booking_custom name contains arrays of data.
|
73 |
+
* @var array
|
74 |
+
*/
|
75 |
+
var $custom = array();
|
76 |
+
/**
|
77 |
+
* If saved in this instance, you can see what previous approval status was.
|
78 |
+
* @var int
|
79 |
+
*/
|
80 |
+
var $previous_status = false;
|
81 |
+
/**
|
82 |
+
* The booking approval status number corresponds to a state in this array.
|
83 |
+
* @var unknown_type
|
84 |
+
*/
|
85 |
+
var $status_array = array();
|
86 |
+
/**
|
87 |
+
* @var EM_Tickets
|
88 |
+
*/
|
89 |
+
var $tickets;
|
90 |
+
/**
|
91 |
+
* @var EM_Event
|
92 |
+
*/
|
93 |
+
var $event;
|
94 |
+
/**
|
95 |
+
* @var EM_Tickets_Bookings
|
96 |
+
*/
|
97 |
+
var $tickets_bookings;
|
98 |
+
/**
|
99 |
+
* If set to true, this booking can be managed by any logged in user.
|
100 |
+
* @var EM_Tickets_Bookings
|
101 |
+
*/
|
102 |
+
var $manage_override;
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Creates booking object and retreives booking data (default is a blank booking object). Accepts either array of booking data (from db) or a booking id.
|
106 |
+
* @param mixed $booking_data
|
107 |
+
* @return null
|
108 |
+
*/
|
109 |
+
function EM_Booking( $booking_data = false ){
|
110 |
+
//Get the person for this booking
|
111 |
+
global $wpdb;
|
112 |
+
if( $booking_data !== false ){
|
113 |
+
//Load booking data
|
114 |
+
$booking = array();
|
115 |
+
if( is_array($booking_data) ){
|
116 |
+
$booking = $booking_data;
|
117 |
+
}elseif( is_numeric($booking_data) ){
|
118 |
+
//Retreiving from the database
|
119 |
+
$sql = "SELECT * FROM ". EM_BOOKINGS_TABLE ." LEFT JOIN ". EM_META_TABLE ." ON object_id=booking_id WHERE booking_id ='$booking_data'";
|
120 |
+
$booking = $wpdb->get_row($sql, ARRAY_A);
|
121 |
+
}
|
122 |
+
//booking meta
|
123 |
+
$booking['booking_meta'] = (!empty($booking['booking_meta'])) ? maybe_unserialize($booking['booking_meta']):array();
|
124 |
+
//Save into the object
|
125 |
+
$this->to_object($booking);
|
126 |
+
$this->previous_status = $this->booking_status;
|
127 |
+
$this->get_person();
|
128 |
+
$this->timestamp = !empty($booking['booking_date']) ? strtotime($booking['booking_date']):false;
|
129 |
+
}
|
130 |
+
//Do it here so things appear in the po file.
|
131 |
+
$this->status_array = array(
|
132 |
+
0 => __('Pending','dbem'),
|
133 |
+
1 => __('Approved','dbem'),
|
134 |
+
2 => __('Rejected','dbem'),
|
135 |
+
3 => __('Cancelled','dbem'),
|
136 |
+
4 => __('Awaiting Online Payment','dbem'),
|
137 |
+
5 => __('Awaiting Payment','dbem')
|
138 |
+
);
|
139 |
+
$this->compat_keys(); //depricating in 6.0
|
140 |
+
//do some legacy checking here for bookings made prior to 5.4, due to how taxes are calculated
|
141 |
+
$this->get_tax_rate();
|
142 |
+
if( !empty($this->legacy_tax_rate) ){
|
143 |
+
//reset booking_price, it'll be recalculated later (if you're using this property directly, don't, use $this->get_price())
|
144 |
+
$this->booking_price = $this->booking_taxes = null;
|
145 |
+
}
|
146 |
+
do_action('em_booking', $this, $booking_data);
|
147 |
+
}
|
148 |
+
|
149 |
+
function get_notes(){
|
150 |
+
global $wpdb;
|
151 |
+
if( !is_array($this->notes) && !empty($this->booking_id) ){
|
152 |
+
$notes = $wpdb->get_results("SELECT * FROM ". EM_META_TABLE ." WHERE meta_key='booking-note' AND object_id ='{$this->booking_id}'", ARRAY_A);
|
153 |
+
$this->notes = array();
|
154 |
+
foreach($notes as $note){
|
155 |
+
$this->notes[] = unserialize($note['meta_value']);
|
156 |
+
}
|
157 |
+
}elseif( empty($this->booking_id) ){
|
158 |
+
$this->notes = array();
|
159 |
+
}
|
160 |
+
return $this->notes;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Saves the booking into the database, whether a new or existing booking
|
165 |
+
* @param $mail whether or not to email the user and contact people
|
166 |
+
* @return boolean
|
167 |
+
*/
|
168 |
+
function save($mail = true){
|
169 |
+
global $wpdb;
|
170 |
+
$table = EM_BOOKINGS_TABLE;
|
171 |
+
do_action('em_booking_save_pre',$this);
|
172 |
+
if( $this->can_manage() ){
|
173 |
+
//update prices, spaces, person_id
|
174 |
+
$this->get_spaces(true);
|
175 |
+
$this->calculate_price();
|
176 |
+
$this->person_id = (empty($this->person_id)) ? $this->get_person()->ID : $this->person_id;
|
177 |
+
//Step 1. Save the booking
|
178 |
+
$data = $this->to_array();
|
179 |
+
$data['booking_meta'] = serialize($data['booking_meta']);
|
180 |
+
//update or save
|
181 |
+
if($this->booking_id != ''){
|
182 |
+
$update = true;
|
183 |
+
$where = array( 'booking_id' => $this->booking_id );
|
184 |
+
$result = $wpdb->update($table, $data, $where, $this->get_types($data));
|
185 |
+
$result = ($result !== false);
|
186 |
+
$this->feedback_message = __('Changes saved','dbem');
|
187 |
+
}else{
|
188 |
+
$update = false;
|
189 |
+
$result = $wpdb->insert($table, $data, $this->get_types($data));
|
190 |
+
$this->booking_id = $wpdb->insert_id;
|
191 |
+
$this->feedback_message = __('Your booking has been recorded','dbem');
|
192 |
+
}
|
193 |
+
//Step 2. Insert ticket bookings for this booking id if no errors so far
|
194 |
+
if( $result === false ){
|
195 |
+
$this->feedback_message = __('There was a problem saving the booking.', 'dbem');
|
196 |
+
$this->errors[] = __('There was a problem saving the booking.', 'dbem');
|
197 |
+
}else{
|
198 |
+
$tickets_bookings_result = $this->get_tickets_bookings()->save();
|
199 |
+
if( !$tickets_bookings_result ){
|
200 |
+
if( !$update ){
|
201 |
+
//delete the booking and tickets, instead of a transaction
|
202 |
+
$this->delete();
|
203 |
+
}
|
204 |
+
$this->errors[] = __('There was a problem saving the booking.', 'dbem');
|
205 |
+
$this->add_error( $this->get_tickets_bookings()->get_errors() );
|
206 |
+
}
|
207 |
+
}
|
208 |
+
//Step 3. email if necessary
|
209 |
+
if ( count($this->errors) == 0 && $mail ) {
|
210 |
+
$this->email();
|
211 |
+
}
|
212 |
+
$this->compat_keys();
|
213 |
+
return apply_filters('em_booking_save', ( count($this->errors) == 0 ), $this);
|
214 |
+
}else{
|
215 |
+
$this->feedback_message = __('There was a problem saving the booking.', 'dbem');
|
216 |
+
if( !$this->can_manage() ){
|
217 |
+
$this->add_error(sprintf(__('You cannot manage this %s.', 'dbem'),__('Booking','dbem')));
|
218 |
+
}
|
219 |
+
}
|
220 |
+
return apply_filters('em_booking_save', false, $this);
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Load an record into this object by passing an associative array of table criterie to search for.
|
225 |
+
* Returns boolean depending on whether a record is found or not.
|
226 |
+
* @param $search
|
227 |
+
* @return boolean
|
228 |
+
*/
|
229 |
+
function get($search) {
|
230 |
+
global $wpdb;
|
231 |
+
$conds = array();
|
232 |
+
foreach($search as $key => $value) {
|
233 |
+
if( array_key_exists($key, $this->fields) ){
|
234 |
+
$value = esc_sql($value);
|
235 |
+
$conds[] = "`$key`='$value'";
|
236 |
+
}
|
237 |
+
}
|
238 |
+
$sql = "SELECT * FROM ". $wpdb->EM_BOOKINGS_TABLE ." WHERE " . implode(' AND ', $conds) ;
|
239 |
+
$result = $wpdb->get_row($sql, ARRAY_A);
|
240 |
+
if($result){
|
241 |
+
$this->to_object($result);
|
242 |
+
$this->person = new EM_Person($this->person_id);
|
243 |
+
return true;
|
244 |
+
}else{
|
245 |
+
return false;
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Get posted data and save it into the object (not db)
|
251 |
+
* @return boolean
|
252 |
+
*/
|
253 |
+
function get_post( $override_availability = false ){
|
254 |
+
$this->tickets_bookings = new EM_Tickets_Bookings($this->booking_id);
|
255 |
+
do_action('em_booking_get_post_pre',$this);
|
256 |
+
$result = array();
|
257 |
+
$this->event_id = $_REQUEST['event_id'];
|
258 |
+
if( isset($_REQUEST['em_tickets']) && is_array($_REQUEST['em_tickets']) && ($_REQUEST['em_tickets'] || $override_availability) ){
|
259 |
+
foreach( $_REQUEST['em_tickets'] as $ticket_id => $values){
|
260 |
+
//make sure ticket exists
|
261 |
+
if( !empty($values['spaces']) || $override_availability ){
|
262 |
+
$args = array('ticket_id'=>$ticket_id, 'ticket_booking_spaces'=>$values['spaces'], 'booking_id'=>$this->booking_id);
|
263 |
+
if($this->get_event()->get_bookings()->ticket_exists($ticket_id)){
|
264 |
+
$EM_Ticket_Booking = new EM_Ticket_Booking($args);
|
265 |
+
$EM_Ticket_Booking->booking = $this;
|
266 |
+
if( !$this->tickets_bookings->add( $EM_Ticket_Booking, $override_availability ) ){
|
267 |
+
$this->add_error($this->tickets_bookings->get_errors());
|
268 |
+
}
|
269 |
+
}else{
|
270 |
+
$this->errors[]=__('You are trying to book a non-existent ticket for this event.','dbem');
|
271 |
+
}
|
272 |
+
}
|
273 |
+
}
|
274 |
+
$this->booking_comment = (!empty($_REQUEST['booking_comment'])) ? wp_kses_data(stripslashes($_REQUEST['booking_comment'])):'';
|
275 |
+
//allow editing of tax rate
|
276 |
+
if( !empty($this->booking_id) && $this->can_manage() ){
|
277 |
+
$this->booking_tax_rate = (!empty($_REQUEST['booking_tax_rate']) && is_numeric($_REQUEST['booking_tax_rate'])) ? $_REQUEST['booking_tax_rate']:$this->booking_tax_rate;
|
278 |
+
}
|
279 |
+
//recalculate spaces/price
|
280 |
+
$this->get_spaces(true);
|
281 |
+
$this->calculate_price();
|
282 |
+
//get person
|
283 |
+
$this->get_person();
|
284 |
+
//re-run compatiblity keys function
|
285 |
+
$this->compat_keys(); //depricating in 6.0
|
286 |
+
}
|
287 |
+
return apply_filters('em_booking_get_post',count($this->errors) == 0,$this);
|
288 |
+
}
|
289 |
+
|
290 |
+
function validate( $override_availability = false ){
|
291 |
+
//step 1, basic info
|
292 |
+
$basic = (
|
293 |
+
(empty($this->event_id) || is_numeric($this->event_id)) &&
|
294 |
+
(empty($this->person_id) || is_numeric($this->person_id)) &&
|
295 |
+
is_numeric($this->booking_spaces) && $this->booking_spaces > 0
|
296 |
+
);
|
297 |
+
//give some errors in step 1
|
298 |
+
if( $this->booking_spaces == 0 ){
|
299 |
+
$this->add_error(get_option('dbem_booking_feedback_min_space'));
|
300 |
+
}
|
301 |
+
//step 2, tickets bookings info
|
302 |
+
if( count($this->get_tickets_bookings()) > 0 ){
|
303 |
+
$ticket_validation = array();
|
304 |
+
foreach($this->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking){
|
305 |
+
if ( !$EM_Ticket_Booking->validate() ){
|
306 |
+
$ticket_validation[] = false;
|
307 |
+
$result = $basic && !in_array(false,$ticket_validation);
|
308 |
+
}
|
309 |
+
$this->errors = array_merge($this->errors, $EM_Ticket_Booking->get_errors());
|
310 |
+
}
|
311 |
+
$result = $basic && !in_array(false,$ticket_validation);
|
312 |
+
}else{
|
313 |
+
$result = false;
|
314 |
+
}
|
315 |
+
//is there enough space overall?
|
316 |
+
if( !$override_availability && $this->get_event()->get_bookings()->get_available_spaces() < $this->get_spaces() ){
|
317 |
+
$result = false;
|
318 |
+
$this->add_error(get_option('dbem_booking_feedback_full'));
|
319 |
+
}
|
320 |
+
//can we book this amount of spaces at once?
|
321 |
+
if( $this->get_event()->event_rsvp_spaces > 0 && $this->get_spaces() > $this->get_event()->event_rsvp_spaces ){
|
322 |
+
$result = false;
|
323 |
+
$this->add_error( sprintf(get_option('dbem_booking_feedback_spaces_limit'), $this->get_event()->event_rsvp_spaces));
|
324 |
+
}
|
325 |
+
return apply_filters('em_booking_validate',$result,$this);
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Get the total number of spaces booked in THIS booking. Seting $force_refresh to true will recheck spaces, even if previously done so.
|
330 |
+
* @param unknown_type $force_refresh
|
331 |
+
* @return mixed
|
332 |
+
*/
|
333 |
+
function get_spaces( $force_refresh=false ){
|
334 |
+
if($this->booking_spaces == 0 || $force_refresh == true ){
|
335 |
+
$this->booking_spaces = $this->get_tickets_bookings()->get_spaces($force_refresh);
|
336 |
+
}
|
337 |
+
return apply_filters('em_booking_get_spaces',$this->booking_spaces,$this);
|
338 |
+
}
|
339 |
+
|
340 |
+
/* Price Calculations */
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Gets the total price for this whole booking, including any discounts, taxes, and any other additional items. In other words, what the person has to pay or has supposedly paid.
|
344 |
+
* This price shouldn't change once established, unless there's any alteration to the booking itself that'd affect the price, such as a change in ticket numbers, discount, etc.
|
345 |
+
* @param boolean $format
|
346 |
+
* @return double|string
|
347 |
+
*/
|
348 |
+
function get_price( $format = false, $format_depricated = null ){
|
349 |
+
if( $format_depricated !== null ) $format = $format_depricated; //support for old parameters, will be depricated soon
|
350 |
+
//recalculate price here only if price is not actually set
|
351 |
+
if( $this->booking_price === null ){
|
352 |
+
$this->calculate_price();
|
353 |
+
apply_filters('em_booking_get_price', $this->booking_price, $this);
|
354 |
+
}
|
355 |
+
//return booking_price, formatted or not
|
356 |
+
if($format){
|
357 |
+
return $this->format_price($this->booking_price);
|
358 |
+
}
|
359 |
+
return $this->booking_price;
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Total of tickets without taxes, discounts or any other modification. No filter given here for that very reason!
|
364 |
+
* @param boolean $format
|
365 |
+
* @return double|string
|
366 |
+
*/
|
367 |
+
function get_price_base( $format = false ){
|
368 |
+
$price = $this->get_tickets_bookings()->get_price();
|
369 |
+
if($format){
|
370 |
+
return $this->format_price($price);
|
371 |
+
}
|
372 |
+
return $price;
|
373 |
+
}
|
374 |
+
|
375 |
+
function get_price_pre_taxes( $format = false ){
|
376 |
+
$price = $base_price = $this->get_price_base();
|
377 |
+
//apply pre-tax discounts
|
378 |
+
$price -= $this->get_price_discounts_amount('pre', $price);
|
379 |
+
if( $price < 0 ){ $price = 0; } //no negative prices
|
380 |
+
//return amount of taxes applied, formatted or not
|
381 |
+
if( $format ) return $this->format_price($price);
|
382 |
+
return $price;
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Gets price AFTER taxes and post-tax discounts have also been added
|
387 |
+
* @param boolean $format
|
388 |
+
* @return double|string
|
389 |
+
*/
|
390 |
+
function get_price_post_taxes( $format = false ){
|
391 |
+
//get price before taxes
|
392 |
+
$price = $this->get_price_pre_taxes();
|
393 |
+
//add taxes to price
|
394 |
+
if( $this->get_tax_rate() > 0 ){
|
395 |
+
$this->booking_taxes = round($price * ($this->get_tax_rate()/100), 2); //calculate and save tax amount
|
396 |
+
$price += $this->booking_taxes; //add taxes
|
397 |
+
$this->taxes_applied = true;
|
398 |
+
}
|
399 |
+
//apply post-tax discounts
|
400 |
+
$price -= $this->get_price_discounts_amount('post', $price);
|
401 |
+
if( $price < 0 ){ $price = 0; } //no negative prices
|
402 |
+
//return amount of taxes applied, formatted or not
|
403 |
+
if( $format ) return $this->format_price($price);
|
404 |
+
return $price;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Get amount of taxes applied to this booking price.
|
409 |
+
* @param boolean $format
|
410 |
+
* @return double|string
|
411 |
+
*/
|
412 |
+
function get_price_taxes( $format=false ){
|
413 |
+
if( $this->booking_taxes !== null ){
|
414 |
+
$this->booking_taxes; //taxes already calculated
|
415 |
+
}else{
|
416 |
+
$this->calculate_price(); //recalculate price and taxes
|
417 |
+
}
|
418 |
+
//return amount of taxes applied, formatted or not
|
419 |
+
if( $format ){
|
420 |
+
return $this->format_price($this->booking_taxes);
|
421 |
+
}
|
422 |
+
return $this->booking_taxes;
|
423 |
+
}
|
424 |
+
|
425 |
+
function get_price_discount(){
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Calculates (or recalculates) the price of this booking including taxes, discounts etc., saves it to the booking_price property and writes to relevant properties booking_meta variables
|
431 |
+
* @return double
|
432 |
+
*/
|
433 |
+
function calculate_price(){
|
434 |
+
//reset price and taxes calculations
|
435 |
+
$this->booking_price = $this->booking_taxes = null;
|
436 |
+
//get post-tax price and save it to booking_price
|
437 |
+
$this->booking_price = $this->get_price_post_taxes();
|
438 |
+
return apply_filters('em_booking_calculate_price', $this->booking_price, $this);
|
439 |
+
}
|
440 |
+
|
441 |
+
/*
|
442 |
+
* Gets tax rate of booking
|
443 |
+
* @see EM_Object::get_tax_rate()
|
444 |
+
* @return double
|
445 |
+
*/
|
446 |
+
function get_tax_rate(){
|
447 |
+
if( $this->booking_tax_rate === null ){
|
448 |
+
//booking not saved or tax never defined
|
449 |
+
if( !empty($this->booking_id) && get_option('dbem_legacy_bookings_tax', 'x') !== 'x'){ //even if 0 if defined as tax rate we still use it, delete the option entirely to stop
|
450 |
+
//no tax applied yet to an existing booking, or tax possibly applied (but handled seperately in EM_Tickets_Bookings but in legacy < v5.4
|
451 |
+
//sort out MultiSite nuances
|
452 |
+
if( EM_MS_GLOBAL && $this->get_event()->blog_id != get_current_blog_id() ){
|
453 |
+
//MultiSite AND Global tables enabled AND this event belongs to another blog - get settings for blog that published the event
|
454 |
+
$this->booking_tax_rate = get_blog_option($this->get_event()->blog_id, 'dbem_legacy_bookings_tax');
|
455 |
+
}else{
|
456 |
+
//get booking from current site, whether or not we're in MultiSite
|
457 |
+
$this->booking_tax_rate = get_option('dbem_legacy_bookings_tax');
|
458 |
+
}
|
459 |
+
$this->legacy_tax_rate = true;
|
460 |
+
}else{
|
461 |
+
//first time we're applying tax rate
|
462 |
+
$this->booking_tax_rate = $this->get_event()->get_tax_rate();
|
463 |
+
}
|
464 |
+
}
|
465 |
+
return $this->booking_tax_rate;
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Returns an array of discounts to be applied to a booking. Here is an example of an array item that is expected:
|
470 |
+
* array('name' => 'Name of Discount', 'type'=>'% or #', 'amount'=> 0.00, 'desc' => 'Comments about discount', 'tax'=>'pre/post', 'data' => 'any info for hooks to use' );
|
471 |
+
* About the array keys:
|
472 |
+
* type - $ means a fixed amount of discount, % means a percentage off the base price
|
473 |
+
* amount - if type is a percentage, it is written as a number from 0-100, e.g. 10 = 10%
|
474 |
+
* tax - 'pre' means discount is applied before tax, 'post' means after tax
|
475 |
+
* data - any data to be stored that can be used by actions/filters
|
476 |
+
* @return array
|
477 |
+
*/
|
478 |
+
function get_price_discounts(){
|
479 |
+
$discounts = array();
|
480 |
+
if( !empty($this->booking_meta['discounts']) && is_array($this->booking_meta['discounts']) ){
|
481 |
+
$discounts = $this->booking_meta['discounts'];
|
482 |
+
}
|
483 |
+
return apply_filters('em_booking_get_price_discounts', $discounts, $this);
|
484 |
+
}
|
485 |
+
|
486 |
+
function get_price_discounts_amount( $pre_or_post = 'pre', $price = false ){
|
487 |
+
$discounts = $this->get_price_discounts_summary($pre_or_post, $price);
|
488 |
+
$discount_amount = 0;
|
489 |
+
foreach($discounts as $discount){
|
490 |
+
$discount_amount += $discount['amount_discounted'];
|
491 |
+
}
|
492 |
+
return $discount_amount;
|
493 |
+
}
|
494 |
+
|
495 |
+
function get_price_discounts_summary( $pre_or_post = 'pre', $price = false ){
|
496 |
+
$discounts= $this->get_price_discounts();
|
497 |
+
$discount_summary = array();
|
498 |
+
if( $price === false ){
|
499 |
+
$price = $this->get_price_base();
|
500 |
+
if( $pre_or_post == 'post' ) $price = $this->get_price_pre_taxes() + $this->get_price_taxes();
|
501 |
+
}
|
502 |
+
foreach($discounts as $discount){
|
503 |
+
$discount_amount = 0;
|
504 |
+
if( !empty($discount['amount']) ){
|
505 |
+
if( !empty($discount['tax']) && $discount['tax'] == $pre_or_post ){
|
506 |
+
if( !empty($discount['type']) ){
|
507 |
+
$discount_summary_item = array('name' => $discount['name'], 'desc' => $discount['desc'], 'discount'=>'0', 'amount_discounted'=>0);
|
508 |
+
if( $discount['type'] == '%' ){ //discount by percentage
|
509 |
+
$discount_summary_item['amount_discounted'] = round($price * ($discount['amount']/100),2);
|
510 |
+
$discount_summary_item['amount'] = $this->format_price($discount_summary_item['amount_discounted']);
|
511 |
+
$discount_summary_item['discount'] = number_format($discount['amount'],2).'%';
|
512 |
+
$discount_summary[] = $discount_summary_item;
|
513 |
+
}elseif( $discount['type'] == '#' ){ //discount by amount
|
514 |
+
$discount_summary_item['amount_discounted'] = round($discount['amount'],2);
|
515 |
+
$discount_summary_item['amount'] = $this->format_price($discount_summary_item['amount_discounted']);
|
516 |
+
$discount_summary_item['discount'] = $this->format_price($discount['amount']);
|
517 |
+
$discount_summary[] = $discount_summary_item;
|
518 |
+
}
|
519 |
+
}
|
520 |
+
}
|
521 |
+
}
|
522 |
+
}
|
523 |
+
return $discount_summary;
|
524 |
+
}
|
525 |
+
|
526 |
+
/**
|
527 |
+
* When generating totals at the bottom of a booking, this creates a useful array for displaying the summary in a meaningful way.
|
528 |
+
*/
|
529 |
+
function get_price_summary_array(){
|
530 |
+
$summary = array();
|
531 |
+
//get base price of bookings
|
532 |
+
$summary['total_base'] = $this->get_price_base();
|
533 |
+
//get discounts
|
534 |
+
//apply pre-tax discounts
|
535 |
+
$summary['discounts_pre_tax'] = $this->get_price_discounts_summary('pre');
|
536 |
+
//add taxes to price
|
537 |
+
$summary['taxes'] = array('rate'=> 0, 'amount'=> 0);
|
538 |
+
if( $this->get_price_taxes() > 0 ){
|
539 |
+
$summary['taxes'] = array('rate'=> number_format($this->get_tax_rate(),2).'%', 'amount'=> $this->get_price_taxes(true));
|
540 |
+
}
|
541 |
+
//apply post-tax discounts
|
542 |
+
$summary['discounts_post_tax'] = $this->get_price_discounts_summary('post');
|
543 |
+
//final price
|
544 |
+
$summary['total'] = $this->get_price(true);
|
545 |
+
return $summary;
|
546 |
+
}
|
547 |
+
|
548 |
+
/* Get Objects linked to booking */
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Gets the event this booking belongs to and saves a refernece in the event property
|
552 |
+
* @return EM_Event
|
553 |
+
*/
|
554 |
+
function get_event(){
|
555 |
+
global $EM_Event;
|
556 |
+
if( is_object($this->event) && get_class($this->event)=='EM_Event' && $this->event->event_id == $this->event_id ){
|
557 |
+
return $this->event;
|
558 |
+
}elseif( is_object($EM_Event) && ( (is_object($this->event) && $this->event->event_id == $this->event_id) || empty($this->booking_id)) ){
|
559 |
+
$this->event = $EM_Event;
|
560 |
+
}else{
|
561 |
+
$this->event = new EM_Event($this->event_id, 'event_id');
|
562 |
+
}
|
563 |
+
return apply_filters('em_booking_get_event',$this->event, $this);
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* Gets the ticket object this booking belongs to, saves a reference in ticket property
|
568 |
+
* @return EM_Tickets
|
569 |
+
*/
|
570 |
+
function get_tickets(){
|
571 |
+
if( is_object($this->tickets) && get_class($this->tickets)=='EM_Tickets' ){
|
572 |
+
return apply_filters('em_booking_get_tickets', $this->tickets, $this);
|
573 |
+
}else{
|
574 |
+
$this->tickets = new EM_Tickets($this);
|
575 |
+
}
|
576 |
+
return apply_filters('em_booking_get_tickets', $this->tickets, $this);
|
577 |
+
}
|
578 |
+
|
579 |
+
/**
|
580 |
+
* Gets the ticket object this booking belongs to, saves a reference in ticket property
|
581 |
+
* @return EM_Tickets_Bookings
|
582 |
+
*/
|
583 |
+
function get_tickets_bookings(){
|
584 |
+
global $wpdb;
|
585 |
+
if( !is_object($this->tickets_bookings) || get_class($this->tickets_bookings)!='EM_Tickets_Bookings'){
|
586 |
+
$this->tickets_bookings = new EM_Tickets_Bookings($this);
|
587 |
+
}
|
588 |
+
return apply_filters('em_booking_get_tickets_bookings', $this->tickets_bookings, $this);
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* @return EM_Person
|
593 |
+
*/
|
594 |
+
function get_person(){
|
595 |
+
global $EM_Person;
|
596 |
+
if( is_object($this->person) && get_class($this->person)=='EM_Person' && ($this->person->ID == $this->person_id || empty($this->person_id) ) ){
|
597 |
+
//This person is already included, so don't do anything
|
598 |
+
}elseif( is_object($EM_Person) && ($EM_Person->ID === $this->person_id || $this->booking_id == '') ){
|
599 |
+
$this->person = $EM_Person;
|
600 |
+
}elseif( is_numeric($this->person_id) ){
|
601 |
+
$this->person = new EM_Person($this->person_id);
|
602 |
+
}else{
|
603 |
+
$this->person = new EM_Person(0);
|
604 |
+
}
|
605 |
+
//if this user is the parent user of disabled registrations, replace user details here:
|
606 |
+
if( get_option('dbem_bookings_registration_disable') && $this->person->ID == get_option('dbem_bookings_registration_user') && (empty($this->person->loaded_no_user) || $this->person->loaded_no_user != $this->booking_id) ){
|
607 |
+
//override any registration data into the person objet
|
608 |
+
if( !empty($this->booking_meta['registration']) ){
|
609 |
+
foreach($this->booking_meta['registration'] as $key => $value){
|
610 |
+
$this->person->$key = $value;
|
611 |
+
}
|
612 |
+
}
|
613 |
+
$this->person->user_email = ( !empty($this->booking_meta['registration']['user_email']) ) ? $this->booking_meta['registration']['user_email']:$this->person->user_email;
|
614 |
+
if( !empty($this->booking_meta['registration']['user_name']) ){
|
615 |
+
$name_string = explode(' ',$this->booking_meta['registration']['user_name']);
|
616 |
+
$this->booking_meta['registration']['first_name'] = array_shift($name_string);
|
617 |
+
$this->booking_meta['registration']['last_name'] = implode(' ', $name_string);
|
618 |
+
}
|
619 |
+
$this->person->user_firstname = ( !empty($this->booking_meta['registration']['first_name']) ) ? $this->booking_meta['registration']['first_name']:__('Guest User','dbem');
|
620 |
+
$this->person->first_name = $this->person->user_firstname;
|
621 |
+
$this->person->user_lastname = ( !empty($this->booking_meta['registration']['last_name']) ) ? $this->booking_meta['registration']['last_name']:'';
|
622 |
+
$this->person->last_name = $this->person->user_lastname;
|
623 |
+
$this->person->phone = ( !empty($this->booking_meta['registration']['dbem_phone']) ) ? $this->booking_meta['registration']['dbem_phone']:__('Not Supplied','dbem');
|
624 |
+
//build display name
|
625 |
+
$full_name = $this->person->user_firstname . " " . $this->person->user_lastname ;
|
626 |
+
$full_name = trim($full_name);
|
627 |
+
$display_name = ( empty($full_name) ) ? __('Guest User','dbem'):$full_name;
|
628 |
+
$this->person->display_name = $display_name;
|
629 |
+
$this->person->loaded_no_user = $this->booking_id;
|
630 |
+
}
|
631 |
+
return apply_filters('em_booking_get_person', $this->person, $this);
|
632 |
+
}
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Gets personal information from the $_REQUEST array and saves it to the $EM_Booking->booking_meta['registration'] array
|
636 |
+
* @return boolean
|
637 |
+
*/
|
638 |
+
function get_person_post(){
|
639 |
+
$user_data = array();
|
640 |
+
$registration = true;
|
641 |
+
if( empty($this->booking_meta['registration']) ) $this->booking_meta['registration'] = array();
|
642 |
+
// Check the e-mail address
|
643 |
+
if ( $_REQUEST['user_email'] == '' ) {
|
644 |
+
$registration = false;
|
645 |
+
$this->add_error(__( '<strong>ERROR</strong>: Please type your e-mail address.', 'dbem') );
|
646 |
+
} elseif ( !is_email( $_REQUEST['user_email'] ) ) {
|
647 |
+
$registration = false;
|
648 |
+
$this->add_error( __( '<strong>ERROR</strong>: The email address isn’t correct.', 'dbem') );
|
649 |
+
}elseif(email_exists( $_REQUEST['user_email'] ) && !get_option('dbem_bookings_registration_disable_user_emails') ){
|
650 |
+
$registration = false;
|
651 |
+
$this->add_error( get_option('dbem_booking_feedback_email_exists') );
|
652 |
+
}else{
|
653 |
+
$user_data['user_email'] = $_REQUEST['user_email'];
|
654 |
+
}
|
655 |
+
//Check the user name
|
656 |
+
if( !empty($_REQUEST['user_name']) ){
|
657 |
+
$name_string = explode(' ',wp_kses($_REQUEST['user_name'], array()));
|
658 |
+
$user_data['first_name'] = array_shift($name_string);
|
659 |
+
$user_data['last_name'] = implode(' ', $name_string);
|
660 |
+
}
|
661 |
+
//Check the first/last name
|
662 |
+
if( !empty($_REQUEST['first_name']) ){
|
663 |
+
$user_data['first_name'] = wp_kses($_REQUEST['first_name'], array());
|
664 |
+
}
|
665 |
+
if( !empty($_REQUEST['last_name']) ){
|
666 |
+
$user_data['last_name'] = wp_kses($_REQUEST['last_name'], array());
|
667 |
+
}
|
668 |
+
//Check the phone
|
669 |
+
if( !empty($_REQUEST['dbem_phone']) ){
|
670 |
+
$user_data['dbem_phone'] = wp_kses($_REQUEST['dbem_phone'], array());
|
671 |
+
}
|
672 |
+
//Add booking meta
|
673 |
+
if( $registration ){
|
674 |
+
$this->booking_meta['registration'] = array_merge($this->booking_meta['registration'], $user_data); //in case someone else added stuff
|
675 |
+
}
|
676 |
+
$registration = apply_filters('em_booking_get_person_post', $registration, $this);
|
677 |
+
if( $registration ){
|
678 |
+
$this->feedback_message = __('Personal details have successfully been modified.', 'dbem');
|
679 |
+
}
|
680 |
+
return $registration;
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Displays a form containing user fields, used in no-user booking mode for editing guest users within a booking
|
685 |
+
* @return string
|
686 |
+
*/
|
687 |
+
function get_person_editor(){
|
688 |
+
ob_start();
|
689 |
+
$name = $this->get_person()->get_name();
|
690 |
+
$email = $this->get_person()->user_email;
|
691 |
+
$phone = ($this->get_person()->phone != __('Not Supplied','dbem')) ? $this->get_person()->phone:'';
|
692 |
+
if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'booking_modify_person' ){
|
693 |
+
$name = !empty($_REQUEST['user_name']) ? $_REQUEST['user_name']:$name;
|
694 |
+
$email = !empty($_REQUEST['user_email']) ? $_REQUEST['user_email']:$email;
|
695 |
+
$phone = !empty($_REQUEST['dbem_phone']) ? $_REQUEST['dbem_phone']:$phone;
|
696 |
+
}
|
697 |
+
?>
|
698 |
+
<table class="em-form-fields">
|
699 |
+
<tr><th><?php _e('Name','dbem'); ?> : </th><td><input type="text" name="user_name" value="<?php echo esc_attr($name); ?>" /></td></tr>
|
700 |
+
<tr><th><?php _e('Email','dbem'); ?> : </th><td><input type="text" name="user_email" value="<?php echo esc_attr($email); ?>" /></td></tr>
|
701 |
+
<tr><th><?php _e('Phone','dbem'); ?> : </th><td><input type="text" name="dbem_phone" value="<?php echo esc_attr($phone); ?>" /></td></tr>
|
702 |
+
</table>
|
703 |
+
<?php
|
704 |
+
return apply_filters('em_booking_get_person_editor', ob_get_clean(), $this);
|
705 |
+
}
|
706 |
+
|
707 |
+
/**
|
708 |
+
* Returns a string representation of the booking's status
|
709 |
+
* @return string
|
710 |
+
*/
|
711 |
+
function get_status(){
|
712 |
+
$status = ($this->booking_status == 0 && !get_option('dbem_bookings_approval') ) ? 1:$this->booking_status;
|
713 |
+
return apply_filters('em_booking_get_status', $this->status_array[$status], $this);
|
714 |
+
}
|
715 |
+
|
716 |
+
/**
|
717 |
+
* I wonder what this does....
|
718 |
+
* @return boolean
|
719 |
+
*/
|
720 |
+
function delete(){
|
721 |
+
global $wpdb;
|
722 |
+
$result = false;
|
723 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
724 |
+
$sql = $wpdb->prepare("DELETE FROM ". EM_BOOKINGS_TABLE . " WHERE booking_id=%d", $this->booking_id);
|
725 |
+
$result = $wpdb->query( $sql );
|
726 |
+
if( $result !== false ){
|
727 |
+
//delete the tickets too
|
728 |
+
$this->get_tickets_bookings()->delete();
|
729 |
+
$this->previous_status = $this->booking_status;
|
730 |
+
$this->booking_status = false;
|
731 |
+
$this->feedback_message = sprintf(__('%s deleted', 'dbem'), __('Booking','dbem'));
|
732 |
+
}else{
|
733 |
+
$this->add_error(sprintf(__('%s could not be deleted', 'dbem'), __('Booking','dbem')));
|
734 |
+
}
|
735 |
+
}
|
736 |
+
return apply_filters('em_booking_delete',( $result !== false ), $this);
|
737 |
+
}
|
738 |
+
|
739 |
+
function cancel($email = true){
|
740 |
+
if( $this->person->ID == get_current_user_id() ){
|
741 |
+
$this->manage_override = true; //normally, users can't manage a bookiing, only event owners, so we allow them to mod their booking status in this case only.
|
742 |
+
}
|
743 |
+
return $this->set_status(3, $email);
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Approve a booking.
|
748 |
+
* @return bool
|
749 |
+
*/
|
750 |
+
function approve($email = true, $ignore_spaces = false){
|
751 |
+
return $this->set_status(1, $email, $ignore_spaces);
|
752 |
+
}
|
753 |
+
/**
|
754 |
+
* Reject a booking and save
|
755 |
+
* @return bool
|
756 |
+
*/
|
757 |
+
function reject($email = true){
|
758 |
+
return $this->set_status(2, $email);
|
759 |
+
}
|
760 |
+
/**
|
761 |
+
* Unapprove a booking.
|
762 |
+
* @return bool
|
763 |
+
*/
|
764 |
+
function unapprove($email = true){
|
765 |
+
return $this->set_status(0, $email);
|
766 |
+
}
|
767 |
+
|
768 |
+
/**
|
769 |
+
* Change the status of the booking. This will save to the Database too.
|
770 |
+
* @param int $status
|
771 |
+
* @return boolean
|
772 |
+
*/
|
773 |
+
function set_status($status, $email = true, $ignore_spaces = false){
|
774 |
+
global $wpdb;
|
775 |
+
$action_string = strtolower($this->status_array[$status]);
|
776 |
+
//if we're approving we can't approve a booking if spaces are full, so check before it's approved.
|
777 |
+
if(!$ignore_spaces && $status == 1){
|
778 |
+
if( !$this->is_reserved() && $this->get_event()->get_bookings()->get_available_spaces() < $this->get_spaces() && !get_option('dbem_bookings_approval_overbooking') ){
|
779 |
+
$this->feedback_message = sprintf(__('Not approved, spaces full.','dbem'), $action_string);
|
780 |
+
$this->add_error($this->feedback_message);
|
781 |
+
return apply_filters('em_booking_set_status', false, $this);
|
782 |
+
}
|
783 |
+
}
|
784 |
+
$this->previous_status = $this->booking_status;
|
785 |
+
$this->booking_status = $status;
|
786 |
+
$result = $wpdb->query($wpdb->prepare('UPDATE '.EM_BOOKINGS_TABLE.' SET booking_status=%d WHERE booking_id=%d', array($status, $this->booking_id)));
|
787 |
+
if($result !== false){
|
788 |
+
$this->feedback_message = sprintf(__('Booking %s.','dbem'), $action_string);
|
789 |
+
if( $email ){
|
790 |
+
if( $this->email() && $this->mails_sent > 0 ){
|
791 |
+
$this->feedback_message .= " ".__('Email Sent.','dbem');
|
792 |
+
}elseif( $this->previous_status == 0 ){
|
793 |
+
//extra errors may be logged by email() in EM_Object
|
794 |
+
$this->feedback_message .= ' <span style="color:red">'.__('ERROR : Email Not Sent.','dbem').'</span>';
|
795 |
+
$this->add_error(__('ERROR : Email Not Sent.','dbem'));
|
796 |
+
}
|
797 |
+
}
|
798 |
+
}else{
|
799 |
+
//errors should be logged by save()
|
800 |
+
$this->feedback_message = sprintf(__('Booking could not be %s.','dbem'), $action_string);
|
801 |
+
$this->add_error(sprintf(__('Booking could not be %s.','dbem'), $action_string));
|
802 |
+
$result = false;
|
803 |
+
}
|
804 |
+
return apply_filters('em_booking_set_status', $result, $this);
|
805 |
+
}
|
806 |
+
|
807 |
+
function is_reserved(){
|
808 |
+
$result = false;
|
809 |
+
if( $this->booking_status == 0 && get_option('dbem_bookings_approval_reserved') ){
|
810 |
+
$result = true;
|
811 |
+
}elseif( $this->booking_status == 0 && !get_option('dbem_bookings_approval') ){
|
812 |
+
$result = true;
|
813 |
+
}elseif( $this->booking_status == 1 ){
|
814 |
+
$result = true;
|
815 |
+
}
|
816 |
+
return apply_filters('em_booking_is_reserved', $result, $this);
|
817 |
+
}
|
818 |
+
|
819 |
+
/**
|
820 |
+
* Add a booking note to this booking. returns wpdb result or false if use can't manage this event.
|
821 |
+
* @param string $note
|
822 |
+
* @return mixed
|
823 |
+
*/
|
824 |
+
function add_note( $note_text ){
|
825 |
+
global $wpdb;
|
826 |
+
if( $this->can_manage() ){
|
827 |
+
$this->get_notes();
|
828 |
+
$note = array('author'=>get_current_user_id(),'note'=>$note_text,'timestamp'=>current_time('timestamp'));
|
829 |
+
$this->notes[] = $note;
|
830 |
+
$this->feedback_message = __('Booking note successfully added.','dbem');
|
831 |
+
return $wpdb->insert(EM_META_TABLE, array('object_id'=>$this->booking_id, 'meta_key'=>'booking-note', 'meta_value'=> serialize($note)),array('%d','%s','%s'));
|
832 |
+
}
|
833 |
+
return false;
|
834 |
+
}
|
835 |
+
|
836 |
+
function get_admin_url(){
|
837 |
+
if( get_option('dbem_edit_bookings_page') && (!is_admin() || !empty($_REQUEST['is_public'])) ){
|
838 |
+
$my_bookings_page = get_permalink(get_option('dbem_edit_bookings_page'));
|
839 |
+
$bookings_link = em_add_get_params($my_bookings_page, array('event_id'=>$this->event_id, 'booking_id'=>'booking_id'), false);
|
840 |
+
}else{
|
841 |
+
if( $this->get_event()->blog_id != get_current_blog_id() ){
|
842 |
+
$bookings_link = get_admin_url($this->get_event()->blog_id, 'edit.php?post_type='.EM_POST_TYPE_EVENT."&page=events-manager-bookings&event_id=".$this->event_id."&booking_id=".$this->booking_id);
|
843 |
+
}else{
|
844 |
+
$bookings_link = EM_ADMIN_URL. "&page=events-manager-bookings&event_id=".$this->event_id."&booking_id=".$this->booking_id;
|
845 |
+
}
|
846 |
+
}
|
847 |
+
return apply_filters('em_booking_get_bookings_url', $bookings_link, $this);
|
848 |
+
}
|
849 |
+
|
850 |
+
function output($format, $target="html") {
|
851 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $format, $placeholders);
|
852 |
+
foreach( $this->get_tickets() as $EM_Ticket){ /* @var $EM_Ticket EM_Ticket */ break; } //Get first ticket for single ticket placeholders
|
853 |
+
$output_string = $format;
|
854 |
+
$replaces = array();
|
855 |
+
foreach($placeholders[1] as $key => $result) {
|
856 |
+
$replace = '';
|
857 |
+
$full_result = $placeholders[0][$key];
|
858 |
+
switch( $result ){
|
859 |
+
case '#_BOOKINGID':
|
860 |
+
$replace = $this->booking_id;
|
861 |
+
break;
|
862 |
+
case '#_RESPNAME' : //Depreciated
|
863 |
+
case '#_BOOKINGNAME':
|
864 |
+
$replace = $this->get_person()->get_name();
|
865 |
+
break;
|
866 |
+
case '#_RESPEMAIL' : //Depreciated
|
867 |
+
case '#_BOOKINGEMAIL':
|
868 |
+
$replace = $this->get_person()->user_email;
|
869 |
+
break;
|
870 |
+
case '#_RESPPHONE' : //Depreciated
|
871 |
+
case '#_BOOKINGPHONE':
|
872 |
+
$replace = $this->get_person()->phone;
|
873 |
+
break;
|
874 |
+
case '#_BOOKINGSPACES':
|
875 |
+
$replace = $this->get_spaces();
|
876 |
+
break;
|
877 |
+
case '#_BOOKINGDATE':
|
878 |
+
$replace = ( $this->timestamp ) ? date_i18n(get_option('dbem_date_format'), $this->timestamp):'n/a';
|
879 |
+
break;
|
880 |
+
case '#_BOOKINGTIME':
|
881 |
+
$replace = ( $this->timestamp ) ? date_i18n(get_option('dbem_time_format'), $this->timestamp):'n/a';
|
882 |
+
break;
|
883 |
+
case '#_BOOKINGDATETIME':
|
884 |
+
$replace = ( $this->timestamp ) ? date_i18n(get_option('dbem_date_format').' '.get_option('dbem_time_format'), $this->timestamp):'n/a';
|
885 |
+
break;
|
886 |
+
case '#_BOOKINGLISTURL':
|
887 |
+
$replace = em_get_my_bookings_url();
|
888 |
+
break;
|
889 |
+
case '#_COMMENT' : //Depreciated
|
890 |
+
case '#_BOOKINGCOMMENT':
|
891 |
+
$replace = $this->booking_comment;
|
892 |
+
break;
|
893 |
+
$replace = $this->get_price(true); //if there's tax, it'll be added here
|
894 |
+
break;
|
895 |
+
case '#_BOOKINGPRICEWITHOUTTAX':
|
896 |
+
$replace = $this->format_price($this->get_price() - $this->get_price_taxes());
|
897 |
+
break;
|
898 |
+
case '#_BOOKINGPRICETAX':
|
899 |
+
$replace = $this->get_price_taxes(true);
|
900 |
+
break;
|
901 |
+
case '#_BOOKINGPRICEWITHTAX':
|
902 |
+
case '#_BOOKINGPRICE':
|
903 |
+
$replace = $this->get_price(true);
|
904 |
+
break;
|
905 |
+
case '#_BOOKINGTICKETNAME':
|
906 |
+
$replace = $EM_Ticket->name;
|
907 |
+
break;
|
908 |
+
case '#_BOOKINGTICKETDESCRIPTION':
|
909 |
+
$replace = $EM_Ticket->description;
|
910 |
+
break;
|
911 |
+
case '#_BOOKINGTICKETPRICEWITHTAX':
|
912 |
+
$replace = $this->format_price( $EM_Ticket->get_price_without_tax() * (1+$this->get_tax_rate()/100) );
|
913 |
+
break;
|
914 |
+
case '#_BOOKINGTICKETPRICEWITHOUTTAX':
|
915 |
+
$replace = $EM_Ticket->get_price_without_tax(true);
|
916 |
+
break;
|
917 |
+
case '#_BOOKINGTICKETTAX':
|
918 |
+
$replace = $this->format_price( $EM_Ticket->get_price_without_tax() * ($this->get_tax_rate()/100) );
|
919 |
+
break;
|
920 |
+
case '#_BOOKINGTICKETPRICE':
|
921 |
+
$replace = $EM_Ticket->get_price(true);
|
922 |
+
break;
|
923 |
+
case '#_BOOKINGTICKETS':
|
924 |
+
ob_start();
|
925 |
+
em_locate_template('emails/bookingtickets.php', true, array('EM_Booking'=>$this));
|
926 |
+
$replace = ob_get_clean();
|
927 |
+
break;
|
928 |
+
case '#_BOOKINGSUMMARY':
|
929 |
+
ob_start();
|
930 |
+
em_locate_template('emails/bookingsummary.php', true, array('EM_Booking'=>$this));
|
931 |
+
$replace = ob_get_clean();
|
932 |
+
break;
|
933 |
+
default:
|
934 |
+
$replace = $full_result;
|
935 |
+
break;
|
936 |
+
}
|
937 |
+
$replaces[$full_result] = apply_filters('em_booking_output_placeholder', $replace, $this, $full_result, $target);
|
938 |
+
}
|
939 |
+
//sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
|
940 |
+
krsort($replaces);
|
941 |
+
foreach($replaces as $full_result => $replacement){
|
942 |
+
$output_string = str_replace($full_result, $replacement , $output_string );
|
943 |
+
}
|
944 |
+
//run event output too, since this is never run from within events and will not infinitely loop
|
945 |
+
$output_string = $this->get_event()->output($output_string, $target);
|
946 |
+
return apply_filters('em_booking_output', $output_string, $this, $format, $target);
|
947 |
+
}
|
948 |
+
|
949 |
+
/**
|
950 |
+
* @param EM_Booking $EM_Booking
|
951 |
+
* @param EM_Event $event
|
952 |
+
* @return boolean
|
953 |
+
*/
|
954 |
+
function email( $email_admin = true, $force_resend = false, $email_attendee = true ){
|
955 |
+
global $EM_Mailer;
|
956 |
+
$result = true;
|
957 |
+
$this->mails_sent = 0;
|
958 |
+
|
959 |
+
//FIXME ticket logic needed
|
960 |
+
$EM_Event = $this->get_event(); //We NEED event details here.
|
961 |
+
$EM_Event->get_bookings(true); //refresh all bookings
|
962 |
+
|
963 |
+
//Make sure event matches booking, and that booking used to be approved.
|
964 |
+
if( $this->booking_status !== $this->previous_status || $force_resend ){
|
965 |
+
//messages can be overriden just before being sent
|
966 |
+
$msg = $this->email_messages();
|
967 |
+
$output_type = get_option('dbem_smtp_html') ? 'html':'email';
|
968 |
+
|
969 |
+
//Send user (booker) emails
|
970 |
+
if( !empty($msg['user']['subject']) && $email_attendee ){
|
971 |
+
$msg['user']['subject'] = $this->output($msg['user']['subject'], 'raw');
|
972 |
+
$msg['user']['body'] = $this->output($msg['user']['body'], $output_type);
|
973 |
+
//Send to the person booking
|
974 |
+
if( !$this->email_send( $msg['user']['subject'], $msg['user']['body'], $this->get_person()->user_email) ){
|
975 |
+
$result = false;
|
976 |
+
}else{
|
977 |
+
$this->mails_sent++;
|
978 |
+
}
|
979 |
+
}
|
980 |
+
|
981 |
+
//Send admin/contact emails if this isn't the event owner or an events admin
|
982 |
+
if( $email_admin && !empty($msg['admin']['subject']) && (!$this->can_manage() || (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'booking_add') || $this->manage_override) ){ //emails won't be sent if admin is logged in unless they book themselves
|
983 |
+
if( get_option('dbem_bookings_contact_email') == 1 || get_option('dbem_bookings_notify_admin') ){
|
984 |
+
//Only gets sent if this is a pending booking, unless approvals are disabled.
|
985 |
+
$msg['admin']['subject'] = $this->output($msg['admin']['subject'],'raw');
|
986 |
+
$msg['admin']['body'] = $this->output($msg['admin']['body'], $output_type);
|
987 |
+
//email contact
|
988 |
+
if( get_option('dbem_bookings_contact_email') == 1 ){
|
989 |
+
if( !$this->email_send( $msg['admin']['subject'], $msg['admin']['body'], $EM_Event->get_contact()->user_email) && current_user_can('list_users')){
|
990 |
+
$this->errors[] = __('Confirmation email could not be sent to contact person. Registrant should have gotten their email (only admin see this warning).','dbem');
|
991 |
+
$result = false;
|
992 |
+
}else{
|
993 |
+
$this->mails_sent++;
|
994 |
+
}
|
995 |
+
}
|
996 |
+
//email admin
|
997 |
+
if( get_option('dbem_bookings_notify_admin') != '' && preg_match('/^([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3},?)+$/', str_replace(' ', '', get_option('dbem_bookings_notify_admin'))) ){
|
998 |
+
$admin_emails = get_option('dbem_bookings_notify_admin');
|
999 |
+
$admin_emails = apply_filters('em_booking_admin_emails', explode(',', $admin_emails), $this); //supply emails as array
|
1000 |
+
foreach($admin_emails as $key => $email){ $admin_emails[$key] = trim($email); } //strip whitespace
|
1001 |
+
if( !$this->email_send( $msg['admin']['subject'], $msg['admin']['body'], $admin_emails) ){
|
1002 |
+
$this->errors[] = __('Confirmation email could not be sent to admin. Registrant should have gotten their email (only admin see this warning).','dbem');
|
1003 |
+
$result = false;
|
1004 |
+
}else{
|
1005 |
+
$this->mails_sent++;
|
1006 |
+
}
|
1007 |
+
}
|
1008 |
+
}
|
1009 |
+
}
|
1010 |
+
}
|
1011 |
+
return $result;
|
1012 |
+
//TODO need error checking for booking mail send
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
function email_messages(){
|
1016 |
+
$msg = array( 'user'=> array('subject'=>'', 'body'=>''), 'admin'=> array('subject'=>'', 'body'=>'')); //blank msg template
|
1017 |
+
//admin messages won't change whether pending or already approved
|
1018 |
+
switch( $this->booking_status ){
|
1019 |
+
case 0:
|
1020 |
+
case 5: //TODO remove offline status from here and move to pro
|
1021 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_pending_subject');
|
1022 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_pending_body');
|
1023 |
+
//admins should get something (if set to)
|
1024 |
+
$msg['admin']['subject'] = get_option('dbem_bookings_contact_email_subject');
|
1025 |
+
$msg['admin']['body'] = get_option('dbem_bookings_contact_email_body');
|
1026 |
+
break;
|
1027 |
+
case 1:
|
1028 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_confirmed_subject');
|
1029 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_confirmed_body');
|
1030 |
+
//admins should get something (if set to)
|
1031 |
+
$msg['admin']['subject'] = get_option('dbem_bookings_contact_email_subject');
|
1032 |
+
$msg['admin']['body'] = get_option('dbem_bookings_contact_email_body');
|
1033 |
+
break;
|
1034 |
+
case 2:
|
1035 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_rejected_subject');
|
1036 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_rejected_body');
|
1037 |
+
break;
|
1038 |
+
case 3:
|
1039 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_cancelled_subject');
|
1040 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_cancelled_body');
|
1041 |
+
//admins should get something (if set to)
|
1042 |
+
$msg['admin']['subject'] = get_option('dbem_contactperson_email_cancelled_subject');
|
1043 |
+
$msg['admin']['body'] = get_option('dbem_contactperson_email_cancelled_body');
|
1044 |
+
break;
|
1045 |
+
}
|
1046 |
+
return apply_filters('em_booking_email_messages', $msg, $this);
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
/**
|
1050 |
+
* Can the user manage this event?
|
1051 |
+
*/
|
1052 |
+
function can_manage(){
|
1053 |
+
return $this->get_event()->can_manage('manage_bookings','manage_others_bookings') || empty($this->booking_id) || !empty($this->manage_override);
|
1054 |
+
}
|
1055 |
+
|
1056 |
+
/**
|
1057 |
+
* Returns this object in the form of an array
|
1058 |
+
* @return array
|
1059 |
+
*/
|
1060 |
+
function to_array($person = false){
|
1061 |
+
$booking = array();
|
1062 |
+
//Core Data
|
1063 |
+
$booking = parent::to_array();
|
1064 |
+
//Person Data
|
1065 |
+
if($person && is_object($this->person)){
|
1066 |
+
$person = $this->person->to_array();
|
1067 |
+
$booking = array_merge($booking, $person);
|
1068 |
+
}
|
1069 |
+
return $booking;
|
1070 |
+
}
|
1071 |
+
}
|
1072 |
Â
?>
|
classes/em-bookings-table.php
ADDED
@@ -0,0 +1,647 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
//Builds a table of bookings, still work in progress...
|
3 |
+
class EM_Bookings_Table{
|
4 |
+
/**
|
5 |
+
* associative array of collumns that'll be shown in order from left to right
|
6 |
+
*
|
7 |
+
* * key - collumn name in the databse, what will be used when searching
|
8 |
+
* * value - label for use in collumn headers
|
9 |
+
* @var array
|
10 |
+
*/
|
11 |
+
public $cols = array('user_name','event_name','booking_spaces','booking_status','booking_price','actions');
|
12 |
+
/**
|
13 |
+
* Asoociative array of available collumn keys and corresponding headers, which will be used to display this table of bookings
|
14 |
+
* @var unknown_type
|
15 |
+
*/
|
16 |
+
public $cols_template = array();
|
17 |
+
public $sortable_cols = array('booking_date');
|
18 |
+
/**
|
19 |
+
* Object we're viewing bookings in relation to.
|
20 |
+
* @var object
|
21 |
+
*/
|
22 |
+
public $cols_view;
|
23 |
+
/**
|
24 |
+
* Index key used for looking up status information we're filtering in the booking table
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
public $string = 'needs-attention';
|
28 |
+
/**
|
29 |
+
* Associative array of status information.
|
30 |
+
*
|
31 |
+
* * key - status index value
|
32 |
+
* * value - associative array containing keys
|
33 |
+
* ** label - the label for use in filter forms
|
34 |
+
* ** search - array or integer status numbers to search
|
35 |
+
*
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
public $statuses = array();
|
39 |
+
/**
|
40 |
+
* Maximum number of rows to show
|
41 |
+
* @var int
|
42 |
+
*/
|
43 |
+
public $limit = 20;
|
44 |
+
public $order = 'ASC';
|
45 |
+
public $orderby = 'booking_name';
|
46 |
+
public $page = 1;
|
47 |
+
public $offset = 0;
|
48 |
+
public $scope = 'future';
|
49 |
+
public $show_tickets = false;
|
50 |
+
|
51 |
+
function __construct($show_tickets = false){
|
52 |
+
$this->statuses = array(
|
53 |
+
'all' => array('label'=>__('All','dbem'), 'search'=>false),
|
54 |
+
'pending' => array('label'=>__('Pending','dbem'), 'search'=>0),
|
55 |
+
'confirmed' => array('label'=>__('Confirmed','dbem'), 'search'=>1),
|
56 |
+
'cancelled' => array('label'=>__('Cancelled','dbem'), 'search'=>3),
|
57 |
+
'rejected' => array('label'=>__('Rejected','dbem'), 'search'=>2),
|
58 |
+
'needs-attention' => array('label'=>__('Needs Attention','dbem'), 'search'=>array(0)),
|
59 |
+
'incomplete' => array('label'=>__('Incomplete Bookings','dbem'), 'search'=>array(0))
|
60 |
+
);
|
61 |
+
if( !get_option('dbem_bookings_approval') ){
|
62 |
+
unset($this->statuses['pending']);
|
63 |
+
unset($this->statuses['incomplete']);
|
64 |
+
$this->statuses['confirmed']['search'] = array(0,1);
|
65 |
+
}
|
66 |
+
//Set basic vars
|
67 |
+
$this->order = ( !empty($_REQUEST ['order']) ) ? $_REQUEST ['order']:'ASC';
|
68 |
+
$this->orderby = ( !empty($_REQUEST ['order']) ) ? $_REQUEST ['order']:'booking_name';
|
69 |
+
$this->limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
|
70 |
+
$this->page = ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:1;
|
71 |
+
$this->offset = ( $this->page > 1 ) ? ($this->page-1)*$this->limit : 0;
|
72 |
+
$this->scope = ( !empty($_REQUEST['scope']) && array_key_exists($_REQUEST ['scope'], em_get_scopes()) ) ? $_REQUEST ['scope']:get_option('dbem_default_bookings_search','future');
|
73 |
+
$this->status = ( !empty($_REQUEST['status']) && array_key_exists($_REQUEST['status'], $this->statuses) ) ? $_REQUEST['status']:get_option('dbem_default_bookings_search','needs-attention');
|
74 |
+
//build template of possible collumns
|
75 |
+
$this->cols_template = apply_filters('em_bookings_table_cols_template', array(
|
76 |
+
'user_name'=>__('Name','dbem'),
|
77 |
+
'first_name'=>__('First Name','dbem'),
|
78 |
+
'last_name'=>__('Last Name','dbem'),
|
79 |
+
'event_name'=>__('Event','dbem'),
|
80 |
+
'event_date'=>__('Event Date(s)','dbem'),
|
81 |
+
'event_time'=>__('Event Time(s)','dbem'),
|
82 |
+
'user_email'=>__('E-mail','dbem'),
|
83 |
+
'dbem_phone'=>__('Phone Number','dbem'),
|
84 |
+
'booking_spaces'=>__('Spaces','dbem'),
|
85 |
+
'booking_status'=>__('Status','dbem'),
|
86 |
+
'booking_date'=>__('Booking Date','dbem'),
|
87 |
+
'booking_price'=>__('Total','dbem'),
|
88 |
+
'booking_id'=>__('Booking ID','dbem'),
|
89 |
+
'booking_comment'=>__('Booking Comment','dbem')
|
90 |
+
), $this);
|
91 |
+
$this->cols_tickets_template = apply_filters('em_bookings_table_cols_tickets_template', array(
|
92 |
+
'ticket_name'=>__('Ticket Name','dbem'),
|
93 |
+
'ticket_description'=>__('Ticket Description','dbem'),
|
94 |
+
'ticket_price'=>__('Ticket Price','dbem'),
|
95 |
+
'ticket_id'=>__('Ticket ID','dbem')
|
96 |
+
), $this);
|
97 |
+
//add tickets to template if we're showing rows by booking-ticket
|
98 |
+
if( $show_tickets ){
|
99 |
+
$this->show_tickets = true;
|
100 |
+
$this->cols = array('user_name','event_name','ticket_name','ticket_price','booking_spaces','booking_status','actions');
|
101 |
+
$this->cols_template = array_merge( $this->cols_template, $this->cols_tickets_template);
|
102 |
+
}
|
103 |
+
$this->cols_template['actions'] = __('Actions','dbem');
|
104 |
+
//calculate collumns if post requests
|
105 |
+
if( !empty($_REQUEST ['cols']) && !is_array($_REQUEST ['cols']) ){
|
106 |
+
$this->cols = explode(',',$_REQUEST['cols']);
|
107 |
+
}elseif( !empty($_REQUEST ['cols']) ){
|
108 |
+
$this->cols = $_REQUEST['cols'];
|
109 |
+
}
|
110 |
+
//load collumn view settings
|
111 |
+
if( $this->get_person() !== false ){
|
112 |
+
$this->cols_view = $this->get_person();
|
113 |
+
}elseif( $this->get_ticket() !== false ){
|
114 |
+
$this->cols_view = $this->get_ticket();
|
115 |
+
}elseif( $this->get_event() !== false ){
|
116 |
+
$this->cols_view = $this->get_event();
|
117 |
+
}
|
118 |
+
foreach($this->cols as $col_key){
|
119 |
+
if( !array_key_exists($col_key, $this->cols_template)){
|
120 |
+
unset($this->cols[$col_key]);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
//save collumns depending on context and user preferences
|
124 |
+
if( empty($_REQUEST['cols']) ){
|
125 |
+
if(!empty($this->cols_view) && is_object($this->cols_view)){
|
126 |
+
//check if user has settings for object type
|
127 |
+
$settings = get_user_meta(get_current_user_id(), 'em_bookings_view-'.get_class($this->cols_view), true );
|
128 |
+
}else{
|
129 |
+
$settings = get_user_meta(get_current_user_id(), 'em_bookings_view', true );
|
130 |
+
}
|
131 |
+
if( !empty($settings) ){
|
132 |
+
$this->cols = $settings;
|
133 |
+
}
|
134 |
+
}elseif( !empty($_REQUEST['cols']) && empty($_REQUEST['no_save']) ){ //save view settings for next time
|
135 |
+
if( !empty($this->cols_view) && is_object($this->cols_view) ){
|
136 |
+
update_user_meta(get_current_user_id(), 'em_bookings_view-'.get_class($this->cols_view), $this->cols );
|
137 |
+
}else{
|
138 |
+
update_user_meta(get_current_user_id(), 'em_bookings_view', $this->cols );
|
139 |
+
}
|
140 |
+
}
|
141 |
+
do_action('em_bookings_table', $this);
|
142 |
+
}
|
143 |
+
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @return EM_Person|false
|
147 |
+
*/
|
148 |
+
function get_person(){
|
149 |
+
global $EM_Person;
|
150 |
+
if( !empty($this->person) && is_object($this->person) ){
|
151 |
+
return $this->person;
|
152 |
+
}elseif( !empty($_REQUEST['person_id']) && !empty($EM_Person) && is_object($EM_Person) ){
|
153 |
+
return $EM_Person;
|
154 |
+
}
|
155 |
+
return false;
|
156 |
+
}
|
157 |
+
/**
|
158 |
+
* @return EM_Ticket|false
|
159 |
+
*/
|
160 |
+
function get_ticket(){
|
161 |
+
global $EM_Ticket;
|
162 |
+
if( !empty($this->ticket) && is_object($this->ticket) ){
|
163 |
+
return $this->ticket;
|
164 |
+
}elseif( !empty($EM_Ticket) && is_object($EM_Ticket) ){
|
165 |
+
return $EM_Ticket;
|
166 |
+
}
|
167 |
+
return false;
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* @return $EM_Event|false
|
171 |
+
*/
|
172 |
+
function get_event(){
|
173 |
+
global $EM_Event;
|
174 |
+
if( !empty($this->event) && is_object($this->event) ){
|
175 |
+
return $this->event;
|
176 |
+
}elseif( !empty($EM_Event) && is_object($EM_Event) ){
|
177 |
+
return $EM_Event;
|
178 |
+
}
|
179 |
+
return false;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Gets the bookings for this object instance according to its settings
|
184 |
+
* @param boolean $force_refresh
|
185 |
+
* @return EM_Bookings
|
186 |
+
*/
|
187 |
+
function get_bookings($force_refresh = true){
|
188 |
+
if( empty($this->bookings) || $force_refresh ){
|
189 |
+
$this->events = array();
|
190 |
+
$EM_Ticket = $this->get_ticket();
|
191 |
+
$EM_Event = $this->get_event();
|
192 |
+
$EM_Person = $this->get_person();
|
193 |
+
if( $EM_Person !== false ){
|
194 |
+
$args = array('person'=>$EM_Person->ID,'scope'=>$this->scope,'status'=>$this->get_status_search(),'order'=>$this->order,'orderby'=>$this->orderby);
|
195 |
+
$this->bookings_count = EM_Bookings::count($args);
|
196 |
+
$this->bookings = EM_Bookings::get(array_merge($args, array('limit'=>$this->limit,'offset'=>$this->offset)));
|
197 |
+
foreach($this->bookings->bookings as $EM_Booking){
|
198 |
+
//create event
|
199 |
+
if( !array_key_exists($EM_Booking->event_id,$this->events) ){
|
200 |
+
$this->events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}elseif( $EM_Ticket !== false ){
|
204 |
+
//searching bookings with a specific ticket
|
205 |
+
$args = array('ticket_id'=>$EM_Ticket->ticket_id, 'order'=>$this->order,'orderby'=>$this->orderby);
|
206 |
+
$this->bookings_count = EM_Bookings::count($args);
|
207 |
+
$this->bookings = EM_Bookings::get(array_merge($args, array('limit'=>$this->limit,'offset'=>$this->offset)));
|
208 |
+
$this->events[$EM_Ticket->event_id] = $EM_Ticket->get_event();
|
209 |
+
}elseif( $EM_Event !== false ){
|
210 |
+
//bookings for an event
|
211 |
+
$args = array('event'=>$EM_Event->event_id,'scope'=>false,'status'=>$this->get_status_search(),'order'=>$this->order,'orderby'=>$this->orderby);
|
212 |
+
$args['owner'] = !current_user_can('manage_others_bookings') ? get_current_user_id() : false;
|
213 |
+
$this->bookings_count = EM_Bookings::count($args);
|
214 |
+
$this->bookings = EM_Bookings::get(array_merge($args, array('limit'=>$this->limit,'offset'=>$this->offset)));
|
215 |
+
$this->events[$EM_Event->event_id] = $EM_Event;
|
216 |
+
}else{
|
217 |
+
//all bookings for a status
|
218 |
+
$args = array('status'=>$this->get_status_search(),'scope'=>$this->scope,'order'=>$this->order,'orderby'=>$this->orderby);
|
219 |
+
$args['owner'] = !current_user_can('manage_others_bookings') ? get_current_user_id() : false;
|
220 |
+
$this->bookings_count = EM_Bookings::count($args);
|
221 |
+
$this->bookings = EM_Bookings::get(array_merge($args, array('limit'=>$this->limit,'offset'=>$this->offset)));
|
222 |
+
//Now let's create events and bookings for this instead of giving each booking an event
|
223 |
+
foreach($this->bookings->bookings as $EM_Booking){
|
224 |
+
//create event
|
225 |
+
if( !array_key_exists($EM_Booking->event_id,$this->events) ){
|
226 |
+
$this->events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
return $this->bookings;
|
232 |
+
}
|
233 |
+
|
234 |
+
function get_count(){
|
235 |
+
return $this->bookings_count;
|
236 |
+
}
|
237 |
+
|
238 |
+
function get_status_search(){
|
239 |
+
if(is_array($this->statuses[$this->status]['search'])){
|
240 |
+
return implode(',',$this->statuses[$this->status]['search']);
|
241 |
+
}
|
242 |
+
return $this->statuses[$this->status]['search'];
|
243 |
+
}
|
244 |
+
|
245 |
+
function output(){
|
246 |
+
do_action('em_bookings_table_header',$this); //won't be overwritten by JS
|
247 |
+
$this->output_overlays();
|
248 |
+
$this->output_table();
|
249 |
+
do_action('em_bookings_table_footer',$this); //won't be overwritten by JS
|
250 |
+
}
|
251 |
+
|
252 |
+
function output_overlays(){
|
253 |
+
$EM_Ticket = $this->get_ticket();
|
254 |
+
$EM_Event = $this->get_event();
|
255 |
+
$EM_Person = $this->get_person();
|
256 |
+
?>
|
257 |
+
<div id="em-bookings-table-settings" class="em-bookings-table-overlay" style="display:none;" title="<?php _e('Bookings Table Settings','dbem'); ?>">
|
258 |
+
<form id="em-bookings-table-settings-form" class="em-bookings-table-form" action="" method="post">
|
259 |
+
<p><?php _e('Modify what information is displayed in this booking table.','dbem') ?></p>
|
260 |
+
<div id="em-bookings-table-settings-form-cols">
|
261 |
+
<p>
|
262 |
+
<strong><?php _e('Columns to show','dbem')?></strong><br />
|
263 |
+
<?php _e('Drag items to or from the left column to add or remove them.','dbem'); ?>
|
264 |
+
</p>
|
265 |
+
<ul id="em-bookings-cols-active" class="em-bookings-cols-sortable">
|
266 |
+
<?php foreach( $this->cols as $col_key ): ?>
|
267 |
+
<li class="ui-state-highlight">
|
268 |
+
<input id="em-bookings-col-<?php echo $col_key; ?>" type="hidden" name="<?php echo $col_key; ?>" value="1" class="em-bookings-col-item" />
|
269 |
+
<?php echo $this->cols_template[$col_key]; ?>
|
270 |
+
</li>
|
271 |
+
<?php endforeach; ?>
|
272 |
+
</ul>
|
273 |
+
<ul id="em-bookings-cols-inactive" class="em-bookings-cols-sortable">
|
274 |
+
<?php foreach( $this->cols_template as $col_key => $col_data ): ?>
|
275 |
+
<?php if( !in_array($col_key, $this->cols) ): ?>
|
276 |
+
<li class="ui-state-default">
|
277 |
+
<input id="em-bookings-col-<?php echo $col_key; ?>" type="hidden" name="<?php echo $col_key; ?>" value="0" class="em-bookings-col-item" />
|
278 |
+
<?php echo $col_data; ?>
|
279 |
+
</li>
|
280 |
+
<?php endif; ?>
|
281 |
+
<?php endforeach; ?>
|
282 |
+
</ul>
|
283 |
+
</div>
|
284 |
+
</form>
|
285 |
+
</div>
|
286 |
+
<div id="em-bookings-table-export" class="em-bookings-table-overlay" style="display:none;" title="<?php _e('Export Bookings','dbem'); ?>">
|
287 |
+
<form id="em-bookings-table-export-form" class="em-bookings-table-form" action="" method="post">
|
288 |
+
<p><?php _e('Select the options below and export all the bookings you have currently filtered (all pages) into a CSV spreadsheet format.','dbem') ?></p>
|
289 |
+
<?php if( !get_option('dbem_bookings_tickets_single') ): //single ticket mode means no splitting by ticket type ?>
|
290 |
+
<p><?php _e('Split bookings by ticket type','dbem')?> <input type="checkbox" name="show_tickets" value="1" />
|
291 |
+
<a href="#" title="<?php _e('If your events have multiple tickets, enabling this will show a seperate row for each ticket within a booking.','dbem'); ?>">?</a>
|
292 |
+
<?php endif; ?>
|
293 |
+
<?php do_action('em_bookings_table_export_options'); ?>
|
294 |
+
<div id="em-bookings-table-settings-form-cols">
|
295 |
+
<p><strong><?php _e('Columns to export','dbem')?></strong></p>
|
296 |
+
<ul id="em-bookings-export-cols-active" class="em-bookings-cols-sortable">
|
297 |
+
<?php foreach( $this->cols as $col_key ): ?>
|
298 |
+
<li class="ui-state-highlight">
|
299 |
+
<input id="em-bookings-col-<?php echo $col_key; ?>" type="hidden" name="cols[<?php echo $col_key; ?>]" value="1" class="em-bookings-col-item" />
|
300 |
+
<?php echo $this->cols_template[$col_key]; ?>
|
301 |
+
</li>
|
302 |
+
<?php endforeach; ?>
|
303 |
+
</ul>
|
304 |
+
<ul id="em-bookings-export-cols-inactive" class="em-bookings-cols-sortable">
|
305 |
+
<?php foreach( $this->cols_template as $col_key => $col_data ): ?>
|
306 |
+
<?php if( !in_array($col_key, $this->cols) ): ?>
|
307 |
+
<li class="ui-state-default">
|
308 |
+
<input id="em-bookings-col-<?php echo $col_key; ?>" type="hidden" name="cols[<?php echo $col_key; ?>]" value="0" class="em-bookings-col-item" />
|
309 |
+
<?php echo $col_data; ?>
|
310 |
+
</li>
|
311 |
+
<?php endif; ?>
|
312 |
+
<?php endforeach; ?>
|
313 |
+
<?php if( !$this->show_tickets ): ?>
|
314 |
+
<?php foreach( $this->cols_tickets_template as $col_key => $col_data ): ?>
|
315 |
+
<?php if( !in_array($col_key, $this->cols) ): ?>
|
316 |
+
<li class="ui-state-default <?php if(array_key_exists($col_key, $this->cols_tickets_template)) echo 'em-bookings-col-item-ticket'; ?>">
|
317 |
+
<input id="em-bookings-col-<?php echo $col_key; ?>" type="hidden" name="cols[<?php echo $col_key; ?>]" value="0" class="em-bookings-col-item" />
|
318 |
+
<?php echo $col_data; ?>
|
319 |
+
</li>
|
320 |
+
<?php endif; ?>
|
321 |
+
<?php endforeach; ?>
|
322 |
+
<?php endif; ?>
|
323 |
+
</ul>
|
324 |
+
</div>
|
325 |
+
<?php if( $EM_Event !== false ): ?>
|
326 |
+
<input type="hidden" name="event_id" value='<?php echo $EM_Event->event_id; ?>' />
|
327 |
+
<?php endif; ?>
|
328 |
+
<?php if( $EM_Ticket !== false ): ?>
|
329 |
+
<input type="hidden" name="ticket_id" value='<?php echo $EM_Ticket->ticket_id; ?>' />
|
330 |
+
<?php endif; ?>
|
331 |
+
<?php if( $EM_Person !== false ): ?>
|
332 |
+
<input type="hidden" name="person_id" value='<?php echo $EM_Person->ID; ?>' />
|
333 |
+
<?php endif; ?>
|
334 |
+
<input type="hidden" name="scope" value='<?php echo $this->scope ?>' />
|
335 |
+
<input type="hidden" name="status" value='<?php echo $this->status ?>' />
|
336 |
+
<input type="hidden" name="no_save" value='1' />
|
337 |
+
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('export_bookings_csv'); ?>" />
|
338 |
+
<input type="hidden" name="action" value="export_bookings_csv" />
|
339 |
+
</form>
|
340 |
+
</div>
|
341 |
+
<br class="clear" />
|
342 |
+
<?php
|
343 |
+
}
|
344 |
+
|
345 |
+
function output_table(){
|
346 |
+
$EM_Ticket = $this->get_ticket();
|
347 |
+
$EM_Event = $this->get_event();
|
348 |
+
$EM_Person = $this->get_person();
|
349 |
+
$this->get_bookings(true); //get bookings and refresh
|
350 |
+
?>
|
351 |
+
<div class='em-bookings-table em_obj' id="em-bookings-table">
|
352 |
+
<form class='bookings-filter' method='post' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
|
353 |
+
<?php if( $EM_Event !== false ): ?>
|
354 |
+
<input type="hidden" name="event_id" value='<?php echo $EM_Event->event_id; ?>' />
|
355 |
+
<?php endif; ?>
|
356 |
+
<?php if( $EM_Ticket !== false ): ?>
|
357 |
+
<input type="hidden" name="ticket_id" value='<?php echo $EM_Ticket->ticket_id; ?>' />
|
358 |
+
<?php endif; ?>
|
359 |
+
<?php if( $EM_Person !== false ): ?>
|
360 |
+
<input type="hidden" name="person_id" value='<?php echo $EM_Person->ID; ?>' />
|
361 |
+
<?php endif; ?>
|
362 |
+
<input type="hidden" name="is_public" value="<?php echo ( !empty($_REQUEST['is_public']) || !is_admin() ) ? 1:0; ?>" />
|
363 |
+
<input type="hidden" name="pno" value='<?php echo $this->page ?>' />
|
364 |
+
<input type="hidden" name="order" value='<?php echo $this->order ?>' />
|
365 |
+
<input type="hidden" name="orderby" value='<?php echo $this->orderby ?>' />
|
366 |
+
<input type="hidden" name="_wpnonce" value="<?php echo ( !empty($_REQUEST['_wpnonce']) ) ? esc_attr($_REQUEST['_wpnonce']):wp_create_nonce('em_bookings_table'); ?>" />
|
367 |
+
<input type="hidden" name="action" value="em_bookings_table" />
|
368 |
+
<input type="hidden" name="cols" value="<?php echo implode(',', $this->cols); ?>" />
|
369 |
+
|
370 |
+
<div class='tablenav'>
|
371 |
+
<div class="alignleft actions">
|
372 |
+
<a href="#" class="em-bookings-table-export" id="em-bookings-table-export-trigger" rel="#em-bookings-table-export" title="<?php _e('Export these bookings.','dbem'); ?>"></a>
|
373 |
+
<a href="#" class="em-bookings-table-settings" id="em-bookings-table-settings-trigger" rel="#em-bookings-table-settings"></a>
|
374 |
+
<?php if( $EM_Event === false ): ?>
|
375 |
+
<select name="scope">
|
376 |
+
<?php
|
377 |
+
foreach ( em_get_scopes() as $key => $value ) {
|
378 |
+
$selected = "";
|
379 |
+
if ($key == $this->scope)
|
380 |
+
$selected = "selected='selected'";
|
381 |
+
echo "<option value='$key' $selected>$value</option> ";
|
382 |
+
}
|
383 |
+
?>
|
384 |
+
</select>
|
385 |
+
<?php endif; ?>
|
386 |
+
<select name="limit">
|
387 |
+
<option value="<?php echo $this->limit ?>"><?php echo sprintf(__('%s Rows','dbem'),$this->limit); ?></option>
|
388 |
+
<option value="5">5</option>
|
389 |
+
<option value="10">10</option>
|
390 |
+
<option value="25">25</option>
|
391 |
+
<option value="50">50</option>
|
392 |
+
<option value="100">100</option>
|
393 |
+
</select>
|
394 |
+
<select name="status">
|
395 |
+
<?php
|
396 |
+
foreach ( $this->statuses as $key => $value ) {
|
397 |
+
$selected = "";
|
398 |
+
if ($key == $this->status)
|
399 |
+
$selected = "selected='selected'";
|
400 |
+
echo "<option value='$key' $selected>{$value['label']}</option> ";
|
401 |
+
}
|
402 |
+
?>
|
403 |
+
</select>
|
404 |
+
<input id="post-query-submit" class="button-secondary" type="submit" value="<?php _e ( 'Filter' )?>" />
|
405 |
+
<?php if( $EM_Event !== false ): ?>
|
406 |
+
<?php _e('Displaying Event','dbem'); ?> : <?php echo $EM_Event->name; ?>
|
407 |
+
<?php elseif( $EM_Person !== false ): ?>
|
408 |
+
<?php _e('Displaying User','dbem'); echo ' : '.$EM_Person->get_name(); ?>
|
409 |
+
<?php endif; ?>
|
410 |
+
</div>
|
411 |
+
<?php
|
412 |
+
if ( $this->bookings_count >= $this->limit ) {
|
413 |
+
$bookings_nav = em_admin_paginate( $this->bookings_count, $this->limit, $this->page, array(),'#%#%','#');
|
414 |
+
echo $bookings_nav;
|
415 |
+
}
|
416 |
+
?>
|
417 |
+
</div>
|
418 |
+
<div class="clear"></div>
|
419 |
+
<div class='table-wrap'>
|
420 |
+
<table id='dbem-bookings-table' class='widefat post '>
|
421 |
+
<thead>
|
422 |
+
<tr>
|
423 |
+
<?php /*
|
424 |
+
<th class='manage-column column-cb check-column' scope='col'>
|
425 |
+
<input class='select-all' type="checkbox" value='1' />
|
426 |
+
</th>
|
427 |
+
*/ ?>
|
428 |
+
<th class='manage-column' scope='col'><?php echo implode("</th><th class='manage-column' scope='col'>", $this->get_headers()); ?></th>
|
429 |
+
</tr>
|
430 |
+
</thead>
|
431 |
+
<?php if( $this->bookings_count > 0 ): ?>
|
432 |
+
<tbody>
|
433 |
+
<?php
|
434 |
+
$rowno = 0;
|
435 |
+
$event_count = (!empty($event_count)) ? $event_count:0;
|
436 |
+
foreach ($this->bookings->bookings as $EM_Booking) {
|
437 |
+
?>
|
438 |
+
<tr>
|
439 |
+
<?php /*
|
440 |
+
<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
|
441 |
+
*/
|
442 |
+
/* @var $EM_Booking EM_Booking */
|
443 |
+
/* @var $EM_Ticket_Booking EM_Ticket_Booking */
|
444 |
+
if( $this->show_tickets ){
|
445 |
+
foreach($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking){
|
446 |
+
?><td><?php echo implode('</td><td>', $this->get_row($EM_Ticket_Booking)); ?></td><?php
|
447 |
+
}
|
448 |
+
}else{
|
449 |
+
?><td><?php echo implode('</td><td>', $this->get_row($EM_Booking)); ?></td><?php
|
450 |
+
}
|
451 |
+
?>
|
452 |
+
</tr>
|
453 |
+
<?php
|
454 |
+
}
|
455 |
+
?>
|
456 |
+
</tbody>
|
457 |
+
<?php else: ?>
|
458 |
+
<tbody>
|
459 |
+
<tr><td scope="row" colspan="<?php echo count($this->cols); ?>"><?php _e('No bookings.', 'dbem'); ?></td></tr>
|
460 |
+
</tbody>
|
461 |
+
<?php endif; ?>
|
462 |
+
</table>
|
463 |
+
</div>
|
464 |
+
<?php if( !empty($bookings_nav) && $this->bookings_count >= $this->limit ) : ?>
|
465 |
+
<div class='tablenav'>
|
466 |
+
<?php echo $bookings_nav; ?>
|
467 |
+
<div class="clear"></div>
|
468 |
+
</div>
|
469 |
+
<?php endif; ?>
|
470 |
+
</form>
|
471 |
+
</div>
|
472 |
+
<?php
|
473 |
+
}
|
474 |
+
|
475 |
+
function get_headers($csv = false){
|
476 |
+
$headers = array();
|
477 |
+
foreach($this->cols as $col){
|
478 |
+
if( $col == 'actions' ){
|
479 |
+
if( !$csv ) $headers[$col] = ' ';
|
480 |
+
}elseif(array_key_exists($col, $this->cols_template)){
|
481 |
+
/* for later - col ordering!
|
482 |
+
if($this->orderby == $col){
|
483 |
+
if($this->order == 'ASC'){
|
484 |
+
$headers[] = '<a class="em-bookings-orderby" href="#'.$col.'">'.$this->cols_template[$col].' (^)</a>';
|
485 |
+
}else{
|
486 |
+
$headers[] = '<a class="em-bookings-orderby" href="#'.$col.'">'.$this->cols_template[$col].' (d)</a>';
|
487 |
+
}
|
488 |
+
}else{
|
489 |
+
$headers[] = '<a class="em-bookings-orderby" href="#'.$col.'">'.$this->cols_template[$col].'</a>';
|
490 |
+
}
|
491 |
+
*/
|
492 |
+
$headers[$col] = $this->cols_template[$col];
|
493 |
+
}
|
494 |
+
}
|
495 |
+
return apply_filters('em_bookings_table_get_headers', $headers, $csv, $this);
|
496 |
+
}
|
497 |
+
|
498 |
+
function get_table(){
|
499 |
+
|
500 |
+
}
|
501 |
+
|
502 |
+
/**
|
503 |
+
* @param Object $object
|
504 |
+
* @return array()
|
505 |
+
*/
|
506 |
+
function get_row( $object, $csv = false ){
|
507 |
+
/* @var $EM_Ticket EM_Ticket */
|
508 |
+
/* @var $EM_Ticket_Booking EM_Ticket_Booking */
|
509 |
+
/* @var $EM_Booking EM_Booking */
|
510 |
+
if( get_class($object) == 'EM_Ticket_Booking' ){
|
511 |
+
$EM_Ticket_Booking = $object;
|
512 |
+
$EM_Ticket = $EM_Ticket_Booking->get_ticket();
|
513 |
+
$EM_Booking = $EM_Ticket_Booking->get_booking();
|
514 |
+
}else{
|
515 |
+
$EM_Booking = $object;
|
516 |
+
}
|
517 |
+
$cols = array();
|
518 |
+
foreach($this->cols as $col){
|
519 |
+
//is col a user col or else?
|
520 |
+
//TODO fix urls so this works in all pages in front as well
|
521 |
+
if( $col == 'user_email' ){
|
522 |
+
$cols[] = $EM_Booking->get_person()->user_email;
|
523 |
+
}elseif($col == 'dbem_phone'){
|
524 |
+
$cols[] = $EM_Booking->get_person()->phone;
|
525 |
+
}elseif($col == 'user_name'){
|
526 |
+
if( $csv || ( get_option('dbem_bookings_registration_disable') && $EM_Booking->get_person()->ID == get_option('dbem_bookings_registration_user') ) ){
|
527 |
+
$cols[] = $EM_Booking->get_person()->get_name();
|
528 |
+
}else{
|
529 |
+
$cols[] = '<a href="'.add_query_arg(array('person_id'=>$EM_Booking->person_id, 'event_id'=>null), $EM_Booking->get_event()->get_bookings_url()).'">'. $EM_Booking->person->get_name() .'</a>';
|
530 |
+
}
|
531 |
+
}elseif($col == 'first_name'){
|
532 |
+
$cols[] = $EM_Booking->get_person()->first_name;
|
533 |
+
}elseif($col == 'last_name'){
|
534 |
+
$cols[] = $EM_Booking->get_person()->last_name;
|
535 |
+
}elseif($col == 'event_name'){
|
536 |
+
if( $csv ){
|
537 |
+
$cols[] = $EM_Booking->get_event()->event_name;
|
538 |
+
}else{
|
539 |
+
$cols[] = '<a href="'.$EM_Booking->get_event()->get_bookings_url().'">'. $EM_Booking->get_event()->event_name .'</a>';
|
540 |
+
}
|
541 |
+
}elseif($col == 'event_date'){
|
542 |
+
$cols[] = $EM_Booking->get_event()->output('#_EVENTDATES');
|
543 |
+
}elseif($col == 'event_time'){
|
544 |
+
$cols[] = $EM_Booking->get_event()->output('#_EVENTTIMES');
|
545 |
+
}elseif($col == 'booking_price'){
|
546 |
+
if($this->show_tickets && !empty($EM_Ticket)){
|
547 |
+
$cols[] = em_get_currency_formatted(apply_filters('em_bookings_table_row_booking_price_ticket', $EM_Ticket_Booking->get_price(false,false, true), $EM_Booking, true));
|
548 |
+
}else{
|
549 |
+
$cols[] = $EM_Booking->get_price(true);
|
550 |
+
}
|
551 |
+
}elseif($col == 'booking_status'){
|
552 |
+
$cols[] = $EM_Booking->get_status(true);
|
553 |
+
}elseif($col == 'booking_date'){
|
554 |
+
$cols[] = date_i18n(get_option('dbem_date_format').' '. get_option('dbem_time_format'), $EM_Booking->timestamp);
|
555 |
+
}elseif($col == 'actions' ){
|
556 |
+
if( !$csv ) $cols[] = implode(' | ', $this->get_booking_actions($EM_Booking));
|
557 |
+
}elseif( $col == 'booking_spaces' ){
|
558 |
+
$cols[] = ($this->show_tickets && !empty($EM_Ticket)) ? $EM_Ticket_Booking->get_spaces() : $EM_Booking->get_spaces();
|
559 |
+
}elseif( $col == 'booking_id' ){
|
560 |
+
$cols[] = $EM_Booking->booking_id;
|
561 |
+
}elseif( $col == 'ticket_name' && $this->show_tickets && !empty($EM_Ticket) ){
|
562 |
+
$cols[] = $EM_Ticket->$col;
|
563 |
+
}elseif( $col == 'ticket_description' && $this->show_tickets && !empty($EM_Ticket) ){
|
564 |
+
$cols[] = $EM_Ticket->$col;
|
565 |
+
}elseif( $col == 'ticket_price' && $this->show_tickets && !empty($EM_Ticket) ){
|
566 |
+
$cols[] = $EM_Ticket->get_price(true);
|
567 |
+
}elseif( $col == 'ticket_id' && $this->show_tickets && !empty($EM_Ticket) ){
|
568 |
+
$cols[] = $EM_Ticket->ticket_id;
|
569 |
+
}elseif( $col == 'booking_comment' ){
|
570 |
+
$cols[] = $EM_Booking->booking_comment;
|
571 |
+
}else{
|
572 |
+
$val = apply_filters('em_bookings_table_rows_col_'.$col, '', $EM_Booking, $this, $csv);
|
573 |
+
$cols[] = apply_filters('em_bookings_table_rows_col', $val, $col, $EM_Booking, $this, $csv);
|
574 |
+
}
|
575 |
+
}
|
576 |
+
//clean up the cols to prevent nasty html or xss
|
577 |
+
global $allowedposttags;
|
578 |
+
foreach($cols as $key => $col){
|
579 |
+
$cols[$key] = wp_kses($col, $allowedposttags);
|
580 |
+
}
|
581 |
+
return $cols;
|
582 |
+
}
|
583 |
+
|
584 |
+
function get_row_csv($EM_Booking){
|
585 |
+
return $this->get_row($EM_Booking, true);
|
586 |
+
}
|
587 |
+
|
588 |
+
/**
|
589 |
+
* @param EM_Booking $EM_Booking
|
590 |
+
* @return mixed
|
591 |
+
*/
|
592 |
+
function get_booking_actions($EM_Booking){
|
593 |
+
$booking_actions = array();
|
594 |
+
$url = $EM_Booking->get_event()->get_bookings_url();
|
595 |
+
switch($EM_Booking->booking_status){
|
596 |
+
case 0:
|
597 |
+
if( get_option('dbem_bookings_approval') ){
|
598 |
+
$booking_actions = array(
|
599 |
+
'approve' => '<a class="em-bookings-approve" href="'.em_add_get_params($url, array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Approve','dbem').'</a>',
|
600 |
+
'reject' => '<a class="em-bookings-reject" href="'.em_add_get_params($url, array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Reject','dbem').'</a>',
|
601 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($url, array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
602 |
+
'edit' => '<a class="em-bookings-edit" href="'.em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id'=>$EM_Booking->booking_id, 'em_ajax'=>null, 'em_obj'=>null)).'">'.__('Edit/View','dbem').'</a>',
|
603 |
+
);
|
604 |
+
break;
|
605 |
+
}//if approvals are off, treat as a 1
|
606 |
+
case 1:
|
607 |
+
$booking_actions = array(
|
608 |
+
'unapprove' => '<a class="em-bookings-unapprove" href="'.em_add_get_params($url, array('action'=>'bookings_unapprove', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Unapprove','dbem').'</a>',
|
609 |
+
'reject' => '<a class="em-bookings-reject" href="'.em_add_get_params($url, array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Reject','dbem').'</a>',
|
610 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($url, array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
611 |
+
'edit' => '<a class="em-bookings-edit" href="'.em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id'=>$EM_Booking->booking_id, 'em_ajax'=>null, 'em_obj'=>null)).'">'.__('Edit/View','dbem').'</a>',
|
612 |
+
);
|
613 |
+
break;
|
614 |
+
case 2:
|
615 |
+
$booking_actions = array(
|
616 |
+
'approve' => '<a class="em-bookings-approve" href="'.em_add_get_params($url, array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Approve','dbem').'</a>',
|
617 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($url, array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
618 |
+
'edit' => '<a class="em-bookings-edit" href="'.em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id'=>$EM_Booking->booking_id, 'em_ajax'=>null, 'em_obj'=>null)).'">'.__('Edit/View','dbem').'</a>',
|
619 |
+
);
|
620 |
+
break;
|
621 |
+
case 3:
|
622 |
+
$booking_actions = array(
|
623 |
+
'approve' => '<a class="em-bookings-approve" href="'.em_add_get_params($url, array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Approve','dbem').'</a>',
|
624 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($url, array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
625 |
+
'edit' => '<a class="em-bookings-edit" href="'.em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id'=>$EM_Booking->booking_id, 'em_ajax'=>null, 'em_obj'=>null)).'">'.__('Edit/View','dbem').'</a>',
|
626 |
+
);
|
627 |
+
break;
|
628 |
+
case 4:
|
629 |
+
$booking_actions = apply_filters('em_bookings_table_booking_actions_4',array(
|
630 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($url, array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
631 |
+
), $EM_Booking);
|
632 |
+
break;
|
633 |
+
case 5:
|
634 |
+
$booking_actions = apply_filters('em_bookings_table_booking_actions_5',array(
|
635 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($url, array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
636 |
+
), $EM_Booking);
|
637 |
+
break;
|
638 |
+
default:
|
639 |
+
$booking_actions = apply_filters('em_bookings_table_booking_actions_'.$EM_Booking->booking_status ,array(), $EM_Booking);
|
640 |
+
break;
|
641 |
+
|
642 |
+
}
|
643 |
+
if( !get_option('dbem_bookings_approval') ) unset($booking_actions['unapprove']);
|
644 |
+
return apply_filters('em_bookings_table_cols_col_action', $booking_actions, $EM_Booking);
|
645 |
+
}
|
646 |
+
}
|
647 |
+
?>
|
classes/em-bookings.php
CHANGED
@@ -1,488 +1,676 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Deals with the booking info for an event
|
4 |
-
* @author marcus
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
class EM_Bookings extends EM_Object{
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Array of EM_Booking objects for a specific event
|
11 |
-
* @var array
|
12 |
-
*/
|
13 |
-
var $bookings = array();
|
14 |
-
/**
|
15 |
-
*
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
var $
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Creates an EM_Bookings instance,
|
30 |
-
* @param EM_Event $event
|
31 |
-
* @return null
|
32 |
-
*/
|
33 |
-
function EM_Bookings( $
|
34 |
-
if( is_object($
|
35 |
-
global $wpdb;
|
36 |
-
$this->event_id = $
|
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 |
-
if(
|
83 |
-
$
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
*
|
140 |
-
* @
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
}
|
176 |
-
return
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
*
|
181 |
-
* @return
|
182 |
-
*/
|
183 |
-
function
|
184 |
-
$
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
*
|
239 |
-
* @return
|
240 |
-
*/
|
241 |
-
function
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
*
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
$
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
$EM_Booking
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
*
|
305 |
-
*/
|
306 |
-
function
|
307 |
-
$
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
*
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
$
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
$
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
$
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
*
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
$
|
470 |
-
|
471 |
-
|
472 |
-
)
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
}
|
483 |
-
$
|
484 |
-
}
|
485 |
-
|
486 |
-
|
487 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
488 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Deals with the booking info for an event
|
4 |
+
* @author marcus
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class EM_Bookings extends EM_Object implements Iterator{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Array of EM_Booking objects for a specific event
|
11 |
+
* @var array
|
12 |
+
*/
|
13 |
+
var $bookings = array();
|
14 |
+
/**
|
15 |
+
* @var EM_Tickets
|
16 |
+
*/
|
17 |
+
var $tickets;
|
18 |
+
/**
|
19 |
+
* @var int
|
20 |
+
*/
|
21 |
+
var $event_id;
|
22 |
+
/**
|
23 |
+
* How many spaces this event has
|
24 |
+
* @var int
|
25 |
+
*/
|
26 |
+
var $spaces;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Creates an EM_Bookings instance, currently accepts an EM_Event object (gets all bookings for that event) or array of any EM_Booking objects, which can be manipulated in bulk with helper functions.
|
30 |
+
* @param EM_Event $event
|
31 |
+
* @return null
|
32 |
+
*/
|
33 |
+
function EM_Bookings( $data = false ){
|
34 |
+
if( is_object($data) && get_class($data) == "EM_Event" ){ //Creates a blank bookings object if needed
|
35 |
+
global $wpdb;
|
36 |
+
$this->event_id = $data->event_id;
|
37 |
+
$bookings = array();
|
38 |
+
if( $this->event_id > 0 ){
|
39 |
+
$sql = "SELECT * FROM ". EM_BOOKINGS_TABLE ." WHERE event_id ='{$this->event_id}' ORDER BY booking_date";
|
40 |
+
$bookings = $wpdb->get_results($sql, ARRAY_A);
|
41 |
+
}
|
42 |
+
foreach ($bookings as $booking){
|
43 |
+
$this->bookings[] = em_get_booking($booking);
|
44 |
+
}
|
45 |
+
$this->spaces = $this->get_spaces();
|
46 |
+
}elseif( is_array($data) ){
|
47 |
+
foreach( $data as $EM_Booking ){
|
48 |
+
if( get_class($EM_Booking) == 'EM_Booking'){
|
49 |
+
$this->bookings[] = $EM_Booking;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add a booking into this event (or add spaces if person already booked this). We assume at this point that the booking has already been validated usin $EM_Booking->validate()
|
57 |
+
* @param EM_Booking $EM_Booking
|
58 |
+
* @return boolean
|
59 |
+
*/
|
60 |
+
function add( $EM_Booking ){
|
61 |
+
global $wpdb,$EM_Mailer;
|
62 |
+
//Save the booking
|
63 |
+
$email = false;
|
64 |
+
//set status depending on approval settings
|
65 |
+
if( empty($EM_Booking->booking_status) ){ //if status is not set, give 1 or 0 depending on approval settings
|
66 |
+
$EM_Booking->booking_status = get_option('dbem_bookings_approval') ? 0:1;
|
67 |
+
}
|
68 |
+
$result = $EM_Booking->save(false);
|
69 |
+
if($result){
|
70 |
+
//Success
|
71 |
+
do_action('em_bookings_added', $EM_Booking);
|
72 |
+
$this->bookings[] = $EM_Booking;
|
73 |
+
$email = $EM_Booking->email();
|
74 |
+
if( get_option('dbem_bookings_approval') == 1 && $EM_Booking->booking_status == 0){
|
75 |
+
$this->feedback_message = get_option('dbem_booking_feedback_pending');
|
76 |
+
}else{
|
77 |
+
$this->feedback_message = get_option('dbem_booking_feedback');
|
78 |
+
}
|
79 |
+
if(!$email){
|
80 |
+
$EM_Booking->email_not_sent = true;
|
81 |
+
$this->feedback_message .= ' '.get_option('dbem_booking_feedback_nomail');
|
82 |
+
if( current_user_can('activate_plugins') ){
|
83 |
+
if( count($EM_Booking->get_errors()) > 0 ){
|
84 |
+
$this->feedback_message .= '<br/><strong>Errors:</strong> (only admins see this message)<br/><ul><li>'. implode('</li><li>', $EM_Booking->get_errors()).'</li></ul>';
|
85 |
+
}else{
|
86 |
+
$this->feedback_message .= '<br/><strong>No errors returned by mailer</strong> (only admins see this message)';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
return apply_filters('em_bookings_add', true, $EM_Booking);
|
91 |
+
}else{
|
92 |
+
//Failure
|
93 |
+
$this->errors[] = "<strong>".get_option('dbem_booking_feedback_error')."</strong><br />". implode('<br />', $EM_Booking->errors);
|
94 |
+
}
|
95 |
+
return apply_filters('em_bookings_add', false, $EM_Booking);
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get POST data and create a booking for each ticket requested. If successful, a booking object is returned, false if not.
|
100 |
+
* @return false|object
|
101 |
+
*/
|
102 |
+
function add_from_post(){
|
103 |
+
$EM_Booking = new EM_booking();
|
104 |
+
$result = $EM_Booking->get_post();
|
105 |
+
if($result){
|
106 |
+
$result = $this->add($EM_Booking);
|
107 |
+
if($result){
|
108 |
+
$result = $EM_Booking;
|
109 |
+
}
|
110 |
+
$this->feedback_message = sprintf(__('%s created.','dbem'),__('Booking','dbem'));
|
111 |
+
}else{
|
112 |
+
$this->errors = array_merge($this->errors, $EM_Booking->errors);
|
113 |
+
}
|
114 |
+
return apply_filters('em_bookings_add_from_post',$result,$EM_Booking,$this);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Smart event locator, saves a database read if possible. Note that if an event doesn't exist, a blank object will be created to prevent duplicates.
|
119 |
+
*/
|
120 |
+
function get_event(){
|
121 |
+
global $EM_Event;
|
122 |
+
if( is_object($EM_Event) && $EM_Event->event_id == $this->event_id ){
|
123 |
+
return $EM_Event;
|
124 |
+
}else{
|
125 |
+
if( is_numeric($this->event_id) && $this->event_id > 0 ){
|
126 |
+
return new EM_Event($this->event_id, 'event_id');
|
127 |
+
}elseif( count($this->bookings) > 0 ){
|
128 |
+
foreach($this->bookings as $EM_Booking){
|
129 |
+
/* @var $EM_Booking EM_Booking */
|
130 |
+
return new EM_Event($EM_Booking->event_id, 'event_id');
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
return new EM_Event($this->event_id);
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Retrieve and save the bookings belonging to instance. If called again will return cached version, set $force_reload to true to create a new EM_Tickets object.
|
139 |
+
* @param boolean $force_reload
|
140 |
+
* @return EM_Tickets
|
141 |
+
*/
|
142 |
+
function get_tickets( $force_reload = false ){
|
143 |
+
if( !is_object($this->tickets) || $force_reload ){
|
144 |
+
$this->tickets = new EM_Tickets($this->event_id);
|
145 |
+
}else{
|
146 |
+
$this->tickets->event_id = $this->event_id;
|
147 |
+
}
|
148 |
+
return apply_filters('em_bookings_get_tickets', $this->tickets, $this);
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Returns EM_Tickets object with available tickets
|
153 |
+
* @param boolean $include_member_tickets - if set to true, member-ony tickets will be considered available even if logged out
|
154 |
+
* @return EM_Tickets
|
155 |
+
*/
|
156 |
+
function get_available_tickets( $include_member_tickets = false ){
|
157 |
+
$tickets = array();
|
158 |
+
foreach ($this->get_tickets() as $EM_Ticket){
|
159 |
+
/* @var $EM_Ticket EM_Ticket */
|
160 |
+
if( $EM_Ticket->is_available($include_member_tickets) ){
|
161 |
+
//within time range
|
162 |
+
if( $EM_Ticket->get_available_spaces() > 0 ){
|
163 |
+
$tickets[] = $EM_Ticket;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
$EM_Tickets = new EM_Tickets($tickets);
|
168 |
+
return apply_filters('em_bookings_get_available_tickets', $EM_Tickets, $this);
|
169 |
+
}
|
170 |
+
|
171 |
+
function get_user_list(){
|
172 |
+
$users = array();
|
173 |
+
foreach( $this->get_bookings()->bookings as $EM_Booking ){
|
174 |
+
$users[$EM_Booking->person->ID] = $EM_Booking->person;
|
175 |
+
}
|
176 |
+
return $users;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* does this ticket exist?
|
181 |
+
* @return bool
|
182 |
+
*/
|
183 |
+
function ticket_exists($ticket_id){
|
184 |
+
$EM_Tickets = $this->get_tickets();
|
185 |
+
foreach( $EM_Tickets->tickets as $EM_Ticket){
|
186 |
+
if($EM_Ticket->ticket_id == $ticket_id){
|
187 |
+
return apply_filters('em_bookings_ticket_exists',true, $EM_Ticket, $this);
|
188 |
+
}
|
189 |
+
}
|
190 |
+
return apply_filters('em_bookings_ticket_exists',false, false,$this);
|
191 |
+
}
|
192 |
+
|
193 |
+
function has_space( $include_member_tickets = false ){
|
194 |
+
return count($this->get_available_tickets( $include_member_tickets )->tickets) > 0;
|
195 |
+
}
|
196 |
+
|
197 |
+
function has_open_time(){
|
198 |
+
$return = false;
|
199 |
+
$EM_Event = $this->get_event();
|
200 |
+
if(!empty($EM_Event->event_rsvp_date) && $EM_Event->rsvp_end > current_time('timestamp')){
|
201 |
+
$return = true;
|
202 |
+
}elseif( empty($EM_Event->event_rsvp_date) && $EM_Event->start > current_time('timestamp') ){
|
203 |
+
$return = true;
|
204 |
+
}
|
205 |
+
return $return;
|
206 |
+
}
|
207 |
+
|
208 |
+
function is_open($include_member_tickets = false){
|
209 |
+
//TODO extend booking options
|
210 |
+
$return = $this->has_open_time() && $this->has_space($include_member_tickets);
|
211 |
+
return apply_filters('em_bookings_is_open', $return, $this, $include_member_tickets);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Delete bookings on this id
|
216 |
+
* @return boolean
|
217 |
+
*/
|
218 |
+
function delete(){
|
219 |
+
global $wpdb;
|
220 |
+
$booking_ids = array();
|
221 |
+
//get the booking ids tied to this event
|
222 |
+
foreach( $this->bookings as $EM_Booking ){
|
223 |
+
$booking_ids[] = $EM_Booking->booking_id;
|
224 |
+
}
|
225 |
+
$result_tickets = true;
|
226 |
+
$result = true;
|
227 |
+
if( count($booking_ids) > 0 ){
|
228 |
+
//Delete bookings and ticket bookings
|
229 |
+
$result_tickets = $wpdb->query("DELETE FROM ". EM_TICKETS_BOOKINGS_TABLE ." WHERE booking_id IN (".implode(',',$booking_ids).");");
|
230 |
+
$result = $wpdb->query("DELETE FROM ".EM_BOOKINGS_TABLE." WHERE event_id IN (".implode(',',$booking_ids).")");
|
231 |
+
}
|
232 |
+
return ($result !== false && $result_tickets !== false);
|
233 |
+
}
|
234 |
+
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Will approve all supplied booking ids, which must be in the form of a numeric array or a single number.
|
238 |
+
* @param array|int $booking_ids
|
239 |
+
* @return boolean
|
240 |
+
*/
|
241 |
+
function approve( $booking_ids ){
|
242 |
+
$this->set_status(1, $booking_ids);
|
243 |
+
return false;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Will reject all supplied booking ids, which must be in the form of a numeric array or a single number.
|
248 |
+
* @param array|int $booking_ids
|
249 |
+
* @return boolean
|
250 |
+
*/
|
251 |
+
function reject( $booking_ids ){
|
252 |
+
return $this->set_status(2, $booking_ids);
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Will unapprove all supplied booking ids, which must be in the form of a numeric array or a single number.
|
257 |
+
* @param array|int $booking_ids
|
258 |
+
* @return boolean
|
259 |
+
*/
|
260 |
+
function unapprove( $booking_ids ){
|
261 |
+
return $this->set_status(0, $booking_ids);
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @param int $status
|
266 |
+
* @param array|int $booking_ids
|
267 |
+
* @return bool
|
268 |
+
*/
|
269 |
+
function set_status($status, $booking_ids){
|
270 |
+
//FIXME status should work with instantiated object
|
271 |
+
if( $this->array_is_numeric($booking_ids) ){
|
272 |
+
//Get all the bookings
|
273 |
+
$results = array();
|
274 |
+
$mails = array();
|
275 |
+
foreach( $booking_ids as $booking_id ){
|
276 |
+
$EM_Booking = em_get_booking($booking_id);
|
277 |
+
if( !$EM_Booking->can_manage() ){
|
278 |
+
$this->feedback_message = __('Bookings %s. Mails Sent.', 'dbem');
|
279 |
+
return false;
|
280 |
+
}
|
281 |
+
$results[] = $EM_Booking->set_status($status);
|
282 |
+
}
|
283 |
+
if( !in_array('false',$results) ){
|
284 |
+
$this->feedback_message = __('Bookings %s. Mails Sent.', 'dbem');
|
285 |
+
return true;
|
286 |
+
}else{
|
287 |
+
//TODO Better error handling needed if some bookings fail approval/failure
|
288 |
+
$this->feedback_message = __('An error occurred.', 'dbem');
|
289 |
+
return false;
|
290 |
+
}
|
291 |
+
}elseif( is_numeric($booking_ids) || is_object($booking_ids) ){
|
292 |
+
$EM_Booking = ( is_object($booking_ids) && get_class($booking_ids) == 'EM_Booking') ? $booking_ids : em_get_booking($booking_ids);
|
293 |
+
$result = $EM_Booking->set_status($status);
|
294 |
+
$this->feedback_message = $EM_Booking->feedback_message;
|
295 |
+
return $result;
|
296 |
+
}
|
297 |
+
return false;
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Get the total number of spaces this event has. This will show the lower value of event global spaces limit or total ticket spaces. Setting $force_refresh to true will recheck spaces, even if previously done so.
|
303 |
+
* @param boolean $force_refresh
|
304 |
+
* @return int
|
305 |
+
*/
|
306 |
+
function get_spaces( $force_refresh=false ){
|
307 |
+
if($force_refresh || $this->spaces == 0){
|
308 |
+
$this->spaces = $this->get_tickets()->get_spaces();
|
309 |
+
}
|
310 |
+
//check overall events cap
|
311 |
+
if(!empty($this->get_event()->event_spaces) && $this->get_event()->event_spaces < $this->spaces) $this->spaces = $this->get_event()->event_spaces;
|
312 |
+
return apply_filters('em_booking_get_spaces',$this->spaces,$this);
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Returns number of available spaces for this event. If approval of bookings is on, will include pending bookings depending on em option.
|
317 |
+
* @return int
|
318 |
+
*/
|
319 |
+
function get_available_spaces(){
|
320 |
+
$spaces = $this->get_spaces();
|
321 |
+
$available_spaces = $spaces - $this->get_booked_spaces();
|
322 |
+
if( get_option('dbem_bookings_approval_reserved') ){ //deduct reserved/pending spaces from available spaces
|
323 |
+
$available_spaces -= $this->get_pending_spaces();
|
324 |
+
}
|
325 |
+
return apply_filters('em_booking_get_available_spaces', $available_spaces, $this);
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Returns number of booked spaces for this event. If approval of bookings is on, will return number of booked confirmed spaces.
|
330 |
+
* @return int
|
331 |
+
*/
|
332 |
+
function get_booked_spaces($force_refresh = false){
|
333 |
+
$booked_spaces = 0;
|
334 |
+
foreach ( $this->bookings as $EM_Booking ){
|
335 |
+
if( $EM_Booking->booking_status == 1 || (!get_option('dbem_bookings_approval') && $EM_Booking->booking_status == 0 ) ){
|
336 |
+
$booked_spaces += $EM_Booking->get_spaces($force_refresh);
|
337 |
+
}
|
338 |
+
}
|
339 |
+
return apply_filters('em_bookings_get_booked_spaces', $booked_spaces, $this);
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Gets number of pending spaces awaiting approval. Will return 0 if booking approval is not enabled.
|
344 |
+
* @return int
|
345 |
+
*/
|
346 |
+
function get_pending_spaces(){
|
347 |
+
if( get_option('dbem_bookings_approval') == 0 ){
|
348 |
+
return apply_filters('em_bookings_get_pending_spaces', 0, $this);
|
349 |
+
}
|
350 |
+
$pending = 0;
|
351 |
+
foreach ( $this->bookings as $booking ){
|
352 |
+
if($booking->booking_status == 0){
|
353 |
+
$pending += $booking->get_spaces();
|
354 |
+
}
|
355 |
+
}
|
356 |
+
return apply_filters('em_bookings_get_pending_spaces', $pending, $this);
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Gets number of bookings (not spaces). If booking approval is enabled, only the number of approved bookings will be shown.
|
361 |
+
* @return EM_Bookings
|
362 |
+
*/
|
363 |
+
function get_bookings( $all_bookings = false ){
|
364 |
+
$confirmed = array();
|
365 |
+
foreach ( $this->bookings as $booking ){
|
366 |
+
if( $booking->booking_status == 1 || (get_option('dbem_bookings_approval') == 0 && $booking->booking_status == 0) || $all_bookings ){
|
367 |
+
$confirmed[] = $booking;
|
368 |
+
}
|
369 |
+
}
|
370 |
+
$EM_Bookings = new EM_Bookings($confirmed);
|
371 |
+
return $EM_Bookings;
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Get pending bookings. If booking approval is disabled, will return no bookings.
|
376 |
+
* @return EM_Bookings
|
377 |
+
*/
|
378 |
+
function get_pending_bookings(){
|
379 |
+
if( get_option('dbem_bookings_approval') == 0 ){
|
380 |
+
return new EM_Bookings();
|
381 |
+
}
|
382 |
+
$pending = array();
|
383 |
+
foreach ( $this->bookings as $booking ){
|
384 |
+
if($booking->booking_status == 0){
|
385 |
+
$pending[] = $booking;
|
386 |
+
}
|
387 |
+
}
|
388 |
+
$EM_Bookings = new EM_Bookings($pending);
|
389 |
+
return $EM_Bookings;
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Get rejected bookings. If booking approval is disabled, will return no bookings.
|
394 |
+
* @return array EM_Bookings
|
395 |
+
*/
|
396 |
+
function get_rejected_bookings(){
|
397 |
+
$rejected = array();
|
398 |
+
foreach ( $this->bookings as $booking ){
|
399 |
+
if($booking->booking_status == 2){
|
400 |
+
$rejected[] = $booking;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
$EM_Bookings = new EM_Bookings($rejected);
|
404 |
+
return $EM_Bookings;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Get cancelled bookings.
|
409 |
+
* @return array EM_Booking
|
410 |
+
*/
|
411 |
+
function get_cancelled_bookings(){
|
412 |
+
$cancelled = array();
|
413 |
+
foreach ( $this->bookings as $booking ){
|
414 |
+
if($booking->booking_status == 3){
|
415 |
+
$cancelled[] = $booking;
|
416 |
+
}
|
417 |
+
}
|
418 |
+
$EM_Bookings = new EM_Bookings($cancelled);
|
419 |
+
return $EM_Bookings;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Checks if a person with similar details has booked for this before
|
424 |
+
* @param $person_id
|
425 |
+
* @return EM_Booking
|
426 |
+
*/
|
427 |
+
function find_previous_booking($EM_Booking){
|
428 |
+
//First see if we have a similar person on record that's making this booking
|
429 |
+
$EM_Booking->person->load_similar();
|
430 |
+
//If person exists on record, see if they've booked this event before, if so return the booking.
|
431 |
+
if( is_numeric($EM_Booking->person->ID) && $EM_Booking->person->ID > 0 ){
|
432 |
+
$EM_Booking->person_id = $EM_Booking->person->ID;
|
433 |
+
foreach ($this->bookings as $booking){
|
434 |
+
if( $booking->person_id == $EM_Booking->person->ID ){
|
435 |
+
return $booking;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
}
|
439 |
+
return false;
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Checks to see if user has a booking for this event
|
444 |
+
* @param unknown_type $user_id
|
445 |
+
*/
|
446 |
+
function has_booking( $user_id = false ){
|
447 |
+
if( $user_id === false ){
|
448 |
+
$user_id = get_current_user_id();
|
449 |
+
}
|
450 |
+
if( is_numeric($user_id) && $user_id > 0 ){
|
451 |
+
foreach ($this->bookings as $EM_Booking){
|
452 |
+
if( $EM_Booking->person->ID == $user_id && !in_array($EM_Booking->booking_status, array(2,3)) ){
|
453 |
+
return apply_filters('em_bookings_has_booking', $EM_Booking, $this);
|
454 |
+
}
|
455 |
+
}
|
456 |
+
}
|
457 |
+
return apply_filters('em_bookings_has_booking', false, $this);
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Get bookings that match the array of arguments passed.
|
462 |
+
* @return array
|
463 |
+
* @static
|
464 |
+
*/
|
465 |
+
function get( $args = array(), $count = false ){
|
466 |
+
global $wpdb,$current_user;
|
467 |
+
$bookings_table = EM_BOOKINGS_TABLE;
|
468 |
+
$events_table = EM_EVENTS_TABLE;
|
469 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
470 |
+
|
471 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
472 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
473 |
+
//We can just get all the events here and return them
|
474 |
+
$sql = "
|
475 |
+
SELECT * FROM $bookings_table b
|
476 |
+
LEFT JOIN $events_table e ON e.event_id=b.event_id
|
477 |
+
WHERE booking_id".implode(" OR booking_id=", $args);
|
478 |
+
$results = $wpdb->get_results(apply_filters('em_bookings_get_sql',$sql),ARRAY_A);
|
479 |
+
$bookings = array();
|
480 |
+
foreach($results as $result){
|
481 |
+
$bookings[] = em_get_booking($result);
|
482 |
+
}
|
483 |
+
return $bookings; //We return all the bookings matched as an EM_Booking array.
|
484 |
+
}
|
485 |
+
|
486 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
487 |
+
$args = self::get_default_search($args);
|
488 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
489 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
490 |
+
|
491 |
+
//Get the default conditions
|
492 |
+
$conditions = self::build_sql_conditions($args);
|
493 |
+
//Put it all together
|
494 |
+
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
495 |
+
|
496 |
+
//Get ordering instructions
|
497 |
+
$EM_Booking = em_get_booking();
|
498 |
+
$accepted_fields = $EM_Booking->get_fields(true);
|
499 |
+
$orderby = self::build_sql_orderby($args, $accepted_fields);
|
500 |
+
//Now, build orderby sql
|
501 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : 'ORDER BY booking_date';
|
502 |
+
//Selector
|
503 |
+
$selectors = ( $count ) ? 'COUNT(*)':'*';
|
504 |
+
|
505 |
+
//Create the SQL statement and execute
|
506 |
+
$sql = "
|
507 |
+
SELECT $selectors FROM $bookings_table
|
508 |
+
LEFT JOIN $events_table ON {$events_table}.event_id={$bookings_table}.event_id
|
509 |
+
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
510 |
+
$where
|
511 |
+
$orderby_sql
|
512 |
+
$limit $offset
|
513 |
+
";
|
514 |
+
//If we're only counting results, return the number of results
|
515 |
+
if( $count ){
|
516 |
+
return apply_filters('em_bookings_get_count', $wpdb->get_var($sql), $args);
|
517 |
+
}
|
518 |
+
$results = $wpdb->get_results( apply_filters('em_events_get_sql',$sql, $args), ARRAY_A);
|
519 |
+
|
520 |
+
//If we want results directly in an array, why not have a shortcut here?
|
521 |
+
if( $args['array'] == true ){
|
522 |
+
return $results;
|
523 |
+
}
|
524 |
+
|
525 |
+
//Make returned results EM_Booking objects
|
526 |
+
$results = (is_array($results)) ? $results:array();
|
527 |
+
$bookings = array();
|
528 |
+
foreach ( $results as $booking ){
|
529 |
+
$bookings[] = em_get_booking($booking);
|
530 |
+
}
|
531 |
+
$EM_Bookings = new EM_Bookings($bookings);
|
532 |
+
return apply_filters('em_bookings_get', $EM_Bookings);
|
533 |
+
}
|
534 |
+
|
535 |
+
function count( $args = array() ){
|
536 |
+
return self::get($args, true);
|
537 |
+
}
|
538 |
+
|
539 |
+
|
540 |
+
//List of patients in the patient database, that a user can choose and go on to edit any previous treatment data, or add a new admission.
|
541 |
+
function export_csv() {
|
542 |
+
global $EM_Event;
|
543 |
+
if($EM_Event->event_id != $this->event_id ){
|
544 |
+
$event = $this->get_event();
|
545 |
+
$event_name = $event->name;
|
546 |
+
}else{
|
547 |
+
$event_name = $EM_Event->name;
|
548 |
+
}
|
549 |
+
// The name of the file on the user's pc
|
550 |
+
$file_name = sanitize_title($event_name). "-bookings.csv";
|
551 |
+
|
552 |
+
header("Content-Type: application/octet-stream");
|
553 |
+
header("Content-Disposition: Attachment; filename=$file_name");
|
554 |
+
em_locate_template('templates/csv-event-bookings.php', true);
|
555 |
+
exit();
|
556 |
+
}
|
557 |
+
|
558 |
+
static function enqueue_js(){
|
559 |
+
if( !defined('EM_BOOKING_JS_LOADED') ){ //request loading of JS file in footer of page load
|
560 |
+
add_action('wp_footer','EM_Bookings::em_booking_js_footer', 20);
|
561 |
+
add_action('admin_footer','EM_Bookings::em_booking_js_footer', 20);
|
562 |
+
define('EM_BOOKING_JS_LOADED',true);
|
563 |
+
}
|
564 |
+
}
|
565 |
+
|
566 |
+
static function em_booking_js_footer(){
|
567 |
+
?>
|
568 |
+
<script type="text/javascript">
|
569 |
+
jQuery(document).ready( function($){
|
570 |
+
<?php
|
571 |
+
//we call the segmented JS files and include them here
|
572 |
+
$include_path = dirname(dirname(__FILE__)); //get path to parent directory
|
573 |
+
include($include_path.'/includes/js/bookingsform.js');
|
574 |
+
do_action('em_gateway_js');
|
575 |
+
?>
|
576 |
+
});
|
577 |
+
<?php
|
578 |
+
do_action('em_booking_js_footer');
|
579 |
+
?>
|
580 |
+
</script>
|
581 |
+
<?php
|
582 |
+
}
|
583 |
+
|
584 |
+
/* Overrides EM_Object method to apply a filter to result
|
585 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
|
586 |
+
*/
|
587 |
+
function build_sql_conditions( $args = array() ){
|
588 |
+
$conditions = apply_filters( 'em_bookings_build_sql_conditions', parent::build_sql_conditions($args), $args );
|
589 |
+
if( is_numeric($args['status']) ){
|
590 |
+
$conditions['status'] = 'booking_status='.$args['status'];
|
591 |
+
}elseif( is_array($args['status']) && count($args['status']) > 0 ){
|
592 |
+
$conditions['status'] = 'booking_status IN ('.implode(',',$args['status']).')';
|
593 |
+
}elseif( !is_array($args['status']) && preg_match('/^([0-9],?)+$/', $args['status']) ){
|
594 |
+
$conditions['status'] = 'booking_status IN ('.$args['status'].')';
|
595 |
+
}
|
596 |
+
if( is_numeric($args['person']) && current_user_can('manage_others_bookings') ){
|
597 |
+
$conditions['person'] = EM_BOOKINGS_TABLE.'.person_id='.$args['person'];
|
598 |
+
}
|
599 |
+
if( EM_MS_GLOBAL && !empty($args['blog']) && is_numeric($args['blog']) ){
|
600 |
+
if( is_main_site($args['blog']) ){
|
601 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']} OR ".EM_EVENTS_TABLE.".blog_id IS NULL)";
|
602 |
+
}else{
|
603 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']})";
|
604 |
+
}
|
605 |
+
}
|
606 |
+
if( empty($conditions['event']) && $args['event'] === false ){
|
607 |
+
$conditions['event'] = EM_BOOKINGS_TABLE.'.event_id != 0';
|
608 |
+
}
|
609 |
+
if( is_numeric($args['ticket_id']) ){
|
610 |
+
$EM_Ticket = new EM_Ticket($args['ticket_id']);
|
611 |
+
if( $EM_Ticket->can_manage() ){
|
612 |
+
$conditions['ticket'] = EM_BOOKINGS_TABLE.'.booking_id IN (SELECT booking_id FROM '.EM_TICKETS_BOOKINGS_TABLE." WHERE ticket_id='{$args['ticket_id']}')";
|
613 |
+
}
|
614 |
+
}
|
615 |
+
return apply_filters('em_bookings_build_sql_conditions', $conditions, $args);
|
616 |
+
}
|
617 |
+
|
618 |
+
/* Overrides EM_Object method to apply a filter to result
|
619 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
|
620 |
+
*/
|
621 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
622 |
+
return apply_filters( 'em_bookings_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_bookings_default_order','booking_date')), $args, $accepted_fields, $default_order );
|
623 |
+
}
|
624 |
+
|
625 |
+
/*
|
626 |
+
* Adds custom Events search defaults
|
627 |
+
* @param array $array
|
628 |
+
* @return array
|
629 |
+
* @uses EM_Object#get_default_search()
|
630 |
+
*/
|
631 |
+
function get_default_search( $array = array() ){
|
632 |
+
$defaults = array(
|
633 |
+
'status' => false,
|
634 |
+
'person' => true, //to add later, search by person's bookings...
|
635 |
+
'blog' => get_current_blog_id(),
|
636 |
+
'ticket_id' => false
|
637 |
+
);
|
638 |
+
if( true || is_admin() ){
|
639 |
+
//figure out default owning permissions
|
640 |
+
if( !current_user_can('edit_others_events') ){
|
641 |
+
$defaults['owner'] = get_current_user_id();
|
642 |
+
}else{
|
643 |
+
$defaults['owner'] = false;
|
644 |
+
}
|
645 |
+
}
|
646 |
+
if( EM_MS_GLOBAL && !is_admin() ){
|
647 |
+
if( empty($array['blog']) && is_main_site() && get_site_option('dbem_ms_global_events') ){
|
648 |
+
$array['blog'] = false;
|
649 |
+
}
|
650 |
+
}
|
651 |
+
return apply_filters('em_bookings_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
|
652 |
+
}
|
653 |
+
|
654 |
+
//Iterator Implementation
|
655 |
+
public function rewind(){
|
656 |
+
reset($this->bookings);
|
657 |
+
}
|
658 |
+
public function current(){
|
659 |
+
$var = current($this->bookings);
|
660 |
+
return $var;
|
661 |
+
}
|
662 |
+
public function key(){
|
663 |
+
$var = key($this->bookings);
|
664 |
+
return $var;
|
665 |
+
}
|
666 |
+
public function next(){
|
667 |
+
$var = next($this->bookings);
|
668 |
+
return $var;
|
669 |
+
}
|
670 |
+
public function valid(){
|
671 |
+
$key = key($this->bookings);
|
672 |
+
$var = ($key !== NULL && $key !== FALSE);
|
673 |
+
return $var;
|
674 |
+
}
|
675 |
+
}
|
676 |
Â
?>
|
classes/em-calendar.php
CHANGED
@@ -1,366 +1,414 @@
|
|
1 |
-
<?php
|
2 |
-
class EM_Calendar extends EM_Object {
|
3 |
-
|
4 |
-
function init(){
|
5 |
-
|
6 |
-
}
|
7 |
-
|
8 |
-
function
|
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 |
-
$offset
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
//
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
//
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
$
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
$
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
$
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
$
|
155 |
-
}
|
156 |
-
|
157 |
-
$
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
//
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
$
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$args['
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
$
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
}
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
if (
|
276 |
-
|
277 |
-
|
278 |
-
$
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
return
|
323 |
-
}
|
324 |
-
|
325 |
-
function
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
$
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
function
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class EM_Calendar extends EM_Object {
|
3 |
+
|
4 |
+
function init(){
|
5 |
+
//nothing to init anymore
|
6 |
+
}
|
7 |
+
|
8 |
+
function get( $args ){
|
9 |
+
|
10 |
+
global $wpdb;
|
11 |
+
|
12 |
+
$calendar_array = array();
|
13 |
+
$calendar_array['cells'] = array();
|
14 |
+
|
15 |
+
$args = apply_filters('em_calendar_get_args', $args);
|
16 |
+
$original_args = $args;
|
17 |
+
$args = self::get_default_search($args);
|
18 |
+
$full = $args['full']; //For ZDE, don't delete pls
|
19 |
+
$month = $args['month'];
|
20 |
+
$year = $args['year'];
|
21 |
+
$long_events = $args['long_events'];
|
22 |
+
$limit = $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_display_calendar_events_limit'); //limit arg will be used per day and not for events search
|
23 |
+
|
24 |
+
$week_starts_on_sunday = get_option('dbem_week_starts_sunday');
|
25 |
+
$start_of_week = get_option('start_of_week');
|
26 |
+
|
27 |
+
if( !(is_numeric($month) && $month <= 12 && $month > 0) ) {
|
28 |
+
$month = date('m');
|
29 |
+
}
|
30 |
+
if( !( is_numeric($year) ) ){
|
31 |
+
$year = date('Y');
|
32 |
+
}
|
33 |
+
|
34 |
+
// Get the first day of the month
|
35 |
+
$month_start = mktime(0,0,0,$month, 1, $year);
|
36 |
+
$calendar_array['month_start'] = $month_start;
|
37 |
+
|
38 |
+
// Get friendly month name
|
39 |
+
$month_name = date('M',$month_start);
|
40 |
+
// Figure out which day of the week
|
41 |
+
// the month starts on.
|
42 |
+
$month_start_day = date('D', $month_start);
|
43 |
+
|
44 |
+
switch($month_start_day){
|
45 |
+
case "Sun": $offset = 0; break;
|
46 |
+
case "Mon": $offset = 1; break;
|
47 |
+
case "Tue": $offset = 2; break;
|
48 |
+
case "Wed": $offset = 3; break;
|
49 |
+
case "Thu": $offset = 4; break;
|
50 |
+
case "Fri": $offset = 5; break;
|
51 |
+
case "Sat": $offset = 6; break;
|
52 |
+
}
|
53 |
+
//We need to go back to the WP defined day when the week started, in case the event day is near the end
|
54 |
+
$offset -= $start_of_week;
|
55 |
+
if($offset<0)
|
56 |
+
$offset += 7;
|
57 |
+
|
58 |
+
// determine how many days are in the last month.
|
59 |
+
$month_last = $month-1;
|
60 |
+
$month_next = $month+1;
|
61 |
+
$calendar_array['month_next'] = $month_next;
|
62 |
+
$year_last = $year;
|
63 |
+
$year_next = $year;
|
64 |
+
$calendar_array['year_next'] = $year_next;
|
65 |
+
|
66 |
+
if($month == 1) {
|
67 |
+
$month_last = 12;
|
68 |
+
$year_last = $year -1;
|
69 |
+
}elseif($month == 12){
|
70 |
+
$month_next = 1;
|
71 |
+
$year_next = $year + 1;
|
72 |
+
}
|
73 |
+
$calendar_array['month_last'] = $month_last;
|
74 |
+
$calendar_array['year_last'] = $year_last;
|
75 |
+
|
76 |
+
$num_days_last = self::days_in_month($month_last, $year_last);
|
77 |
+
|
78 |
+
// determine how many days are in the current month.
|
79 |
+
$num_days_current = self::days_in_month($month, $year);
|
80 |
+
// Build an array for the current days
|
81 |
+
// in the month
|
82 |
+
for($i = 1; $i <= $num_days_current; $i++){
|
83 |
+
$num_days_array[] = mktime(0,0,0,$month, $i, $year);
|
84 |
+
}
|
85 |
+
// Build an array for the number of days
|
86 |
+
// in last month
|
87 |
+
for($i = 1; $i <= $num_days_last; $i++){
|
88 |
+
$num_days_last_array[] = mktime(0,0,0,$month_last, $i, $year_last);
|
89 |
+
}
|
90 |
+
// If the $offset from the starting day of the
|
91 |
+
// week happens to be Sunday, $offset would be 0,
|
92 |
+
// so don't need an offset correction.
|
93 |
+
|
94 |
+
if($offset > 0){
|
95 |
+
$offset_correction = array_slice($num_days_last_array, -$offset, $offset);
|
96 |
+
$new_count = array_merge($offset_correction, $num_days_array);
|
97 |
+
$offset_count = count($offset_correction);
|
98 |
+
} else { // The else statement is to prevent building the $offset array.
|
99 |
+
$offset_count = 0;
|
100 |
+
$new_count = $num_days_array;
|
101 |
+
}
|
102 |
+
// count how many days we have with the two
|
103 |
+
// previous arrays merged together
|
104 |
+
$current_num = count($new_count);
|
105 |
+
|
106 |
+
// Since we will have 5 HTML table rows (TR)
|
107 |
+
// with 7 table data entries (TD)
|
108 |
+
// we need to fill in 35 TDs
|
109 |
+
// so, we will have to figure out
|
110 |
+
// how many days to appened to the end
|
111 |
+
// of the final array to make it 35 days.
|
112 |
+
if($current_num > 35){
|
113 |
+
$num_weeks = 6;
|
114 |
+
$outset = (42 - $current_num);
|
115 |
+
} elseif($current_num < 35){
|
116 |
+
$num_weeks = 5;
|
117 |
+
$outset = (35 - $current_num);
|
118 |
+
}
|
119 |
+
if($current_num == 35){
|
120 |
+
$num_weeks = 5;
|
121 |
+
$outset = 0;
|
122 |
+
}
|
123 |
+
// Outset Correction
|
124 |
+
for($i = 1; $i <= $outset; $i++){
|
125 |
+
$new_count[] = mktime(0,0,0,$month_next, $i, $year_next);
|
126 |
+
}
|
127 |
+
// Now let's "chunk" the $all_days array
|
128 |
+
// into weeks. Each week has 7 days
|
129 |
+
// so we will array_chunk it into 7 days.
|
130 |
+
$weeks = array_chunk($new_count, 7);
|
131 |
+
|
132 |
+
//Get an array of arguments that don't include default valued args
|
133 |
+
$link_args = self::get_link_args($args);
|
134 |
+
|
135 |
+
$previous_url = "?ajaxCalendar=1&mo={$month_last}&yr={$year_last}&{$link_args}";
|
136 |
+
$next_url = "?ajaxCalendar=1&mo={$month_next}&yr={$year_next}&{$link_args}";
|
137 |
+
|
138 |
+
$weekdays = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
|
139 |
+
if(!empty($args['full'])) {
|
140 |
+
if( get_option('dbem_full_calendar_abbreviated_weekdays') ) $weekdays = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
|
141 |
+
$day_initials_length = get_option('dbem_full_calendar_initials_length');
|
142 |
+
} else {
|
143 |
+
if ( get_option('dbem_small_calendar_abbreviated_weekdays') ) $weekdays = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
|
144 |
+
$day_initials_length = get_option('dbem_small_calendar_initials_length');
|
145 |
+
}
|
146 |
+
|
147 |
+
for( $n = 0; $n < $start_of_week; $n++ ) {
|
148 |
+
$last_day = array_shift($weekdays);
|
149 |
+
$weekdays[]= $last_day;
|
150 |
+
}
|
151 |
+
|
152 |
+
$days_initials_array = array();
|
153 |
+
foreach($weekdays as $weekday) {
|
154 |
+
$days_initials_array[] = self::translate_and_trim($weekday, $day_initials_length);
|
155 |
+
}
|
156 |
+
|
157 |
+
$calendar_array['links'] = array( 'previous_url'=>$previous_url, 'next_url'=>$next_url);
|
158 |
+
$calendar_array['row_headers'] = $days_initials_array;
|
159 |
+
|
160 |
+
// Now we break each key of the array
|
161 |
+
// into a week and create a new table row for each
|
162 |
+
// week with the days of that week in the table data
|
163 |
+
|
164 |
+
$i = 0;
|
165 |
+
$current_date = date('Y-m-d', current_time('timestamp'));
|
166 |
+
$week_count = 0;
|
167 |
+
foreach ( $weeks as $week ) {
|
168 |
+
foreach ( $week as $d ) {
|
169 |
+
$date = date('Y-m-d', $d);
|
170 |
+
$calendar_array['cells'][$date] = array('date'=>$d, 'events'=>array(), 'events_count'=>0); //set it up so we have the exact array of dates to be filled
|
171 |
+
if ($i < $offset_count) { //if it is PREVIOUS month
|
172 |
+
$calendar_array['cells'][$date]['type'] = 'pre';
|
173 |
+
}
|
174 |
+
if (($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)) { // if it is THIS month
|
175 |
+
if ( $current_date == $date ){
|
176 |
+
$calendar_array['cells'][$date]['type'] = 'today';
|
177 |
+
}
|
178 |
+
} elseif (($outset > 0)) { //if it is NEXT month
|
179 |
+
if (($i >= ($num_weeks * 7) - $outset)) {
|
180 |
+
$calendar_array['cells'][$date]['type'] = 'post';
|
181 |
+
}
|
182 |
+
}
|
183 |
+
$i ++;
|
184 |
+
}
|
185 |
+
$week_count++;
|
186 |
+
}
|
187 |
+
|
188 |
+
//query the database for events in this time span with 7 days before and after this month to account for these cells in the calendar
|
189 |
+
$scope_datetime_start = new DateTime("{$year}-{$month}-1");
|
190 |
+
$scope_datetime_end = new DateTime($scope_datetime_start->format('Y-m-t'));
|
191 |
+
$scope_datetime_start->modify('-7 days');
|
192 |
+
$scope_datetime_end->modify('+7 days');
|
193 |
+
//we have two methods here, one for high-volume event sites i.e. many thousands of events per month, and another for thousands or less per month.
|
194 |
+
$args['array'] = true; //we're getting an array first to avoid extra queries during object creation
|
195 |
+
unset($args['month']);
|
196 |
+
unset($args['year']);
|
197 |
+
unset($args['limit']); //limits in the events search won't help
|
198 |
+
if( defined('EM_CALENDAR_OPT') && EM_CALENDAR_OPT ){
|
199 |
+
//here we loop through each day, query that specific date, and then compile a list of event objects
|
200 |
+
//in this mode the count will never be accurate, we're grabing at most (31 + 14 days) * (limit + 1) events to reduce memory loads
|
201 |
+
$args['limit'] = $limit + 1;
|
202 |
+
$scope_datetime_loop = $scope_datetime_start->format('U');
|
203 |
+
$events = array();
|
204 |
+
while( $scope_datetime_loop <= $scope_datetime_end->format('U') ){
|
205 |
+
$args['scope'] = date('Y-m-d', $scope_datetime_loop);
|
206 |
+
foreach( EM_Events::get($args) as $event ){
|
207 |
+
$events[$event['event_id']] = $event;
|
208 |
+
}
|
209 |
+
$scope_datetime_loop += (86400); //add a day
|
210 |
+
}
|
211 |
+
}else{
|
212 |
+
//just load all the events for this time-range
|
213 |
+
$args['scope'] = array( $scope_datetime_start->format('Y-m-d'), $scope_datetime_end->format('Y-m-d'));
|
214 |
+
$events = EM_Events::get($args);
|
215 |
+
}
|
216 |
+
//back to what it was
|
217 |
+
$args['month'] = $month;
|
218 |
+
$args['year'] = $year;
|
219 |
+
$args['limit'] = $limit;
|
220 |
+
|
221 |
+
$event_format = get_option('dbem_full_calendar_event_format');
|
222 |
+
$event_title_format = get_option('dbem_small_calendar_event_title_format');
|
223 |
+
$event_title_separator_format = get_option('dbem_small_calendar_event_title_separator');
|
224 |
+
|
225 |
+
$eventful_days= array();
|
226 |
+
$eventful_days_count = array();
|
227 |
+
if($events){
|
228 |
+
//Go through the events and slot them into the right d-m index
|
229 |
+
foreach($events as $event) {
|
230 |
+
$event = apply_filters('em_calendar_output_loop_start', $event);
|
231 |
+
if( $long_events ){
|
232 |
+
//If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day
|
233 |
+
$event_start_ts = strtotime($event['event_start_date']);
|
234 |
+
$event_end_ts = strtotime($event['event_end_date']);
|
235 |
+
$event_end_ts = $event_end_ts > $scope_datetime_end->format('U') ? $scope_datetime_end->format('U') : $event_end_ts;
|
236 |
+
while( $event_start_ts <= $event_end_ts ){ //we loop until the last day of our time-range, not the end date of the event, which could be in a year
|
237 |
+
//Ensure date is within event dates and also within the limits of events to show per day, if so add to eventful days array
|
238 |
+
$event_eventful_date = date('Y-m-d', $event_start_ts);
|
239 |
+
if( empty($eventful_days_count[$event_eventful_date]) || !$limit || $eventful_days_count[$event_eventful_date] < $limit ){
|
240 |
+
//now we know this is an event that'll be used, convert it to an object
|
241 |
+
$EM_Event = EM_MS_GLOBAL ? em_get_event($event['post_id'], $event['blog_id']) : $EM_Event = em_get_event($event['post_id'], 'post_id');
|
242 |
+
if( empty($eventful_days[$event_eventful_date]) || !is_array($eventful_days[$event_eventful_date]) ) $eventful_days[$event_eventful_date] = array();
|
243 |
+
//add event to array with a corresponding timestamp for sorting of times including long and all-day events
|
244 |
+
$event_ts_marker = ($EM_Event->event_all_day) ? 0 : strtotime($event_eventful_date.' '.$EM_Event->event_start_time);
|
245 |
+
while( !empty($eventful_days[$event_eventful_date][$event_ts_marker]) ){
|
246 |
+
$event_ts_marker++; //add a second
|
247 |
+
}
|
248 |
+
$eventful_days[$event_eventful_date][$event_ts_marker] = $EM_Event;
|
249 |
+
}
|
250 |
+
//count events for that day
|
251 |
+
$eventful_days_count[$event_eventful_date] = empty($eventful_days_count[$event_eventful_date]) ? 1 : $eventful_days_count[$event_eventful_date]+1;
|
252 |
+
$event_start_ts += (86400); //add a day
|
253 |
+
}
|
254 |
+
}else{
|
255 |
+
//Only show events on the day that they start
|
256 |
+
$event_eventful_date = $event['event_start_date'];
|
257 |
+
if( empty($eventful_days_count[$event_eventful_date]) || !$limit || $eventful_days_count[$event_eventful_date] < $limit ){
|
258 |
+
$EM_Event = EM_MS_GLOBAL ? em_get_event($event['post_id'], $event['blog_id']) : em_get_event($event['post_id'], 'post_id');
|
259 |
+
if( empty($eventful_days[$event_eventful_date]) || !is_array($eventful_days[$event_eventful_date]) ) $eventful_days[$event_eventful_date] = array();
|
260 |
+
//add event to array with a corresponding timestamp for sorting of times including long and all-day events
|
261 |
+
$event_ts_marker = ($EM_Event->event_all_day) ? 0 : $EM_Event->start;
|
262 |
+
while( !empty($eventful_days[$event_eventful_date][$event_ts_marker]) ){
|
263 |
+
$event_ts_marker++; //add a second
|
264 |
+
}
|
265 |
+
$eventful_days[$event_eventful_date][$event_ts_marker] = $EM_Event;
|
266 |
+
}
|
267 |
+
//count events for that day
|
268 |
+
$eventful_days_count[$event['event_start_date']] = empty($eventful_days_count[$event['event_start_date']]) ? 1 : $eventful_days_count[$event['event_start_date']]+1;
|
269 |
+
}
|
270 |
+
}
|
271 |
+
}
|
272 |
+
//generate a link argument string containing event search only
|
273 |
+
$day_link_args = self::get_link_args( array_intersect_key($original_args, EM_Events::get_post_search($args, true) ));
|
274 |
+
foreach($eventful_days as $day_key => $events) {
|
275 |
+
if( array_key_exists($day_key, $calendar_array['cells']) ){
|
276 |
+
//Get link title for this date
|
277 |
+
$events_titles = array();
|
278 |
+
foreach($events as $event) {
|
279 |
+
if( !$limit || count($events_titles) < $limit ){
|
280 |
+
$events_titles[] = $event->output($event_title_format);
|
281 |
+
}else{
|
282 |
+
$events_titles[] = get_option('dbem_display_calendar_events_limit_msg');
|
283 |
+
break;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
$calendar_array['cells'][$day_key]['link_title'] = implode( $event_title_separator_format, $events_titles);
|
287 |
+
|
288 |
+
//Get the link to this calendar day
|
289 |
+
global $wp_rewrite;
|
290 |
+
if( count($events) > 1 || !get_option('dbem_calendar_direct_links') ){
|
291 |
+
if( get_option("dbem_events_page") > 0 ){
|
292 |
+
$event_page_link = get_permalink(get_option("dbem_events_page")); //PAGE URI OF EM
|
293 |
+
}else{
|
294 |
+
if( $wp_rewrite->using_permalinks() ){
|
295 |
+
$event_page_link = trailingslashit(home_url()).EM_POST_TYPE_EVENT_SLUG.'/'; //don't use EM_URI here, since ajax calls this before EM_URI is defined.
|
296 |
+
}else{
|
297 |
+
$event_page_link = trailingslashit(home_url()).'?post_type='.EM_POST_TYPE_EVENT; //don't use EM_URI here, since ajax calls this before EM_URI is defined.
|
298 |
+
}
|
299 |
+
}
|
300 |
+
if( $wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS') ){
|
301 |
+
$calendar_array['cells'][$day_key]['link'] = trailingslashit($event_page_link).$day_key."/";
|
302 |
+
if( !empty($day_link_args) ){
|
303 |
+
$calendar_array['cells'][$day_key]['link'] .= '?'.$day_link_args;
|
304 |
+
}
|
305 |
+
}else{
|
306 |
+
$joiner = (stristr($event_page_link, "?")) ? "&" : "?";
|
307 |
+
$calendar_array['cells'][$day_key]['link'] = $event_page_link.$joiner."calendar_day=".$day_key;
|
308 |
+
if( !empty($day_link_args) ){
|
309 |
+
$calendar_array['cells'][$day_key]['link'] .= '&'.$day_link_args;
|
310 |
+
}
|
311 |
+
}
|
312 |
+
}else{
|
313 |
+
foreach($events as $EM_Event){
|
314 |
+
$calendar_array['cells'][$day_key]['link'] = $EM_Event->get_permalink();
|
315 |
+
}
|
316 |
+
}
|
317 |
+
//Add events to array
|
318 |
+
$calendar_array['cells'][$day_key]['events_count'] = $eventful_days_count[$day_key];
|
319 |
+
$calendar_array['cells'][$day_key]['events'] = $events;
|
320 |
+
}
|
321 |
+
}
|
322 |
+
return apply_filters('em_calendar_get',$calendar_array, $args);
|
323 |
+
}
|
324 |
+
|
325 |
+
function output($args = array(), $wrapper = true) {
|
326 |
+
//Let month and year REQUEST override for non-JS users
|
327 |
+
$args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_display_calendar_events_limit'); //limit arg will be used per day and not for events search
|
328 |
+
if( !empty($_REQUEST['mo']) || !empty($args['mo']) ){
|
329 |
+
$args['month'] = ($_REQUEST['mo']) ? $_REQUEST['mo']:$args['mo'];
|
330 |
+
}
|
331 |
+
if( !empty($_REQUEST['yr']) || !empty($args['yr']) ){
|
332 |
+
$args['year'] = (!empty($_REQUEST['yr'])) ? $_REQUEST['yr']:$args['yr'];
|
333 |
+
}
|
334 |
+
$calendar_array = self::get($args);
|
335 |
+
$template = (!empty($args['full'])) ? 'templates/calendar-full.php':'templates/calendar-small.php';
|
336 |
+
ob_start();
|
337 |
+
em_locate_template($template, true, array('calendar'=>$calendar_array,'args'=>$args));
|
338 |
+
if($wrapper){
|
339 |
+
$calendar = '<div id="em-calendar-'.rand(100,200).'" class="em-calendar-wrapper">'.ob_get_clean().'</div>';
|
340 |
+
}else{
|
341 |
+
$calendar = ob_get_clean();
|
342 |
+
}
|
343 |
+
return apply_filters('em_calendar_output', $calendar, $args);
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
function days_in_month($month, $year) {
|
348 |
+
return date('t', mktime(0,0,0,$month,1,$year));
|
349 |
+
}
|
350 |
+
|
351 |
+
function translate_and_trim($string, $length = 1) {
|
352 |
+
if( $length > 0 ){
|
353 |
+
if(function_exists('mb_substr')){ //fix for diacritic calendar names
|
354 |
+
return mb_substr(__($string,'dbem'), 0, $length, 'UTF-8');
|
355 |
+
}else{
|
356 |
+
return substr(__($string,'dbem'), 0, $length);
|
357 |
+
}
|
358 |
+
}
|
359 |
+
return __($string,'dbem');
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Helper function to create a link querystring from array which contains arguments with only values that aren't defuaults.
|
364 |
+
*/
|
365 |
+
function get_link_args($args = array(), $html_entities=true){
|
366 |
+
unset($args['month']); unset($args['year']);
|
367 |
+
$default_args = self::get_default_search(array());
|
368 |
+
foreach($default_args as $arg_key => $arg_value){
|
369 |
+
if( !isset($args[$arg_key]) || $args[$arg_key] == $arg_value ){
|
370 |
+
unset($args[$arg_key]);
|
371 |
+
}
|
372 |
+
}
|
373 |
+
$qs_array = array();
|
374 |
+
foreach($args as $key => $value){
|
375 |
+
if(is_array($value)){
|
376 |
+
$value = implode(',',$value);
|
377 |
+
}
|
378 |
+
$qs_array[] = "$key=".urlencode($value);
|
379 |
+
}
|
380 |
+
return ($html_entities) ? implode('&', $qs_array) : implode('&', $qs_array);
|
381 |
+
}
|
382 |
+
|
383 |
+
|
384 |
+
function get_default_search($array=array()){
|
385 |
+
//These defaults aren't for db queries, but flags for what to display in calendar output
|
386 |
+
$defaults = array(
|
387 |
+
'full' => 0, //Will display a full calendar with event names
|
388 |
+
'long_events' => 0, //Events that last longer than a day
|
389 |
+
'scope' => 'future',
|
390 |
+
'status' => 1, //approved events only
|
391 |
+
'town' => false,
|
392 |
+
'state' => false,
|
393 |
+
'country' => false,
|
394 |
+
'region' => false,
|
395 |
+
'blog' => get_current_blog_id(),
|
396 |
+
'orderby' => get_option('dbem_display_calendar_orderby'),
|
397 |
+
'order' => get_option('dbem_display_calendar_order')
|
398 |
+
);
|
399 |
+
if(is_multisite()){
|
400 |
+
global $bp;
|
401 |
+
if( !is_main_site() && !array_key_exists('blog',$array) ){
|
402 |
+
//not the main blog, force single blog search
|
403 |
+
$array['blog'] = get_current_blog_id();
|
404 |
+
}elseif( empty($array['blog']) && get_site_option('dbem_ms_global_events') ) {
|
405 |
+
$array['blog'] = false;
|
406 |
+
}
|
407 |
+
}
|
408 |
+
$atts = parent::get_default_search($defaults, $array);
|
409 |
+
$atts['full'] = ($atts['full']==true) ? 1:0;
|
410 |
+
$atts['long_events'] = ($atts['long_events']==true) ? 1:0;
|
411 |
+
return apply_filters('em_calendar_get_default_search', $atts, $array, $defaults);
|
412 |
+
}
|
413 |
+
}
|
414 |
+
add_action('init', array('EM_Calendar', 'init'));
|
classes/em-categories-taxonomy.php
ADDED
@@ -0,0 +1,115 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class EM_Categories_Taxonomy{
|
3 |
+
function init(){
|
4 |
+
add_action( EM_TAXONOMY_CATEGORY.'_edit_form_fields', array('EM_Categories_Taxonomy','form'), 10, 1);
|
5 |
+
add_action( EM_TAXONOMY_CATEGORY.'_add_form_fields', array('EM_Categories_Taxonomy','form'), 10, 1);
|
6 |
+
add_action( 'edited_'.EM_TAXONOMY_CATEGORY, array('EM_Categories_Taxonomy','save'), 10, 2);
|
7 |
+
add_action( 'create_'.EM_TAXONOMY_CATEGORY, array('EM_Categories_Taxonomy','save'), 10, 2);
|
8 |
+
add_action( 'delete_'.EM_TAXONOMY_CATEGORY, array('EM_Categories_Taxonomy','delete'), 10, 2);
|
9 |
+
|
10 |
+
add_filter('manage_edit-'.EM_TAXONOMY_CATEGORY.'_columns' , array('EM_Categories_Taxonomy','columns_add'));
|
11 |
+
add_filter('manage_'.EM_TAXONOMY_CATEGORY.'_custom_column' , array('EM_Categories_Taxonomy','columns_output'),10,3);
|
12 |
+
|
13 |
+
self::admin_init();
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
function columns_add($columns) {
|
18 |
+
//prepend ID after checkbox
|
19 |
+
$columns['cat-id'] = __('ID','dbem');
|
20 |
+
return $columns;
|
21 |
+
}
|
22 |
+
|
23 |
+
function columns_output( $val, $column, $term_id ) {
|
24 |
+
switch ( $column ) {
|
25 |
+
case 'cat-id':
|
26 |
+
return $term_id;
|
27 |
+
break;
|
28 |
+
}
|
29 |
+
return $val;
|
30 |
+
}
|
31 |
+
|
32 |
+
function admin_init(){
|
33 |
+
global $pagenow;
|
34 |
+
if($pagenow == 'edit-tags.php' && !empty($_GET['taxonomy']) && $_GET['taxonomy'] == EM_TAXONOMY_CATEGORY){
|
35 |
+
wp_enqueue_style( 'farbtastic' );
|
36 |
+
wp_enqueue_style( 'thickbox' );
|
37 |
+
|
38 |
+
wp_enqueue_script( 'em-categories-admin', plugins_url().'/events-manager/includes/js/categories-admin.js', array( 'jquery','media-upload','thickbox','farbtastic' ) );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
function form($tag){
|
43 |
+
$category_color = '#FFFFFF';
|
44 |
+
$category_image = '';
|
45 |
+
if( $tag != EM_TAXONOMY_CATEGORY ){ //not an add new tag form
|
46 |
+
$EM_Category = new EM_Category($tag);
|
47 |
+
$category_color = $EM_Category->get_color();
|
48 |
+
$category_image = $EM_Category->get_image_url();
|
49 |
+
$category_image_id = $EM_Category->get_image_id();
|
50 |
+
}
|
51 |
+
?>
|
52 |
+
<tr class="form-field">
|
53 |
+
<th scope="row" valign="top"><label for="category-bgcolor">Calendar Color</label></th>
|
54 |
+
<td>
|
55 |
+
<input type="text" name="category_bgcolor" id="category-bgcolor" class="colorwell" value="<?php echo esc_attr($category_color); ?>" style="width:100px;"/><br />
|
56 |
+
<p class="description"><?php echo sprintf(__('Choose a color for your category. You can access this using the %s placeholder.','dbem'),'<code>#_CATEGORYCOLOR</code>'); ?></p>
|
57 |
+
<div id="picker" style="position:absolute; display:none; background:#DEDEDE"></div>
|
58 |
+
</td>
|
59 |
+
</tr>
|
60 |
+
<tr class="form-field">
|
61 |
+
<th scope="row" valign="top"><label for="category-image">Image</label></th>
|
62 |
+
<td>
|
63 |
+
<?php if( !empty($category_image) ): ?>
|
64 |
+
<p><img src="<?php echo $category_image; ?>" /></p>
|
65 |
+
<?php endif; ?>
|
66 |
+
<input type="text" name="category_image" id="category-image" value="<?php echo esc_attr($category_image); ?>" style="width:300px;" />
|
67 |
+
<input type="hidden" name="category_image_id" id="category-image-id" value="<?php echo esc_attr($category_image); ?>" />
|
68 |
+
<input id="upload_image_button" type="button" value="<?php _e('Choose/Upload Image','dbem'); ?>" class="button-secondary" style="width:auto;" /><br />
|
69 |
+
<p class="description"><?php echo sprintf(__('Choose an image for your category, which can be displayed using the %s placeholder.','dbem'),'<code>#_CATEGORYIMAGE</code>'); ?></p>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
<?php
|
73 |
+
}
|
74 |
+
|
75 |
+
function save($term_id, $tt_id){
|
76 |
+
global $wpdb;
|
77 |
+
if (!$term_id) return;
|
78 |
+
if( !empty($_POST['category_bgcolor']) && preg_match('/^#[a-zA-Z0-9]{6}$/', $_POST['category_bgcolor']) ){
|
79 |
+
//get results and save/update
|
80 |
+
$prev_settings = $wpdb->get_results('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$term_id}' AND meta_key='category-bgcolor'");
|
81 |
+
if( count($prev_settings) > 0 ){
|
82 |
+
$wpdb->update(EM_META_TABLE, array('object_id'=>$term_id,'meta_value'=>$_POST['category_bgcolor']), array('object_id'=>$term_id,'meta_key'=>'category-bgcolor'));
|
83 |
+
}else{
|
84 |
+
$wpdb->insert(EM_META_TABLE, array('object_id'=>$term_id,'meta_key'=>'category-bgcolor','meta_value'=>$_POST['category_bgcolor']));
|
85 |
+
}
|
86 |
+
}
|
87 |
+
if( !empty($_POST['category_image']) ){
|
88 |
+
//get results and save/update
|
89 |
+
$prev_settings = $wpdb->get_results('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$term_id}' AND meta_key='category-image'");
|
90 |
+
if( count($prev_settings) > 0 ){
|
91 |
+
$wpdb->update(EM_META_TABLE, array('object_id'=>$term_id,'meta_value'=>$_POST['category_image']), array('object_id'=>$term_id,'meta_key'=>'category-image'));
|
92 |
+
}else{
|
93 |
+
$wpdb->insert(EM_META_TABLE, array('object_id'=>$term_id,'meta_key'=>'category-image','meta_value'=>$_POST['category_image']));
|
94 |
+
}
|
95 |
+
if( !empty($_POST['category_image_id']) && is_numeric($_POST['category_image_id']) ){
|
96 |
+
//get results and save/update
|
97 |
+
$prev_settings = $wpdb->get_results('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$term_id}' AND meta_key='category-image-id'");
|
98 |
+
if( count($prev_settings) > 0 ){
|
99 |
+
$wpdb->update(EM_META_TABLE, array('object_id'=>$term_id,'meta_value'=>$_POST['category_image_id']), array('object_id'=>$term_id,'meta_key'=>'category-image-id'));
|
100 |
+
}else{
|
101 |
+
$wpdb->insert(EM_META_TABLE, array('object_id'=>$term_id,'meta_key'=>'category-image-id','meta_value'=>$_POST['category_image_id']));
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
function delete( $term_id ){
|
108 |
+
global $wpdb;
|
109 |
+
//delete category image and color
|
110 |
+
$wpdb->query('DELETE FROM '.EM_META_TABLE." WHERE object_id='$term_id' AND (meta_key='category-image' OR meta_key='category-bgcolor')");
|
111 |
+
//delete all events category relations
|
112 |
+
$wpdb->query('DELETE FROM '.EM_META_TABLE." WHERE meta_value='{$term_id}' AND meta_key='event-category'");
|
113 |
+
}
|
114 |
+
}
|
115 |
+
add_action('admin_init',array('EM_Categories_Taxonomy','init'));
|
classes/em-categories.php
CHANGED
@@ -1,157 +1,283 @@
|
|
1 |
-
<?php
|
2 |
-
class EM_Categories extends EM_Object {
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
$
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
//
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
$
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
);
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
$
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
157 |
Â
}
|
1 |
+
<?php
|
2 |
+
class EM_Categories extends EM_Object implements Iterator{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Array of EM_Category objects for a specific event
|
6 |
+
* @var array
|
7 |
+
*/
|
8 |
+
var $categories = array();
|
9 |
+
/**
|
10 |
+
* Event ID of this set of categories
|
11 |
+
* @var int
|
12 |
+
*/
|
13 |
+
var $event_id;
|
14 |
+
/**
|
15 |
+
* Post ID of this set of categories
|
16 |
+
* @var int
|
17 |
+
*/
|
18 |
+
var $post_id;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Creates an EM_Categories instance, currently accepts an EM_Event object (gets all Categories for that event) or array of any EM_Category objects, which can be manipulated in bulk with helper functions.
|
22 |
+
* @param mixed $data
|
23 |
+
* @return null
|
24 |
+
*/
|
25 |
+
function EM_Categories( $data = false ){
|
26 |
+
global $wpdb;
|
27 |
+
$this->ms_global_switch();
|
28 |
+
if( is_object($data) && get_class($data) == "EM_Event" && !empty($data->post_id) ){ //Creates a blank categories object if needed
|
29 |
+
$this->event_id = $data->event_id;
|
30 |
+
$this->post_id = $data->post_id;
|
31 |
+
if( EM_MS_GLOBAL && !is_main_site($data->blog_id) ){
|
32 |
+
$cat_ids = $wpdb->get_col('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$this->event_id}' AND meta_key='event-category'");
|
33 |
+
foreach($cat_ids as $cat_id){
|
34 |
+
$this->categories[$cat_id] = new EM_Category($cat_id);
|
35 |
+
}
|
36 |
+
}else{
|
37 |
+
$results = get_the_terms( $data->post_id, EM_TAXONOMY_CATEGORY );
|
38 |
+
if( is_array($results) ){
|
39 |
+
foreach($results as $result){
|
40 |
+
$this->categories[$result->term_id] = new EM_Category($result);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}elseif( is_array($data) && $this->array_is_numeric($data) ){
|
45 |
+
foreach($data as $category_id){
|
46 |
+
$this->categories[$category_id] = new EM_Category($category_id);
|
47 |
+
}
|
48 |
+
}elseif( is_array($data) ){
|
49 |
+
foreach( $data as $EM_Category ){
|
50 |
+
if( get_class($EM_Category) == 'EM_Category'){
|
51 |
+
$this->categories[] = $EM_Category;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
$this->ms_global_switch_back();
|
56 |
+
do_action('em_categories', $this);
|
57 |
+
}
|
58 |
+
|
59 |
+
function get_post(){
|
60 |
+
$this->ms_global_switch();
|
61 |
+
$this->categories = array();
|
62 |
+
if(!empty($_POST['event_categories']) && $this->array_is_numeric($_POST['event_categories'])){
|
63 |
+
foreach( $_POST['event_categories'] as $term ){
|
64 |
+
$this->categories[$term] = new EM_Category($term);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
$this->ms_global_switch_back();
|
68 |
+
do_action('em_categories_get_post', $this);
|
69 |
+
}
|
70 |
+
|
71 |
+
function save(){
|
72 |
+
$term_slugs = array();
|
73 |
+
foreach($this->categories as $EM_Category){
|
74 |
+
/* @var $EM_Category EM_Category */
|
75 |
+
if( !empty($EM_Category->slug) ) $term_slugs[] = $EM_Category->slug; //save of category will soft-fail if slug is empty
|
76 |
+
}
|
77 |
+
if( count($term_slugs) == 0 && get_option('dbem_default_category') > 0 ){
|
78 |
+
$default_term = get_term_by('id',get_option('dbem_default_category'), EM_TAXONOMY_CATEGORY);
|
79 |
+
if($default_term) $term_slugs[] = $default_term->slug;
|
80 |
+
}
|
81 |
+
if( count($term_slugs) > 0 ){
|
82 |
+
if( is_multisite() ){
|
83 |
+
//In MS Global mode, we also save category meta information for global lookups
|
84 |
+
if( EM_MS_GLOBAL && !empty($this->event_id) ){
|
85 |
+
//delete categories
|
86 |
+
$this->save_index();
|
87 |
+
}
|
88 |
+
if( !EM_MS_GLOBAL || is_main_site() ){
|
89 |
+
wp_set_object_terms($this->post_id, $term_slugs, EM_TAXONOMY_CATEGORY);
|
90 |
+
}
|
91 |
+
}else{
|
92 |
+
wp_set_object_terms($this->post_id, $term_slugs, EM_TAXONOMY_CATEGORY);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
do_action('em_categories_save', $this);
|
96 |
+
}
|
97 |
+
|
98 |
+
function save_index(){
|
99 |
+
global $wpdb;
|
100 |
+
$wpdb->query('DELETE FROM '.EM_META_TABLE." WHERE object_id='{$this->event_id}' AND meta_key='event-category'");
|
101 |
+
foreach($this->categories as $EM_Category){
|
102 |
+
$wpdb->insert(EM_META_TABLE, array('meta_value'=>$EM_Category->term_id,'object_id'=>$this->event_id,'meta_key'=>'event-category'));
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
function get( $args = array() ) {
|
107 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
108 |
+
self::ms_global_switch();
|
109 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
110 |
+
$results = get_terms( EM_TAXONOMY_CATEGORY );
|
111 |
+
$categories = array();
|
112 |
+
foreach($results as $result){
|
113 |
+
if( in_array($result->term_id, $args) ){
|
114 |
+
$categories[$result->term_id] = new EM_Category($result);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}else{
|
118 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
119 |
+
$term_args = self::get_default_search($args);
|
120 |
+
$results = get_terms( EM_TAXONOMY_CATEGORY, $term_args);
|
121 |
+
|
122 |
+
//If we want results directly in an array, why not have a shortcut here? We don't use this in code, so if you're using it and filter the em_categories_get hook, you may want to do this one too.
|
123 |
+
if( !empty($args['array']) ){
|
124 |
+
return apply_filters('em_categories_get_array', $results, $args);
|
125 |
+
}
|
126 |
+
|
127 |
+
//Make returned results EM_Category objects
|
128 |
+
$results = (is_array($results)) ? $results:array();
|
129 |
+
$categories = array();
|
130 |
+
foreach ( $results as $category ){
|
131 |
+
$categories[$category->term_id] = new EM_Category($category);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
self::ms_global_switch_back();
|
135 |
+
return apply_filters('em_categories_get', $categories, $args);
|
136 |
+
}
|
137 |
+
|
138 |
+
function output( $args ){
|
139 |
+
global $EM_Category;
|
140 |
+
$EM_Category_old = $EM_Category; //When looping, we can replace EM_Category global with the current event in the loop
|
141 |
+
//get page number if passed on by request (still needs pagination enabled to have effect)
|
142 |
+
if( !array_key_exists('page',$args) && !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ){
|
143 |
+
$page = $args['page'] = $_REQUEST['pno'];
|
144 |
+
}
|
145 |
+
//Can be either an array for the get search or an array of EM_Category objects
|
146 |
+
if( is_object(current($args)) && get_class((current($args))) == 'EM_Category' ){
|
147 |
+
$func_args = func_get_args();
|
148 |
+
$categories = $func_args[0];
|
149 |
+
$args = (!empty($func_args[1])) ? $func_args[1] : array();
|
150 |
+
$args = apply_filters('em_categories_output_args', self::get_default_search($args), $categories);
|
151 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
152 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
153 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
154 |
+
}else{
|
155 |
+
$args = apply_filters('em_categories_output_args', self::get_default_search($args) );
|
156 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
157 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
158 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
159 |
+
$args['limit'] = $args['offset'] = $args['page'] = false; //we count overall categories here
|
160 |
+
$categories = self::get( $args );
|
161 |
+
$args['limit'] = $limit;
|
162 |
+
$args['offset'] = $offset;
|
163 |
+
$args['page'] = $page;
|
164 |
+
}
|
165 |
+
//What format shall we output this to, or use default
|
166 |
+
$format = ( $args['format'] == '' ) ? get_option( 'dbem_categories_list_item_format' ) : $args['format'] ;
|
167 |
+
|
168 |
+
$output = "";
|
169 |
+
$categories_count = count($categories);
|
170 |
+
$categories = apply_filters('em_categories_output_categories', $categories);
|
171 |
+
if ( count($categories) > 0 ) {
|
172 |
+
$category_count = 0;
|
173 |
+
$categories_shown = 0;
|
174 |
+
foreach ( $categories as $EM_Category ) {
|
175 |
+
if( ($categories_shown < $limit || empty($limit)) && ($category_count >= $offset || $offset === 0) ){
|
176 |
+
$output .= $EM_Category->output($format);
|
177 |
+
$categories_shown++;
|
178 |
+
}
|
179 |
+
$category_count++;
|
180 |
+
}
|
181 |
+
//Add headers and footers to output
|
182 |
+
if( $format == get_option ( 'dbem_categories_list_item_format' ) ){
|
183 |
+
$single_event_format_header = get_option ( 'dbem_categories_list_item_format_header' );
|
184 |
+
$single_event_format_header = ( $single_event_format_header != '' ) ? $single_event_format_header : "<ul class='em-categories-list'>";
|
185 |
+
$single_event_format_footer = get_option ( 'dbem_categories_list_item_format_footer' );
|
186 |
+
$single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
|
187 |
+
$output = $single_event_format_header . $output . $single_event_format_footer;
|
188 |
+
}
|
189 |
+
//Pagination (if needed/requested)
|
190 |
+
if( !empty($args['pagination']) && !empty($limit) && $categories_count >= $limit ){
|
191 |
+
//Show the pagination links (unless there's less than 10 events, or the custom limit)
|
192 |
+
$output .= apply_filters('em_categories_output_pagination', self::get_pagination_links($args, $categories_count, 'search_cats', self::get_default_search()), '', $categories_count, $limit, $page);
|
193 |
+
}
|
194 |
+
} else {
|
195 |
+
$output = get_option ( 'dbem_no_categories_message' );
|
196 |
+
}
|
197 |
+
//FIXME check if reference is ok when restoring object, due to changes in php5 v 4
|
198 |
+
$EM_Category_old= $EM_Category;
|
199 |
+
return apply_filters('em_categories_output', $output, $categories, $args);
|
200 |
+
}
|
201 |
+
|
202 |
+
function has( $search ){
|
203 |
+
if( is_numeric($search) ){
|
204 |
+
foreach($this->categories as $EM_Category){
|
205 |
+
if($EM_Category->term_id == $search) return apply_filters('em_categories_has', true, $search, $this);
|
206 |
+
}
|
207 |
+
}else{
|
208 |
+
foreach($this->categories as $EM_Category){
|
209 |
+
if($EM_Category->slug == $search || $EM_Category->name == $search ) return apply_filters('em_categories_has', true, $search, $this);
|
210 |
+
}
|
211 |
+
}
|
212 |
+
return apply_filters('em_categories_has', false, $search, $this);
|
213 |
+
}
|
214 |
+
|
215 |
+
function get_first(){
|
216 |
+
foreach($this->categories as $EM_Category){
|
217 |
+
return $EM_Category;
|
218 |
+
}
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
function get_ids(){
|
223 |
+
$ids = array();
|
224 |
+
foreach($this->categories as $EM_Category){
|
225 |
+
if( !empty($EM_Category->term_id) ){
|
226 |
+
$ids[] = $EM_Category->term_id;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
return $ids;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Gets the event for this object, or a blank event if none exists
|
234 |
+
* @return EM_Event
|
235 |
+
*/
|
236 |
+
function get_event(){
|
237 |
+
if( is_numeric($this->event_id) ){
|
238 |
+
return em_get_event($this->event_id);
|
239 |
+
}else{
|
240 |
+
return new EM_Event();
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
/*
|
245 |
+
* Adds custom categories search defaults
|
246 |
+
* @param array $array
|
247 |
+
* @return array
|
248 |
+
* @uses EM_Object#get_default_search()
|
249 |
+
*/
|
250 |
+
function get_default_search( $array = array() ){
|
251 |
+
$defaults = array(
|
252 |
+
//added from get_terms, so they don't get filtered out
|
253 |
+
'orderby' => get_option('dbem_categories_default_orderby'), 'order' => get_option('dbem_categories_default_order'),
|
254 |
+
'hide_empty' => false, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(),
|
255 |
+
'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
|
256 |
+
'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
|
257 |
+
'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core'
|
258 |
+
);
|
259 |
+
return apply_filters('em_categories_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
|
260 |
+
}
|
261 |
+
|
262 |
+
//Iterator Implementation
|
263 |
+
public function rewind(){
|
264 |
+
reset($this->categories);
|
265 |
+
}
|
266 |
+
public function current(){
|
267 |
+
$var = current($this->categories);
|
268 |
+
return $var;
|
269 |
+
}
|
270 |
+
public function key(){
|
271 |
+
$var = key($this->categories);
|
272 |
+
return $var;
|
273 |
+
}
|
274 |
+
public function next(){
|
275 |
+
$var = next($this->categories);
|
276 |
+
return $var;
|
277 |
+
}
|
278 |
+
public function valid(){
|
279 |
+
$key = key($this->categories);
|
280 |
+
$var = ($key !== NULL && $key !== FALSE);
|
281 |
+
return $var;
|
282 |
+
}
|
283 |
Â
}
|
classes/em-category-taxonomy.php
ADDED
@@ -0,0 +1,181 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class EM_Category_Taxonomy{
|
3 |
+
function init(){
|
4 |
+
if( !is_admin() ){
|
5 |
+
add_filter('archive_template', array('EM_Category_Taxonomy','template'));
|
6 |
+
add_filter('category_template', array('EM_Category_Taxonomy','template'));
|
7 |
+
add_filter('parse_query', array('EM_Category_Taxonomy','parse_query'));
|
8 |
+
}
|
9 |
+
}
|
10 |
+
/**
|
11 |
+
* Overrides archive pages e.g. locations, events, event categories, event tags based on user settings
|
12 |
+
* @param string $template
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
function template($template){
|
16 |
+
global $wp_query, $EM_Category, $em_category_id, $post;
|
17 |
+
if( is_tax(EM_TAXONOMY_CATEGORY) && get_option('dbem_cp_categories_formats', true) ){
|
18 |
+
$EM_Category = em_get_category($wp_query->queried_object->term_id);
|
19 |
+
if( get_option('dbem_categories_page') ){
|
20 |
+
//less chance for things to go wrong with themes etc. so just reset the WP_Query to think it's a page rather than taxonomy
|
21 |
+
$wp_query = new WP_Query(array('page_id'=> get_option('dbem_categories_page')));
|
22 |
+
$wp_query->post->post_title = $wp_query->posts[0]->post_title = $wp_query->queried_object->post_title = $EM_Category->output(get_option('dbem_category_page_title_format'));
|
23 |
+
if( !function_exists('yoast_breadcrumb') ){ //not needed by WP SEO Breadcrumbs
|
24 |
+
$wp_query->post->post_parent = $wp_query->posts[0]->post_parent = $wp_query->queried_object->post_parent = $EM_Category->output(get_option('dbem_categories_page'));
|
25 |
+
}
|
26 |
+
$wp_query->queried_object = $wp_query->post;
|
27 |
+
$wp_query->queried_object_id = $wp_query->post->ID;
|
28 |
+
$post = $wp_query->post;
|
29 |
+
}else{
|
30 |
+
//we don't have a categories page, so we create a fake page
|
31 |
+
$wp_query->posts = array();
|
32 |
+
$wp_query->posts[0] = new stdClass();
|
33 |
+
$wp_query->posts[0]->post_title = $wp_query->queried_object->post_title = $EM_Category->output(get_option('dbem_category_page_title_format'));
|
34 |
+
$post_array = array('ID', 'post_author', 'post_date','post_date_gmt','post_content','post_excerpt','post_status','comment_status','ping_status','post_password','post_name','to_ping','pinged','post_modified','post_modified_gmt','post_content_filtered','post_parent','guid','menu_order','post_type','post_mime_type','comment_count','filter');
|
35 |
+
foreach($post_array as $post_array_item){
|
36 |
+
$wp_query->posts[0]->$post_array_item = '';
|
37 |
+
}
|
38 |
+
$wp_query->post = $wp_query->posts[0];
|
39 |
+
$wp_query->post_count = 1;
|
40 |
+
$wp_query->found_posts = 1;
|
41 |
+
$wp_query->max_num_pages = 1;
|
42 |
+
//tweak flags for determining page type
|
43 |
+
$wp_query->is_tax = 0;
|
44 |
+
$wp_query->is_page = 1;
|
45 |
+
$wp_query->is_single = 0;
|
46 |
+
$wp_query->is_singular = 1;
|
47 |
+
$wp_query->is_archive = 0;
|
48 |
+
}
|
49 |
+
remove_filter('the_content', 'em_content'); //one less filter
|
50 |
+
add_filter('the_content', array('EM_Category_Taxonomy','the_content')); //come in slightly early and consider other plugins
|
51 |
+
add_filter('wpseo_breadcrumb_links',array('EM_Category_Taxonomy','wpseo_breadcrumb_links')); //for Yoast WP SEO
|
52 |
+
$wp_query->em_category_id = $em_category_id = $EM_Category->term_id; //we assign $em_category_id just in case other themes/plugins do something out of the ordinary to WP_Query
|
53 |
+
$template = locate_template(array('page.php','index.php'),false); //category becomes a page
|
54 |
+
}
|
55 |
+
return $template;
|
56 |
+
}
|
57 |
+
|
58 |
+
function the_content($content){
|
59 |
+
global $wp_query, $EM_Category, $post, $em_category_id;
|
60 |
+
$is_categories_page = $post->ID == get_option('dbem_categories_page');
|
61 |
+
$category_flag = (!empty($wp_query->em_category_id) || !empty($em_category_id));
|
62 |
+
if( ($is_categories_page && $category_flag) || (empty($post->ID) && $category_flag) ){
|
63 |
+
$EM_Category = empty($wp_query->em_category_id) ? em_get_category($em_category_id):em_get_category($wp_query->em_category_id);
|
64 |
+
ob_start();
|
65 |
+
em_locate_template('templates/category-single.php',true);
|
66 |
+
return ob_get_clean();
|
67 |
+
}
|
68 |
+
return $content;
|
69 |
+
}
|
70 |
+
|
71 |
+
function parse_query( ){
|
72 |
+
global $wp_query, $post;
|
73 |
+
if( is_tax(EM_TAXONOMY_CATEGORY) ){
|
74 |
+
//Scope is future
|
75 |
+
$today = strtotime(date('Y-m-d', current_time('timestamp')));
|
76 |
+
if( get_option('dbem_events_current_are_past') ){
|
77 |
+
$wp_query->query_vars['meta_query'][] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '>=' );
|
78 |
+
}else{
|
79 |
+
$wp_query->query_vars['meta_query'][] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
80 |
+
}
|
81 |
+
if( get_option('dbem_categories_default_archive_orderby') == 'title'){
|
82 |
+
$wp_query->query_vars['orderby'] = 'title';
|
83 |
+
}else{
|
84 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
85 |
+
$wp_query->query_vars['meta_key'] = get_option('dbem_categories_default_archive_orderby','_start_ts');
|
86 |
+
}
|
87 |
+
$wp_query->query_vars['order'] = get_option('dbem_categories_default_archive_order','ASC');
|
88 |
+
}elseif( !empty($wp_query->em_category_id) ){
|
89 |
+
$post = $wp_query->post;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
function wpseo_breadcrumb_links( $links ){
|
94 |
+
global $wp_query;
|
95 |
+
array_pop($links);
|
96 |
+
if( get_option('dbem_categories_page') ){
|
97 |
+
$links[] = array('id'=> get_option('dbem_categories_page'));
|
98 |
+
}
|
99 |
+
$links[] = array('text'=> $wp_query->posts[0]->post_title);
|
100 |
+
return $links;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
EM_Category_Taxonomy::init();
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Create an array of Categories. Copied from Walker_CategoryDropdown, but makes it possible for the selected argument to be an array.
|
107 |
+
*
|
108 |
+
* @package WordPress
|
109 |
+
* @since 2.1.0
|
110 |
+
* @uses Walker
|
111 |
+
*/
|
112 |
+
class EM_Walker_Category extends Walker {
|
113 |
+
/**
|
114 |
+
* @see Walker::$tree_type
|
115 |
+
* @since 2.1.0
|
116 |
+
* @var string
|
117 |
+
*/
|
118 |
+
var $tree_type = 'event-category';
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @see Walker::$db_fields
|
122 |
+
* @since 2.1.0
|
123 |
+
* @todo Decouple this
|
124 |
+
* @var array
|
125 |
+
*/
|
126 |
+
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
|
127 |
+
|
128 |
+
function __construct(){
|
129 |
+
$tree_type = EM_TAXONOMY_CATEGORY;
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* @see Walker::start_el()
|
133 |
+
* @since 2.1.0
|
134 |
+
*
|
135 |
+
* @param string $output Passed by reference. Used to append additional content.
|
136 |
+
* @param object $category Category data object.
|
137 |
+
* @param int $depth Depth of category. Used for padding.
|
138 |
+
* @param array $args Uses 'selected', 'show_count', and 'show_last_update' etc. keys, if they exist.
|
139 |
+
*/
|
140 |
+
function start_el(&$output, $category, $depth, $args) {
|
141 |
+
$pad = str_repeat(' ', $depth * 3);
|
142 |
+
$cat_name = $category->name;
|
143 |
+
$name = !empty($args['name']) ? $args['name']:'event_categories[]';
|
144 |
+
$output .= !empty($args['before']) ? $args['after']:'';
|
145 |
+
$output .= $pad."<input type=\"checkbox\" name=\"$name\" class=\"level-$depth\" value=\"".$category->term_id."\"";
|
146 |
+
if ( (is_array($args['selected']) && in_array($category->term_id, $args['selected'])) || ($category->term_id == $args['selected']) )
|
147 |
+
$output .= ' checked="checked"';
|
148 |
+
$output .= ' /> ';
|
149 |
+
$output .= $cat_name;
|
150 |
+
$output .= !empty($args['after']) ? $args['after']:'<br />';
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Create an array of Categories. Copied from Walker_CategoryDropdown, but makes it possible for the selected argument to be an array.
|
156 |
+
*
|
157 |
+
* @package WordPress
|
158 |
+
* @since 2.1.0
|
159 |
+
* @uses Walker
|
160 |
+
*/
|
161 |
+
class EM_Walker_CategoryMultiselect extends EM_Walker_Category {
|
162 |
+
/**
|
163 |
+
* @see Walker::start_el()
|
164 |
+
* @since 2.1.0
|
165 |
+
*
|
166 |
+
* @param string $output Passed by reference. Used to append additional content.
|
167 |
+
* @param object $category Category data object.
|
168 |
+
* @param int $depth Depth of category. Used for padding.
|
169 |
+
* @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist.
|
170 |
+
*/
|
171 |
+
function start_el(&$output, $category, $depth, $args) {
|
172 |
+
$pad = str_repeat(' ', $depth * 3);
|
173 |
+
$cat_name = $category->name;
|
174 |
+
$output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
|
175 |
+
if ( (is_array($args['selected']) && in_array($category->term_id, $args['selected'])) || ($category->term_id == $args['selected']) )
|
176 |
+
$output .= ' selected="selected"';
|
177 |
+
$output .= '>';
|
178 |
+
$output .= $pad.$cat_name;
|
179 |
+
$output .= "</option>\n";
|
180 |
+
}
|
181 |
+
}
|
classes/em-category.php
CHANGED
@@ -1,152 +1,251 @@
|
|
1 |
-
<?php
|
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 |
-
$category
|
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 |
-
function
|
82 |
-
|
83 |
-
|
84 |
-
$
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
return
|
107 |
-
}
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
152 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Get an category in a db friendly way, by checking globals and passed variables to avoid extra class instantiations
|
4 |
+
* @param mixed $id
|
5 |
+
* @return EM_Category
|
6 |
+
*/
|
7 |
+
function em_get_category($id = false) {
|
8 |
+
global $EM_Category;
|
9 |
+
//check if it's not already global so we don't instantiate again
|
10 |
+
if( is_object($EM_Category) && get_class($EM_Category) == 'EM_Category' ){
|
11 |
+
if( $EM_Category->term_id == $id ){
|
12 |
+
return $EM_Category;
|
13 |
+
}elseif( is_object($id) && $EM_Category->term_id == $id->term_id ){
|
14 |
+
return $EM_Category;
|
15 |
+
}
|
16 |
+
}
|
17 |
+
if( is_object($id) && get_class($id) == 'EM_Category' ){
|
18 |
+
return $id;
|
19 |
+
}else{
|
20 |
+
return new EM_Category($id);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
class EM_Category extends EM_Object {
|
24 |
+
//Taxonomy Fields
|
25 |
+
var $id = '';
|
26 |
+
var $term_id;
|
27 |
+
var $name;
|
28 |
+
var $slug;
|
29 |
+
var $term_group;
|
30 |
+
var $term_taxonomy_id;
|
31 |
+
var $taxonomy;
|
32 |
+
var $description = '';
|
33 |
+
var $parent = 0;
|
34 |
+
var $count;
|
35 |
+
//extra attributes imposed by EM_Category
|
36 |
+
var $image_url = '';
|
37 |
+
var $color;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Gets data from POST (default), supplied array, or from the database if an ID is supplied
|
41 |
+
* @param $category_data
|
42 |
+
* @return null
|
43 |
+
*/
|
44 |
+
function EM_Category( $category_data = false ) {
|
45 |
+
global $wpdb;
|
46 |
+
$this->ms_global_switch();
|
47 |
+
//Initialize
|
48 |
+
$category = array();
|
49 |
+
if( !empty($category_data) ){
|
50 |
+
//Load category data
|
51 |
+
if( is_object($category_data) && !empty($category_data->taxonomy) && $category_data->taxonomy == EM_TAXONOMY_CATEGORY ){
|
52 |
+
$category = $category_data;
|
53 |
+
}elseif( !is_numeric($category_data) ){
|
54 |
+
$category = get_term_by('slug', $category_data, EM_TAXONOMY_CATEGORY);
|
55 |
+
if( !$category ){
|
56 |
+
$category = get_term_by('name', $category_data, EM_TAXONOMY_CATEGORY);
|
57 |
+
}
|
58 |
+
}else{
|
59 |
+
$category = get_term_by('id', $category_data, EM_TAXONOMY_CATEGORY);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
if( is_object($category) || is_array($category) ){
|
63 |
+
foreach($category as $key => $value){
|
64 |
+
$this->$key = $value;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
$this->id = $this->term_id; //backward compatability
|
68 |
+
$this->ms_global_switch_back();
|
69 |
+
do_action('em_category',$this, $category_data);
|
70 |
+
}
|
71 |
+
|
72 |
+
function get_color(){
|
73 |
+
if( empty($this->color) ){
|
74 |
+
global $wpdb;
|
75 |
+
$color = $wpdb->get_var('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$this->term_id}' AND meta_key='category-bgcolor' LIMIT 1");
|
76 |
+
$this->color = ($color != '') ? $color:'#FFFFFF';
|
77 |
+
}
|
78 |
+
return $this->color;
|
79 |
+
}
|
80 |
+
|
81 |
+
function get_image_url(){
|
82 |
+
if( empty($this->image_url) ){
|
83 |
+
global $wpdb;
|
84 |
+
$image_url = $wpdb->get_var('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$this->term_id}' AND meta_key='category-image' LIMIT 1");
|
85 |
+
$this->image_url = ($image_url != '') ? $image_url:'';
|
86 |
+
}
|
87 |
+
return $this->image_url;
|
88 |
+
}
|
89 |
+
|
90 |
+
function get_image_id(){
|
91 |
+
if( empty($this->image_id) ){
|
92 |
+
global $wpdb;
|
93 |
+
$image_id = $wpdb->get_var('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$this->term_id}' AND meta_key='category-image-id' LIMIT 1");
|
94 |
+
$this->image_id = ($image_id != '') ? $image_id:'';
|
95 |
+
}
|
96 |
+
return $this->image_id;
|
97 |
+
}
|
98 |
+
|
99 |
+
function get_url(){
|
100 |
+
if( empty($this->link) ){
|
101 |
+
$this->ms_global_switch();
|
102 |
+
$this->link = get_term_link($this->slug, EM_TAXONOMY_CATEGORY);
|
103 |
+
$this->ms_global_switch_back();
|
104 |
+
if ( is_wp_error($this->link) ) $this->link = '';
|
105 |
+
}
|
106 |
+
return $this->link;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Depreciated, don't use.
|
111 |
+
* @return mixed
|
112 |
+
*/
|
113 |
+
function has_events(){
|
114 |
+
global $wpdb;
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
|
118 |
+
function output_single($target = 'html'){
|
119 |
+
$format = get_option ( 'dbem_category_page_format' );
|
120 |
+
return apply_filters('em_category_output_single', $this->output($format, $target), $this, $target);
|
121 |
+
}
|
122 |
+
|
123 |
+
function output($format, $target="html") {
|
124 |
+
preg_match_all('/\{([a-zA-Z0-9_]+)\}([^{]+)\{\/[a-zA-Z0-9_]+\}/', $format, $conditionals);
|
125 |
+
if( count($conditionals[0]) > 0 ){
|
126 |
+
//Check if the language we want exists, if not we take the first language there
|
127 |
+
foreach($conditionals[1] as $key => $condition){
|
128 |
+
$format = str_replace($conditionals[0][$key], apply_filters('em_category_output_condition', '', $condition, $conditionals[0][$key], $this), $format);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
$category_string = $format;
|
132 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
|
133 |
+
$replaces = array();
|
134 |
+
foreach($placeholders[1] as $key => $result) {
|
135 |
+
$replace = '';
|
136 |
+
$full_result = $placeholders[0][$key];
|
137 |
+
switch( $result ){
|
138 |
+
case '#_CATEGORYNAME':
|
139 |
+
$replace = $this->name;
|
140 |
+
break;
|
141 |
+
case '#_CATEGORYID':
|
142 |
+
$replace = $this->term_id;
|
143 |
+
break;
|
144 |
+
case '#_CATEGORYNOTES':
|
145 |
+
case '#_CATEGORYDESCRIPTION':
|
146 |
+
$replace = $this->description;
|
147 |
+
break;
|
148 |
+
case '#_CATEGORYIMAGE':
|
149 |
+
case '#_CATEGORYIMAGEURL':
|
150 |
+
if( $this->get_image_url() != ''){
|
151 |
+
if($result == '#_CATEGORYIMAGEURL'){
|
152 |
+
$replace = $this->get_image_url();
|
153 |
+
}else{
|
154 |
+
if( empty($placeholders[3][$key]) ){
|
155 |
+
$replace = "<img src='".esc_url($this->get_image_url())."' alt='".esc_attr($this->name)."'/>";
|
156 |
+
}else{
|
157 |
+
$image_size = explode(',', $placeholders[3][$key]);
|
158 |
+
if( $this->array_is_numeric($image_size) && count($image_size) > 1 ){
|
159 |
+
if( get_option('dbem_disable_timthumb') && $this->get_image_id() ){
|
160 |
+
//since we previously didn't store image ids along with the url to the image (since taxonomies don't allow normal featured images), sometimes we won't be able to do this, which is why we check there's a valid image id first
|
161 |
+
$this->ms_global_switch();
|
162 |
+
$replace = wp_get_attachment_image($this->get_image_id(), $image_size);
|
163 |
+
$this->ms_global_switch_back();
|
164 |
+
}else{
|
165 |
+
$width = ($image_size[0]) ? 'width="'.esc_attr($image_size[0]).'"':'';
|
166 |
+
$height = ($image_size[1]) ? 'height="'.esc_attr($image_size[1]).'"':'';
|
167 |
+
$replace = "<img src='".esc_url(em_get_thumbnail_url($this->get_image_url(), $image_size[0], $image_size[1]))."' alt='".esc_attr($this->name)."' $width $height />";
|
168 |
+
}
|
169 |
+
}else{
|
170 |
+
$replace = "<img src='".esc_url($this->get_image_url())."' alt='".esc_attr($this->name)."'/>";
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
break;
|
176 |
+
case '#_CATEGORYCOLOR':
|
177 |
+
$replace = $this->get_color();
|
178 |
+
break;
|
179 |
+
case '#_CATEGORYLINK':
|
180 |
+
case '#_CATEGORYURL':
|
181 |
+
$link = $this->get_url();
|
182 |
+
$replace = ($result == '#_CATEGORYURL') ? $link : '<a href="'.$link.'">'.esc_html($this->name).'</a>';
|
183 |
+
break;
|
184 |
+
case '#_CATEGORYSLUG':
|
185 |
+
$replace = $this->slug;
|
186 |
+
break;
|
187 |
+
case '#_CATEGORYEVENTSPAST': //depreciated, erroneous documentation, left for compatability
|
188 |
+
case '#_CATEGORYEVENTSNEXT': //depreciated, erroneous documentation, left for compatability
|
189 |
+
case '#_CATEGORYEVENTSALL': //depreciated, erroneous documentation, left for compatability
|
190 |
+
case '#_CATEGORYPASTEVENTS':
|
191 |
+
case '#_CATEGORYNEXTEVENTS':
|
192 |
+
case '#_CATEGORYALLEVENTS':
|
193 |
+
//convert depreciated placeholders for compatability
|
194 |
+
$result = ($result == '#_CATEGORYEVENTSPAST') ? '#_CATEGORYPASTEVENTS':$result;
|
195 |
+
$result = ($result == '#_CATEGORYEVENTSNEXT') ? '#_CATEGORYNEXTEVENTS':$result;
|
196 |
+
$result = ($result == '#_CATEGORYEVENTSALL') ? '#_CATEGORYALLEVENTS':$result;
|
197 |
+
//forget it ever happened? :/
|
198 |
+
if ($result == '#_CATEGORYPASTEVENTS'){ $scope = 'past'; }
|
199 |
+
elseif ( $result == '#_CATEGORYNEXTEVENTS' ){ $scope = 'future'; }
|
200 |
+
else{ $scope = 'all'; }
|
201 |
+
$events_count = EM_Events::count( array('category'=>$this->term_id, 'scope'=>$scope) );
|
202 |
+
if ( $events_count > 0 ){
|
203 |
+
$args = array('category'=>$this->term_id, 'scope'=>$scope, 'pagination'=>1, 'ajax'=>0);
|
204 |
+
$args['format_header'] = get_option('dbem_category_event_list_item_header_format');
|
205 |
+
$args['format_footer'] = get_option('dbem_category_event_list_item_footer_format');
|
206 |
+
$args['format'] = get_option('dbem_category_event_list_item_format');
|
207 |
+
$args['limit'] = get_option('dbem_category_event_list_limit');
|
208 |
+
$args['page'] = (!empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) )? $_REQUEST['pno'] : 1;
|
209 |
+
$replace = EM_Events::output($args);
|
210 |
+
} else {
|
211 |
+
$replace = get_option('dbem_category_no_events_message','</ul>');
|
212 |
+
}
|
213 |
+
break;
|
214 |
+
case '#_CATEGORYNEXTEVENT':
|
215 |
+
$events = EM_Events::get( array('category'=>$this->term_id, 'scope'=>'future', 'limit'=>1, 'orderby'=>'event_start_date,event_start_time') );
|
216 |
+
$replace = get_option('dbem_category_no_event_message');
|
217 |
+
foreach($events as $EM_Event){
|
218 |
+
$replace = $EM_Event->output(get_option('dbem_category_event_single_format'));
|
219 |
+
}
|
220 |
+
break;
|
221 |
+
default:
|
222 |
+
$replace = $full_result;
|
223 |
+
break;
|
224 |
+
}
|
225 |
+
$replaces[$full_result] = apply_filters('em_category_output_placeholder', $replace, $this, $full_result, $target);
|
226 |
+
}
|
227 |
+
krsort($replaces);
|
228 |
+
foreach($replaces as $full_result => $replacement){
|
229 |
+
$category_string = str_replace($full_result, $replacement , $category_string );
|
230 |
+
}
|
231 |
+
return apply_filters('em_category_output', $category_string, $this, $format, $target);
|
232 |
+
}
|
233 |
+
|
234 |
+
function can_manage( $capability_owner = 'edit_categories', $capability_admin = false ){
|
235 |
+
global $em_capabilities_array;
|
236 |
+
//Figure out if this is multisite and require an extra bit of validation
|
237 |
+
$multisite_check = true;
|
238 |
+
$can_manage = current_user_can($capability_owner);
|
239 |
+
//if multisite and supoer admin, just return true
|
240 |
+
if( is_multisite() && is_super_admin() ){ return true; }
|
241 |
+
if( EM_MS_GLOBAL && !is_main_site() ){
|
242 |
+
//User can't admin this bit, as they're on a sub-blog
|
243 |
+
$can_manage = false;
|
244 |
+
if(array_key_exists($capability_owner, $em_capabilities_array) ){
|
245 |
+
$this->add_error( $em_capabilities_array[$capability_owner]);
|
246 |
+
}
|
247 |
+
}
|
248 |
+
return $can_manage;
|
249 |
+
}
|
250 |
+
}
|
251 |
Â
?>
|
classes/em-event-post-admin.php
ADDED
@@ -0,0 +1,406 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Events Edit Page
|
4 |
+
*/
|
5 |
+
class EM_Event_Post_Admin{
|
6 |
+
public static function init(){
|
7 |
+
global $pagenow;
|
8 |
+
if($pagenow == 'post.php' || $pagenow == 'post-new.php' ){ //only needed if editing post
|
9 |
+
add_action('admin_head', array('EM_Event_Post_Admin','admin_head'));
|
10 |
+
//Meta Boxes
|
11 |
+
add_action('add_meta_boxes', array('EM_Event_Post_Admin','meta_boxes'));
|
12 |
+
//Notices
|
13 |
+
add_action('admin_notices',array('EM_Event_Post_Admin','admin_notices'));
|
14 |
+
}
|
15 |
+
//Save/Edit actions
|
16 |
+
add_filter('wp_insert_post_data',array('EM_Event_Post_Admin','wp_insert_post_data'),100,2); //validate post meta before saving is done
|
17 |
+
add_action('save_post',array('EM_Event_Post_Admin','save_post'),1,1); //set to 1 so metadata gets saved ASAP
|
18 |
+
add_action('before_delete_post',array('EM_Event_Post_Admin','before_delete_post'),10,1);
|
19 |
+
add_action('trashed_post',array('EM_Event_Post_Admin','trashed_post'),10,1);
|
20 |
+
add_action('untrash_post',array('EM_Event_Post_Admin','untrash_post'),10,1);
|
21 |
+
add_action('untrashed_post',array('EM_Event_Post_Admin','untrashed_post'),10,1);
|
22 |
+
//Notices
|
23 |
+
add_action('post_updated_messages',array('EM_Event_Post_Admin','admin_notices_filter'),1,1);
|
24 |
+
}
|
25 |
+
|
26 |
+
public static function admin_head(){
|
27 |
+
global $post, $EM_Event;
|
28 |
+
if( !empty($post) && $post->post_type == EM_POST_TYPE_EVENT ){
|
29 |
+
$EM_Event = em_get_event($post->ID, 'post_id');
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
public static function admin_notices(){
|
34 |
+
//When editing
|
35 |
+
global $post, $EM_Event, $pagenow;
|
36 |
+
if( $pagenow == 'post.php' && ($post->post_type == EM_POST_TYPE_EVENT || $post->post_type == 'event-recurring') ){
|
37 |
+
if ( $EM_Event->is_recurring() ) {
|
38 |
+
$warning = "<p><strong>".__( 'WARNING: This is a recurring event.', 'dbem' )."</strong></p>";
|
39 |
+
$warning .= "<p>". __( 'Modifications to this event will cause all recurrences of this event to be deleted and recreated and previous bookings will be deleted! You can edit individual recurrences and disassociate them with this recurring event.', 'dbem' );
|
40 |
+
?><div class="updated"><?php echo $warning; ?></div><?php
|
41 |
+
} elseif ( $EM_Event->is_recurrence() ) {
|
42 |
+
$warning = "<p><strong>".__('WARNING: This is a recurrence in a set of recurring events.', 'dbem')."</strong></p>";
|
43 |
+
$warning .= "<p>". sprintf(__('If you update this event data and save, it could get overwritten if you edit the recurring event template. To make it an independent, <a href="%s">detach it</a>.', 'dbem' ), $EM_Event->get_detach_url())."</p>";
|
44 |
+
$warning .= "<p>".sprintf(__('To manage the whole set, <a href="%s">edit the recurring event template</a>.', 'dbem'),admin_url('post.php?action=edit&post='.$EM_Event->get_event_recurrence()->post_id))."</p>";
|
45 |
+
?><div class="updated"><?php echo $warning; ?></div><?php
|
46 |
+
}
|
47 |
+
if( !empty($EM_Event->group_id) && function_exists('groups_get_group') ){
|
48 |
+
$group = groups_get_group(array('group_id'=>$EM_Event->group_id));
|
49 |
+
$warning = sprintf(__('WARNING: This is a event belonging to the group "%s". Other group admins can also modify this event.', 'dbem'), $group->name);
|
50 |
+
?><div class="updated"><p><?php echo $warning; ?></p></div><?php
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
public static function admin_notices_filter($messages){
|
56 |
+
//When editing
|
57 |
+
global $post, $EM_Notices;
|
58 |
+
if( $post->post_type == EM_POST_TYPE_EVENT || $post->post_type == 'event-recurring' ){
|
59 |
+
if ( $EM_Notices->count_errors() > 0 ) {
|
60 |
+
unset($_GET['message']);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
return $messages;
|
64 |
+
}
|
65 |
+
|
66 |
+
public static function wp_insert_post_data( $data, $postarr ){
|
67 |
+
global $wpdb, $EM_Event, $EM_Location, $EM_Notices;
|
68 |
+
$post_type = $data['post_type'];
|
69 |
+
$post_ID = !empty($postarr['ID']) ? $postarr['ID'] : false;
|
70 |
+
$is_post_type = $post_type == EM_POST_TYPE_EVENT || $post_type == 'event-recurring';
|
71 |
+
$saving_status = !in_array($data['post_status'], array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
72 |
+
$untrashing = $post_ID && defined('UNTRASHING_'.$post_ID);
|
73 |
+
if( !$untrashing && $is_post_type && $saving_status ){
|
74 |
+
if( !empty($_REQUEST['_emnonce']) && wp_verify_nonce($_REQUEST['_emnonce'], 'edit_event') ){
|
75 |
+
//this is only run if we know form data was submitted, hence the nonce
|
76 |
+
$EM_Event = em_get_event();
|
77 |
+
//Handle Errors by making post draft
|
78 |
+
$get_meta = $EM_Event->get_post_meta();
|
79 |
+
$validate_meta = $EM_Event->validate_meta();
|
80 |
+
if( !$get_meta || !$validate_meta ) $data['post_status'] = 'draft';
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $data;
|
84 |
+
}
|
85 |
+
|
86 |
+
public static function save_post($post_id){
|
87 |
+
global $wpdb, $EM_Event, $EM_Location, $EM_Notices;
|
88 |
+
$post_type = get_post_type($post_id);
|
89 |
+
$is_post_type = $post_type == EM_POST_TYPE_EVENT || $post_type == 'event-recurring';
|
90 |
+
$saving_status = !in_array(get_post_status($post_id), array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
91 |
+
if(!defined('UNTRASHING_'.$post_id) && $is_post_type && $saving_status ){
|
92 |
+
if( !empty($_REQUEST['_emnonce']) && wp_verify_nonce($_REQUEST['_emnonce'], 'edit_event') ){
|
93 |
+
//this is only run if we know form data was submitted, hence the nonce
|
94 |
+
$EM_Event = em_get_event($post_id, 'post_id');
|
95 |
+
do_action('em_event_save_pre', $EM_Event); //technically, the event is saved... but the meta isn't. wp doesn't give an pre-intervention action for this (or does it?)
|
96 |
+
//Handle Errors by making post draft
|
97 |
+
$get_meta = $EM_Event->get_post_meta();
|
98 |
+
$validate_meta = $EM_Event->validate_meta();
|
99 |
+
$save_meta = $EM_Event->save_meta();
|
100 |
+
$EM_Event->get_categories()->save(); //save categories in case of default category
|
101 |
+
if( !$get_meta || !$validate_meta || !$save_meta ){
|
102 |
+
//failed somewhere, set to draft, don't publish
|
103 |
+
$EM_Event->set_status(null, true);
|
104 |
+
if( $EM_Event->is_recurring() ){
|
105 |
+
$EM_Notices->add_error( '<strong>'.__('Your event details are incorrect and recurrences cannot be created, please correct these errors first:','dbem').'</strong>', true); //Always seems to redirect, so we make it static
|
106 |
+
}else{
|
107 |
+
$EM_Notices->add_error( '<strong>'.sprintf(__('Your %s details are incorrect and cannot be published, please correct these errors first:','dbem'),__('event','dbem')).'</strong>', true); //Always seems to redirect, so we make it static
|
108 |
+
}
|
109 |
+
$EM_Notices->add_error($EM_Event->get_errors(), true); //Always seems to redirect, so we make it static
|
110 |
+
apply_filters('em_event_save', false, $EM_Event);
|
111 |
+
}else{
|
112 |
+
//if this is just published, we need to email the user about the publication, or send to pending mode again for review
|
113 |
+
if( (!$EM_Event->is_recurring() && !current_user_can('publish_events')) || ($EM_Event->is_recurring() && !current_user_can('publish_recurring_events')) ){
|
114 |
+
if( $EM_Event->is_published() ){ $EM_Event->set_status(0, true); } //no publishing and editing... security threat
|
115 |
+
}
|
116 |
+
apply_filters('em_event_save', true, $EM_Event);
|
117 |
+
}
|
118 |
+
}else{
|
119 |
+
//we're updating only the quick-edit style information, which is only post info saved into the index
|
120 |
+
$EM_Event = em_get_event($post_id, 'post_id'); //grab event, via post info
|
121 |
+
if( $EM_Event->validate() ){
|
122 |
+
do_action('em_event_save_pre', $EM_Event); //technically, the event is saved... but the meta isn't. wp doesn't give an pre-intervention action for this (or does it?)
|
123 |
+
//first things first, we must make sure we have an index, if not, reset it to a new one:
|
124 |
+
$event_truly_exists = $wpdb->get_var('SELECT event_id FROM '.EM_EVENTS_TABLE." WHERE event_id={$EM_Event->event_id}") == $EM_Event->event_id;
|
125 |
+
if(empty($EM_Event->event_id) || !$event_truly_exists){ $EM_Event->save_meta(); }
|
126 |
+
//we can save the status now
|
127 |
+
$EM_Event->get_previous_status(); //before we save anything
|
128 |
+
$event_status = $EM_Event->get_status(true);
|
129 |
+
//if this is just published, we need to email the user about the publication, or send to pending mode again for review
|
130 |
+
if( (!$EM_Event->is_recurring() && !current_user_can('publish_events')) || ($EM_Event->is_recurring() && !current_user_can('publish_recurring_events')) ){
|
131 |
+
if( $EM_Event->is_published() ){ $EM_Event->set_status(0, true); } //no publishing and editing... security threat
|
132 |
+
}
|
133 |
+
//now update the db
|
134 |
+
$where_array = array($EM_Event->event_name, $EM_Event->event_owner, $EM_Event->event_slug, $EM_Event->event_private, $EM_Event->event_id);
|
135 |
+
$sql = $wpdb->prepare("UPDATE ".EM_EVENTS_TABLE." SET event_name=%s, event_owner=%d, event_slug=%s, event_status={$event_status}, event_private=%d WHERE event_id=%d", $where_array);
|
136 |
+
$wpdb->query($sql);
|
137 |
+
if( $EM_Event->is_recurring() && $EM_Event->is_published()){
|
138 |
+
//recurrences are (re)saved only if event is published
|
139 |
+
$EM_Event->save_events();
|
140 |
+
}
|
141 |
+
apply_filters('em_event_save', true, $EM_Event);
|
142 |
+
}else{
|
143 |
+
do_action('em_event_save_pre', $EM_Event); //technically, the event is saved... but the meta isn't. wp doesn't give an pre-intervention action for this (or does it?)
|
144 |
+
//Event doesn't validate, so set status to null
|
145 |
+
$EM_Event->set_status(null, true);
|
146 |
+
apply_filters('em_event_save', false, $EM_Event);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
self::maybe_publish_location($EM_Event);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Publish the location if the event has just been approved and the location is pending. We assume an editor published the event and approves the location too.
|
155 |
+
* @param EM_Event $EM_Event
|
156 |
+
*/
|
157 |
+
public static function maybe_publish_location($EM_Event){
|
158 |
+
//do a dirty update for location too if it's not published
|
159 |
+
if( $EM_Event->is_published() && !empty($EM_Event->location_id) ){
|
160 |
+
$EM_Location = $EM_Event->get_location();
|
161 |
+
if( $EM_Location->location_status !== 1 ){
|
162 |
+
//let's also publish the location
|
163 |
+
$EM_Location->set_status(1, true);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
public static function before_delete_post($post_id){
|
169 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
170 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
171 |
+
do_action('em_event_delete_pre ',$EM_Event);
|
172 |
+
$EM_Event->delete_meta();
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
public static function trashed_post($post_id){
|
177 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
178 |
+
global $EM_Notices;
|
179 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
180 |
+
$EM_Event->set_status(-1);
|
181 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
public static function untrash_post($post_id){
|
186 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
187 |
+
//set a constant so we know this event doesn't need 'saving'
|
188 |
+
if(!defined('UNTRASHING_'.$post_id)) define('UNTRASHING_'.$post_id, true);
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
public static function untrashed_post($post_id){
|
193 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
194 |
+
global $EM_Notices, $EM_Event;
|
195 |
+
$EM_Event = new EM_Event($post_id, 'post_id'); //get a refreshed $EM_Event because otherwise statuses don't get updated by WP
|
196 |
+
$EM_Event->set_status( $EM_Event->get_status() );
|
197 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
public static function meta_boxes(){
|
202 |
+
global $EM_Event;
|
203 |
+
if( !empty($EM_Event->event_owner_anonymous) ){
|
204 |
+
add_meta_box('em-event-anonymous', __('Anonymous Submitter Info','dbem'), array('EM_Event_Post_Admin','meta_box_anonymous'),EM_POST_TYPE_EVENT, 'side','high');
|
205 |
+
}
|
206 |
+
add_meta_box('em-event-when', __('When','dbem'), array('EM_Event_Post_Admin','meta_box_date'),EM_POST_TYPE_EVENT, 'side','high');
|
207 |
+
if(get_option('dbem_locations_enabled', true)){
|
208 |
+
add_meta_box('em-event-where', __('Where','dbem'), array('EM_Event_Post_Admin','meta_box_location'),EM_POST_TYPE_EVENT, 'normal','high');
|
209 |
+
}
|
210 |
+
if( defined('WP_DEBUG') && WP_DEBUG ){
|
211 |
+
add_meta_box('em-event-meta', 'Event Meta (debugging only)', array('EM_Event_Post_Admin','meta_box_metadump'),EM_POST_TYPE_EVENT, 'normal','high');
|
212 |
+
}
|
213 |
+
if(get_option('dbem_rsvp_enabled', true)){
|
214 |
+
add_meta_box('em-event-bookings', __('Bookings/Registration','dbem'), array('EM_Event_Post_Admin','meta_box_bookings'),EM_POST_TYPE_EVENT, 'normal','high');
|
215 |
+
if( !empty($EM_Event->event_id) && $EM_Event->event_rsvp ){
|
216 |
+
add_meta_box('em-event-bookings-stats', __('Bookings Stats','dbem'), array('EM_Event_Post_Admin','meta_box_bookings_stats'),EM_POST_TYPE_EVENT, 'side','core');
|
217 |
+
}
|
218 |
+
}
|
219 |
+
if( get_option('dbem_attributes_enabled', true) ){
|
220 |
+
add_meta_box('em-event-attributes', __('Attributes','dbem'), array('EM_Event_Post_Admin','meta_box_attributes'),EM_POST_TYPE_EVENT, 'normal','default');
|
221 |
+
}
|
222 |
+
if( EM_MS_GLOBAL && !is_main_site() && get_option('dbem_categories_enabled') ){
|
223 |
+
add_meta_box('em-event-categories', __('Site Categories','dbem'), array('EM_Event_Post_Admin','meta_box_ms_categories'),EM_POST_TYPE_EVENT, 'side','low');
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
public static function meta_box_metadump(){
|
228 |
+
global $post,$EM_Event;
|
229 |
+
echo "<pre>"; print_r($EM_Event); echo "</pre>";
|
230 |
+
}
|
231 |
+
|
232 |
+
public static function meta_box_anonymous(){
|
233 |
+
global $EM_Event;
|
234 |
+
?>
|
235 |
+
<div class='updated'><p><?php _e('This event was submitted by a guest. You will find their details in the <em>Anonymous Submitter Info</em> box','dbem')?></p></div>
|
236 |
+
<p><strong><?php _e('Name','dbem'); ?> :</strong> <?php echo $EM_Event->event_owner_name; ?></p>
|
237 |
+
<p><strong><?php _e('Name','dbem'); ?> :</strong> <?php echo $EM_Event->event_owner_email; ?></p>
|
238 |
+
<?php
|
239 |
+
}
|
240 |
+
|
241 |
+
public static function meta_box_date(){
|
242 |
+
//create meta box check of date nonce
|
243 |
+
?><input type="hidden" name="_emnonce" value="<?php echo wp_create_nonce('edit_event'); ?>" /><?php
|
244 |
+
em_locate_template('forms/event/when.php', true);
|
245 |
+
}
|
246 |
+
|
247 |
+
public static function meta_box_bookings_stats(){
|
248 |
+
em_locate_template('forms/event/booking-stats.php',true);
|
249 |
+
}
|
250 |
+
|
251 |
+
public static function meta_box_bookings(){
|
252 |
+
em_locate_template('forms/event/bookings.php', true);
|
253 |
+
add_action('admin_footer',array('EM_Event_Post_Admin','meta_box_bookings_overlay'));
|
254 |
+
}
|
255 |
+
|
256 |
+
public static function meta_box_bookings_overlay(){
|
257 |
+
em_locate_template('forms/tickets-form.php', true); //put here as it can't be in the add event form
|
258 |
+
}
|
259 |
+
|
260 |
+
public static function meta_box_attributes(){
|
261 |
+
em_locate_template('forms/event/attributes.php',true);
|
262 |
+
}
|
263 |
+
|
264 |
+
public static function meta_box_location(){
|
265 |
+
em_locate_template('forms/event/location.php',true);
|
266 |
+
}
|
267 |
+
|
268 |
+
public static function meta_box_ms_categories(){
|
269 |
+
global $EM_Event;
|
270 |
+
EM_Object::ms_global_switch();
|
271 |
+
$categories = EM_Categories::get(array('hide_empty'=>false));
|
272 |
+
?>
|
273 |
+
<?php if( count($categories) > 0 ): ?>
|
274 |
+
<p class="ms-global-categories">
|
275 |
+
<?php $selected = $EM_Event->get_categories()->get_ids(); ?>
|
276 |
+
<?php $walker = new EM_Walker_Category(); ?>
|
277 |
+
<?php $args_em = array( 'hide_empty' => 0, 'name' => 'event_categories[]', 'hierarchical' => true, 'id' => EM_TAXONOMY_CATEGORY, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'walker'=> $walker); ?>
|
278 |
+
<?php echo walk_category_dropdown_tree($categories, 0, $args_em); ?>
|
279 |
+
</p>
|
280 |
+
<?php else: ?>
|
281 |
+
<p><?php sprintf(__('No categories available, <a href="%s">create one here first</a>','dbem'), get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-categories'); ?></p>
|
282 |
+
<?php endif; ?>
|
283 |
+
<!-- END Categories -->
|
284 |
+
<?php
|
285 |
+
EM_Object::ms_global_switch_back();
|
286 |
+
}
|
287 |
+
}
|
288 |
+
add_action('admin_init',array('EM_Event_Post_Admin','init'));
|
289 |
+
|
290 |
+
/*
|
291 |
+
* Recurring Events
|
292 |
+
*/
|
293 |
+
class EM_Event_Recurring_Post_Admin{
|
294 |
+
public static function init(){
|
295 |
+
global $pagenow;
|
296 |
+
if($pagenow == 'post.php' || $pagenow == 'post-new.php' ){ //only needed if editing post
|
297 |
+
add_action('admin_head', array('EM_Event_Recurring_Post_Admin','admin_head'));
|
298 |
+
//Meta Boxes
|
299 |
+
add_action('add_meta_boxes', array('EM_Event_Recurring_Post_Admin','meta_boxes'));
|
300 |
+
//Notices
|
301 |
+
add_action('admin_notices',array('EM_Event_Post_Admin','admin_notices')); //shared with posts
|
302 |
+
}
|
303 |
+
//Save/Edit actions
|
304 |
+
add_action('before_delete_post',array('EM_Event_Recurring_Post_Admin','before_delete_post'),10,1);
|
305 |
+
add_action('trashed_post',array('EM_Event_Recurring_Post_Admin','trashed_post'),10,1);
|
306 |
+
add_action('untrash_post',array('EM_Event_Recurring_Post_Admin','untrash_post'),10,1);
|
307 |
+
add_action('untrashed_post',array('EM_Event_Recurring_Post_Admin','untrashed_post'),10,1);
|
308 |
+
//Notices
|
309 |
+
add_action('post_updated_messages',array('EM_Event_Post_Admin','admin_notices_filter'),1,1); //shared with posts
|
310 |
+
}
|
311 |
+
|
312 |
+
public static function admin_head(){
|
313 |
+
global $post, $EM_Event;
|
314 |
+
if( !empty($post) && $post->post_type == 'event-recurring' ){
|
315 |
+
$EM_Event = em_get_event($post->ID, 'post_id');
|
316 |
+
//quick hacks to make event admin table make more sense for events
|
317 |
+
?>
|
318 |
+
<script type="text/javascript">
|
319 |
+
jQuery(document).ready( function($){
|
320 |
+
if(!EM.recurrences_menu){
|
321 |
+
$('#menu-posts-'+EM.event_post_type+', #menu-posts-'+EM.event_post_type+' > a').addClass('wp-has-current-submenu');
|
322 |
+
}
|
323 |
+
});
|
324 |
+
</script>
|
325 |
+
<?php
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
public static function before_delete_post($post_id){
|
330 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
331 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
332 |
+
do_action('em_event_delete_pre ',$EM_Event);
|
333 |
+
//now delete recurrences
|
334 |
+
$events_array = EM_Events::get( array('recurrence'=>$EM_Event->event_id, 'scope'=>'all', 'status'=>'all' ) );
|
335 |
+
foreach($events_array as $event){
|
336 |
+
/* @var $event EM_Event */
|
337 |
+
if($EM_Event->event_id == $event->recurrence_id && !empty($event->recurrence_id) ){ //double check the event is a recurrence of this event
|
338 |
+
wp_delete_post($event->post_id, true);
|
339 |
+
}
|
340 |
+
}
|
341 |
+
$EM_Event->post_type = EM_POST_TYPE_EVENT; //trick it into thinking it's one event.
|
342 |
+
$EM_Event->delete_meta();
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
public static function trashed_post($post_id){
|
347 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
348 |
+
global $EM_Notices, $wpdb;
|
349 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
350 |
+
$EM_Event->set_status(null);
|
351 |
+
//now trash recurrences
|
352 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$EM_Event->event_id, 'scope'=>'all', 'status'=>'all' ) );
|
353 |
+
foreach($events_array as $event){
|
354 |
+
/* @var $event EM_Event */
|
355 |
+
if($EM_Event->event_id == $event->recurrence_id ){ //double check the event is a recurrence of this event
|
356 |
+
wp_trash_post($event->post_id);
|
357 |
+
}
|
358 |
+
}
|
359 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
public static function untrash_post($post_id){
|
364 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
365 |
+
global $wpdb;
|
366 |
+
//set a constant so we know this event doesn't need 'saving'
|
367 |
+
if(!defined('UNTRASHING_'.$post_id)) define('UNTRASHING_'.$post_id, true);
|
368 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
369 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$EM_Event->event_id, 'scope'=>'all', 'status'=>'all' ) );
|
370 |
+
foreach($events_array as $event){
|
371 |
+
/* @var $event EM_Event */
|
372 |
+
if($EM_Event->event_id == $event->recurrence_id){
|
373 |
+
wp_untrash_post($event->post_id);
|
374 |
+
}
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
public static function untrashed_post($post_id){
|
380 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
381 |
+
global $EM_Notices,$EM_Event;
|
382 |
+
$EM_Event->set_status(1);
|
383 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
public static function meta_boxes(){
|
388 |
+
add_meta_box('em-event-recurring', __('Recurrences','dbem'), array('EM_Event_Recurring_Post_Admin','meta_box_recurrence'),'event-recurring', 'normal','high');
|
389 |
+
//add_meta_box('em-event-meta', 'Event Meta (debugging only)', array('EM_Event_Post_Admin','meta_box_metadump'),'event-recurring', 'normal','high');
|
390 |
+
add_meta_box('em-event-where', __('Where','dbem'), array('EM_Event_Post_Admin','meta_box_location'),'event-recurring', 'normal','high');
|
391 |
+
if(get_option('dbem_rsvp_enabled')){
|
392 |
+
add_meta_box('em-event-bookings', __('Bookings/Registration','dbem'), array('EM_Event_Post_Admin','meta_box_bookings'),'event-recurring', 'normal','high');
|
393 |
+
}
|
394 |
+
if( get_option('dbem_attributes_enabled') ){
|
395 |
+
add_meta_box('em-event-attributes', __('Attributes','dbem'), array('EM_Event_Post_Admin','meta_box_attributes'),'event-recurring', 'normal','default');
|
396 |
+
}
|
397 |
+
if( EM_MS_GLOBAL && !is_main_site() && get_option('dbem_categories_enabled') ){
|
398 |
+
add_meta_box('em-event-categories', __('Site Categories','dbem'), array('EM_Event_Post_Admin','meta_box_ms_categories'),'event-recurring', 'side','low');
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
public static function meta_box_recurrence(){
|
403 |
+
em_locate_template('forms/event/recurring-when.php', true);
|
404 |
+
}
|
405 |
+
}
|
406 |
+
add_action('admin_init',array('EM_Event_Recurring_Post_Admin','init'));
|
classes/em-event-post.php
ADDED
@@ -0,0 +1,337 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Controls how events are queried and displayed via the WordPress Custom Post APIs
|
4 |
+
* @author marcus
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class EM_Event_Post {
|
8 |
+
function init(){
|
9 |
+
global $wp_query;
|
10 |
+
//Front Side Modifiers
|
11 |
+
if( !is_admin() ){
|
12 |
+
//override single page with formats?
|
13 |
+
add_filter('the_content', array('EM_Event_Post','the_content'));
|
14 |
+
add_filter('the_excerpt_rss', array('EM_Event_Post','the_excerpt_rss'));
|
15 |
+
//display as page template?
|
16 |
+
if( get_option('dbem_cp_events_template') ){
|
17 |
+
add_filter('single_template',array('EM_Event_Post','single_template'));
|
18 |
+
}
|
19 |
+
//add classes to body and post_class()
|
20 |
+
if( get_option('dbem_cp_events_post_class') != '' ){
|
21 |
+
add_filter('post_class', array('EM_Event_Post','post_class'), 10, 3);
|
22 |
+
}
|
23 |
+
if( get_option('dbem_cp_events_body_class') != '' ){
|
24 |
+
add_filter('body_class', array('EM_Event_Post','body_class'), 10, 3);
|
25 |
+
}
|
26 |
+
//Override post template tags
|
27 |
+
add_filter('the_date',array('EM_Event_Post','the_date'),10,2);
|
28 |
+
add_filter('get_the_date',array('EM_Event_Post','the_date'),10,2);
|
29 |
+
add_filter('the_time',array('EM_Event_Post','the_time'),10,2);
|
30 |
+
add_filter('get_the_time',array('EM_Event_Post','the_time'),10,2);
|
31 |
+
add_filter('the_category',array('EM_Event_Post','the_category'),10,3);
|
32 |
+
}
|
33 |
+
add_action('parse_query', array('EM_Event_Post','parse_query'));
|
34 |
+
add_action('publish_future_post',array('EM_Event_Post','publish_future_post'),10,1);
|
35 |
+
}
|
36 |
+
|
37 |
+
function publish_future_post($post_id){
|
38 |
+
global $wpdb, $EM_Event, $EM_Location, $EM_Notices;
|
39 |
+
$post_type = get_post_type($post_id);
|
40 |
+
$is_post_type = $post_type == EM_POST_TYPE_EVENT || $post_type == 'event-recurring';
|
41 |
+
$saving_status = !in_array(get_post_status($post_id), array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
42 |
+
if(!defined('UNTRASHING_'.$post_id) && $is_post_type && $saving_status ){
|
43 |
+
$EM_Event = em_get_event($post_id, 'post_id');
|
44 |
+
$EM_Event->set_status(1);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Overrides the default post format of an event and can display an event as a page, which uses the page.php template.
|
50 |
+
* @param string $template
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
function single_template($template){
|
54 |
+
global $post;
|
55 |
+
if( !locate_template('single-'.EM_POST_TYPE_EVENT.'.php') && $post->post_type == EM_POST_TYPE_EVENT ){
|
56 |
+
//do we have a default template to choose for events?
|
57 |
+
if( get_option('dbem_cp_events_template') == 'page' ){
|
58 |
+
$post_templates = array('page.php','index.php');
|
59 |
+
}else{
|
60 |
+
$post_templates = array(get_option('dbem_cp_events_template'));
|
61 |
+
}
|
62 |
+
if( !empty($post_templates) ){
|
63 |
+
$post_template = locate_template($post_templates,false);
|
64 |
+
if( !empty($post_template) ) $template = $post_template;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
return $template;
|
68 |
+
}
|
69 |
+
|
70 |
+
function post_class( $classes, $class, $post_id ){
|
71 |
+
$post = get_post($post_id);
|
72 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
73 |
+
foreach( explode(' ', get_option('dbem_cp_events_post_class')) as $class ){
|
74 |
+
$classes[] = esc_attr($class);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
return $classes;
|
78 |
+
}
|
79 |
+
|
80 |
+
function body_class( $classes ){
|
81 |
+
if( em_is_event_page() ){
|
82 |
+
foreach( explode(' ', get_option('dbem_cp_events_body_class')) as $class ){
|
83 |
+
$classes[] = esc_attr($class);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return $classes;
|
87 |
+
}
|
88 |
+
|
89 |
+
function the_excerpt_rss( $content ){
|
90 |
+
global $post, $EM_Event;
|
91 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
92 |
+
if( get_option('dbem_cp_events_formats') ){
|
93 |
+
$EM_Event = em_get_event($post);
|
94 |
+
$content = $EM_Event->output( get_option ( 'dbem_rss_description_format' ), "rss");
|
95 |
+
$content = ent2ncr(convert_chars($content)); //Some RSS filtering
|
96 |
+
}
|
97 |
+
}
|
98 |
+
return $content;
|
99 |
+
}
|
100 |
+
|
101 |
+
function the_content( $content ){
|
102 |
+
global $post, $EM_Event;
|
103 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
104 |
+
if( is_archive() || is_search() ){
|
105 |
+
if(get_option('dbem_cp_events_archive_formats')){
|
106 |
+
$EM_Event = em_get_event($post);
|
107 |
+
$content = $EM_Event->output(get_option('dbem_event_list_item_format'));
|
108 |
+
}
|
109 |
+
}else{
|
110 |
+
if( get_option('dbem_cp_events_formats') && !post_password_required() ){
|
111 |
+
$EM_Event = em_get_event($post);
|
112 |
+
ob_start();
|
113 |
+
em_locate_template('templates/event-single.php',true);
|
114 |
+
$content = ob_get_clean();
|
115 |
+
}elseif( !post_password_required() ){
|
116 |
+
$EM_Event = em_get_event($post);
|
117 |
+
if( $EM_Event->event_rsvp ){
|
118 |
+
$content .= $EM_Event->output('<h2>Bookings</h2>#_BOOKINGFORM');
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
return $content;
|
124 |
+
}
|
125 |
+
|
126 |
+
function the_date( $the_date, $d = '' ){
|
127 |
+
global $post;
|
128 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
129 |
+
$EM_Event = em_get_event($post);
|
130 |
+
if ( '' == $d ){
|
131 |
+
$the_date = date_i18n(get_option('date_format'), $EM_Event->start);
|
132 |
+
}else{
|
133 |
+
$the_date = date_i18n($d, $EM_Event->start);
|
134 |
+
}
|
135 |
+
}
|
136 |
+
return $the_date;
|
137 |
+
}
|
138 |
+
|
139 |
+
function the_time( $the_time, $f = '' ){
|
140 |
+
global $post;
|
141 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
142 |
+
$EM_Event = em_get_event($post);
|
143 |
+
if ( '' == $f ){
|
144 |
+
$the_time = date_i18n(get_option('time_format'), $EM_Event->start);
|
145 |
+
}else{
|
146 |
+
$the_time = date_i18n($f, $EM_Event->start);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
return $the_time;
|
150 |
+
}
|
151 |
+
|
152 |
+
function the_category( $thelist, $separator = '', $parents='' ){
|
153 |
+
global $post, $wp_rewrite;
|
154 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
155 |
+
$EM_Event = em_get_event($post);
|
156 |
+
$categories = $EM_Event->get_categories();
|
157 |
+
if( empty($categories) ) return '';
|
158 |
+
|
159 |
+
/* Copied from get_the_category_list function, with a few minor edits to make urls work, and removing parent stuff (for now) */
|
160 |
+
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
|
161 |
+
|
162 |
+
$thelist = '';
|
163 |
+
if ( '' == $separator ) {
|
164 |
+
$thelist .= '<ul class="post-categories">';
|
165 |
+
foreach ( $categories as $category ) {
|
166 |
+
$thelist .= "\n\t<li>";
|
167 |
+
switch ( strtolower( $parents ) ) {
|
168 |
+
case 'multiple':
|
169 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
|
170 |
+
break;
|
171 |
+
case 'single':
|
172 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>';
|
173 |
+
$thelist .= $category->name.'</a></li>';
|
174 |
+
break;
|
175 |
+
case '':
|
176 |
+
default:
|
177 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
|
178 |
+
}
|
179 |
+
}
|
180 |
+
$thelist .= '</ul>';
|
181 |
+
} else {
|
182 |
+
$i = 0;
|
183 |
+
foreach ( $categories as $category ) {
|
184 |
+
if ( 0 < $i )
|
185 |
+
$thelist .= $separator;
|
186 |
+
switch ( strtolower( $parents ) ) {
|
187 |
+
case 'multiple':
|
188 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
|
189 |
+
break;
|
190 |
+
case 'single':
|
191 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>';
|
192 |
+
$thelist .= "$category->name</a>";
|
193 |
+
break;
|
194 |
+
case '':
|
195 |
+
default:
|
196 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
|
197 |
+
}
|
198 |
+
++$i;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
/* End copying */
|
202 |
+
}
|
203 |
+
return $thelist;
|
204 |
+
}
|
205 |
+
|
206 |
+
function parse_query(){
|
207 |
+
global $wp_query;
|
208 |
+
//Search Query Filtering
|
209 |
+
if( is_admin() ){
|
210 |
+
if( !empty($wp_query->query_vars[EM_TAXONOMY_CATEGORY]) && is_numeric($wp_query->query_vars[EM_TAXONOMY_CATEGORY]) ){
|
211 |
+
//sorts out filtering admin-side as it searches by id
|
212 |
+
$term = get_term_by('id', $wp_query->query_vars[EM_TAXONOMY_CATEGORY], EM_TAXONOMY_CATEGORY);
|
213 |
+
$wp_query->query_vars[EM_TAXONOMY_CATEGORY] = ( $term !== false && !is_wp_error($term) )? $term->slug:0;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
//Scoping
|
217 |
+
if( !empty($wp_query->query_vars['post_type']) && ($wp_query->query_vars['post_type'] == EM_POST_TYPE_EVENT || $wp_query->query_vars['post_type'] == 'event-recurring') && (empty($wp_query->query_vars['post_status']) || !in_array($wp_query->query_vars['post_status'],array('trash','pending','draft'))) ) {
|
218 |
+
//Let's deal with the scope - default is future
|
219 |
+
if( is_admin() ){
|
220 |
+
$scope = $wp_query->query_vars['scope'] = (!empty($_REQUEST['scope'])) ? $_REQUEST['scope']:'future';
|
221 |
+
//TODO limit what a user can see admin side for events/locations/recurring events
|
222 |
+
}else{
|
223 |
+
if( !empty($wp_query->query_vars['calendar_day']) ) $wp_query->query_vars['scope'] = $wp_query->query_vars['calendar_day'];
|
224 |
+
if( empty($wp_query->query_vars['scope']) ){
|
225 |
+
if( is_archive() ){
|
226 |
+
$scope = $wp_query->query_vars['scope'] = get_option('dbem_events_archive_scope');
|
227 |
+
}else{
|
228 |
+
$scope = $wp_query->query_vars['scope'] = 'all'; //otherwise we'll get 404s for past events
|
229 |
+
}
|
230 |
+
}else{
|
231 |
+
$scope = $wp_query->query_vars['scope'];
|
232 |
+
}
|
233 |
+
}
|
234 |
+
$query = array();
|
235 |
+
$time = current_time('timestamp');
|
236 |
+
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
237 |
+
$today = strtotime($scope);
|
238 |
+
$tomorrow = $today + 60*60*24-1;
|
239 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
240 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($today,$tomorrow), 'compare' => 'BETWEEN' );
|
241 |
+
}else{
|
242 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<=' );
|
243 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
244 |
+
}
|
245 |
+
}elseif ($scope == "future"){
|
246 |
+
$today = strtotime(date('Y-m-d', $time));
|
247 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
248 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '>=' );
|
249 |
+
}else{
|
250 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
251 |
+
}
|
252 |
+
}elseif ($scope == "past"){
|
253 |
+
$today = strtotime(date('Y-m-d', $time));
|
254 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
255 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '<' );
|
256 |
+
}else{
|
257 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '<' );
|
258 |
+
}
|
259 |
+
}elseif ($scope == "today"){
|
260 |
+
$today = strtotime(date('Y-m-d', $time));
|
261 |
+
$tomorrow = strtotime(date('Y-m-d',$time+60*60*24));
|
262 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
263 |
+
//date must be only today
|
264 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($today, $tomorrow), 'compare' => 'BETWEEN');
|
265 |
+
}else{
|
266 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<' );
|
267 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
268 |
+
}
|
269 |
+
}elseif ($scope == "tomorrow"){
|
270 |
+
$tomorrow = strtotime(date('Y-m-d',$time+60*60*24));
|
271 |
+
$after_tomorrow = $tomorrow + 60*60*24;
|
272 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
273 |
+
//date must be only tomorrow
|
274 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($tomorrow, $after_tomorrow), 'compare' => 'BETWEEN');
|
275 |
+
}else{
|
276 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $after_tomorrow, 'compare' => '<' );
|
277 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $tomorrow, 'compare' => '>=' );
|
278 |
+
}
|
279 |
+
}elseif ($scope == "month"){
|
280 |
+
$start_month = strtotime(date('Y-m-d',$time));
|
281 |
+
$end_month = strtotime(date('Y-m-t',$time)) + 86399;
|
282 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
283 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
284 |
+
}else{
|
285 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
286 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
287 |
+
}
|
288 |
+
}elseif ($scope == "next-month"){
|
289 |
+
$start_month_timestamp = strtotime('+1 month', $time); //get the end of this month + 1 day
|
290 |
+
$start_month = strtotime(date('Y-m-1',$start_month_timestamp));
|
291 |
+
$end_month = strtotime(date('Y-m-t',$start_month_timestamp)) + 86399;
|
292 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
293 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
294 |
+
}else{
|
295 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
296 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
297 |
+
}
|
298 |
+
}elseif( preg_match('/(\d\d?)\-months/',$scope,$matches) ){ // next x months means this month (what's left of it), plus the following x months until the end of that month.
|
299 |
+
$months_to_add = $matches[1];
|
300 |
+
$start_month = strtotime(date('Y-m-d',$time));
|
301 |
+
$end_month = strtotime(date('Y-m-t',strtotime("+$months_to_add month", $time))) + 86399;
|
302 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
303 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
304 |
+
}else{
|
305 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
306 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
307 |
+
}
|
308 |
+
}
|
309 |
+
if( !empty($query) && is_array($query) ){
|
310 |
+
$wp_query->query_vars['meta_query'] = $query;
|
311 |
+
}
|
312 |
+
if( is_admin() ){
|
313 |
+
//admin areas don't need special ordering, so make it simple
|
314 |
+
$wp_query->query_vars['orderby'] = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby']:'meta_value_num';
|
315 |
+
$wp_query->query_vars['meta_key'] = '_start_ts';
|
316 |
+
$wp_query->query_vars['order'] = (!empty($_REQUEST['order'])) ? $_REQUEST['order']:'ASC';
|
317 |
+
}else{
|
318 |
+
if( get_option('dbem_events_default_archive_orderby') == 'title'){
|
319 |
+
$wp_query->query_vars['orderby'] = 'title';
|
320 |
+
$wp_query->query_vars['order'] = get_option('dbem_events_default_archive_order','ASC');
|
321 |
+
}else{
|
322 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
323 |
+
$wp_query->query_vars['meta_key'] = '_start_ts';
|
324 |
+
}
|
325 |
+
$wp_query->query_vars['order'] = get_option('dbem_events_default_archive_order','ASC');
|
326 |
+
}
|
327 |
+
}elseif( !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == EM_POST_TYPE_EVENT ){
|
328 |
+
$wp_query->query_vars['scope'] = 'all';
|
329 |
+
if( $wp_query->query_vars['post_status'] == 'pending' ){
|
330 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
331 |
+
$wp_query->query_vars['order'] = 'ASC';
|
332 |
+
$wp_query->query_vars['meta_key'] = '_start_ts';
|
333 |
+
}
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
EM_Event_Post::init();
|
classes/em-event-posts-admin.php
ADDED
@@ -0,0 +1,280 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class EM_Event_Posts_Admin{
|
3 |
+
function init(){
|
4 |
+
global $pagenow;
|
5 |
+
if( $pagenow == 'edit.php' && !empty($_REQUEST['post_type']) && $_REQUEST['post_type'] == EM_POST_TYPE_EVENT ){ //only needed for events list
|
6 |
+
if( !empty($_REQUEST['category_id']) && is_numeric($_REQUEST['category_id']) ){
|
7 |
+
$term = get_term_by('id', $_REQUEST['category_id'], EM_TAXONOMY_CATEGORY);
|
8 |
+
if( !empty($term->slug) ){
|
9 |
+
$_REQUEST['category_id'] = $term->slug;
|
10 |
+
}
|
11 |
+
}
|
12 |
+
//hide some cols by default:
|
13 |
+
$screen = 'edit-'.EM_POST_TYPE_EVENT;
|
14 |
+
$hidden = get_user_option( 'manage' . $screen . 'columnshidden' );
|
15 |
+
if( !$hidden ){
|
16 |
+
$hidden = array('event-id');
|
17 |
+
update_user_option(get_current_user_id(), "manage{$screen}columnshidden", $hidden, true);
|
18 |
+
}
|
19 |
+
//deal with actions
|
20 |
+
$row_action_type = is_post_type_hierarchical( EM_POST_TYPE_EVENT ) ? 'page_row_actions' : 'post_row_actions';
|
21 |
+
add_filter($row_action_type, array('EM_Event_Posts_Admin','row_actions'),10,2);
|
22 |
+
add_action('admin_head', array('EM_Event_Posts_Admin','admin_head'));
|
23 |
+
//collumns
|
24 |
+
add_filter('manage_edit-'.EM_POST_TYPE_EVENT.'_columns' , array('EM_Event_Posts_Admin','columns_add'));
|
25 |
+
add_filter('manage_'.EM_POST_TYPE_EVENT.'_posts_custom_column' , array('EM_Event_Posts_Admin','columns_output'),10,2 );
|
26 |
+
//TODO alter views of locations, events and recurrences, specifically find a good way to alter the wp_count_posts method to force user owned posts only
|
27 |
+
//add_filter('views_edit-'.EM_POST_TYPE_EVENT, array('EM_Event_Posts_Admin','views'),10,1);
|
28 |
+
}
|
29 |
+
add_action('restrict_manage_posts', array('EM_Event_Posts_Admin','restrict_manage_posts'));
|
30 |
+
}
|
31 |
+
|
32 |
+
function admin_head(){
|
33 |
+
//quick hacks to make event admin table make more sense for events
|
34 |
+
?>
|
35 |
+
<script type="text/javascript">
|
36 |
+
jQuery(document).ready( function($){
|
37 |
+
$('.inline-edit-date').prev().css('display','none').next().css('display','none').next().css('display','none');
|
38 |
+
$('.em-detach-link').click(function( event ){
|
39 |
+
if( !confirm(EM.event_detach_warning) ){
|
40 |
+
event.preventDefault();
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
});
|
44 |
+
$('.em-delete-recurrence-link').click(function( event ){
|
45 |
+
if( !confirm(EM.delete_recurrence_warning) ){
|
46 |
+
event.preventDefault();
|
47 |
+
return false;
|
48 |
+
}
|
49 |
+
});
|
50 |
+
});
|
51 |
+
</script>
|
52 |
+
<style>
|
53 |
+
table.fixed{ table-layout:auto !important; }
|
54 |
+
.tablenav select[name="m"] { display:none; }
|
55 |
+
</style>
|
56 |
+
<?php
|
57 |
+
}
|
58 |
+
|
59 |
+
function restrict_manage_posts(){
|
60 |
+
global $wp_query;
|
61 |
+
if( $wp_query->query_vars['post_type'] == EM_POST_TYPE_EVENT || $wp_query->query_vars['post_type'] == 'event-recurring' ){
|
62 |
+
?>
|
63 |
+
<select name="scope">
|
64 |
+
<?php
|
65 |
+
$scope = (!empty($wp_query->query_vars['scope'])) ? $wp_query->query_vars['scope']:'future';
|
66 |
+
foreach ( em_get_scopes() as $key => $value ) {
|
67 |
+
$selected = "";
|
68 |
+
if ($key == $scope)
|
69 |
+
$selected = "selected='selected'";
|
70 |
+
echo "<option value='$key' $selected>$value</option> ";
|
71 |
+
}
|
72 |
+
?>
|
73 |
+
</select>
|
74 |
+
<?php
|
75 |
+
if( get_option('dbem_categories_enabled') ){
|
76 |
+
//Categories
|
77 |
+
$selected = !empty($_GET['event-categories']) ? $_GET['event-categories'] : 0;
|
78 |
+
wp_dropdown_categories(array( 'hide_empty' => 1, 'name' => EM_TAXONOMY_CATEGORY,
|
79 |
+
'hierarchical' => true, 'orderby'=>'name', 'id' => EM_TAXONOMY_CATEGORY,
|
80 |
+
'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected,
|
81 |
+
'show_option_all' => __('View all categories')));
|
82 |
+
}
|
83 |
+
if( !empty($_REQUEST['author']) ){
|
84 |
+
?>
|
85 |
+
<input type="hidden" name="author" value="<?php echo esc_attr($_REQUEST['author']); ?>" />
|
86 |
+
<?php
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
function views($views){
|
92 |
+
if( !current_user_can('edit_others_events') ){
|
93 |
+
//alter the views to reflect correct numbering
|
94 |
+
|
95 |
+
}
|
96 |
+
return $views;
|
97 |
+
}
|
98 |
+
|
99 |
+
function columns_add($columns) {
|
100 |
+
if( array_key_exists('cb', $columns) ){
|
101 |
+
$cb = $columns['cb'];
|
102 |
+
unset($columns['cb']);
|
103 |
+
$id_array = array('cb'=>$cb, 'event-id' => sprintf(__('%s ID','dbem'),__('Event','dbem')));
|
104 |
+
}else{
|
105 |
+
$id_array = array('event-id' => sprintf(__('%s ID','dbem'),__('Event','dbem')));
|
106 |
+
}
|
107 |
+
unset($columns['comments']);
|
108 |
+
unset($columns['date']);
|
109 |
+
unset($columns['author']);
|
110 |
+
$columns = array_merge($id_array, $columns, array(
|
111 |
+
'location' => __('Location','dbem'),
|
112 |
+
'date-time' => __('Date and Time','dbem'),
|
113 |
+
'author' => __('Owner','dbem'),
|
114 |
+
'extra' => ''
|
115 |
+
));
|
116 |
+
if( !get_option('dbem_locations_enabled') ){
|
117 |
+
unset($columns['location']);
|
118 |
+
}
|
119 |
+
return $columns;
|
120 |
+
}
|
121 |
+
|
122 |
+
function columns_output( $column ) {
|
123 |
+
global $post, $EM_Event;
|
124 |
+
$EM_Event = em_get_event($post, 'post_id');
|
125 |
+
/* @var $post EM_Event */
|
126 |
+
switch ( $column ) {
|
127 |
+
case 'event-id':
|
128 |
+
echo $EM_Event->event_id;
|
129 |
+
break;
|
130 |
+
case 'location':
|
131 |
+
//get meta value to see if post has location, otherwise
|
132 |
+
$EM_Location = $EM_Event->get_location();
|
133 |
+
if( !empty($EM_Location->location_id) ){
|
134 |
+
echo "<strong>" . $EM_Location->location_name . "</strong><br/>" . $EM_Location->location_address . " - " . $EM_Location->location_town;
|
135 |
+
}else{
|
136 |
+
echo __('None','dbem');
|
137 |
+
}
|
138 |
+
break;
|
139 |
+
case 'date-time':
|
140 |
+
//get meta value to see if post has location, otherwise
|
141 |
+
$localised_start_date = date_i18n(get_option('date_format'), $EM_Event->start);
|
142 |
+
$localised_end_date = date_i18n(get_option('date_format'), $EM_Event->end);
|
143 |
+
echo $localised_start_date;
|
144 |
+
echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'';
|
145 |
+
echo "<br />";
|
146 |
+
if(!$EM_Event->event_all_day){
|
147 |
+
echo date_i18n(get_option('time_format'), $EM_Event->start) . " - " . date_i18n(get_option('time_format'), $EM_Event->end);
|
148 |
+
}else{
|
149 |
+
echo get_option('dbem_event_all_day_message');
|
150 |
+
}
|
151 |
+
break;
|
152 |
+
case 'extra':
|
153 |
+
if( get_option('dbem_rsvp_enabled') == 1 && !empty($EM_Event->event_rsvp) && $EM_Event->can_manage('manage_bookings','manage_others_bookings')){
|
154 |
+
?>
|
155 |
+
<a href="<?php echo $EM_Event->get_bookings_url(); ?>"><?php echo __("Bookings",'dbem'); ?></a> –
|
156 |
+
<?php _e("Booked",'dbem'); ?>: <?php echo $EM_Event->get_bookings()->get_booked_spaces()."/".$EM_Event->get_spaces(); ?>
|
157 |
+
<?php if( get_option('dbem_bookings_approval') == 1 ): ?>
|
158 |
+
| <?php _e("Pending",'dbem') ?>: <?php echo $EM_Event->get_bookings()->get_pending_spaces(); ?>
|
159 |
+
<?php endif;
|
160 |
+
echo ($EM_Event->is_recurrence()) ? '<br />':'';
|
161 |
+
}
|
162 |
+
if ( $EM_Event->is_recurrence() && $EM_Event->can_manage('edit_recurring_events','edit_others_recurring_events') ) {
|
163 |
+
$recurrence_delete_confirm = __('WARNING! You will delete ALL recurrences of this event, including booking history associated with any event in this recurrence. To keep booking information, go to the relevant single event and save it to detach it from this recurrence series.','dbem');
|
164 |
+
?>
|
165 |
+
<strong>
|
166 |
+
<?php echo $EM_Event->get_recurrence_description(); ?> <br />
|
167 |
+
</strong>
|
168 |
+
<div class="row-actions">
|
169 |
+
<a href="<?php echo admin_url(); ?>post.php?action=edit&post=<?php echo $EM_Event->get_event_recurrence()->post_id ?>"><?php _e ( 'Edit Recurring Events', 'dbem' ); ?></a> | <span class="trash"><a class="em-delete-recurrence-link" href="<?php echo get_delete_post_link($EM_Event->get_event_recurrence()->post_id); ?>"><?php _e('Delete','dbem'); ?></a></span> | <a class="em-detach-link" href="<?php echo $EM_Event->get_detach_url(); ?>"><?php _e('Detach', 'dbem'); ?></a>
|
170 |
+
</div>
|
171 |
+
<?php
|
172 |
+
}
|
173 |
+
|
174 |
+
break;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
function row_actions($actions, $post){
|
179 |
+
if($post->post_type == EM_POST_TYPE_EVENT){
|
180 |
+
global $post, $EM_Event;
|
181 |
+
$EM_Event = em_get_event($post, 'post_id');
|
182 |
+
$actions['duplicate'] = '<a href="'.admin_url().'edit.php?action=event_duplicate&event_id='.$EM_Event->event_id.'&_wpnonce='.wp_create_nonce('event_duplicate_'.$EM_Event->event_id).'" title="'.sprintf(__('Duplicate %s','dbem'), __('Event','dbem')).'">'.__('Duplicate','dbem').'</a>';
|
183 |
+
}
|
184 |
+
return $actions;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
add_action('admin_init', array('EM_Event_Posts_Admin','init'));
|
188 |
+
|
189 |
+
/*
|
190 |
+
* Recurring Events
|
191 |
+
*/
|
192 |
+
class EM_Event_Recurring_Posts_Admin{
|
193 |
+
function init(){
|
194 |
+
global $pagenow;
|
195 |
+
if( $pagenow == 'edit.php' && !empty($_REQUEST['post_type']) && $_REQUEST['post_type'] == 'event-recurring' ){
|
196 |
+
//hide some cols by default:
|
197 |
+
$screen = 'edit-'.EM_POST_TYPE_EVENT;
|
198 |
+
$hidden = get_user_option( 'manage' . $screen . 'columnshidden' );
|
199 |
+
if( !$hidden ){
|
200 |
+
$hidden = array('event-id');
|
201 |
+
update_user_option(get_current_user_id(), "manage{$screen}columnshidden", $hidden, true);
|
202 |
+
}
|
203 |
+
//notices
|
204 |
+
add_action('admin_notices',array('EM_Event_Recurring_Posts_Admin','admin_notices'));
|
205 |
+
add_action('admin_head', array('EM_Event_Recurring_Posts_Admin','admin_head'));
|
206 |
+
//collumns
|
207 |
+
add_filter('manage_edit-event-recurring_columns' , array('EM_Event_Recurring_Posts_Admin','columns_add'));
|
208 |
+
add_filter('manage_posts_custom_column' , array('EM_Event_Recurring_Posts_Admin','columns_output'),10,1 );
|
209 |
+
add_action('restrict_manage_posts', array('EM_Event_Posts_Admin','restrict_manage_posts'));
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
function admin_notices(){
|
214 |
+
$warning = sprintf(__( 'Modifications to these events will cause all recurrences of each event to be deleted and recreated and previous bookings will be deleted! You can edit individual recurrences and detach them from recurring events by visiting the <a href="%s">events page</a>.', 'dbem' ), admin_url().'edit.php?post_type='.EM_POST_TYPE_EVENT);
|
215 |
+
?><div class="updated"><p><?php echo $warning; ?></p></div><?php
|
216 |
+
}
|
217 |
+
|
218 |
+
function admin_head(){
|
219 |
+
//quick hacks to make event admin table make more sense for events
|
220 |
+
?>
|
221 |
+
<script type="text/javascript">
|
222 |
+
jQuery(document).ready( function($){
|
223 |
+
$('.inline-edit-date').prev().css('display','none').next().css('display','none').next().css('display','none');
|
224 |
+
if(!EM.recurrences_menu){
|
225 |
+
$('#menu-posts-'+EM.event_post_type+', #menu-posts-'+EM.event_post_type+' > a').addClass('wp-has-current-submenu');
|
226 |
+
}
|
227 |
+
});
|
228 |
+
</script>
|
229 |
+
<style>
|
230 |
+
table.fixed{ table-layout:auto !important; }
|
231 |
+
.tablenav select[name="m"] { display:none; }
|
232 |
+
</style>
|
233 |
+
<?php
|
234 |
+
}
|
235 |
+
|
236 |
+
function columns_add($columns) {
|
237 |
+
if( array_key_exists('cb', $columns) ){
|
238 |
+
$cb = $columns['cb'];
|
239 |
+
unset($columns['cb']);
|
240 |
+
$id_array = array('cb'=>$cb, 'event-id' => sprintf(__('%s ID','dbem'),__('Event','dbem')));
|
241 |
+
}else{
|
242 |
+
$id_array = array('event-id' => sprintf(__('%s ID','dbem'),__('Event','dbem')));
|
243 |
+
}
|
244 |
+
unset($columns['comments']);
|
245 |
+
unset($columns['date']);
|
246 |
+
unset($columns['author']);
|
247 |
+
return array_merge($id_array, $columns, array(
|
248 |
+
'location' => __('Location'),
|
249 |
+
'date-time' => __('Date and Time'),
|
250 |
+
'author' => __('Owner','dbem'),
|
251 |
+
));
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
function columns_output( $column ) {
|
256 |
+
global $post, $EM_Event;
|
257 |
+
if( $post->post_type == 'event-recurring' ){
|
258 |
+
$post = $EM_Event = em_get_event($post);
|
259 |
+
/* @var $post EM_Event */
|
260 |
+
switch ( $column ) {
|
261 |
+
case 'event-id':
|
262 |
+
echo $EM_Event->event_id;
|
263 |
+
break;
|
264 |
+
case 'location':
|
265 |
+
//get meta value to see if post has location, otherwise
|
266 |
+
$EM_Location = $EM_Event->get_location();
|
267 |
+
if( !empty($EM_Location->location_id) ){
|
268 |
+
echo "<strong>" . $EM_Location->location_name . "</strong><br/>" . $EM_Location->location_address . " - " . $EM_Location->location_town;
|
269 |
+
}else{
|
270 |
+
echo __('None','dbem');
|
271 |
+
}
|
272 |
+
break;
|
273 |
+
case 'date-time':
|
274 |
+
echo $EM_Event->get_recurrence_description();
|
275 |
+
break;
|
276 |
+
}
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
280 |
+
add_action('admin_init', array('EM_Event_Recurring_Posts_Admin','init'));
|
classes/em-event.php
CHANGED
@@ -1,1006 +1,2321 @@
|
|
1 |
-
<?php
|
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 |
-
var $
|
45 |
-
var $
|
46 |
-
var $
|
47 |
-
var $
|
48 |
-
var $
|
49 |
-
var $
|
50 |
-
var $
|
51 |
-
var $
|
52 |
-
var $
|
53 |
-
var $
|
54 |
-
var $
|
55 |
-
var $
|
56 |
-
var $
|
57 |
-
var $
|
58 |
-
var $
|
59 |
-
var $
|
60 |
-
var $
|
61 |
-
var $
|
62 |
-
var $
|
63 |
-
var $
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
var $
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
var $
|
121 |
-
|
122 |
-
|
123 |
-
*
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
if
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
$this->
|
261 |
-
}
|
262 |
-
|
263 |
-
//
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
$
|
340 |
-
$
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
$
|
396 |
-
$
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
if(
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
}
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
$
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
$
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
$
|
645 |
-
|
646 |
-
|
647 |
-
}
|
648 |
-
//
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
}
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
$
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
$
|
679 |
-
|
680 |
-
$
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
$
|
725 |
-
|
726 |
-
if(
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
*
|
900 |
-
* @
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
global $
|
905 |
-
if(
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
$
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
$
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
$
|
926 |
-
}
|
927 |
-
|
928 |
-
}
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
/**
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
}
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1006 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Get an event in a db friendly way, by checking globals and passed variables to avoid extra class instantiations
|
4 |
+
* @param mixed $id
|
5 |
+
* @param mixed $search_by
|
6 |
+
* @return EM_Event
|
7 |
+
*/
|
8 |
+
function em_get_event($id = false, $search_by = 'event_id') {
|
9 |
+
global $EM_Event;
|
10 |
+
//check if it's not already global so we don't instantiate again
|
11 |
+
if( is_object($EM_Event) && get_class($EM_Event) == 'EM_Event' ){
|
12 |
+
if( is_object($id) && $EM_Event->post_id == $id->ID ){
|
13 |
+
return apply_filters('em_get_event', $EM_Event);
|
14 |
+
}elseif( !is_object($id) ){
|
15 |
+
if( $search_by == 'event_id' && $EM_Event->event_id == $id ){
|
16 |
+
return apply_filters('em_get_event', $EM_Event);
|
17 |
+
}elseif( $search_by == 'post_id' && $EM_Event->post_id == $id ){
|
18 |
+
return apply_filters('em_get_event', $EM_Event);
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
if( is_object($id) && get_class($id) == 'EM_Event' ){
|
23 |
+
return apply_filters('em_get_event', $id);
|
24 |
+
}else{
|
25 |
+
return apply_filters('em_get_event', new EM_Event($id,$search_by));
|
26 |
+
}
|
27 |
+
}
|
28 |
+
/**
|
29 |
+
* Event Object. This holds all the info pertaining to an event, including location and recurrence info.
|
30 |
+
* An event object can be one of three "types" a recurring event, recurrence of a recurring event, or a single event.
|
31 |
+
* The single event might be part of a set of recurring events, but if loaded by specific event id then any operations and saves are
|
32 |
+
* specifically done on this event. However, if you edit the recurring group, any changes made to single events are overwritten.
|
33 |
+
*
|
34 |
+
* @author marcus
|
35 |
+
*/
|
36 |
+
//TODO Can add more recurring functionality such as "also update all future recurring events" or "edit all events" like google calendar does.
|
37 |
+
//TODO Integrate recurrences into events table
|
38 |
+
//FIXME If you create a super long recurrence timespan, there could be thousands of events... need an upper limit here.
|
39 |
+
class EM_Event extends EM_Object{
|
40 |
+
/* Field Names */
|
41 |
+
var $event_id;
|
42 |
+
var $post_id;
|
43 |
+
var $event_slug;
|
44 |
+
var $event_owner;
|
45 |
+
var $event_name;
|
46 |
+
var $event_start_time;
|
47 |
+
var $event_end_time;
|
48 |
+
var $event_all_day;
|
49 |
+
var $event_start_date;
|
50 |
+
var $event_end_date;
|
51 |
+
var $post_content;
|
52 |
+
var $event_rsvp;
|
53 |
+
var $event_rsvp_date;
|
54 |
+
var $event_rsvp_time = "00:00:00";
|
55 |
+
var $event_rsvp_spaces;
|
56 |
+
var $event_spaces;
|
57 |
+
var $location_id;
|
58 |
+
var $recurrence_id;
|
59 |
+
var $event_status;
|
60 |
+
var $event_date_created;
|
61 |
+
var $event_date_modified;
|
62 |
+
var $blog_id;
|
63 |
+
var $group_id;
|
64 |
+
/**
|
65 |
+
* Populated with the non-hidden event post custom fields (i.e. not starting with _)
|
66 |
+
* @var array
|
67 |
+
*/
|
68 |
+
var $event_attributes = array();
|
69 |
+
/* Recurring Specific Values */
|
70 |
+
var $recurrence;
|
71 |
+
var $recurrence_interval;
|
72 |
+
var $recurrence_freq;
|
73 |
+
var $recurrence_byday;
|
74 |
+
var $recurrence_days = 0;
|
75 |
+
var $recurrence_byweekno;
|
76 |
+
/* anonymous submission information */
|
77 |
+
var $event_owner_anonymous;
|
78 |
+
var $event_owner_name;
|
79 |
+
var $event_owner_email;
|
80 |
+
/**
|
81 |
+
* Previously used to give this object shorter property names for db values (each key has a name) but this is now depreciated, use the db field names as properties. This propertey provides extra info about the db fields.
|
82 |
+
* @var array
|
83 |
+
*/
|
84 |
+
var $fields = array(
|
85 |
+
'event_id' => array( 'name'=>'id', 'type'=>'%d' ),
|
86 |
+
'post_id' => array( 'name'=>'post_id', 'type'=>'%d' ),
|
87 |
+
'event_slug' => array( 'name'=>'slug', 'type'=>'%s', 'null'=>true ),
|
88 |
+
'event_owner' => array( 'name'=>'owner', 'type'=>'%d', 'null'=>true ),
|
89 |
+
'event_name' => array( 'name'=>'name', 'type'=>'%s', 'null'=>true ),
|
90 |
+
'event_start_time' => array( 'name'=>'start_time', 'type'=>'%s', 'null'=>true ),
|
91 |
+
'event_end_time' => array( 'name'=>'end_time', 'type'=>'%s', 'null'=>true ),
|
92 |
+
'event_all_day' => array( 'name'=>'all_day', 'type'=>'%d', 'null'=>true ),
|
93 |
+
'event_start_date' => array( 'name'=>'start_date', 'type'=>'%s', 'null'=>true ),
|
94 |
+
'event_end_date' => array( 'name'=>'end_date', 'type'=>'%s', 'null'=>true ),
|
95 |
+
'post_content' => array( 'name'=>'notes', 'type'=>'%s', 'null'=>true ),
|
96 |
+
'event_rsvp' => array( 'name'=>'rsvp', 'type'=>'%d', 'null'=>true ), //has a default, so can be null/excluded
|
97 |
+
'event_rsvp_date' => array( 'name'=>'rsvp_date', 'type'=>'%s', 'null'=>true ),
|
98 |
+
'event_rsvp_time' => array( 'name'=>'rsvp_time', 'type'=>'%s', 'null'=>true ),
|
99 |
+
'event_rsvp_spaces' => array( 'name'=>'rsvp_spaces', 'type'=>'%d', 'null'=>true ),
|
100 |
+
'event_spaces' => array( 'name'=>'spaces', 'type'=>'%d', 'null'=>true),
|
101 |
+
'location_id' => array( 'name'=>'location_id', 'type'=>'%d', 'null'=>true ),
|
102 |
+
'recurrence_id' => array( 'name'=>'recurrence_id', 'type'=>'%d', 'null'=>true ),
|
103 |
+
'event_status' => array( 'name'=>'status', 'type'=>'%d', 'null'=>true ),
|
104 |
+
'event_private' => array( 'name'=>'status', 'type'=>'%d', 'null'=>true ),
|
105 |
+
'event_date_created' => array( 'name'=>'date_created', 'type'=>'%s', 'null'=>true ),
|
106 |
+
'event_date_modified' => array( 'name'=>'date_modified', 'type'=>'%s', 'null'=>true ),
|
107 |
+
'event_attributes' => array( 'name'=>'attributes', 'type'=>'%s', 'null'=>true ),
|
108 |
+
'blog_id' => array( 'name'=>'blog_id', 'type'=>'%d', 'null'=>true ),
|
109 |
+
'group_id' => array( 'name'=>'group_id', 'type'=>'%d', 'null'=>true ),
|
110 |
+
'recurrence' => array( 'name'=>'recurrence', 'type'=>'%d', 'null'=>true ), //every x day(s)/week(s)/month(s)
|
111 |
+
'recurrence_interval' => array( 'name'=>'interval', 'type'=>'%d', 'null'=>true ), //every x day(s)/week(s)/month(s)
|
112 |
+
'recurrence_freq' => array( 'name'=>'freq', 'type'=>'%s', 'null'=>true ), //daily,weekly,monthly?
|
113 |
+
'recurrence_days' => array( 'name'=>'days', 'type'=>'%d', 'null'=>true ), //daily,weekly,monthly?
|
114 |
+
'recurrence_byday' => array( 'name'=>'byday', 'type'=>'%s', 'null'=>true ), //if weekly or monthly, what days of the week?
|
115 |
+
'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d', 'null'=>true ), //if monthly which week (-1 is last)
|
116 |
+
);
|
117 |
+
var $post_fields = array('event_slug','event_owner','event_name','event_attributes','post_id','post_content'); //fields that won't be taken from the em_events table anymore
|
118 |
+
var $recurrence_fields = array('recurrence_interval', 'recurrence_freq', 'recurrence_days', 'recurrence_byday', 'recurrence_byweekno');
|
119 |
+
|
120 |
+
var $image_url = '';
|
121 |
+
/**
|
122 |
+
* Timestamp of start date/time
|
123 |
+
* @var int
|
124 |
+
*/
|
125 |
+
var $start;
|
126 |
+
/**
|
127 |
+
* Timestamp of end date/time
|
128 |
+
* @var int
|
129 |
+
*/
|
130 |
+
var $end;
|
131 |
+
/**
|
132 |
+
* Timestamp for booking cut-off date/time
|
133 |
+
* @var int
|
134 |
+
*/
|
135 |
+
var $rsvp_end;
|
136 |
+
/**
|
137 |
+
* Created on timestamp, taken from DB, converted to TS
|
138 |
+
* @var int
|
139 |
+
*/
|
140 |
+
var $created;
|
141 |
+
/**
|
142 |
+
* Created on timestamp, taken from DB, converted to TS
|
143 |
+
* @var int
|
144 |
+
*/
|
145 |
+
var $modified;
|
146 |
+
|
147 |
+
/**
|
148 |
+
* @var EM_Location
|
149 |
+
*/
|
150 |
+
var $location;
|
151 |
+
/**
|
152 |
+
* @var EM_Bookings
|
153 |
+
*/
|
154 |
+
var $bookings;
|
155 |
+
/**
|
156 |
+
* The contact person for this event
|
157 |
+
* @var WP_User
|
158 |
+
*/
|
159 |
+
var $contact;
|
160 |
+
/**
|
161 |
+
* The category object
|
162 |
+
* @var EM_Category
|
163 |
+
*/
|
164 |
+
var $category;
|
165 |
+
/**
|
166 |
+
* If there are any errors, they will be added here.
|
167 |
+
* @var array
|
168 |
+
*/
|
169 |
+
var $errors = array();
|
170 |
+
/**
|
171 |
+
* If something was successful, a feedback message might be supplied here.
|
172 |
+
* @var string
|
173 |
+
*/
|
174 |
+
var $feedback_message;
|
175 |
+
/**
|
176 |
+
* Any warnings about an event (e.g. bad data, recurrence, etc.)
|
177 |
+
* @var string
|
178 |
+
*/
|
179 |
+
var $warnings;
|
180 |
+
/**
|
181 |
+
* Array of dbem_event field names required to create an event
|
182 |
+
* @var array
|
183 |
+
*/
|
184 |
+
var $required_fields = array('event_name', 'event_start_date');
|
185 |
+
var $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
|
186 |
+
/**
|
187 |
+
* previous status of event when instantiated
|
188 |
+
* @access protected
|
189 |
+
* @var mixed
|
190 |
+
*/
|
191 |
+
var $previous_status = false;
|
192 |
+
|
193 |
+
/* Post Variables - copied out of post object for easy IDE reference */
|
194 |
+
var $ID;
|
195 |
+
var $post_author;
|
196 |
+
var $post_date;
|
197 |
+
var $post_date_gmt;
|
198 |
+
var $post_title;
|
199 |
+
var $post_excerpt;
|
200 |
+
var $post_status;
|
201 |
+
var $comment_status;
|
202 |
+
var $ping_status;
|
203 |
+
var $post_password;
|
204 |
+
var $post_name;
|
205 |
+
var $to_ping;
|
206 |
+
var $pinged;
|
207 |
+
var $post_modified;
|
208 |
+
var $post_modified_gmt;
|
209 |
+
var $post_content_filtered;
|
210 |
+
var $post_parent;
|
211 |
+
var $guid;
|
212 |
+
var $menu_order;
|
213 |
+
var $post_type;
|
214 |
+
var $post_mime_type;
|
215 |
+
var $comment_count;
|
216 |
+
var $ancestors;
|
217 |
+
var $filter;
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Initialize an event. You can provide event data in an associative array (using database table field names), an id number, or false (default) to create empty event.
|
221 |
+
* @param mixed $event_data
|
222 |
+
* @param mixed $search_by default is post_id, otherwise it can be by event_id as well.
|
223 |
+
* @return null
|
224 |
+
*/
|
225 |
+
function __construct($id = false, $search_by = 'event_id') {
|
226 |
+
global $wpdb;
|
227 |
+
if( is_array($id) ){
|
228 |
+
//deal with the old array style, but we can't supply arrays anymore
|
229 |
+
$id = (!empty($id['event_id'])) ? $id['event_id'] : $id['post_id'];
|
230 |
+
$search_by = (!empty($id['event_id'])) ? 'event_id':'post_id';
|
231 |
+
}
|
232 |
+
$is_post = !empty($id->ID) && ($id->post_type == EM_POST_TYPE_EVENT || $id->post_type == 'event-recurring');
|
233 |
+
if( is_numeric($id) || $is_post ){ //only load info if $id is a number
|
234 |
+
if($search_by == 'event_id' && !$is_post ){
|
235 |
+
//search by event_id, get post_id and blog_id (if in ms mode) and load the post
|
236 |
+
$results = $wpdb->get_row($wpdb->prepare("SELECT post_id, blog_id FROM ".EM_EVENTS_TABLE." WHERE event_id=%d",$id), ARRAY_A);
|
237 |
+
if( !empty($results['post_id']) ){ $this->post_id = $results['post_id']; }
|
238 |
+
if( is_multisite() && (is_numeric($results['blog_id']) || $results['blog_id']=='' ) ){
|
239 |
+
if( $results['blog_id']=='' ) $results['blog_id'] = get_current_site()->blog_id;
|
240 |
+
$event_post = get_blog_post($results['blog_id'], $results['post_id']);
|
241 |
+
$search_by = $results['blog_id'];
|
242 |
+
}else{
|
243 |
+
$event_post = get_post($results['post_id']);
|
244 |
+
}
|
245 |
+
}else{
|
246 |
+
if(!$is_post){
|
247 |
+
if( is_multisite() && (is_numeric($search_by) || $search_by == '') ){
|
248 |
+
if( $search_by == '' ) $search_by = get_current_site()->blog_id;
|
249 |
+
//we've been given a blog_id, so we're searching for a post id
|
250 |
+
$event_post = get_blog_post($search_by, $id);
|
251 |
+
}else{
|
252 |
+
//search for the post id only
|
253 |
+
$event_post = get_post($id);
|
254 |
+
}
|
255 |
+
}else{
|
256 |
+
$event_post = $id;
|
257 |
+
}
|
258 |
+
$this->post_id = !empty($id->ID) ? $id->ID : $id;
|
259 |
+
}
|
260 |
+
$this->load_postdata($event_post, $search_by);
|
261 |
+
}
|
262 |
+
$this->recurrence = $this->is_recurring() ? 1:0;
|
263 |
+
//if(defined('trashtest')){ print_r($this); die("got here");}
|
264 |
+
//Do it here so things appear in the po file.
|
265 |
+
$this->status_array = array(
|
266 |
+
0 => __('Pending','dbem'),
|
267 |
+
1 => __('Approved','dbem')
|
268 |
+
);
|
269 |
+
do_action('em_event', $this, $id, $search_by);
|
270 |
+
}
|
271 |
+
|
272 |
+
function load_postdata($event_post, $search_by = false){
|
273 |
+
if( is_object($event_post) ){
|
274 |
+
//load post data - regardless
|
275 |
+
$this->post_id = $event_post->ID;
|
276 |
+
$this->event_name = $event_post->post_title;
|
277 |
+
$this->event_owner = $event_post->post_author;
|
278 |
+
$this->post_content = $event_post->post_content;
|
279 |
+
$this->post_excerpt = $event_post->post_excerpt;
|
280 |
+
$this->event_slug = $event_post->post_name;
|
281 |
+
$this->event_modified = $event_post->post_modified;
|
282 |
+
foreach( $event_post as $key => $value ){ //merge post object into this object
|
283 |
+
$this->$key = $value;
|
284 |
+
}
|
285 |
+
$this->recurrence = $this->is_recurring() ? 1:0;
|
286 |
+
//load meta data and other related information
|
287 |
+
if( $event_post->post_status != 'auto-draft' ){
|
288 |
+
$event_meta = $this->get_event_meta($search_by);
|
289 |
+
//Get custom fields and post meta
|
290 |
+
foreach($event_meta as $event_meta_key => $event_meta_val){
|
291 |
+
$field_name = substr($event_meta_key, 1);
|
292 |
+
if($event_meta_key[0] != '_'){
|
293 |
+
$this->event_attributes[$event_meta_key] = ( count($event_meta_val) > 1 ) ? $event_meta_val:$event_meta_val[0];
|
294 |
+
}elseif( is_string($field_name) && !in_array($field_name, $this->post_fields) ){
|
295 |
+
if( array_key_exists($field_name, $this->fields) ){
|
296 |
+
$this->$field_name = $event_meta_val[0];
|
297 |
+
}elseif( in_array($field_name, array('event_owner_name','event_owner_anonymous','event_owner_email')) ){
|
298 |
+
$this->$field_name = $event_meta_val[0];
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
302 |
+
//Start/End times should be available as timestamp
|
303 |
+
$this->start = strtotime($this->event_start_date." ".$this->event_start_time);
|
304 |
+
$this->end = strtotime($this->event_end_date." ".$this->event_end_time);
|
305 |
+
if( !empty($this->event_rsvp_date ) ){
|
306 |
+
$this->rsvp_end = strtotime($this->event_rsvp_date." ".$this->event_rsvp_time);
|
307 |
+
}
|
308 |
+
//quick compatability fix in case _event_id isn't loaded or somehow got erased in post meta
|
309 |
+
if( empty($this->event_id) && !$this->is_recurring() ){
|
310 |
+
global $wpdb;
|
311 |
+
$event_array = $wpdb->get_row('SELECT * FROM '.EM_EVENTS_TABLE. ' WHERE post_id='.$event_post->ID, ARRAY_A);
|
312 |
+
if( !empty($event_array['event_id']) ){
|
313 |
+
foreach($event_array as $key => $value){
|
314 |
+
if( !empty($value) && empty($this->$key) ){
|
315 |
+
update_post_meta($event_post->ID, '_'.$key, $value);
|
316 |
+
$this->$key = $value;
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
}
|
321 |
+
}
|
322 |
+
$this->get_status();
|
323 |
+
$this->compat_keys();
|
324 |
+
}elseif( !empty($this->post_id) ){
|
325 |
+
//we have an orphan... show it, so that we can at least remove it on the front-end
|
326 |
+
global $wpdb;
|
327 |
+
$event_array = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".EM_EVENTS_TABLE." WHERE post_id=%d",$this->post_id), ARRAY_A);
|
328 |
+
if( is_array($event_array) ){
|
329 |
+
$this->orphaned_event = true;
|
330 |
+
$this->post_id = $this->ID = $event_array['post_id'] = null; //reset post_id because it doesn't really exist
|
331 |
+
$this->to_object($event_array);
|
332 |
+
}
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
function get_event_meta($blog_id = false){
|
337 |
+
if( is_numeric($blog_id) && $blog_id > 0 && is_multisite() ){
|
338 |
+
// if in multisite mode, switch blogs quickly to get the right post meta.
|
339 |
+
switch_to_blog($blog_id);
|
340 |
+
$event_meta = get_post_meta($this->post_id);
|
341 |
+
restore_current_blog();
|
342 |
+
$this->blog_id = $blog_id;
|
343 |
+
}else{
|
344 |
+
$event_meta = get_post_meta($this->post_id);
|
345 |
+
}
|
346 |
+
return $event_meta;
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Retrieve event information via POST (only used in situations where posts aren't submitted via WP)
|
351 |
+
* @return boolean
|
352 |
+
*/
|
353 |
+
function get_post($validate = true){
|
354 |
+
global $allowedposttags;
|
355 |
+
//we need to get the post/event name and content.... that's it.
|
356 |
+
$this->post_content = isset($_POST['content']) ? wp_kses( stripslashes($_POST['content']), $allowedposttags):'';
|
357 |
+
$this->event_name = !empty($_POST['event_name']) ? htmlspecialchars_decode(wp_kses_data(htmlspecialchars_decode(stripslashes($_POST['event_name'])))):'';
|
358 |
+
$this->post_type = ($this->is_recurring() || !empty($_POST['recurring'])) ? 'event-recurring':EM_POST_TYPE_EVENT;
|
359 |
+
//don't forget categories!
|
360 |
+
$this->get_categories()->get_post();
|
361 |
+
//anonymous submissions and guest basic info
|
362 |
+
if( !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->event_id) ){
|
363 |
+
$this->event_owner_anonymous = 1;
|
364 |
+
$this->event_owner_name = !empty($_POST['event_owner_name']) ? wp_kses_data(stripslashes($_POST['event_owner_name'])):'';
|
365 |
+
$this->event_owner_email = !empty($_POST['event_owner_email']) ? wp_kses_data($_POST['event_owner_email']):'';
|
366 |
+
}
|
367 |
+
//get the rest and validate (optional)
|
368 |
+
$this->get_post_meta(false);
|
369 |
+
$result = $validate ? $this->validate():true; //validate both post and meta, otherwise return true
|
370 |
+
return apply_filters('em_event_get_post', $result, $this);
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Retrieve event post meta information via POST, which should be always be called when saving the event custom post via WP.
|
375 |
+
* @param boolean $validate whether or not to run validation, default is true
|
376 |
+
* @return boolean
|
377 |
+
*/
|
378 |
+
function get_post_meta($validate = true){
|
379 |
+
//Grab POST data
|
380 |
+
$this->event_start_date = ( !empty($_POST['event_start_date']) ) ? wp_kses_data($_POST['event_start_date']) : '';
|
381 |
+
$this->event_end_date = ( !empty($_POST['event_end_date']) ) ? wp_kses_data($_POST['event_end_date']) : $this->event_start_date;
|
382 |
+
//check if this is recurring or not
|
383 |
+
if( !empty($_POST['recurring']) ){
|
384 |
+
$this->recurrence = 1;
|
385 |
+
$this->post_type = 'event-recurring';
|
386 |
+
}
|
387 |
+
//Get Location info
|
388 |
+
if( !get_option('dbem_locations_enabled') || (!empty($_POST['no_location']) && !get_option('dbem_require_location',true)) || (empty($_POST['location_id']) && !get_option('dbem_require_location',true) && get_option('dbem_use_select_for_locations')) ){
|
389 |
+
$this->location_id = 0;
|
390 |
+
}elseif( !empty($_POST['location_id']) && is_numeric($_POST['location_id']) ){
|
391 |
+
$this->location_id = $_POST['location_id'];
|
392 |
+
}else{
|
393 |
+
//we're adding a new location, so create an empty location and populate
|
394 |
+
$this->location_id = null;
|
395 |
+
$this->get_location()->get_post(false);
|
396 |
+
$this->get_location()->post_content = ''; //reset post content, as it'll grab the event description otherwise
|
397 |
+
}
|
398 |
+
//Sort out time
|
399 |
+
$this->event_all_day = ( !empty($_POST['event_all_day']) ) ? 1 : 0;
|
400 |
+
if( !$this->event_all_day ){
|
401 |
+
$this->event_start_time = $this->event_end_time = '00:00:00';
|
402 |
+
}
|
403 |
+
foreach( array('event_start_time','event_end_time', 'event_rsvp_time') as $timeName ){
|
404 |
+
$match = array();
|
405 |
+
if( !empty($_POST[$timeName]) && preg_match ( '/^([01]\d|2[0-3]):([0-5]\d) ?(AM|PM)?$/', $_POST[$timeName], $match ) ){
|
406 |
+
if( !empty($match[3]) && $match[3] == 'PM' && $match[1] != 12 ){
|
407 |
+
$match[1] = 12+$match[1];
|
408 |
+
}elseif( !empty($match[3]) && $match[3] == 'AM' && $match[1] == 12 ){
|
409 |
+
$match[1] = '00';
|
410 |
+
}
|
411 |
+
$this->$timeName = $match[1].":".$match[2].":00";
|
412 |
+
}else{
|
413 |
+
$this->$timeName = ($timeName == 'event_start_time') ? "00:00:00":$this->event_start_time;
|
414 |
+
}
|
415 |
+
}
|
416 |
+
//Start/End times should be available as timestamp
|
417 |
+
$this->start = strtotime($this->event_start_date." ".$this->event_start_time);
|
418 |
+
$this->end = strtotime($this->event_end_date." ".$this->event_end_time);
|
419 |
+
//Bookings
|
420 |
+
if( !empty($_POST['event_rsvp']) && $_POST['event_rsvp'] ){
|
421 |
+
$this->get_bookings()->get_tickets()->get_post();
|
422 |
+
$this->event_rsvp = 1;
|
423 |
+
//RSVP cuttoff TIME is set up above where start/end times are as well
|
424 |
+
if( !$this->is_recurring() ){
|
425 |
+
$this->event_rsvp_date = ( isset($_POST['event_rsvp_date']) ) ? wp_kses_data($_POST['event_rsvp_date']) : $this->event_start_date;
|
426 |
+
if( empty($this->event_rsvp_date) ){ $this->event_rsvp_time = '00:00:00'; }
|
427 |
+
}
|
428 |
+
$this->event_spaces = ( isset($_POST['event_spaces']) ) ? absint($_POST['event_spaces']):0;
|
429 |
+
$this->event_rsvp_spaces = ( isset($_POST['event_rsvp_spaces']) ) ? absint($_POST['event_rsvp_spaces']):0;
|
430 |
+
}else{
|
431 |
+
$this->event_rsvp = 0;
|
432 |
+
$this->event_rsvp_time = '00:00:00';
|
433 |
+
}
|
434 |
+
//Sort out event attributes - note that custom post meta now also gets inserted here automatically (and is overwritten by these attributes)
|
435 |
+
if(get_option('dbem_attributes_enabled')){
|
436 |
+
global $allowedtags;
|
437 |
+
if( !is_array($this->event_attributes) ){ $this->event_attributes = array(); }
|
438 |
+
$event_available_attributes = em_get_attributes();
|
439 |
+
if( !empty($_POST['em_attributes']) && is_array($_POST['em_attributes']) ){
|
440 |
+
foreach($_POST['em_attributes'] as $att_key => $att_value ){
|
441 |
+
if( (in_array($att_key, $event_available_attributes['names']) || array_key_exists($att_key, $this->event_attributes) ) ){
|
442 |
+
$this->event_attributes[$att_key] = '';
|
443 |
+
$att_vals = count($event_available_attributes['values'][$att_key]);
|
444 |
+
if( !empty($att_value) ){
|
445 |
+
if( $att_vals <= 1 || ($att_vals > 1 && in_array($att_value, $event_available_attributes['values'][$att_key])) ){
|
446 |
+
$this->event_attributes[$att_key] = stripslashes($att_value);
|
447 |
+
}
|
448 |
+
}
|
449 |
+
if( empty($att_value) && $att_vals > 1){
|
450 |
+
$this->event_attributes[$att_key] = stripslashes(wp_kses($event_available_attributes['values'][$att_key][0], $allowedtags));
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
454 |
+
}
|
455 |
+
}
|
456 |
+
//Set Blog ID
|
457 |
+
if( is_multisite() ){
|
458 |
+
$this->blog_id = get_current_blog_id();
|
459 |
+
}
|
460 |
+
//group id
|
461 |
+
$this->group_id = (!empty($_POST['group_id']) && is_numeric($_POST['group_id'])) ? $_POST['group_id']:0;
|
462 |
+
//Recurrence data
|
463 |
+
if( $this->is_recurring() ){
|
464 |
+
$this->recurrence = 1; //just in case
|
465 |
+
$this->recurrence_freq = ( !empty($_POST['recurrence_freq']) && in_array($_POST['recurrence_freq'], array('daily','weekly','monthly','yearly')) ) ? $_POST['recurrence_freq']:'daily';
|
466 |
+
if( !empty($_POST['recurrence_bydays']) && $this->recurrence_freq == 'weekly' && self::array_is_numeric($_POST['recurrence_bydays']) ){
|
467 |
+
$this->recurrence_byday = implode( ",", $_POST['recurrence_bydays'] );
|
468 |
+
}elseif( !empty($_POST['recurrence_byday']) && $this->recurrence_freq == 'monthly' ){
|
469 |
+
$this->recurrence_byday = wp_kses_data($_POST['recurrence_byday']);
|
470 |
+
}
|
471 |
+
$this->recurrence_interval = ( !empty($_POST['recurrence_interval']) && is_numeric($_POST['recurrence_interval']) ) ? $_POST['recurrence_interval']:1;
|
472 |
+
$this->recurrence_byweekno = ( !empty($_POST['recurrence_byweekno']) ) ? wp_kses_data($_POST['recurrence_byweekno']):'';
|
473 |
+
$this->recurrence_days = ( !empty($_POST['recurrence_days']) && is_numeric($_POST['recurrence_days']) ) ? (int) $_POST['recurrence_days']:0;
|
474 |
+
}
|
475 |
+
//categories in MS GLobal
|
476 |
+
if(EM_MS_GLOBAL && !is_main_site()){
|
477 |
+
$this->get_categories()->get_post(); //it'll know what to do
|
478 |
+
}
|
479 |
+
//validate (optional) and return result
|
480 |
+
$this->compat_keys(); //compatability
|
481 |
+
return apply_filters('em_event_get_post', count($this->errors) == 0, $this);
|
482 |
+
}
|
483 |
+
|
484 |
+
function validate(){
|
485 |
+
$validate_post = true;
|
486 |
+
if( empty($this->event_name) ){
|
487 |
+
$validate_post = false;
|
488 |
+
$this->add_error( sprintf(__("%s is required.", "dbem"), __('Event name','dbem')) );
|
489 |
+
}
|
490 |
+
//anonymous submissions and guest basic info
|
491 |
+
if( !empty($this->event_owner_anonymous) ){
|
492 |
+
if( !is_email($this->event_owner_email) ){
|
493 |
+
$this->add_error( sprintf(__("%s is required.", "dbem"), __('A valid email','dbem')) );
|
494 |
+
}
|
495 |
+
if( empty($this->event_owner_name) ){
|
496 |
+
$this->add_error( sprintf(__("%s is required.", "dbem"), __('Your name','dbem')) );
|
497 |
+
}
|
498 |
+
}
|
499 |
+
$validate_tickets = $this->get_bookings()->get_tickets()->validate();
|
500 |
+
$validate_image = $this->image_validate();
|
501 |
+
$validate_meta = $this->validate_meta();
|
502 |
+
return apply_filters('em_event_validate', $validate_post && $validate_image && $validate_meta && $validate_tickets, $this );
|
503 |
+
}
|
504 |
+
function validate_meta(){
|
505 |
+
$missing_fields = Array ();
|
506 |
+
foreach ( array('event_start_date') as $field ) {
|
507 |
+
if ( $this->$field == "") {
|
508 |
+
$missing_fields[$field] = $field;
|
509 |
+
}
|
510 |
+
}
|
511 |
+
if( preg_match('/\d{4}-\d{2}-\d{2}/', $this->event_start_date) && preg_match('/\d{4}-\d{2}-\d{2}/', $this->event_end_date) ){
|
512 |
+
if( strtotime($this->event_start_date . $this->event_start_time) > strtotime($this->event_end_date . $this->event_end_time) ){
|
513 |
+
$this->add_error(__('Events cannot start after they end.','dbem'));
|
514 |
+
}elseif( $this->is_recurring() && $this->recurrence_days == 0 && strtotime($this->event_start_date . $this->event_start_time) > strtotime($this->event_start_date . $this->event_end_time) ){
|
515 |
+
$this->add_error(__('Events cannot start after they end.','dbem').' '.__('For recurring events that end the following day, ensure you make your event last 1 or more days.'));
|
516 |
+
}
|
517 |
+
}else{
|
518 |
+
if( !empty($missing_fields['event_start_date']) ) { unset($missing_fields['event_start_date']); }
|
519 |
+
if( !empty($missing_fields['event_end_date']) ) { unset($missing_fields['event_end_date']); }
|
520 |
+
$this->add_error(__('Dates must have correct formatting. Please use the date picker provided.','dbem'));
|
521 |
+
}
|
522 |
+
if( $this->event_rsvp ){
|
523 |
+
if( !$this->get_bookings()->get_tickets()->validate() ){
|
524 |
+
$this->add_error($this->get_bookings()->get_tickets()->get_errors());
|
525 |
+
}
|
526 |
+
if( !empty($this->event_rsvp_date) && !preg_match('/\d{4}-\d{2}-\d{2}/', $this->event_rsvp_date) ){
|
527 |
+
$this->add_error(__('Dates must have correct formatting. Please use the date picker provided.','dbem'));
|
528 |
+
}
|
529 |
+
}
|
530 |
+
if( get_option('dbem_locations_enabled') && empty($this->location_id) ){ //location ids don't need validating as we're not saving a location
|
531 |
+
if( get_option('dbem_require_location',true) || $this->location_id !== 0 ){
|
532 |
+
if( !$this->get_location()->validate() ){
|
533 |
+
$this->add_error($this->get_location()->get_errors());
|
534 |
+
}
|
535 |
+
}
|
536 |
+
}
|
537 |
+
if ( count($missing_fields) > 0){
|
538 |
+
// TODO Create friendly equivelant names for missing fields notice in validation
|
539 |
+
$this->add_error( __( 'Missing fields: ', 'dbem') . implode ( ", ", $missing_fields ) . ". " );
|
540 |
+
}
|
541 |
+
if ( $this->is_recurring() && ($this->event_end_date == "" || $this->event_end_date == $this->event_start_date) ){
|
542 |
+
$this->add_error( __( 'Since the event is repeated, you must specify an event end date greater than the start date.', 'dbem' ));
|
543 |
+
}
|
544 |
+
return apply_filters('em_event_validate_meta', count($this->errors) == 0, $this );
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Will save the current instance into the database, along with location information if a new one was created and return true if successful, false if not.
|
549 |
+
* Will automatically detect whether it's a new or existing event.
|
550 |
+
* @return boolean
|
551 |
+
*/
|
552 |
+
function save(){
|
553 |
+
global $wpdb, $current_user, $blog_id;
|
554 |
+
if( !$this->can_manage('edit_events', 'edit_others_events') && !( get_option('dbem_events_anonymous_submissions') && empty($this->event_id)) ){
|
555 |
+
//unless events can be submitted by an anonymous user (and this is a new event), user must have permissions.
|
556 |
+
return apply_filters('em_event_save', false, $this);
|
557 |
+
}
|
558 |
+
remove_action('save_post',array('EM_Event_Post_Admin','save_post'),10,1); //disable the default save post action, we'll do it manually this way
|
559 |
+
do_action('em_event_save_pre', $this);
|
560 |
+
$post_array = array();
|
561 |
+
//Deal with updates to an event
|
562 |
+
if( !empty($this->post_id) ){
|
563 |
+
//get the full array of post data so we don't overwrite anything.
|
564 |
+
if( !empty($this->blog_id) && is_multisite() ){
|
565 |
+
$post_array = (array) get_blog_post($this->blog_id, $this->post_id);
|
566 |
+
}else{
|
567 |
+
$post_array = (array) get_post($this->post_id);
|
568 |
+
}
|
569 |
+
}
|
570 |
+
//Overwrite new post info
|
571 |
+
$post_array['post_type'] = ($this->recurrence && get_option('dbem_recurrence_enabled')) ? 'event-recurring':EM_POST_TYPE_EVENT;
|
572 |
+
$post_array['post_title'] = $this->event_name;
|
573 |
+
$post_array['post_content'] = $this->post_content;
|
574 |
+
$post_array['post_excerpt'] = $this->post_excerpt;
|
575 |
+
//decide on post status
|
576 |
+
if( empty($this->force_status) ){
|
577 |
+
if( count($this->errors) == 0 ){
|
578 |
+
$post_array['post_status'] = ( $this->can_manage('publish_events','publish_events') ) ? 'publish':'pending';
|
579 |
+
}else{
|
580 |
+
$post_array['post_status'] = 'draft';
|
581 |
+
}
|
582 |
+
}else{
|
583 |
+
$post_array['post_status'] = $this->force_status;
|
584 |
+
}
|
585 |
+
//anonymous submission only
|
586 |
+
if( !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->event_id) ){
|
587 |
+
$post_array['post_author'] = get_option('dbem_events_anonymous_user');
|
588 |
+
if( !is_numeric($post_array['post_author']) ) $post_array['post_author'] = 0;
|
589 |
+
}
|
590 |
+
//Save post and continue with meta
|
591 |
+
$post_id = wp_insert_post($post_array);
|
592 |
+
$post_save = false;
|
593 |
+
$meta_save = false;
|
594 |
+
if( !is_wp_error($post_id) && !empty($post_id) ){
|
595 |
+
$post_save = true;
|
596 |
+
//refresh this event with wp post info we'll put into the db
|
597 |
+
$post_data = get_post($post_id);
|
598 |
+
$this->post_id = $post_id;
|
599 |
+
$this->event_slug = $post_data->post_name;
|
600 |
+
$this->event_owner = $post_data->post_author;
|
601 |
+
$this->post_status = $post_data->post_status;
|
602 |
+
$this->get_status();
|
603 |
+
//Categories? note that categories will soft-fail, so no errors
|
604 |
+
$this->get_categories()->event_id = $this->event_id;
|
605 |
+
$this->categories->post_id = $this->post_id;
|
606 |
+
$this->categories->save();
|
607 |
+
//anonymous submissions should save this information
|
608 |
+
if( !empty($this->event_owner_anonymous) ){
|
609 |
+
update_post_meta($this->post_id, '_event_owner_anonymous', 1);
|
610 |
+
update_post_meta($this->post_id, '_event_owner_name', $this->event_owner_name);
|
611 |
+
update_post_meta($this->post_id, '_event_owner_email', $this->event_owner_email);
|
612 |
+
}
|
613 |
+
//save the image
|
614 |
+
$this->image_upload();
|
615 |
+
//now save the meta
|
616 |
+
$meta_save = $this->save_meta();
|
617 |
+
$image_save = (count($this->errors) == 0); //whilst it might not be an image save that fails, we can know something went wrong
|
618 |
+
}
|
619 |
+
$result = $meta_save && $post_save && $image_save;
|
620 |
+
if($result) $this->load_postdata($post_data, $blog_id); //reload post info
|
621 |
+
//do a dirty update for location too if it's not published
|
622 |
+
if( $this->is_published() && !empty($this->location_id) ){
|
623 |
+
$EM_Location = $this->get_location();
|
624 |
+
if( $EM_Location->location_status !== 1 ){
|
625 |
+
//let's also publish the location
|
626 |
+
$EM_Location->set_status(1, true);
|
627 |
+
}
|
628 |
+
}
|
629 |
+
return apply_filters('em_event_save', $result, $this);
|
630 |
+
}
|
631 |
+
|
632 |
+
function save_meta(){
|
633 |
+
global $wpdb;
|
634 |
+
if( ( get_option('dbem_events_anonymous_submissions') && empty($this->event_id)) || $this->can_manage('edit_events', 'edit_others_events') ){
|
635 |
+
do_action('em_event_save_meta_pre', $this);
|
636 |
+
//first save location
|
637 |
+
if( empty($this->location_id) && !($this->location_id === 0 && !get_option('dbem_require_location',true)) ){
|
638 |
+
if( !$this->get_location()->save() ){ //soft fail
|
639 |
+
global $EM_Notices;
|
640 |
+
if( !empty($this->get_location()->location_id) ){
|
641 |
+
$EM_Notices->add_error( __('There were some errors saving your location.','dbem').' '.sprintf(__('It will not be displayed on the website listings, to correct this you must <a href="%s">edit your location</a> directly.'),$this->get_location()->output('#_LOCATIONEDITURL')), true);
|
642 |
+
}
|
643 |
+
}
|
644 |
+
if( !empty($this->location->location_id) ){ //only case we don't use get_location(), since it will fail as location has an id, whereas location_id isn't set in this object
|
645 |
+
$this->location_id = $this->location->location_id;
|
646 |
+
}
|
647 |
+
}
|
648 |
+
//Update Post Meta
|
649 |
+
foreach($this->fields as $key => $field_info){
|
650 |
+
if( !in_array($key, $this->post_fields) && $key != 'event_attributes' ){
|
651 |
+
update_post_meta($this->post_id, '_'.$key, $this->$key);
|
652 |
+
}elseif($key == 'event_attributes'){
|
653 |
+
//attributes get saved as individual keys
|
654 |
+
foreach($this->event_attributes as $event_attribute_key => $event_attribute){
|
655 |
+
if( !empty($event_attribute) ){
|
656 |
+
update_post_meta($this->post_id, $event_attribute_key, $event_attribute);
|
657 |
+
}else{
|
658 |
+
delete_post_meta($this->post_id, $event_attribute_key);
|
659 |
+
}
|
660 |
+
}
|
661 |
+
}
|
662 |
+
}
|
663 |
+
//update timestampes
|
664 |
+
update_post_meta($this->post_id, '_start_ts', str_pad($this->start, 10, 0, STR_PAD_LEFT));
|
665 |
+
update_post_meta($this->post_id, '_end_ts', str_pad($this->end, 10, 0, STR_PAD_LEFT));
|
666 |
+
//sort out event status
|
667 |
+
$result = count($this->errors) == 0;
|
668 |
+
$this->get_status();
|
669 |
+
$this->event_status = ($result) ? $this->event_status:null; //set status at this point, it's either the current status, or if validation fails, null
|
670 |
+
//Save to em_event table
|
671 |
+
$event_array = $this->to_array(true);
|
672 |
+
unset($event_array['event_id']);
|
673 |
+
//decide whether or not event is private at this point
|
674 |
+
$event_array['event_private'] = ( $this->post_status == 'private' ) ? 1:0;
|
675 |
+
//save event_attributes just in case
|
676 |
+
$event_array['event_attributes'] = serialize($this->event_attributes);
|
677 |
+
//check if event truly exists, meaning the event_id is actually a valid event id
|
678 |
+
if( !empty($this->event_id) ){
|
679 |
+
$blog_condition = '';
|
680 |
+
if( !empty($this->orphaned_event ) && !empty($this->post_id) ){
|
681 |
+
//we're dealing with an orphaned event in wp_em_events table, so we want to update the post_id and give it a post parent
|
682 |
+
$event_truly_exists = true;
|
683 |
+
}else{
|
684 |
+
if( EM_MS_GLOBAL ){
|
685 |
+
if( is_main_site() ){
|
686 |
+
$blog_condition = " AND (blog_id='".get_current_blog_id()."' OR blog_id IS NULL)";
|
687 |
+
}else{
|
688 |
+
$blog_condition = " AND blog_id='".get_current_blog_id()."' ";
|
689 |
+
}
|
690 |
+
}
|
691 |
+
$event_truly_exists = $wpdb->get_var('SELECT post_id FROM '.EM_EVENTS_TABLE." WHERE event_id={$this->event_id}".$blog_condition) == $this->post_id;
|
692 |
+
}
|
693 |
+
}else{
|
694 |
+
$event_truly_exists = false;
|
695 |
+
}
|
696 |
+
//save all the meta
|
697 |
+
if( empty($this->event_id) || !$event_truly_exists ){
|
698 |
+
$this->previous_status = 0; //for sure this was previously status 0
|
699 |
+
$this->event_date_created = $event_array['event_date_created'] = current_time('mysql');
|
700 |
+
if ( !$wpdb->insert(EM_EVENTS_TABLE, $event_array) ){
|
701 |
+
$this->add_error( sprintf(__('Something went wrong saving your %s to the index table. Please inform a site administrator about this.','dbem'),__('event','dbem')));
|
702 |
+
}else{
|
703 |
+
//success, so link the event with the post via an event id meta value for easy retrieval
|
704 |
+
$this->event_id = $wpdb->insert_id;
|
705 |
+
update_post_meta($this->post_id, '_event_id', $this->event_id);
|
706 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Event','dbem'));
|
707 |
+
$just_added_event = true; //make an easy hook
|
708 |
+
do_action('em_event_save_new', $this);
|
709 |
+
}
|
710 |
+
}else{
|
711 |
+
$event_array['post_content'] = $this->post_content; //in case the content was removed, which is acceptable
|
712 |
+
$this->get_previous_status();
|
713 |
+
$this->event_date_modified = $event_array['event_date_modified'] = current_time('mysql');
|
714 |
+
if ( $wpdb->update(EM_EVENTS_TABLE, $event_array, array('event_id'=>$this->event_id) ) === false ){
|
715 |
+
$this->add_error( sprintf(__('Something went wrong updating your %s to the index table. Please inform a site administrator about this.','dbem'),__('event','dbem')));
|
716 |
+
}else{
|
717 |
+
//Also set the status here if status != previous status
|
718 |
+
if( $this->previous_status != $this->get_status() ) $this->set_status($this->get_status());
|
719 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Event','dbem'));
|
720 |
+
}
|
721 |
+
}
|
722 |
+
//Add/Delete Tickets
|
723 |
+
if($this->event_rsvp == 0){
|
724 |
+
$this->get_bookings()->delete();
|
725 |
+
}else{
|
726 |
+
if( !$this->get_bookings()->get_tickets()->save() ){
|
727 |
+
$this->add_error( $this->get_bookings()->get_tickets()->get_errors() );
|
728 |
+
}
|
729 |
+
}
|
730 |
+
$result = count($this->errors) == 0;
|
731 |
+
//If we're saving event categories in MS Global mode, we'll add them here, saving by term id (cat ids are gone now)
|
732 |
+
if( EM_MS_GLOBAL && !is_main_site() ){
|
733 |
+
$this->get_categories()->save(); //it'll know what to do
|
734 |
+
}elseif( EM_MS_GLOBAL ){
|
735 |
+
$this->get_categories()->save_index(); //just save to index, we assume cats are saved in $this->save();
|
736 |
+
}
|
737 |
+
//build recurrences if needed
|
738 |
+
if( $this->is_recurring() && $result && $this->is_published() ){ //only save events if recurring event validates and is published
|
739 |
+
if( !$this->save_events() ){ //only save if post is 'published'
|
740 |
+
$this->add_error(__ ( 'Something went wrong with the recurrence update...', 'dbem' ). __ ( 'There was a problem saving the recurring events.', 'dbem' ));
|
741 |
+
}
|
742 |
+
}
|
743 |
+
if( !empty($just_added_event) ){
|
744 |
+
do_action('em_event_added', $this);
|
745 |
+
}
|
746 |
+
}
|
747 |
+
$this->compat_keys();
|
748 |
+
return apply_filters('em_event_save_meta', count($this->errors) == 0, $this);
|
749 |
+
}
|
750 |
+
|
751 |
+
/**
|
752 |
+
* Duplicates this event and returns the duplicated event. Will return false if there is a problem with duplication.
|
753 |
+
* @return EM_Event
|
754 |
+
*/
|
755 |
+
function duplicate(){
|
756 |
+
global $wpdb, $EZSQL_ERROR;
|
757 |
+
//First, duplicate.
|
758 |
+
if( $this->can_manage('edit_events','edit_others_events') ){
|
759 |
+
$EM_Event = clone $this;
|
760 |
+
$EM_Event->get_categories(); //before we remove event/post ids
|
761 |
+
$EM_Event->get_bookings()->get_tickets(); //in case this wasn't loaded and before we reset ids
|
762 |
+
$EM_Event->event_id = null;
|
763 |
+
$EM_Event->post_id = null;
|
764 |
+
$EM_Event->ID = null;
|
765 |
+
$EM_Event->post_name = '';
|
766 |
+
$EM_Event->location_id = (empty($EM_Event->location_id) && !get_option('dbem_require_location')) ? 0:$EM_Event->location_id;
|
767 |
+
$EM_Event->get_bookings()->event_id = null;
|
768 |
+
$EM_Event->get_bookings()->get_tickets()->event_id = null;
|
769 |
+
//if bookings reset ticket ids and duplicate tickets
|
770 |
+
foreach($EM_Event->get_bookings()->get_tickets()->tickets as $EM_Ticket){
|
771 |
+
$EM_Ticket->ticket_id = null;
|
772 |
+
$EM_Ticket->event_id = null;
|
773 |
+
}
|
774 |
+
do_action('em_event_duplicate_pre', $EM_Event);
|
775 |
+
$EM_Event->duplicated = true;
|
776 |
+
$EM_Event->force_status = 'draft';
|
777 |
+
if( $EM_Event->save() ){
|
778 |
+
$EM_Event->feedback_message = sprintf(__("%s successfully duplicated.", 'dbem'), __('Event','dbem'));
|
779 |
+
//save tags here - eventually will be moved into part of $this->save();
|
780 |
+
$EM_Tags = new EM_Tags($this);
|
781 |
+
$EM_Tags->event_id = $EM_Event->event_id;
|
782 |
+
$EM_Tags->post_id = $EM_Event->post_id;
|
783 |
+
$EM_Tags->save();
|
784 |
+
//other non-EM post meta inc. featured image
|
785 |
+
$event_meta = $this->get_event_meta($this->blog_id);
|
786 |
+
$event_meta['_event_approvals_count'] = 0; //reset this counter for new event
|
787 |
+
$event_meta_inserts = array();
|
788 |
+
//Get custom fields and post meta - adapted from $this->load_post_meta()
|
789 |
+
foreach($event_meta as $event_meta_key => $event_meta_vals){
|
790 |
+
if($event_meta_key[0] == '_' && is_array($event_meta_vals)){
|
791 |
+
$field_name = substr($event_meta_key, 1);
|
792 |
+
if($field_name != 'event_attributes' && !array_key_exists($field_name, $this->fields) && !in_array($field_name, array('edit_last', 'edit_lock', 'event_owner_name','event_owner_anonymous','event_owner_email')) ){
|
793 |
+
foreach($event_meta_vals as $event_meta_val){
|
794 |
+
$event_meta_inserts[] = "({$EM_Event->post_id}, '{$event_meta_key}', '{$event_meta_val}')";
|
795 |
+
}
|
796 |
+
}
|
797 |
+
}
|
798 |
+
}
|
799 |
+
//save in one SQL statement
|
800 |
+
if( !empty($event_meta_inserts) ){
|
801 |
+
$wpdb->query('INSERT INTO '.$wpdb->postmeta." (post_id, meta_key, meta_value) VALUES ".implode(', ', $event_meta_inserts));
|
802 |
+
}
|
803 |
+
//set event to draft status
|
804 |
+
return apply_filters('em_event_duplicate', $EM_Event, $this);
|
805 |
+
}
|
806 |
+
}
|
807 |
+
//TODO add error notifications for duplication failures.
|
808 |
+
return apply_filters('em_event_duplicate', false, $this);;
|
809 |
+
}
|
810 |
+
|
811 |
+
/**
|
812 |
+
* Delete whole event, including bookings, tickets, etc.
|
813 |
+
* @return boolean
|
814 |
+
*/
|
815 |
+
function delete($force_delete = false){ //atm wp seems to force cp deletions anyway
|
816 |
+
if( $this->can_manage('delete_events', 'delete_others_events') ){
|
817 |
+
if( !is_admin() ){
|
818 |
+
include_once('em-event-post-admin.php');
|
819 |
+
if( !defined('EM_EVENT_DELETE_INCLUDE') ){
|
820 |
+
EM_Event_Post_Admin::init();
|
821 |
+
EM_Event_Recurring_Post_Admin::init();
|
822 |
+
define('EM_EVENT_DELETE_INCLUDE',true);
|
823 |
+
}
|
824 |
+
}
|
825 |
+
do_action('em_event_delete_pre', $this);
|
826 |
+
if( $force_delete ){
|
827 |
+
$result = wp_delete_post($this->post_id,$force_delete);
|
828 |
+
}else{
|
829 |
+
$result = wp_trash_post($this->post_id);
|
830 |
+
if( !$result && $this->post_status == 'trash' ){
|
831 |
+
//we're probably dealing with a trashed post already, but the event_status is null from < v5.4.1
|
832 |
+
$this->set_status(-1);
|
833 |
+
$result = true;
|
834 |
+
}
|
835 |
+
}
|
836 |
+
if( !$result && !empty($this->orphaned_event) ){
|
837 |
+
//this is an orphaned event, so the wp delete posts would have never worked, so we just delete the row in our events table
|
838 |
+
$this->delete_meta();
|
839 |
+
}
|
840 |
+
}else{
|
841 |
+
$result = false;
|
842 |
+
}
|
843 |
+
//print_r($result); echo "|"; print_r($result_meta); die('DELETING');
|
844 |
+
return apply_filters('em_event_delete', $result != false, $this);
|
845 |
+
}
|
846 |
+
|
847 |
+
function delete_meta(){
|
848 |
+
global $wpdb;
|
849 |
+
$result = false;
|
850 |
+
if( $this->can_manage('delete_events', 'delete_others_events') ){
|
851 |
+
do_action('em_event_delete_meta_event_pre', $this);
|
852 |
+
$result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". EM_EVENTS_TABLE ." WHERE event_id=%d", $this->event_id) );
|
853 |
+
if( $result !== false ){
|
854 |
+
$this->delete_bookings();
|
855 |
+
$this->delete_tickets();
|
856 |
+
//Delete the recurrences then this recurrence event
|
857 |
+
if( $this->is_recurring() ){
|
858 |
+
$result = $this->delete_events(); //was true at this point, so false if fails
|
859 |
+
}
|
860 |
+
//Delete categories from meta if in MS global mode
|
861 |
+
if( EM_MS_GLOBAL ){
|
862 |
+
$wpdb->query('DELETE FROM '.EM_META_TABLE.' WHERE object_id='.$this->event_id." AND meta_key='event-category'");
|
863 |
+
}
|
864 |
+
}
|
865 |
+
}
|
866 |
+
return apply_filters('em_event_delete_meta', $result !== false, $this);
|
867 |
+
}
|
868 |
+
|
869 |
+
/**
|
870 |
+
* Shortcut function for $this->get_bookings()->delete(), because using the EM_Bookings requires loading previous bookings, which isn't neceesary.
|
871 |
+
*/
|
872 |
+
function delete_bookings(){
|
873 |
+
global $wpdb;
|
874 |
+
do_action('em_event_delete_bookings_pre', $this);
|
875 |
+
$result = false;
|
876 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
877 |
+
$result_bt = $wpdb->query( $wpdb->prepare("DELETE FROM ".EM_TICKETS_BOOKINGS_TABLE." WHERE booking_id IN (SELECT booking_id FROM ".EM_BOOKINGS_TABLE." WHERE event_id=%d)", $this->event_id) );
|
878 |
+
$result = $wpdb->query( $wpdb->prepare("DELETE FROM ".EM_BOOKINGS_TABLE." WHERE event_id=%d", $this->event_id) );
|
879 |
+
}
|
880 |
+
return apply_filters('em_event_delete_bookings', $result !== false && $result_bt !== false, $this);
|
881 |
+
}
|
882 |
+
|
883 |
+
/**
|
884 |
+
* Shortcut function for $this->get_bookings()->delete(), because using the EM_Bookings requires loading previous bookings, which isn't neceesary.
|
885 |
+
*/
|
886 |
+
function delete_tickets(){
|
887 |
+
global $wpdb;
|
888 |
+
do_action('em_event_delete_tickets_pre', $this);
|
889 |
+
$result = false;
|
890 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
891 |
+
$result_bt = $wpdb->query( $wpdb->prepare("DELETE FROM ".EM_TICKETS_BOOKINGS_TABLE." WHERE ticket_id IN (SELECT ticket_id FROM ".EM_TICKETS_TABLE." WHERE event_id=%d)", $this->event_id) );
|
892 |
+
$result = $wpdb->query( $wpdb->prepare("DELETE FROM ".EM_TICKETS_TABLE." WHERE event_id=%d", $this->event_id) );
|
893 |
+
}
|
894 |
+
return apply_filters('em_event_delete_tickets', $result, $this);
|
895 |
+
}
|
896 |
+
|
897 |
+
/**
|
898 |
+
* Change the status of the event. This will save to the Database too.
|
899 |
+
* @param int $status
|
900 |
+
* @param boolean $set_post_status
|
901 |
+
* @return string
|
902 |
+
*/
|
903 |
+
function set_status($status, $set_post_status = false){
|
904 |
+
global $wpdb;
|
905 |
+
if($status === null){
|
906 |
+
$set_status='NULL';
|
907 |
+
if($set_post_status){
|
908 |
+
//if the post is trash, don't untrash it!
|
909 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $this->post_id ) );
|
910 |
+
}
|
911 |
+
$this->post_status = 'draft'; //set post status in this instance
|
912 |
+
}elseif( $status == -1 ){ //trashed post
|
913 |
+
$set_status = -1;
|
914 |
+
if($set_post_status){
|
915 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => $this->post_status ), array( 'ID' => $this->post_id ) );
|
916 |
+
}
|
917 |
+
$this->post_status = 'trash'; //set post status in this instance
|
918 |
+
}else{
|
919 |
+
$set_status = $status ? 1:0;
|
920 |
+
$post_status = $set_status ? 'publish':'pending';
|
921 |
+
if($set_post_status){
|
922 |
+
if($this->post_status == 'pending' && empty($this->post_name)){
|
923 |
+
$this->post_name = sanitize_title($this->post_title);
|
924 |
+
}
|
925 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => $post_status, 'post_name' => $this->post_name ), array( 'ID' => $this->post_id ) );
|
926 |
+
}
|
927 |
+
$this->post_status = $post_status;
|
928 |
+
}
|
929 |
+
$this->get_previous_status();
|
930 |
+
$result = $wpdb->query( $wpdb->prepare("UPDATE ".EM_EVENTS_TABLE." SET event_status=$set_status, event_slug=%s WHERE event_id=%d", array($this->post_name, $this->event_id)) );
|
931 |
+
$this->get_status(); //reload status
|
932 |
+
return apply_filters('em_event_set_status', $result !== false, $status, $this);
|
933 |
+
}
|
934 |
+
|
935 |
+
function is_published(){
|
936 |
+
return apply_filters('em_event_is_published', ($this->post_status == 'publish' || $this->post_status == 'private'), $this);
|
937 |
+
}
|
938 |
+
|
939 |
+
function get_status($db = false){
|
940 |
+
switch( $this->post_status ){
|
941 |
+
case 'private':
|
942 |
+
$this->event_private = 1;
|
943 |
+
$this->event_status = $status = 1;
|
944 |
+
break;
|
945 |
+
case 'publish':
|
946 |
+
$this->event_private = 0;
|
947 |
+
$this->event_status = $status = 1;
|
948 |
+
break;
|
949 |
+
case 'pending':
|
950 |
+
$this->event_private = 0;
|
951 |
+
$this->event_status = $status = 0;
|
952 |
+
break;
|
953 |
+
case 'trash':
|
954 |
+
$this->event_private = 0;
|
955 |
+
$this->event_status = $status = -1;
|
956 |
+
break;
|
957 |
+
default: //draft or unknown
|
958 |
+
$this->event_private = 0;
|
959 |
+
$status = $db ? 'NULL':null;
|
960 |
+
$this->event_status = null;
|
961 |
+
break;
|
962 |
+
}
|
963 |
+
return $status;
|
964 |
+
}
|
965 |
+
|
966 |
+
function get_previous_status( $force = false ){
|
967 |
+
global $wpdb;
|
968 |
+
if( $this->previous_status === false || $force ){
|
969 |
+
$this->previous_status = $wpdb->get_var('SELECT event_status FROM '.EM_EVENTS_TABLE.' WHERE event_id='.$this->event_id); //get status from db, not post_status, as posts get saved quickly
|
970 |
+
}
|
971 |
+
return $this->previous_status;
|
972 |
+
}
|
973 |
+
|
974 |
+
/**
|
975 |
+
* Returns an EM_Categories object of the EM_Event instance.
|
976 |
+
* @return EM_Categories
|
977 |
+
*/
|
978 |
+
function get_categories() {
|
979 |
+
if( empty($this->categories) ){
|
980 |
+
$this->categories = new EM_Categories($this);
|
981 |
+
}elseif(empty($this->categories->event_id)){
|
982 |
+
$this->categories->event_id = $this->event_id;
|
983 |
+
$this->categories->post_id = $this->post_id;
|
984 |
+
}
|
985 |
+
return apply_filters('em_event_get_categories', $this->categories, $this);
|
986 |
+
}
|
987 |
+
|
988 |
+
/**
|
989 |
+
* Returns the location object this event belongs to.
|
990 |
+
* @return EM_Location
|
991 |
+
*/
|
992 |
+
function get_location() {
|
993 |
+
global $EM_Location;
|
994 |
+
if( is_object($EM_Location) && $EM_Location->location_id == $this->location_id ){
|
995 |
+
$this->location = $EM_Location;
|
996 |
+
}else{
|
997 |
+
if( !is_object($this->location) || $this->location->location_id != $this->location_id ){
|
998 |
+
$this->location = em_get_location($this->location_id);
|
999 |
+
}
|
1000 |
+
}
|
1001 |
+
return $this->location;
|
1002 |
+
}
|
1003 |
+
|
1004 |
+
/**
|
1005 |
+
* Returns the location object this event belongs to.
|
1006 |
+
* @return EM_Person
|
1007 |
+
*/
|
1008 |
+
function get_contact(){
|
1009 |
+
if( !is_object($this->contact) ){
|
1010 |
+
$this->contact = new EM_Person($this->event_owner);
|
1011 |
+
//if this is anonymous submission, change contact email and name
|
1012 |
+
if( $this->event_owner_anonymous ){
|
1013 |
+
$this->contact->user_email = $this->event_owner_email;
|
1014 |
+
$name = explode(' ',$this->event_owner_name);
|
1015 |
+
$first_name = array_shift($name);
|
1016 |
+
$last_name = (count($name) > 0) ? implode(' ',$name):'';
|
1017 |
+
$this->contact->user_firstname = $this->contact->first_name = $first_name;
|
1018 |
+
$this->contact->user_lastname = $this->contact->last_name = $last_name;
|
1019 |
+
}
|
1020 |
+
}
|
1021 |
+
return $this->contact;
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
/**
|
1025 |
+
* Retrieve and save the bookings belonging to instance. If called again will return cached version, set $force_reload to true to create a new EM_Bookings object.
|
1026 |
+
* @param boolean $force_reload
|
1027 |
+
* @return EM_Bookings
|
1028 |
+
*/
|
1029 |
+
function get_bookings( $force_reload = false ){
|
1030 |
+
if( get_option('dbem_rsvp_enabled') ){
|
1031 |
+
if( (!$this->bookings || $force_reload) ){
|
1032 |
+
$this->bookings = new EM_Bookings($this);
|
1033 |
+
}
|
1034 |
+
$this->bookings->event_id = $this->event_id; //always refresh event_id
|
1035 |
+
}else{
|
1036 |
+
return new EM_Bookings();
|
1037 |
+
}
|
1038 |
+
//TODO for some reason this returned instance doesn't modify the original, e.g. try $this->get_bookings()->add($EM_Booking) and see how $this->bookings->feedback_message doesn't change
|
1039 |
+
return apply_filters('em_event_get_bookings', $this->bookings, $this);
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
/**
|
1043 |
+
* Get the tickets related to this event.
|
1044 |
+
* @param boolean $force_reload
|
1045 |
+
* @return EM_Tickets
|
1046 |
+
*/
|
1047 |
+
function get_tickets( $force_reload = false ){
|
1048 |
+
return $this->get_bookings($force_reload)->get_tickets();
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
/*
|
1052 |
+
* Provides the tax rate for this event.
|
1053 |
+
* Currently a site-wide default, but this hook allows easy overriding of tax rates for specific events.
|
1054 |
+
* @uses apply_filters() on 'em_event_get_tax_rate' before returning value
|
1055 |
+
* @uses EM_Object::get_tax_rate()
|
1056 |
+
*/
|
1057 |
+
function get_tax_rate(){
|
1058 |
+
return apply_filters('em_event_get_tax_rate', parent::get_tax_rate(), $this);
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
/**
|
1062 |
+
* Gets number of spaces in this event, dependent on ticket spaces or hard limit, whichever is smaller.
|
1063 |
+
* @param boolean $force_refresh
|
1064 |
+
* @return int
|
1065 |
+
*/
|
1066 |
+
function get_spaces($force_refresh=false){
|
1067 |
+
return $this->get_bookings()->get_spaces($force_refresh);
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
/*
|
1071 |
+
* Extends the default EM_Object function by switching blogs as needed if in MS Global mode
|
1072 |
+
* @param string $size
|
1073 |
+
* @return string
|
1074 |
+
* @see EM_Object::get_image_url()
|
1075 |
+
*/
|
1076 |
+
function get_image_url($size = 'full'){
|
1077 |
+
if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){
|
1078 |
+
switch_to_blog($this->blog_id);
|
1079 |
+
$switch_back = true;
|
1080 |
+
}
|
1081 |
+
$return = parent::get_image_url($size);
|
1082 |
+
if( !empty($switch_back) ){ restore_current_blog(); }
|
1083 |
+
return $return;
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
function get_edit_reschedule_url(){
|
1087 |
+
if( $this->is_recurrence() ){
|
1088 |
+
$EM_Event = em_get_event($this->recurrence_id);
|
1089 |
+
return $EM_Event->get_edit_url();
|
1090 |
+
}
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
function get_edit_url(){
|
1094 |
+
if( $this->can_manage('edit_events','edit_others_events') ){
|
1095 |
+
if( EM_MS_GLOBAL && get_site_option('dbem_ms_global_events_links') && !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id() ){
|
1096 |
+
if( get_blog_option($this->blog_id, 'dbem_edit_events_page') ){
|
1097 |
+
$link = em_add_get_params(get_permalink(get_blog_option($this->blog_id, 'dbem_edit_events_page')), array('action'=>'edit','event_id'=>$this->event_id), false);
|
1098 |
+
}
|
1099 |
+
if( empty($link))
|
1100 |
+
$link = get_admin_url($this->blog_id, "post.php?post={$this->post_id}&action=edit");
|
1101 |
+
}else{
|
1102 |
+
if( get_option('dbem_edit_events_page') && !is_admin() ){
|
1103 |
+
$link = em_add_get_params(get_permalink(get_option('dbem_edit_events_page')), array('action'=>'edit','event_id'=>$this->event_id), false);
|
1104 |
+
}
|
1105 |
+
if( empty($link))
|
1106 |
+
$link = admin_url()."post.php?post={$this->post_id}&action=edit";
|
1107 |
+
}
|
1108 |
+
return apply_filters('em_event_get_edit_url', $link, $this);
|
1109 |
+
}
|
1110 |
+
}
|
1111 |
+
|
1112 |
+
function get_bookings_url(){
|
1113 |
+
if( get_option('dbem_edit_bookings_page') && (!is_admin() || !empty($_REQUEST['is_public'])) ){
|
1114 |
+
$my_bookings_page = get_permalink(get_option('dbem_edit_bookings_page'));
|
1115 |
+
$bookings_link = em_add_get_params($my_bookings_page, array('event_id'=>$this->event_id), false);
|
1116 |
+
}else{
|
1117 |
+
if( is_multisite() && $this->blog_id != get_current_blog_id() ){
|
1118 |
+
$bookings_link = get_admin_url($this->blog_id, 'edit.php?post_type='.EM_POST_TYPE_EVENT."&page=events-manager-bookings&event_id=".$this->event_id);
|
1119 |
+
}else{
|
1120 |
+
$bookings_link = EM_ADMIN_URL. "&page=events-manager-bookings&event_id=".$this->event_id;
|
1121 |
+
}
|
1122 |
+
}
|
1123 |
+
return apply_filters('em_event_get_bookings_url', $bookings_link, $this);
|
1124 |
+
}
|
1125 |
+
|
1126 |
+
function get_permalink(){
|
1127 |
+
if( EM_MS_GLOBAL ){
|
1128 |
+
$blog_id = empty($this->blog_id) ? get_current_blog_id():$this->blog_id;
|
1129 |
+
//linking directly to the blog by default
|
1130 |
+
$event_link = get_blog_permalink( $this->blog_id, $this->post_id);
|
1131 |
+
//if on main site and direct links disabled then show link to main site
|
1132 |
+
if( !get_site_option('dbem_ms_global_events_links') && is_main_site() && $blog_id != get_current_blog_id() ){
|
1133 |
+
if( get_option('dbem_events_page') ){
|
1134 |
+
$event_link = trailingslashit(get_permalink(get_option('dbem_events_page')).get_site_option('dbem_ms_events_slug',EM_EVENT_SLUG).'/'.$this->event_slug.'-'.$this->event_id);
|
1135 |
+
}
|
1136 |
+
}
|
1137 |
+
}
|
1138 |
+
if( empty($event_link) ){
|
1139 |
+
$event_link = get_post_permalink($this->post_id);
|
1140 |
+
}
|
1141 |
+
return apply_filters('em_event_get_permalink', $event_link, $this);
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
function get_ical_url(){
|
1145 |
+
global $wp_rewrite;
|
1146 |
+
if( !empty($wp_rewrite) && $wp_rewrite->using_permalinks() ){
|
1147 |
+
return trailingslashit($this->get_permalink()).'ical/';
|
1148 |
+
}else{
|
1149 |
+
return em_add_get_params($this->get_permalink(), array('ical'=>1));
|
1150 |
+
}
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
function is_free( $now = false ){
|
1154 |
+
$free = true;
|
1155 |
+
foreach($this->get_tickets() as $EM_Ticket){
|
1156 |
+
/* @var $EM_Ticket EM_Ticket */
|
1157 |
+
if( $EM_Ticket->get_price() > 0 ){
|
1158 |
+
if( !$now || $EM_Ticket->is_available() ){
|
1159 |
+
$free = false;
|
1160 |
+
}
|
1161 |
+
}
|
1162 |
+
}
|
1163 |
+
return apply_filters('em_event_is_free',$free,$this);
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
/**
|
1167 |
+
* Will output a single event format of this event.
|
1168 |
+
* Equivalent of calling EM_Event::output( get_option ( 'dbem_single_event_format' ) )
|
1169 |
+
* @param string $target
|
1170 |
+
* @return string
|
1171 |
+
*/
|
1172 |
+
function output_single($target='html'){
|
1173 |
+
$format = get_option ( 'dbem_single_event_format' );
|
1174 |
+
return apply_filters('em_event_output_single', $this->output($format, $target), $this, $target);
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
/**
|
1178 |
+
* Will output a event in the format passed in $format by replacing placeholders within the format.
|
1179 |
+
* @param string $format
|
1180 |
+
* @param string $target
|
1181 |
+
* @return string
|
1182 |
+
*/
|
1183 |
+
function output($format, $target="html") {
|
1184 |
+
$event_string = $format;
|
1185 |
+
//Time place holder that doesn't show if empty.
|
1186 |
+
//TODO add filter here too
|
1187 |
+
preg_match_all('/#@?_\{[^}]+\}/', $format, $results);
|
1188 |
+
foreach($results[0] as $result) {
|
1189 |
+
if(substr($result, 0, 3 ) == "#@_"){
|
1190 |
+
$date = 'end_date';
|
1191 |
+
$offset = 4;
|
1192 |
+
}else{
|
1193 |
+
$date = 'start_date';
|
1194 |
+
$offset = 3;
|
1195 |
+
}
|
1196 |
+
if( $date == 'end_date' && $this->event_end_date == $this->event_start_date ){
|
1197 |
+
$replace = __( apply_filters('em_event_output_placeholder', '', $this, $result, $target) );
|
1198 |
+
}else{
|
1199 |
+
$replace = __( apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, (strlen($result)-($offset+1)) ), $this->$date), $this, $result, $target) );
|
1200 |
+
}
|
1201 |
+
$event_string = str_replace($result,$replace,$event_string );
|
1202 |
+
}
|
1203 |
+
//This is for the custom attributes
|
1204 |
+
preg_match_all('/#_ATT\{([^}]+)\}(\{([^}]+)\})?/', $event_string, $results);
|
1205 |
+
$attributes = em_get_attributes();
|
1206 |
+
foreach($results[0] as $resultKey => $result) {
|
1207 |
+
//Strip string of placeholder and just leave the reference
|
1208 |
+
$attRef = substr( substr($result, 0, strpos($result, '}')), 6 );
|
1209 |
+
$attString = '';
|
1210 |
+
if( is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes) ){
|
1211 |
+
$attString = $this->event_attributes[$attRef];
|
1212 |
+
}elseif( !empty($results[3][$resultKey]) ){
|
1213 |
+
//Check to see if we have a second set of braces;
|
1214 |
+
$attString = $results[3][$resultKey];
|
1215 |
+
}elseif( !empty($attributes['values'][$attRef][0]) ){
|
1216 |
+
$attString = $attributes['values'][$attRef][0];
|
1217 |
+
}
|
1218 |
+
$attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
|
1219 |
+
$event_string = str_replace($result, $attString ,$event_string );
|
1220 |
+
}
|
1221 |
+
//First let's do some conditional placeholder removals
|
1222 |
+
for ($i = 0 ; $i < EM_CONDITIONAL_RECURSIONS; $i++){ //you can add nested recursions by modifying this setting in your wp_options table
|
1223 |
+
preg_match_all('/\{([a-zA-Z0-9_]+)\}(.+?)\{\/\1\}/s', $event_string, $conditionals);
|
1224 |
+
if( count($conditionals[0]) > 0 ){
|
1225 |
+
//Check if the language we want exists, if not we take the first language there
|
1226 |
+
foreach($conditionals[1] as $key => $condition){
|
1227 |
+
$show_condition = false;
|
1228 |
+
if ($condition == 'has_bookings') {
|
1229 |
+
//check if there's a booking, if not, remove this section of code.
|
1230 |
+
$show_condition = ($this->event_rsvp && get_option('dbem_rsvp_enabled'));
|
1231 |
+
}elseif ($condition == 'no_bookings') {
|
1232 |
+
//check if there's a booking, if not, remove this section of code.
|
1233 |
+
$show_condition = (!$this->event_rsvp && get_option('dbem_rsvp_enabled'));
|
1234 |
+
}elseif ($condition == 'no_location'){
|
1235 |
+
//does this event have a valid location?
|
1236 |
+
$show_condition = ( empty($this->location_id) || !$this->get_location()->location_status );
|
1237 |
+
}elseif ($condition == 'has_location'){
|
1238 |
+
//does this event have a valid location?
|
1239 |
+
$show_condition = ( !empty($this->location_id) && $this->get_location()->location_status );
|
1240 |
+
}elseif ($condition == 'has_image'){
|
1241 |
+
//does this event have an image?
|
1242 |
+
$show_condition = ( $this->get_image_url() != '' );
|
1243 |
+
}elseif ($condition == 'no_image'){
|
1244 |
+
//does this event have an image?
|
1245 |
+
$show_condition = ( $this->get_image_url() == '' );
|
1246 |
+
}elseif ($condition == 'has_time'){
|
1247 |
+
//are the booking times different and not an all-day event
|
1248 |
+
$show_condition = ( $this->event_start_time != $this->event_end_time && !$this->event_all_day );
|
1249 |
+
}elseif ($condition == 'no_time'){
|
1250 |
+
//are the booking times exactly the same and it's not an all-day event.
|
1251 |
+
$show_condition = ( $this->event_start_time == $this->event_end_time && !$this->event_all_day );
|
1252 |
+
}elseif ($condition == 'all_day'){
|
1253 |
+
//is it an all day event
|
1254 |
+
$show_condition = !empty($this->event_all_day);
|
1255 |
+
}elseif ($condition == 'logged_in'){
|
1256 |
+
//user is logged in
|
1257 |
+
$show_condition = is_user_logged_in();
|
1258 |
+
}elseif ($condition == 'not_logged_in'){
|
1259 |
+
//not logged in
|
1260 |
+
$show_condition = !is_user_logged_in();
|
1261 |
+
}elseif ($condition == 'has_spaces'){
|
1262 |
+
//there are still empty spaces
|
1263 |
+
$show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
|
1264 |
+
}elseif ($condition == 'fully_booked'){
|
1265 |
+
//event is fully booked
|
1266 |
+
$show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
|
1267 |
+
}elseif ($condition == 'bookings_open'){
|
1268 |
+
//bookings are still open
|
1269 |
+
$show_condition = $this->event_rsvp && $this->get_bookings()->is_open();
|
1270 |
+
}elseif ($condition == 'bookings_closed'){
|
1271 |
+
//bookings are still closed
|
1272 |
+
$show_condition = $this->event_rsvp && !$this->get_bookings()->is_open();
|
1273 |
+
}elseif ($condition == 'is_free' || $condition == 'is_free_now'){
|
1274 |
+
//is it a free day event, if _now then free right now
|
1275 |
+
$show_condition = !$this->event_rsvp || $this->is_free( $condition == 'is_free_now' );
|
1276 |
+
}elseif ($condition == 'not_free' || $condition == 'not_free_now'){
|
1277 |
+
//is it a paid event, if _now then paid right now
|
1278 |
+
$show_condition = $this->event_rsvp && !$this->is_free( $condition == 'not_free_now' );
|
1279 |
+
}elseif ($condition == 'is_long'){
|
1280 |
+
//is it an all day event
|
1281 |
+
$show_condition = $this->event_start_date != $this->event_end_date;
|
1282 |
+
}elseif ($condition == 'not_long'){
|
1283 |
+
//is it an all day event
|
1284 |
+
$show_condition = $this->event_start_date == $this->event_end_date;
|
1285 |
+
}elseif ($condition == 'is_past'){
|
1286 |
+
//if event is past
|
1287 |
+
if( get_option('dbem_events_current_are_past') ){
|
1288 |
+
$show_condition = $this->start <= current_time('timestamp');
|
1289 |
+
}else{
|
1290 |
+
$show_condition = $this->end <= current_time('timestamp');
|
1291 |
+
}
|
1292 |
+
}elseif ($condition == 'is_future'){
|
1293 |
+
//if event is upcoming
|
1294 |
+
$show_condition = $this->start > current_time('timestamp');
|
1295 |
+
}elseif ($condition == 'is_current'){
|
1296 |
+
//if event is upcoming
|
1297 |
+
$ts = current_time('timestamp');
|
1298 |
+
$show_condition = $this->start <= $ts && $this->end >= $ts;
|
1299 |
+
}elseif ($condition == 'is_recurrence'){
|
1300 |
+
//if event is a recurrence
|
1301 |
+
$show_condition = $this->is_recurrence();
|
1302 |
+
}elseif ($condition == 'not_recurrence'){
|
1303 |
+
//if event is not a recurrence
|
1304 |
+
$show_condition = !$this->is_recurrence();
|
1305 |
+
}elseif ($condition == 'is_private'){
|
1306 |
+
//if event is a recurrence
|
1307 |
+
$show_condition = $this->event_private == 1;
|
1308 |
+
}elseif ($condition == 'not_private'){
|
1309 |
+
//if event is not a recurrence
|
1310 |
+
$show_condition = $this->event_private == 0;
|
1311 |
+
}elseif ( preg_match('/^has_category_([a-zA-Z0-9_\-]+)$/', $condition, $category_match)){
|
1312 |
+
//event is in this category
|
1313 |
+
$show_condition = has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
|
1314 |
+
}elseif ( preg_match('/^no_category_([a-zA-Z0-9_\-]+)$/', $condition, $category_match)){
|
1315 |
+
//event is NOT in this category
|
1316 |
+
$show_condition = !has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
|
1317 |
+
}elseif ( preg_match('/^has_tag_([a-zA-Z0-9_\-]+)$/', $condition, $tag_match)){
|
1318 |
+
//event has this tag
|
1319 |
+
$show_condition = has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
|
1320 |
+
}elseif ( preg_match('/^no_tag_([a-zA-Z0-9_\-]+)$/', $condition, $tag_match)){
|
1321 |
+
//event doesn't have this tag
|
1322 |
+
$show_condition = !has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
|
1323 |
+
}
|
1324 |
+
//other potential ones - has_attribute_... no_attribute_... has_categories_...
|
1325 |
+
$show_condition = apply_filters('em_event_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
|
1326 |
+
if($show_condition){
|
1327 |
+
//calculate lengths to delete placeholders
|
1328 |
+
$placeholder_length = strlen($condition)+2;
|
1329 |
+
$replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key])-($placeholder_length *2 +1));
|
1330 |
+
}else{
|
1331 |
+
$replacement = '';
|
1332 |
+
}
|
1333 |
+
$event_string = str_replace($conditionals[0][$key], apply_filters('em_event_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $event_string);
|
1334 |
+
}
|
1335 |
+
}
|
1336 |
+
}
|
1337 |
+
//Now let's check out the placeholders.
|
1338 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $event_string, $placeholders);
|
1339 |
+
$replaces = array();
|
1340 |
+
foreach($placeholders[1] as $key => $result) {
|
1341 |
+
$match = true;
|
1342 |
+
$replace = '';
|
1343 |
+
$full_result = $placeholders[0][$key];
|
1344 |
+
switch( $result ){
|
1345 |
+
//Event Details
|
1346 |
+
case '#_EVENTID':
|
1347 |
+
$replace = $this->event_id;
|
1348 |
+
break;
|
1349 |
+
case '#_EVENTPOSTID':
|
1350 |
+
$replace = $this->post_id;
|
1351 |
+
break;
|
1352 |
+
case '#_NAME': //depreciated
|
1353 |
+
case '#_EVENTNAME':
|
1354 |
+
$replace = $this->event_name;
|
1355 |
+
break;
|
1356 |
+
case '#_NOTES': //depreciated
|
1357 |
+
case '#_EXCERPT': //depreciated
|
1358 |
+
case '#_EVENTNOTES':
|
1359 |
+
case '#_EVENTEXCERPT':
|
1360 |
+
$replace = $this->post_content;
|
1361 |
+
if($result == "#_EXCERPT" || $result == "#_EVENTEXCERPT"){
|
1362 |
+
if( !empty($this->post_excerpt) ){
|
1363 |
+
$replace = $this->post_excerpt;
|
1364 |
+
}else{
|
1365 |
+
$excerpt_length = 55;
|
1366 |
+
$excerpt_more = apply_filters('em_excerpt_more', ' ' . '[...]');
|
1367 |
+
if( !empty($placeholders[3][$key]) ){
|
1368 |
+
$trim = true;
|
1369 |
+
$ph_args = explode(',', $placeholders[3][$key]);
|
1370 |
+
if( is_numeric($ph_args[0]) ) $excerpt_length = $ph_args[0];
|
1371 |
+
if( !empty($ph_args[1]) ) $excerpt_more = $ph_args[1];
|
1372 |
+
}
|
1373 |
+
if ( preg_match('/<!--more(.*?)?-->/', $replace, $matches) ) {
|
1374 |
+
$content = explode($matches[0], $replace, 2);
|
1375 |
+
$replace = force_balance_tags($content[0]);
|
1376 |
+
}
|
1377 |
+
if( !empty($trim) ){
|
1378 |
+
//shorten content by supplied number - copied from wp_trim_excerpt
|
1379 |
+
$replace = strip_shortcodes( $replace );
|
1380 |
+
$replace = str_replace(']]>', ']]>', $replace);
|
1381 |
+
$replace = wp_trim_words( $replace, $excerpt_length, $excerpt_more );
|
1382 |
+
}
|
1383 |
+
}
|
1384 |
+
}
|
1385 |
+
break;
|
1386 |
+
case '#_EVENTIMAGEURL':
|
1387 |
+
case '#_EVENTIMAGE':
|
1388 |
+
if($this->get_image_url() != ''){
|
1389 |
+
if($result == '#_EVENTIMAGEURL'){
|
1390 |
+
$replace = esc_url($this->image_url);
|
1391 |
+
}else{
|
1392 |
+
if( empty($placeholders[3][$key]) ){
|
1393 |
+
$replace = "<img src='".esc_url($this->image_url)."' alt='".esc_attr($this->event_name)."'/>";
|
1394 |
+
}else{
|
1395 |
+
$image_size = explode(',', $placeholders[3][$key]);
|
1396 |
+
$image_src = $this->image_url;
|
1397 |
+
if( $this->array_is_numeric($image_size) && count($image_size) > 1 ){
|
1398 |
+
//get a thumbnail
|
1399 |
+
if( get_option('dbem_disable_timthumb') ){
|
1400 |
+
if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){
|
1401 |
+
switch_to_blog($this->blog_id);
|
1402 |
+
$switch_back = true;
|
1403 |
+
}
|
1404 |
+
$replace = get_the_post_thumbnail($this->ID, $image_size);
|
1405 |
+
if( !empty($switch_back) ){ restore_current_blog(); }
|
1406 |
+
}else{
|
1407 |
+
if ( is_multisite() ) { //get the direct url as timthumb doesn't support redirect urls
|
1408 |
+
global $blog_id;
|
1409 |
+
$imageParts = explode('/blogs.dir/', $image_src);
|
1410 |
+
if (isset($imageParts[1])) {
|
1411 |
+
$image_src = network_site_url('/wp-content/blogs.dir/'. $imageParts[1]);
|
1412 |
+
}
|
1413 |
+
}
|
1414 |
+
$width = ($image_size[0]) ? 'width="'.esc_attr($image_size[0]).'"':'';
|
1415 |
+
$height = ($image_size[1]) ? 'height="'.esc_attr($image_size[1]).'"':'';
|
1416 |
+
$replace = "<img src='".esc_url(em_get_thumbnail_url($image_src, $image_size[0], $image_size[1]))."' alt='".esc_attr($this->event_name)."' $width $height />";
|
1417 |
+
}
|
1418 |
+
}else{
|
1419 |
+
$replace = "<img src='".esc_url($image_src)."' alt='".esc_attr($this->event_name)."'/>";
|
1420 |
+
}
|
1421 |
+
}
|
1422 |
+
}
|
1423 |
+
}
|
1424 |
+
break;
|
1425 |
+
//Times & Dates
|
1426 |
+
case '#_24HSTARTTIME':
|
1427 |
+
case '#_24HENDTIME':
|
1428 |
+
$time = ($result == '#_24HSTARTTIME') ? $this->event_start_time:$this->event_end_time;
|
1429 |
+
$replace = substr($time, 0,5);
|
1430 |
+
break;
|
1431 |
+
case '#_12HSTARTTIME':
|
1432 |
+
case '#_12HENDTIME':
|
1433 |
+
$time = ($result == '#_12HSTARTTIME') ? $this->event_start_time:$this->event_end_time;
|
1434 |
+
$replace = date('g:i A', strtotime($time));
|
1435 |
+
break;
|
1436 |
+
case '#_EVENTTIMES':
|
1437 |
+
//get format of time to show
|
1438 |
+
if( !$this->event_all_day ){
|
1439 |
+
$time_format = ( get_option('dbem_time_format') ) ? get_option('dbem_time_format'):get_option('time_format');
|
1440 |
+
if($this->event_start_time != $this->event_end_time ){
|
1441 |
+
$replace = date_i18n($time_format, $this->start). get_option('dbem_times_separator') . date_i18n($time_format, $this->end);
|
1442 |
+
}else{
|
1443 |
+
$replace = date_i18n($time_format, $this->start);
|
1444 |
+
}
|
1445 |
+
}else{
|
1446 |
+
$replace = get_option('dbem_event_all_day_message');
|
1447 |
+
}
|
1448 |
+
break;
|
1449 |
+
case '#_EVENTDATES':
|
1450 |
+
//get format of time to show
|
1451 |
+
$date_format = ( get_option('dbem_date_format') ) ? get_option('dbem_date_format'):get_option('date_format');
|
1452 |
+
if( $this->event_start_date != $this->event_end_date){
|
1453 |
+
$replace = date_i18n($date_format, $this->start). get_option('dbem_dates_separator') . date_i18n($date_format, $this->end);
|
1454 |
+
}else{
|
1455 |
+
$replace = date_i18n($date_format, $this->start);
|
1456 |
+
}
|
1457 |
+
break;
|
1458 |
+
//Links
|
1459 |
+
case '#_EVENTPAGEURL': //Depreciated
|
1460 |
+
case '#_LINKEDNAME': //Depreciated
|
1461 |
+
case '#_EVENTURL': //Just the URL
|
1462 |
+
case '#_EVENTLINK': //HTML Link
|
1463 |
+
$event_link = esc_url($this->get_permalink());
|
1464 |
+
if($result == '#_LINKEDNAME' || $result == '#_EVENTLINK'){
|
1465 |
+
$replace = '<a href="'.$event_link.'" title="'.esc_attr($this->event_name).'">'.esc_attr($this->event_name).'</a>';
|
1466 |
+
}else{
|
1467 |
+
$replace = $event_link;
|
1468 |
+
}
|
1469 |
+
break;
|
1470 |
+
case '#_EDITEVENTURL':
|
1471 |
+
case '#_EDITEVENTLINK':
|
1472 |
+
if( $this->can_manage('edit_events','edit_others_events') ){
|
1473 |
+
$link = esc_url($this->get_edit_url());
|
1474 |
+
if( $result == '#_EDITEVENTLINK'){
|
1475 |
+
$replace = '<a href="'.$link.'">'.esc_html(sprintf(__('Edit Event','dbem'))).'</a>';
|
1476 |
+
}else{
|
1477 |
+
$replace = $link;
|
1478 |
+
}
|
1479 |
+
}
|
1480 |
+
break;
|
1481 |
+
//Bookings
|
1482 |
+
case '#_ADDBOOKINGFORM': //Depreciated
|
1483 |
+
case '#_REMOVEBOOKINGFORM': //Depreciated
|
1484 |
+
case '#_BOOKINGFORM':
|
1485 |
+
if( get_option('dbem_rsvp_enabled')){
|
1486 |
+
ob_start();
|
1487 |
+
$template = em_locate_template('placeholders/bookingform.php', true, array('EM_Event'=>$this));
|
1488 |
+
EM_Bookings::enqueue_js();
|
1489 |
+
$replace = ob_get_clean();
|
1490 |
+
}
|
1491 |
+
break;
|
1492 |
+
case '#_BOOKINGBUTTON':
|
1493 |
+
if( get_option('dbem_rsvp_enabled') && $this->event_rsvp ){
|
1494 |
+
ob_start();
|
1495 |
+
$template = em_locate_template('placeholders/bookingbutton.php', true, array('EM_Event'=>$this));
|
1496 |
+
$replace = ob_get_clean();
|
1497 |
+
}
|
1498 |
+
break;
|
1499 |
+
case '#_EVENTPRICERANGEALL':
|
1500 |
+
$show_all_ticket_prices = true; //continues below
|
1501 |
+
case '#_EVENTPRICERANGE':
|
1502 |
+
//get the range of prices
|
1503 |
+
$min = false;
|
1504 |
+
$max = 0;
|
1505 |
+
if( $this->get_bookings()->is_open() || !empty($show_all_ticket_prices) ){
|
1506 |
+
foreach( $this->get_tickets()->tickets as $EM_Ticket ){
|
1507 |
+
/* @var $EM_Ticket EM_Ticket */
|
1508 |
+
if( $EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable') || !empty($show_all_ticket_prices) ){
|
1509 |
+
if($EM_Ticket->get_price() > $max ){
|
1510 |
+
$max = $EM_Ticket->get_price();
|
1511 |
+
}
|
1512 |
+
if($EM_Ticket->get_price() < $min || $min === false){
|
1513 |
+
$min = $EM_Ticket->get_price();
|
1514 |
+
}
|
1515 |
+
}
|
1516 |
+
}
|
1517 |
+
}
|
1518 |
+
if( $min === false ) $min = 0;
|
1519 |
+
if( $min != $max ){
|
1520 |
+
$replace = em_get_currency_formatted($min).' - '.em_get_currency_formatted($max);
|
1521 |
+
}else{
|
1522 |
+
$replace = em_get_currency_formatted($min);
|
1523 |
+
}
|
1524 |
+
break;
|
1525 |
+
case '#_EVENTPRICEMIN':
|
1526 |
+
//get the range of prices
|
1527 |
+
$min = false;
|
1528 |
+
foreach( $this->get_tickets()->tickets as $EM_Ticket ){
|
1529 |
+
/* @var $EM_Ticket EM_Ticket */
|
1530 |
+
if( $EM_Ticket->is_available()|| get_option('dbem_bookings_tickets_show_unavailable') ){
|
1531 |
+
if( $EM_Ticket->get_price() < $min || $min === false){
|
1532 |
+
$min = $EM_Ticket->get_price();
|
1533 |
+
}
|
1534 |
+
}
|
1535 |
+
}
|
1536 |
+
if( $min === false ) $min = 0;
|
1537 |
+
$replace = em_get_currency_formatted($min);
|
1538 |
+
break;
|
1539 |
+
case '#_EVENTPRICEMAX':
|
1540 |
+
//get the range of prices
|
1541 |
+
$max = 0;
|
1542 |
+
foreach( $this->get_tickets()->tickets as $EM_Ticket ){
|
1543 |
+
/* @var $EM_Ticket EM_Ticket */
|
1544 |
+
if( $EM_Ticket->is_available()|| get_option('dbem_bookings_tickets_show_unavailable') ){
|
1545 |
+
if( $EM_Ticket->get_price() > $max ){
|
1546 |
+
$max = $EM_Ticket->get_price();
|
1547 |
+
}
|
1548 |
+
}
|
1549 |
+
}
|
1550 |
+
$replace = em_get_currency_formatted($max);
|
1551 |
+
break;
|
1552 |
+
case '#_AVAILABLESEATS': //Depreciated
|
1553 |
+
case '#_AVAILABLESPACES':
|
1554 |
+
if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
|
1555 |
+
$replace = $this->get_bookings()->get_available_spaces();
|
1556 |
+
} else {
|
1557 |
+
$replace = "0";
|
1558 |
+
}
|
1559 |
+
break;
|
1560 |
+
case '#_BOOKEDSEATS': //Depreciated
|
1561 |
+
case '#_BOOKEDSPACES':
|
1562 |
+
//This placeholder is actually a little misleading, as it'll consider reserved (i.e. pending) bookings as 'booked'
|
1563 |
+
if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
|
1564 |
+
$replace = $this->get_bookings()->get_booked_spaces();
|
1565 |
+
if( get_option('dbem_bookings_approval_reserved') ){
|
1566 |
+
$replace += $this->get_bookings()->get_pending_spaces();
|
1567 |
+
}
|
1568 |
+
} else {
|
1569 |
+
$replace = "0";
|
1570 |
+
}
|
1571 |
+
break;
|
1572 |
+
case '#_PENDINGSPACES':
|
1573 |
+
if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
|
1574 |
+
$replace = $this->get_bookings()->get_pending_spaces();
|
1575 |
+
} else {
|
1576 |
+
$replace = "0";
|
1577 |
+
}
|
1578 |
+
break;
|
1579 |
+
case '#_SEATS': //Depreciated
|
1580 |
+
case '#_SPACES':
|
1581 |
+
$replace = $this->get_spaces();
|
1582 |
+
break;
|
1583 |
+
case '#_BOOKINGSURL':
|
1584 |
+
case '#_BOOKINGSLINK':
|
1585 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
1586 |
+
$bookings_link = esc_url($this->get_bookings_url());
|
1587 |
+
if($result == '#_BOOKINGSLINK'){
|
1588 |
+
$replace = '<a href="'.$bookings_link.'" title="'.esc_attr($this->event_name).'">'.esc_html($this->event_name).'</a>';
|
1589 |
+
}else{
|
1590 |
+
$replace = $bookings_link;
|
1591 |
+
}
|
1592 |
+
}
|
1593 |
+
break;
|
1594 |
+
//Contact Person
|
1595 |
+
case '#_CONTACTNAME':
|
1596 |
+
case '#_CONTACTPERSON': //Depreciated (your call, I think name is better)
|
1597 |
+
$replace = $this->get_contact()->display_name;
|
1598 |
+
break;
|
1599 |
+
case '#_CONTACTUSERNAME':
|
1600 |
+
$replace = $this->get_contact()->user_login;
|
1601 |
+
break;
|
1602 |
+
case '#_CONTACTEMAIL':
|
1603 |
+
case '#_CONTACTMAIL': //Depreciated
|
1604 |
+
$replace = $this->get_contact()->user_email;
|
1605 |
+
break;
|
1606 |
+
case '#_CONTACTURL':
|
1607 |
+
$replace = $this->get_contact()->user_url;
|
1608 |
+
break;
|
1609 |
+
case '#_CONTACTID':
|
1610 |
+
$replace = $this->get_contact()->ID;
|
1611 |
+
break;
|
1612 |
+
case '#_CONTACTPHONE':
|
1613 |
+
$replace = ( $this->get_contact()->phone != '') ? $this->get_contact()->phone : __('N/A', 'dbem');
|
1614 |
+
break;
|
1615 |
+
case '#_CONTACTAVATAR':
|
1616 |
+
$replace = get_avatar( $this->get_contact()->ID, $size = '50' );
|
1617 |
+
break;
|
1618 |
+
case '#_CONTACTPROFILELINK':
|
1619 |
+
case '#_CONTACTPROFILEURL':
|
1620 |
+
if( function_exists('bp_core_get_user_domain') ){
|
1621 |
+
$replace = bp_core_get_user_domain($this->get_contact()->ID);
|
1622 |
+
if( $result == '#_CONTACTPROFILELINK' ){
|
1623 |
+
$replace = '<a href="'.esc_url($replace).'">'.__('Profile', 'dbem').'</a>';
|
1624 |
+
}
|
1625 |
+
}
|
1626 |
+
break;
|
1627 |
+
case '#_CONTACTMETA':
|
1628 |
+
if( !empty($placeholders[3][$key]) ){
|
1629 |
+
$replace = get_user_meta($this->event_owner, $placeholders[3][$key], true);
|
1630 |
+
}
|
1631 |
+
break;
|
1632 |
+
case '#_ATTENDEES':
|
1633 |
+
ob_start();
|
1634 |
+
$template = em_locate_template('placeholders/attendees.php', true, array('EM_Event'=>$this));
|
1635 |
+
$replace = ob_get_clean();
|
1636 |
+
break;
|
1637 |
+
case '#_ATTENDEESLIST':
|
1638 |
+
ob_start();
|
1639 |
+
$template = em_locate_template('placeholders/attendeeslist.php', true, array('EM_Event'=>$this));
|
1640 |
+
$replace = ob_get_clean();
|
1641 |
+
break;
|
1642 |
+
case '#_ATTENDEESPENDINGLIST':
|
1643 |
+
ob_start();
|
1644 |
+
$template = em_locate_template('placeholders/attendeespendinglist.php', true, array('EM_Event'=>$this));
|
1645 |
+
$replace = ob_get_clean();
|
1646 |
+
break;
|
1647 |
+
//Categories and Tags
|
1648 |
+
case '#_EVENTCATEGORIESIMAGES':
|
1649 |
+
ob_start();
|
1650 |
+
$template = em_locate_template('placeholders/eventcategoriesimages.php', true, array('EM_Event'=>$this));
|
1651 |
+
$replace = ob_get_clean();
|
1652 |
+
break;
|
1653 |
+
case '#_EVENTTAGS':
|
1654 |
+
ob_start();
|
1655 |
+
$template = em_locate_template('placeholders/eventtags.php', true, array('EM_Event'=>$this));
|
1656 |
+
$replace = ob_get_clean();
|
1657 |
+
break;
|
1658 |
+
case '#_CATEGORIES': //depreciated
|
1659 |
+
case '#_EVENTCATEGORIES':
|
1660 |
+
ob_start();
|
1661 |
+
$template = em_locate_template('placeholders/categories.php', true, array('EM_Event'=>$this));
|
1662 |
+
$replace = ob_get_clean();
|
1663 |
+
break;
|
1664 |
+
//Ical Stuff
|
1665 |
+
case '#_EVENTICALURL':
|
1666 |
+
case '#_EVENTICALLINK':
|
1667 |
+
$replace = $this->get_ical_url();
|
1668 |
+
if( $result == '#_EVENTICALLINK' ){
|
1669 |
+
$replace = '<a href="'.esc_url($replace).'">iCal</a>';
|
1670 |
+
}
|
1671 |
+
break;
|
1672 |
+
case '#_EVENTGCALURL':
|
1673 |
+
case '#_EVENTGCALLINK':
|
1674 |
+
//get dates
|
1675 |
+
if($this->event_all_day && $this->event_start_date == $this->event_end_date){
|
1676 |
+
$dateStart = date('Ymd',$this->start - (60*60*get_option('gmt_offset')));
|
1677 |
+
$dateEnd = date('Ymd',$this->start + 60*60*24 - (60*60*get_option('gmt_offset')));
|
1678 |
+
}else{
|
1679 |
+
$dateStart = date('Ymd\THis\Z',$this->start - (60*60*get_option('gmt_offset')));
|
1680 |
+
$dateEnd = date('Ymd\THis\Z',$this->end - (60*60*get_option('gmt_offset')));
|
1681 |
+
}
|
1682 |
+
//build url
|
1683 |
+
$gcal_url = 'http://www.google.com/calendar/event?action=TEMPLATE&text=event_name&dates=start_date/end_date&details=post_content&location=location_name&trp=false&sprop=event_url&sprop=name:blog_name';
|
1684 |
+
$gcal_url = str_replace('event_name', urlencode($this->event_name), $gcal_url);
|
1685 |
+
$gcal_url = str_replace('start_date', urlencode($dateStart), $gcal_url);
|
1686 |
+
$gcal_url = str_replace('end_date', urlencode($dateEnd), $gcal_url);
|
1687 |
+
$gcal_url = str_replace('location_name', urlencode($this->output('#_LOCATION')), $gcal_url);
|
1688 |
+
$gcal_url = str_replace('blog_name', urlencode(get_bloginfo()), $gcal_url);
|
1689 |
+
$gcal_url = str_replace('event_url', urlencode($this->get_permalink()), $gcal_url);
|
1690 |
+
//calculate URL length so we know how much we can work with to make a description.
|
1691 |
+
if( !empty($this->post_excerpt) ){
|
1692 |
+
$gcal_url_description = $this->post_excerpt;
|
1693 |
+
}else{
|
1694 |
+
$matches = explode('<!--more', $this->post_content);
|
1695 |
+
$gcal_url_description = wp_kses_data($matches[0]);
|
1696 |
+
}
|
1697 |
+
$gcal_url_length = strlen($gcal_url) - 9;
|
1698 |
+
if( strlen($gcal_url_description) + $gcal_url_length > 1350 ){
|
1699 |
+
$gcal_url_description = substr($gcal_url_description, 0, 1380 - $gcal_url_length - 3 ).'...';
|
1700 |
+
}
|
1701 |
+
$gcal_url = str_replace('post_content', urlencode($gcal_url_description), $gcal_url);
|
1702 |
+
//get the final url
|
1703 |
+
$replace = $gcal_url;
|
1704 |
+
if( $result == '#_EVENTGCALLINK' ){
|
1705 |
+
$img_url = 'www.google.com/calendar/images/ext/gc_button2.gif';
|
1706 |
+
$img_url = is_ssl() ? 'https://'.$img_url:'http://'.$img_url;
|
1707 |
+
$replace = '<a href="'.esc_url($replace).'" target="_blank"><img src="'.esc_url($img_url).'" alt="0" border="0"></a>';
|
1708 |
+
}
|
1709 |
+
break;
|
1710 |
+
default:
|
1711 |
+
$replace = $full_result;
|
1712 |
+
break;
|
1713 |
+
}
|
1714 |
+
$replaces[$full_result] = apply_filters('em_event_output_placeholder', $replace, $this, $full_result, $target);
|
1715 |
+
}
|
1716 |
+
//sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
|
1717 |
+
krsort($replaces);
|
1718 |
+
foreach($replaces as $full_result => $replacement){
|
1719 |
+
if( !in_array($full_result, array('#_NOTES','#_EVENTNOTES')) ){
|
1720 |
+
$event_string = str_replace($full_result, $replacement , $event_string );
|
1721 |
+
}else{
|
1722 |
+
$new_placeholder = str_replace('#_', '__#', $full_result); //this will avoid repeated filters when locations/categories are parsed
|
1723 |
+
$event_string = str_replace($full_result, $new_placeholder , $event_string );
|
1724 |
+
$desc_replace[$new_placeholder] = $replacement;
|
1725 |
+
}
|
1726 |
+
}
|
1727 |
+
//Time placeholders
|
1728 |
+
foreach($placeholders[1] as $result) {
|
1729 |
+
// matches all PHP START date and time placeholders
|
1730 |
+
if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
|
1731 |
+
$replace = date_i18n(ltrim($result, "#"), $this->start);
|
1732 |
+
$replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
|
1733 |
+
$event_string = str_replace($result, $replace, $event_string );
|
1734 |
+
}
|
1735 |
+
// matches all PHP END time placeholders for endtime
|
1736 |
+
if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
|
1737 |
+
$replace = date_i18n(ltrim($result, "#@"), $this->end);
|
1738 |
+
$replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
|
1739 |
+
$event_string = str_replace($result, $replace, $event_string );
|
1740 |
+
}
|
1741 |
+
}
|
1742 |
+
//Now do dependent objects
|
1743 |
+
if( !empty($this->location_id) && $this->get_location()->location_status ){
|
1744 |
+
$event_string = $this->get_location()->output($event_string, $target);
|
1745 |
+
}else{
|
1746 |
+
$EM_Location = new EM_Location();
|
1747 |
+
$event_string = $EM_Location->output($event_string, $target);
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
//for backwards compat and easy use, take over the individual category placeholders with the frirst cat in th elist.
|
1751 |
+
$EM_Categories = $this->get_categories();
|
1752 |
+
if( count($EM_Categories->categories) > 0 ){
|
1753 |
+
$EM_Category = $EM_Categories->get_first();
|
1754 |
+
}
|
1755 |
+
|
1756 |
+
if( empty($EM_Category) ) $EM_Category = new EM_Category();
|
1757 |
+
$event_string = $EM_Category->output($event_string, $target);
|
1758 |
+
|
1759 |
+
//Finally, do the event notes, so that previous placeholders don't get replaced within the content, which may use shortcodes
|
1760 |
+
if( !empty($desc_replace) ){
|
1761 |
+
foreach($desc_replace as $full_result => $replacement){
|
1762 |
+
$event_string = str_replace($full_result, $replacement , $event_string );
|
1763 |
+
}
|
1764 |
+
}
|
1765 |
+
|
1766 |
+
//do some specific formatting
|
1767 |
+
//TODO apply this sort of formatting to any output() function
|
1768 |
+
if( $target == 'ical' ){
|
1769 |
+
//strip html and escape characters
|
1770 |
+
$event_string = str_replace('\\','\\\\',strip_tags($event_string));
|
1771 |
+
$event_string = str_replace(';','\;',$event_string);
|
1772 |
+
$event_string = str_replace(',','\,',$event_string);
|
1773 |
+
//remove and define line breaks in ical format
|
1774 |
+
$event_string = str_replace("\r\n",'\n',$event_string);
|
1775 |
+
$event_string = str_replace("\n",'\n',$event_string);
|
1776 |
+
}
|
1777 |
+
|
1778 |
+
return apply_filters('em_event_output', $event_string, $this, $format, $target);
|
1779 |
+
}
|
1780 |
+
|
1781 |
+
/**********************************************************
|
1782 |
+
* RECURRENCE METHODS
|
1783 |
+
***********************************************************/
|
1784 |
+
|
1785 |
+
/**
|
1786 |
+
* Returns true if this is a recurring event.
|
1787 |
+
* @return boolean
|
1788 |
+
*/
|
1789 |
+
function is_recurring(){
|
1790 |
+
return $this->post_type == 'event-recurring' && get_option('dbem_recurrence_enabled');
|
1791 |
+
}
|
1792 |
+
/**
|
1793 |
+
* Will return true if this individual event is part of a set of events that recur
|
1794 |
+
* @return boolean
|
1795 |
+
*/
|
1796 |
+
function is_recurrence(){
|
1797 |
+
return ( $this->event_id > 0 && $this->recurrence_id > 0 && get_option('dbem_recurrence_enabled') );
|
1798 |
+
}
|
1799 |
+
/**
|
1800 |
+
* Returns if this is an individual event and is not a recurrence
|
1801 |
+
* @return boolean
|
1802 |
+
*/
|
1803 |
+
function is_individual(){
|
1804 |
+
return ( !$this->is_recurring() && !$this->is_recurrence() );
|
1805 |
+
}
|
1806 |
+
|
1807 |
+
/**
|
1808 |
+
* Gets the event recurrence template, which is an EM_Event_Recurrence object (based off an event-recurring post)
|
1809 |
+
* @return EM_Event_Recurrence
|
1810 |
+
*/
|
1811 |
+
function get_event_recurrence(){
|
1812 |
+
if(!$this->is_recurring()){
|
1813 |
+
return new EM_Event($this->recurrence_id); //remember, recurrence_id is a post!
|
1814 |
+
}else{
|
1815 |
+
return $this;
|
1816 |
+
}
|
1817 |
+
}
|
1818 |
+
|
1819 |
+
function get_detach_url(){
|
1820 |
+
return admin_url().'admin.php?event_id='.$this->event_id.'&action=event_detach&_wpnonce='.wp_create_nonce('event_detach_'.get_current_user_id().'_'.$this->event_id);
|
1821 |
+
}
|
1822 |
+
|
1823 |
+
function get_attach_url($recurrence_id){
|
1824 |
+
return admin_url().'admin.php?undo_id='.$recurrence_id.'&event_id='.$this->event_id.'&action=event_attach&_wpnonce='.wp_create_nonce('event_attach_'.get_current_user_id().'_'.$this->event_id);
|
1825 |
+
}
|
1826 |
+
|
1827 |
+
/**
|
1828 |
+
* Returns if this is an individual event and is not recurring or a recurrence
|
1829 |
+
* @return boolean
|
1830 |
+
*/
|
1831 |
+
function detach(){
|
1832 |
+
global $wpdb;
|
1833 |
+
if( $this->is_recurrence() && !$this->is_recurring() && $this->can_manage('edit_recurring_events','edit_others_recurring_events') ){
|
1834 |
+
//remove recurrence id from post meta and index table
|
1835 |
+
$url = $this->get_attach_url($this->recurrence_id);
|
1836 |
+
$wpdb->update(EM_EVENTS_TABLE, array('recurrence_id'=>0), array('event_id' => $this->event_id));
|
1837 |
+
update_post_meta($this->post_id, '_recurrence_id', 0);
|
1838 |
+
$this->feedback_message = __('Event detached.','dbem') . ' <a href="'.$url.'">'.__('Undo','dbem').'</a>';
|
1839 |
+
$this->recurrence_id = 0;
|
1840 |
+
return true;
|
1841 |
+
}
|
1842 |
+
$this->add_error(__('Event could not be detached.','dbem'));
|
1843 |
+
return false;
|
1844 |
+
}
|
1845 |
+
|
1846 |
+
/**
|
1847 |
+
* Returns if this is an individual event and is not recurring or a recurrence
|
1848 |
+
* @return boolean
|
1849 |
+
*/
|
1850 |
+
function attach($recurrence_id){
|
1851 |
+
global $wpdb;
|
1852 |
+
if( !$this->is_recurrence() && !$this->is_recurring() && is_numeric($recurrence_id) && $this->can_manage('edit_recurring_events','edit_others_recurring_events') ){
|
1853 |
+
//add recurrence id to post meta and index table
|
1854 |
+
$wpdb->update(EM_EVENTS_TABLE, array('recurrence_id'=>$recurrence_id), array('event_id' => $this->event_id));
|
1855 |
+
update_post_meta($this->post_id, '_recurrence_id', $recurrence_id);
|
1856 |
+
$this->feedback_message = __('Event re-attached to recurrence.','dbem');
|
1857 |
+
return true;
|
1858 |
+
}
|
1859 |
+
$this->add_error(__('Event could not be attached.','dbem'));
|
1860 |
+
return false;
|
1861 |
+
}
|
1862 |
+
|
1863 |
+
/**
|
1864 |
+
* Saves events and replaces old ones. Returns true if sucecssful or false if not.
|
1865 |
+
* @return boolean
|
1866 |
+
*/
|
1867 |
+
function save_events() {
|
1868 |
+
global $wpdb;
|
1869 |
+
if( $this->can_manage('edit_events','edit_others_events') && $this->is_published() ){
|
1870 |
+
do_action('em_event_save_events_pre', $this); //actions/filters only run if event is recurring
|
1871 |
+
//Make template event index, post, and meta (and we just change event dates)
|
1872 |
+
$event = $this->to_array(true); //event template - for index
|
1873 |
+
$event['event_attributes'] = serialize($event['event_attributes']);
|
1874 |
+
$post_fields = $wpdb->get_row('SELECT * FROM '.$wpdb->posts.' WHERE ID='.$this->post_id, ARRAY_A); //post to copy
|
1875 |
+
$post_name = $post_fields['post_name']; //save post slug since we'll be using this
|
1876 |
+
$post_fields['post_type'] = 'event'; //make sure we'll save events, not recurrence templates
|
1877 |
+
$meta_fields_map = $wpdb->get_results('SELECT meta_key,meta_value FROM '.$wpdb->postmeta.' WHERE post_id='.$this->post_id, ARRAY_A);
|
1878 |
+
$meta_fields = array();
|
1879 |
+
//convert meta_fields into a cleaner array
|
1880 |
+
foreach($meta_fields_map as $meta_data){
|
1881 |
+
$meta_fields[$meta_data['meta_key']] = $meta_data['meta_value'];
|
1882 |
+
}
|
1883 |
+
//remove id and we have a event template to feed to wpdb insert
|
1884 |
+
unset($event['event_id']);
|
1885 |
+
unset($post_fields['ID']);
|
1886 |
+
//remove recurrence meta info we won't need in events
|
1887 |
+
foreach( array_keys($this->recurrence_fields) as $recurrence_field){
|
1888 |
+
unset($event[$recurrence_field]);
|
1889 |
+
unset($meta_fields['_'.$recurrence_field]);
|
1890 |
+
}
|
1891 |
+
$event['event_date_created'] = current_time('mysql'); //since the recurrences are recreated
|
1892 |
+
unset($event['event_date_modified']);
|
1893 |
+
//Set the recurrence ID
|
1894 |
+
$event['recurrence_id'] = $meta_fields['_recurrence_id'] = $this->event_id;
|
1895 |
+
$event['recurrence'] = $meta_fields['_recurrence'] = 0;
|
1896 |
+
//Let's start saving!
|
1897 |
+
$this->delete_events(); //Delete old events beforehand, this will change soon
|
1898 |
+
$event_saves = array();
|
1899 |
+
$event_ids = array();
|
1900 |
+
$post_ids = array();
|
1901 |
+
$matching_days = $this->get_recurrence_days(); //Get days where events recur
|
1902 |
+
if( count($matching_days) > 0 ){
|
1903 |
+
//first save event post data
|
1904 |
+
$recurring_date_format = apply_filters('em_event_save_events_format', 'Y-m-d');
|
1905 |
+
foreach( $matching_days as $day ) {
|
1906 |
+
//rewrite post fields if needed
|
1907 |
+
$post_fields['post_name'] = $event['event_slug'] = $meta_fields['_event_slug'] = apply_filters('em_event_save_events_slug', $post_name.'-'.date($recurring_date_format, $day), $post_fields, $day, $matching_days, $this);
|
1908 |
+
//adjust certain meta information
|
1909 |
+
$event['event_start_date'] = $meta_fields['_event_start_date'] = date("Y-m-d", $day);
|
1910 |
+
$meta_fields['_start_ts'] = strtotime($event['event_start_date'].' '.$event['event_start_time']);
|
1911 |
+
$event['event_rsvp_date'] = $meta_fields['_event_rsvp_date'] = $event['event_start_date'];
|
1912 |
+
$event['event_rsvp_time'] = $meta_fields['_event_rsvp_time'] = $event['event_start_time'];
|
1913 |
+
if($this->recurrence_days > 0){
|
1914 |
+
$event['event_end_date'] = $meta_fields['_event_end_date'] = date("Y-m-d", $meta_fields['_start_ts'] + ($this->recurrence_days * 60*60*24));
|
1915 |
+
}else{
|
1916 |
+
$event['event_end_date'] = $meta_fields['_event_end_date'] = $event['event_start_date'];
|
1917 |
+
}
|
1918 |
+
$meta_fields['_end_ts'] = strtotime($event['event_end_date'].' '.$event['event_end_time']);
|
1919 |
+
//create the event
|
1920 |
+
if( $wpdb->insert($wpdb->posts, $post_fields ) ){
|
1921 |
+
$event['post_id'] = $meta_fields['_post_id'] = $post_id = $post_ids[] = $wpdb->insert_id; //post id saved into event and also as a var for later user
|
1922 |
+
// Set GUID and event slug as per wp_insert_post
|
1923 |
+
$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_id ) ), array('ID'=>$post_id) );
|
1924 |
+
//insert into events index table
|
1925 |
+
$event_saves[] = $wpdb->insert(EM_EVENTS_TABLE, $event);
|
1926 |
+
$event_ids[] = $event_id = $wpdb->insert_id;
|
1927 |
+
//create the meta inserts for each event
|
1928 |
+
$meta_fields['_event_id'] = $event_id;
|
1929 |
+
foreach($meta_fields as $meta_key => $meta_val){
|
1930 |
+
$meta_inserts[] = $wpdb->prepare("(%d, '%s', '%s')", array($post_id, $meta_key, $meta_val));
|
1931 |
+
}
|
1932 |
+
}else{
|
1933 |
+
$event_saves[] = false;
|
1934 |
+
}
|
1935 |
+
//if( EM_DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
|
1936 |
+
}
|
1937 |
+
//insert the metas in one go, faster than one by one
|
1938 |
+
if( count($meta_inserts) > 0 ){
|
1939 |
+
$result = $wpdb->query("INSERT INTO ".$wpdb->postmeta." (post_id,meta_key,meta_value) VALUES ".implode(',',$meta_inserts));
|
1940 |
+
if($result === false){
|
1941 |
+
$this->add_error('There was a problem adding custom fields to your recurring events.','dbem');
|
1942 |
+
}
|
1943 |
+
}
|
1944 |
+
//copy the event tags and categories
|
1945 |
+
$categories = $this->get_categories()->categories;
|
1946 |
+
foreach( $categories as $category){
|
1947 |
+
if( !empty($category->slug) ) $cat_slugs[] = $category->slug; //save of category will soft-fail if slug is empty
|
1948 |
+
}
|
1949 |
+
$cat_slugs_count = count($categories);
|
1950 |
+
$tags = get_the_terms( $this->post_id, EM_TAXONOMY_TAG);
|
1951 |
+
$tax_slugs = array();
|
1952 |
+
if( is_array($tags) ){
|
1953 |
+
foreach($tags as $tag){
|
1954 |
+
if( !empty($tag->slug) ) $tax_slugs[] = $tag->slug; //save of category will soft-fail if slug is empty
|
1955 |
+
}
|
1956 |
+
}
|
1957 |
+
$tax_slugs_count = count($tags);
|
1958 |
+
foreach($post_ids as $post_id){
|
1959 |
+
if( $cat_slugs_count > 0 && (!EM_MS_GLOBAL || is_main_site()) ){
|
1960 |
+
wp_set_object_terms($post_id, $cat_slugs, EM_TAXONOMY_CATEGORY);
|
1961 |
+
}
|
1962 |
+
if( $tax_slugs_count > 0 ){
|
1963 |
+
wp_set_object_terms($post_id, $tax_slugs, EM_TAXONOMY_TAG);
|
1964 |
+
}
|
1965 |
+
}
|
1966 |
+
//featured images
|
1967 |
+
if( !empty($this->attributes['thumbnail_id']) ){
|
1968 |
+
$image_inserts = array();
|
1969 |
+
foreach($post_ids as $post_ids){
|
1970 |
+
$image_inserts[] = "({$this->post_id}, '_thumbnail_id', {$this->attributes['thumbnail_id']})";
|
1971 |
+
}
|
1972 |
+
if( count($image_inserts) > 0 ){
|
1973 |
+
$wpdb->query('INSERT INTO '.$wpdb->postmeta.' (post_id, meta_key, meta_value) VALUES '.implode(', ', $image_inserts));
|
1974 |
+
}
|
1975 |
+
}
|
1976 |
+
//MS Global Categories
|
1977 |
+
if( $cat_slugs_count > 0 && EM_MS_GLOBAL ){
|
1978 |
+
foreach($categories as $EM_Category){
|
1979 |
+
foreach($event_ids as $event_id){
|
1980 |
+
$wpdb->insert(EM_META_TABLE, array('meta_value'=>$EM_Category->term_id,'object_id'=>$event_id,'meta_key'=>'event-category'));
|
1981 |
+
}
|
1982 |
+
}
|
1983 |
+
}
|
1984 |
+
//now, save booking info for each event
|
1985 |
+
if( $this->event_rsvp ){
|
1986 |
+
$meta_inserts = array();
|
1987 |
+
foreach($this->get_tickets() as $EM_Ticket){
|
1988 |
+
/* @var $EM_Ticket EM_Ticket */
|
1989 |
+
//get array, modify event id and insert
|
1990 |
+
$ticket = $EM_Ticket->to_array();
|
1991 |
+
unset($ticket['ticket_id']);
|
1992 |
+
//clean up ticket values
|
1993 |
+
foreach($ticket as $k => $v){
|
1994 |
+
if( empty($v) && $k != 'ticket_name' ){
|
1995 |
+
$ticket[$k] = 'NULL';
|
1996 |
+
}else{
|
1997 |
+
$data_type = !empty($EM_Ticket->fields[$k]['type']) ? $EM_Ticket->fields[$k]['type']:'%s';
|
1998 |
+
$ticket[$k] = $wpdb->prepare($data_type,$v);
|
1999 |
+
}
|
2000 |
+
}
|
2001 |
+
foreach($event_ids as $event_id){
|
2002 |
+
$ticket['event_id'] = $event_id;
|
2003 |
+
$meta_inserts[] = "(".implode(",",$ticket).")";
|
2004 |
+
}
|
2005 |
+
}
|
2006 |
+
$keys = "(".implode(",",array_keys($ticket)).")";
|
2007 |
+
$values = implode(',',$meta_inserts);
|
2008 |
+
$sql = "INSERT INTO ".EM_TICKETS_TABLE." $keys VALUES $values";
|
2009 |
+
$result = $wpdb->query($sql);
|
2010 |
+
}
|
2011 |
+
}else{
|
2012 |
+
$this->add_error('You have not defined a date range long enough to create a recurrence.','dbem');
|
2013 |
+
$result = false;
|
2014 |
+
}
|
2015 |
+
return apply_filters('em_event_save_events', !in_array(false, $event_saves) && $result !== false, $this, $event_ids, $post_ids);
|
2016 |
+
}
|
2017 |
+
return apply_filters('em_event_save_events', false, $this, $event_ids, $post_ids);
|
2018 |
+
}
|
2019 |
+
|
2020 |
+
/**
|
2021 |
+
* Removes all reoccurring events.
|
2022 |
+
* @param $recurrence_id
|
2023 |
+
* @return null
|
2024 |
+
*/
|
2025 |
+
function delete_events(){
|
2026 |
+
global $wpdb;
|
2027 |
+
do_action('em_event_delete_events_pre', $this);
|
2028 |
+
//So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer
|
2029 |
+
$result = false;
|
2030 |
+
if( $this->can_manage('delete_events', 'delete_others_events') ){
|
2031 |
+
//delete events from em_events table
|
2032 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$this->event_id, 'scope'=>'all', 'status'=>false ) );
|
2033 |
+
foreach($events_array as $EM_Event){
|
2034 |
+
/* @var $EM_Event EM_Event */
|
2035 |
+
if($EM_Event->recurrence_id == $this->event_id){
|
2036 |
+
$EM_Event->delete(true);
|
2037 |
+
}
|
2038 |
+
}
|
2039 |
+
}
|
2040 |
+
return apply_filters('delete_events', $result, $this, $events_array);
|
2041 |
+
}
|
2042 |
+
|
2043 |
+
/**
|
2044 |
+
* Returns the days that match the recurrance array passed (unix timestamps)
|
2045 |
+
* @param array $recurrence
|
2046 |
+
* @return array
|
2047 |
+
*/
|
2048 |
+
function get_recurrence_days(){
|
2049 |
+
$start_date = strtotime($this->event_start_date);
|
2050 |
+
$end_date = strtotime($this->event_end_date);
|
2051 |
+
|
2052 |
+
$weekdays = explode(",", $this->recurrence_byday); //what days of the week (or if monthly, one value at index 0)
|
2053 |
+
|
2054 |
+
$matching_days = array();
|
2055 |
+
$aDay = 86400; // a day in seconds
|
2056 |
+
$aWeek = $aDay * 7;
|
2057 |
+
|
2058 |
+
//TODO can this be optimized?
|
2059 |
+
switch ( $this->recurrence_freq ){
|
2060 |
+
case 'daily':
|
2061 |
+
//If daily, it's simple. Get start date, add interval timestamps to that and create matching day for each interval until end date.
|
2062 |
+
$current_date = $start_date;
|
2063 |
+
while( $current_date <= $end_date ){
|
2064 |
+
$matching_days[] = $current_date;
|
2065 |
+
$current_date = $current_date + ($aDay * $this->recurrence_interval);
|
2066 |
+
}
|
2067 |
+
break;
|
2068 |
+
case 'weekly':
|
2069 |
+
//sort out week one, get starting days and then days that match time span of event (i.e. remove past events in week 1)
|
2070 |
+
$start_of_week = get_option('start_of_week'); //Start of week depends on WordPress
|
2071 |
+
//first, get the start of this week as timestamp
|
2072 |
+
$event_start_day = date('w', $start_date);
|
2073 |
+
//then get the timestamps of weekdays during this first week, regardless if within event range
|
2074 |
+
$start_weekday_dates = array(); //Days in week 1 where there would events, regardless of event date range
|
2075 |
+
for($i = 0; $i < 7; $i++){
|
2076 |
+
$weekday_date = $start_date+($aDay*$i); //the date of the weekday we're currently checking
|
2077 |
+
$weekday_day = date('w',$weekday_date); //the day of the week we're checking, taking into account wp start of week setting
|
2078 |
+
|
2079 |
+
if( in_array( $weekday_day, $weekdays) ){
|
2080 |
+
$start_weekday_dates[] = $weekday_date; //it's in our starting week day, so add it
|
2081 |
+
}
|
2082 |
+
}
|
2083 |
+
//for each day of eventful days in week 1, add 7 days * weekly intervals
|
2084 |
+
foreach ($start_weekday_dates as $weekday_date){
|
2085 |
+
//Loop weeks by interval until we reach or surpass end date
|
2086 |
+
while($weekday_date <= $end_date){
|
2087 |
+
if( $weekday_date >= $start_date && $weekday_date <= $end_date ){
|
2088 |
+
$matching_days[] = $weekday_date;
|
2089 |
+
}
|
2090 |
+
$weekday_date = $weekday_date + ($aWeek * $this->recurrence_interval);
|
2091 |
+
}
|
2092 |
+
}//done!
|
2093 |
+
break;
|
2094 |
+
case 'monthly':
|
2095 |
+
//loop months starting this month by intervals
|
2096 |
+
$current_arr = getdate($start_date);
|
2097 |
+
$end_arr = getdate($end_date);
|
2098 |
+
$end_month_date = strtotime( date('Y-m-t', $end_date) ); //End date on last day of month
|
2099 |
+
$current_date = strtotime( date('Y-m-1', $start_date) ); //Start date on first day of month
|
2100 |
+
while( $current_date <= $end_month_date ){
|
2101 |
+
$last_day_of_month = date('t', $current_date);
|
2102 |
+
//Now find which day we're talking about
|
2103 |
+
$current_week_day = date('w',$current_date);
|
2104 |
+
$matching_month_days = array();
|
2105 |
+
//Loop through days of this years month and save matching days to temp array
|
2106 |
+
for($day = 1; $day <= $last_day_of_month; $day++){
|
2107 |
+
if((int) $current_week_day == $this->recurrence_byday){
|
2108 |
+
$matching_month_days[] = $day;
|
2109 |
+
}
|
2110 |
+
$current_week_day = ($current_week_day < 6) ? $current_week_day+1 : 0;
|
2111 |
+
}
|
2112 |
+
//Now grab from the array the x day of the month
|
2113 |
+
$matching_day = ($this->recurrence_byweekno > 0) ? $matching_month_days[$this->recurrence_byweekno-1] : array_pop($matching_month_days);
|
2114 |
+
$matching_date = strtotime(date('Y-m',$current_date).'-'.$matching_day);
|
2115 |
+
if($matching_date >= $start_date && $matching_date <= $end_date){
|
2116 |
+
$matching_days[] = $matching_date;
|
2117 |
+
}
|
2118 |
+
//add the number of days in this month to make start of next month
|
2119 |
+
$current_arr['mon'] += $this->recurrence_interval;
|
2120 |
+
if($current_arr['mon'] > 12){
|
2121 |
+
//FIXME this won't work if interval is more than 12
|
2122 |
+
$current_arr['mon'] = $current_arr['mon'] - 12;
|
2123 |
+
$current_arr['year']++;
|
2124 |
+
}
|
2125 |
+
$current_date = strtotime("{$current_arr['year']}-{$current_arr['mon']}-1");
|
2126 |
+
}
|
2127 |
+
break;
|
2128 |
+
case 'yearly':
|
2129 |
+
//If yearly, it's simple. Get start date, add interval timestamps to that and create matching day for each interval until end date.
|
2130 |
+
$month = date('m', $this->start);
|
2131 |
+
$day = date('d',$this->start);
|
2132 |
+
$year = date('Y',$this->start);
|
2133 |
+
$end_year = date('Y',$this->end);
|
2134 |
+
if( @mktime(0,0,0,$day,$month,$end_year) < $this->end ) $end_year--;
|
2135 |
+
while( $year <= $end_year ){
|
2136 |
+
$matching_days[] = mktime(0,0,0,$month,$day,$year);
|
2137 |
+
$year++;
|
2138 |
+
}
|
2139 |
+
break;
|
2140 |
+
}
|
2141 |
+
sort($matching_days);
|
2142 |
+
return apply_filters('em_events_get_recurrence_days', $matching_days, $this);
|
2143 |
+
}
|
2144 |
+
|
2145 |
+
/**
|
2146 |
+
* If event is recurring, set recurrences to same status as template
|
2147 |
+
* @param $status
|
2148 |
+
*/
|
2149 |
+
function set_status_events($status){
|
2150 |
+
//give sub events same status
|
2151 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$this->post_id, 'scope'=>'all', 'status'=>false ) );
|
2152 |
+
foreach($events_array as $EM_Event){
|
2153 |
+
/* @var $EM_Event EM_Event */
|
2154 |
+
if($EM_Event->recurrence_id == $this->event_id){
|
2155 |
+
$EM_Event->set_status($status);
|
2156 |
+
}
|
2157 |
+
}
|
2158 |
+
}
|
2159 |
+
|
2160 |
+
/**
|
2161 |
+
* Returns a string representation of this recurrence. Will return false if not a recurrence
|
2162 |
+
* @return string
|
2163 |
+
*/
|
2164 |
+
function get_recurrence_description() {
|
2165 |
+
$EM_Event_Recurring = $this->get_event_recurrence();
|
2166 |
+
$recurrence = $this->to_array();
|
2167 |
+
$weekdays_name = array(__('Sunday', 'dbem'),__('Monday', 'dbem'),__('Tuesday', 'dbem'),__('Wednesday', 'dbem'),__('Thursday', 'dbem'),__('Friday', 'dbem'),__('Saturday', 'dbem'));
|
2168 |
+
$monthweek_name = array('1' => __('the first %s of the month', 'dbem'),'2' => __('the second %s of the month', 'dbem'), '3' => __('the third %s of the month', 'dbem'), '4' => __('the fourth %s of the month', 'dbem'), '-1' => __('the last %s of the month', 'dbem'));
|
2169 |
+
$output = sprintf (__('From %1$s to %2$s', 'dbem'), $EM_Event_Recurring->event_start_date, $EM_Event_Recurring->event_end_date).", ";
|
2170 |
+
if ($EM_Event_Recurring->recurrence_freq == 'daily') {
|
2171 |
+
$freq_desc =__('everyday', 'dbem');
|
2172 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2173 |
+
$freq_desc = sprintf (__("every %s days", 'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2174 |
+
}
|
2175 |
+
}elseif ($EM_Event_Recurring->recurrence_freq == 'weekly') {
|
2176 |
+
$weekday_array = explode(",", $EM_Event_Recurring->recurrence_byday);
|
2177 |
+
$natural_days = array();
|
2178 |
+
foreach($weekday_array as $day){
|
2179 |
+
array_push($natural_days, $weekdays_name[$day]);
|
2180 |
+
}
|
2181 |
+
$output .= implode(", ", $natural_days);
|
2182 |
+
$freq_desc = " " . __("every week", 'dbem');
|
2183 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2184 |
+
$freq_desc = " ".sprintf (__("every %s weeks", 'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2185 |
+
}
|
2186 |
+
|
2187 |
+
}elseif ($EM_Event_Recurring->recurrence_freq == 'monthly') {
|
2188 |
+
$weekday_array = explode(",", $EM_Event_Recurring->recurrence_byday);
|
2189 |
+
$natural_days = array();
|
2190 |
+
foreach($weekday_array as $day){
|
2191 |
+
if( !empty($day) ){
|
2192 |
+
array_push($natural_days, $weekdays_name[$day]);
|
2193 |
+
}
|
2194 |
+
}
|
2195 |
+
$freq_desc = sprintf (($monthweek_name[$EM_Event_Recurring->recurrence_byweekno]), implode(" and ", $natural_days));
|
2196 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2197 |
+
$freq_desc .= ", ".sprintf (__("every %s months",'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2198 |
+
}
|
2199 |
+
}elseif ($EM_Event_Recurring->recurrence_freq == 'yearly') {
|
2200 |
+
$freq_desc .= __("every year", 'dbem');
|
2201 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2202 |
+
$freq_desc .= sprintf (__("every %s years",'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2203 |
+
}
|
2204 |
+
}else{
|
2205 |
+
$freq_desc = "[ERROR: corrupted database record]";
|
2206 |
+
}
|
2207 |
+
$output .= $freq_desc;
|
2208 |
+
return $output;
|
2209 |
+
}
|
2210 |
+
|
2211 |
+
/**********************************************************
|
2212 |
+
* UTILITIES
|
2213 |
+
***********************************************************/
|
2214 |
+
|
2215 |
+
/**
|
2216 |
+
* Can the user manage this?
|
2217 |
+
*/
|
2218 |
+
function can_manage( $owner_capability = false, $admin_capability = false, $user_to_check = false ){
|
2219 |
+
if( $this->event_id == '' && !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') ){
|
2220 |
+
$user_to_check = get_option('dbem_events_anonymous_user');
|
2221 |
+
}
|
2222 |
+
return apply_filters('em_event_can_manage', parent::can_manage($owner_capability, $admin_capability, $user_to_check), $this, $owner_capability, $admin_capability, $user_to_check);
|
2223 |
+
}
|
2224 |
+
}
|
2225 |
+
|
2226 |
+
//TODO placeholder targets filtering could be streamlined better
|
2227 |
+
/**
|
2228 |
+
* This is a temporary filter function which mimicks the old filters in the old 2.x placeholders function
|
2229 |
+
* @param string $result
|
2230 |
+
* @param EM_Event $event
|
2231 |
+
* @param string $placeholder
|
2232 |
+
* @param string $target
|
2233 |
+
* @return mixed
|
2234 |
+
*/
|
2235 |
+
function em_event_output_placeholder($result,$event,$placeholder,$target='html'){
|
2236 |
+
if( $target == 'raw' ) return $result;
|
2237 |
+
if( in_array($placeholder, array("#_EXCERPT",'#_EVENTEXCERPT', "#_LOCATIONEXCERPT")) && $target == 'html' ){
|
2238 |
+
$result = apply_filters('dbem_notes_excerpt', $result);
|
2239 |
+
}elseif( $placeholder == '#_CONTACTEMAIL' && $target == 'html' ){
|
2240 |
+
$result = em_ascii_encode($event->get_contact()->user_email);
|
2241 |
+
}elseif( in_array($placeholder, array('#_EVENTNOTES','#_NOTES','#_DESCRIPTION','#_LOCATIONNOTES','#_CATEGORYNOTES','#_CATEGORYDESCRIPTION')) ){
|
2242 |
+
if($target == 'rss'){
|
2243 |
+
$result = apply_filters('dbem_notes_rss', $result);
|
2244 |
+
$result = apply_filters('the_content_rss', $result);
|
2245 |
+
}elseif($target == 'map'){
|
2246 |
+
$result = apply_filters('dbem_notes_map', $result);
|
2247 |
+
}elseif($target == 'ical'){
|
2248 |
+
$result = apply_filters('dbem_notes_ical', $result);
|
2249 |
+
}elseif ($target == "email"){
|
2250 |
+
$result = apply_filters('dbem_notes_email', $result);
|
2251 |
+
}else{ //html
|
2252 |
+
$result = apply_filters('dbem_notes', $result);
|
2253 |
+
}
|
2254 |
+
}elseif( in_array($placeholder, array("#_NAME",'#_LOCATION','#_TOWN','#_ADDRESS','#_LOCATIONNAME',"#_EVENTNAME","#_LOCATIONNAME",'#_CATEGORY')) ){
|
2255 |
+
if ($target == "rss"){
|
2256 |
+
$result = apply_filters('dbem_general_rss', $result);
|
2257 |
+
}elseif ($target == "ical"){
|
2258 |
+
$result = apply_filters('dbem_general_ical', $result);
|
2259 |
+
}elseif ($target == "email"){
|
2260 |
+
$result = apply_filters('dbem_general_email', $result);
|
2261 |
+
}else{ //html
|
2262 |
+
$result = apply_filters('dbem_general', $result);
|
2263 |
+
}
|
2264 |
+
}
|
2265 |
+
return $result;
|
2266 |
+
}
|
2267 |
+
add_filter('em_category_output_placeholder','em_event_output_placeholder',1,4);
|
2268 |
+
add_filter('em_event_output_placeholder','em_event_output_placeholder',1,4);
|
2269 |
+
add_filter('em_location_output_placeholder','em_event_output_placeholder',1,4);
|
2270 |
+
// FILTERS
|
2271 |
+
// filters for general events field (corresponding to those of "the _title")
|
2272 |
+
add_filter('dbem_general', 'wptexturize');
|
2273 |
+
add_filter('dbem_general', 'convert_chars');
|
2274 |
+
add_filter('dbem_general', 'trim');
|
2275 |
+
// filters for the notes field in html (corresponding to those of "the _content")
|
2276 |
+
add_filter('dbem_notes', 'wptexturize');
|
2277 |
+
add_filter('dbem_notes', 'convert_smilies');
|
2278 |
+
add_filter('dbem_notes', 'convert_chars');
|
2279 |
+
add_filter('dbem_notes', 'wpautop');
|
2280 |
+
add_filter('dbem_notes', 'prepend_attachment');
|
2281 |
+
add_filter('dbem_notes', 'do_shortcode');
|
2282 |
+
// filters for the notes field in html (corresponding to those of "the _content")
|
2283 |
+
add_filter('dbem_notes_excerpt', 'wptexturize');
|
2284 |
+
add_filter('dbem_notes_excerpt', 'convert_smilies');
|
2285 |
+
add_filter('dbem_notes_excerpt', 'convert_chars');
|
2286 |
+
add_filter('dbem_notes_excerpt', 'wpautop');
|
2287 |
+
add_filter('dbem_notes_excerpt', 'prepend_attachment');
|
2288 |
+
add_filter('dbem_notes_excerpt', 'do_shortcode');
|
2289 |
+
// RSS content filter
|
2290 |
+
add_filter('dbem_notes_rss', 'convert_chars', 8);
|
2291 |
+
add_filter('dbem_general_rss', 'esc_html', 8);
|
2292 |
+
// Notes map filters
|
2293 |
+
add_filter('dbem_notes_map', 'convert_chars', 8);
|
2294 |
+
add_filter('dbem_notes_map', 'js_escape');
|
2295 |
+
//embeds support if using placeholders
|
2296 |
+
if ( is_object($GLOBALS['wp_embed']) ){
|
2297 |
+
add_filter( 'dbem_notes', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
|
2298 |
+
add_filter( 'dbem_notes', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
|
2299 |
+
}
|
2300 |
+
|
2301 |
+
/**
|
2302 |
+
* This function replaces the default gallery shortcode, so it can check if this is a recurring event recurrence and pass on the parent post id as the default post.
|
2303 |
+
* @param array $attr
|
2304 |
+
*/
|
2305 |
+
function em_event_gallery_override( $attr = array() ){
|
2306 |
+
global $post;
|
2307 |
+
if( $post->post_type == EM_POST_TYPE_EVENT && empty($attr['id']) && empty($attr['ids']) ){
|
2308 |
+
//no id specified, so check if it's recurring and override id with recurrence template post id
|
2309 |
+
$EM_Event = em_get_event($post->ID, 'post_id');
|
2310 |
+
if( $EM_Event->is_recurrence() ){
|
2311 |
+
$attr['id'] = $EM_Event->get_event_recurrence()->post_id;
|
2312 |
+
}
|
2313 |
+
}
|
2314 |
+
return gallery_shortcode($attr);
|
2315 |
+
}
|
2316 |
+
function em_event_gallery_override_init(){
|
2317 |
+
remove_shortcode('gallery');
|
2318 |
+
add_shortcode('gallery', 'em_event_gallery_override');
|
2319 |
+
}
|
2320 |
+
add_action('init','em_event_gallery_override_init', 1000); //so that plugins like JetPack don't think we're overriding gallery, we're not i swear!
|
2321 |
Â
?>
|
classes/em-events.php
CHANGED
@@ -1,254 +1,437 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
*
|
11 |
-
*
|
12 |
-
*
|
13 |
-
*
|
14 |
-
* @
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$
|
20 |
-
$
|
21 |
-
|
22 |
-
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
23 |
-
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
24 |
-
//We can just get all the events here and return them
|
25 |
-
$sql = "
|
26 |
-
SELECT * FROM $events_table
|
27 |
-
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
$
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
//
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
$
|
157 |
-
}
|
158 |
-
//
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
$output .=
|
189 |
-
}
|
190 |
-
|
191 |
-
$
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
return
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
*
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
$
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
)
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
$
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
254 |
Â
?>
|
1 |
+
<?php
|
2 |
+
//TODO EM_Events is currently static, better we make this non-static so we can loop sets of events, and standardize with other objects.
|
3 |
+
/**
|
4 |
+
* Use this class to query and manipulate sets of events. If dealing with more than one event, you probably want to use this class in some way.
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class EM_Events extends EM_Object {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Returns an array of EM_Events that match the given specs in the argument, or returns a list of future evetnts in future
|
11 |
+
* (see EM_Events::get_default_search() ) for explanation of possible search array values. You can also supply a numeric array
|
12 |
+
* containing the ids of the events you'd like to obtain
|
13 |
+
*
|
14 |
+
* @param array $args
|
15 |
+
* @return EM_Event array()
|
16 |
+
*/
|
17 |
+
function get( $args = array(), $count=false ) {
|
18 |
+
global $wpdb;
|
19 |
+
$events_table = EM_EVENTS_TABLE;
|
20 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
21 |
+
|
22 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
23 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
24 |
+
//We can just get all the events here and return them
|
25 |
+
$sql = "
|
26 |
+
SELECT * FROM $events_table
|
27 |
+
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
28 |
+
WHERE event_id=".implode(" OR event_id=", $args)."
|
29 |
+
";
|
30 |
+
$results = $wpdb->get_results(apply_filters('em_events_get_sql',$sql),ARRAY_A);
|
31 |
+
$events = array();
|
32 |
+
foreach($results as $result){
|
33 |
+
$events[$result['event_id']] = new EM_Event($result);
|
34 |
+
}
|
35 |
+
return $events; //We return all the events matched as an EM_Event array.
|
36 |
+
}
|
37 |
+
|
38 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
39 |
+
$args = self::get_default_search($args);
|
40 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
41 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
42 |
+
|
43 |
+
//Get the default conditions
|
44 |
+
$conditions = self::build_sql_conditions($args);
|
45 |
+
//Put it all together
|
46 |
+
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
47 |
+
|
48 |
+
//Get ordering instructions
|
49 |
+
$EM_Event = new EM_Event();
|
50 |
+
$EM_Location = new EM_Location();
|
51 |
+
$orderby = self::build_sql_orderby($args, array_keys(array_merge($EM_Event->fields, $EM_Location->fields)), get_option('dbem_events_default_order'));
|
52 |
+
//Now, build orderby sql
|
53 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
|
54 |
+
|
55 |
+
//Create the SQL statement and execute
|
56 |
+
|
57 |
+
if( !$count && $args['array'] ){
|
58 |
+
$selectors_array = array();
|
59 |
+
foreach( array_keys($EM_Event->fields) as $field_selector){
|
60 |
+
$selectors_array[] = $events_table.'.'.$field_selector;
|
61 |
+
}
|
62 |
+
$selectors = implode(',', $selectors_array);
|
63 |
+
}elseif( EM_MS_GLOBAL ){
|
64 |
+
$selectors = ( $count ) ? 'COUNT(*)':$events_table.'.post_id, '.$events_table.'.blog_id';
|
65 |
+
}else{
|
66 |
+
$selectors = ( $count ) ? 'COUNT(*)':$events_table.'.post_id';
|
67 |
+
}
|
68 |
+
|
69 |
+
$sql = apply_filters('em_events_get_sql',"
|
70 |
+
SELECT $selectors FROM $events_table
|
71 |
+
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
72 |
+
$where
|
73 |
+
$orderby_sql
|
74 |
+
$limit $offset
|
75 |
+
", $args);
|
76 |
+
|
77 |
+
//If we're only counting results, return the number of results
|
78 |
+
if( $count ){
|
79 |
+
return apply_filters('em_events_get_count', $wpdb->get_var($sql), $args);
|
80 |
+
}
|
81 |
+
$results = $wpdb->get_results( $sql, ARRAY_A);
|
82 |
+
|
83 |
+
//If we want results directly in an array, why not have a shortcut here?
|
84 |
+
if( $args['array'] == true ){
|
85 |
+
return apply_filters('em_events_get_array',$results, $args);
|
86 |
+
}
|
87 |
+
|
88 |
+
//Make returned results EM_Event objects
|
89 |
+
$results = (is_array($results)) ? $results:array();
|
90 |
+
$events = array();
|
91 |
+
|
92 |
+
if( EM_MS_GLOBAL ){
|
93 |
+
foreach ( $results as $event ){
|
94 |
+
$events[] = em_get_event($event['post_id'], $event['blog_id']);
|
95 |
+
}
|
96 |
+
}else{
|
97 |
+
foreach ( $results as $event ){
|
98 |
+
$events[] = em_get_event($event['post_id'], 'post_id');
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
return apply_filters('em_events_get', $events, $args);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Returns the number of events on a given date
|
107 |
+
* @param $date
|
108 |
+
* @return int
|
109 |
+
*/
|
110 |
+
function count_date($date){
|
111 |
+
global $wpdb;
|
112 |
+
$table_name = EM_EVENTS_TABLE;
|
113 |
+
$sql = "SELECT COUNT(*) FROM $table_name WHERE (event_start_date like '$date') OR (event_start_date <= '$date' AND event_end_date >= '$date');";
|
114 |
+
return apply_filters('em_events_count_date', $wpdb->get_var($sql));
|
115 |
+
}
|
116 |
+
|
117 |
+
function count( $args = array() ){
|
118 |
+
return apply_filters('em_events_count', self::get($args, true), $args);
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Will delete given an array of event_ids or EM_Event objects
|
123 |
+
* @param unknown_type $id_array
|
124 |
+
*/
|
125 |
+
function delete( $array ){
|
126 |
+
global $wpdb;
|
127 |
+
//Detect array type and generate SQL for event IDs
|
128 |
+
$results = array();
|
129 |
+
if( !empty($array) && @get_class(current($array)) != 'EM_Event' ){
|
130 |
+
$events = self::get($array);
|
131 |
+
}else{
|
132 |
+
$events = $array;
|
133 |
+
}
|
134 |
+
$event_ids = array();
|
135 |
+
foreach ($events as $EM_Event){
|
136 |
+
$event_ids[] = $EM_Event->event_id;
|
137 |
+
$results[] = $EM_Event->delete();
|
138 |
+
}
|
139 |
+
//TODO add better error feedback on events delete fails
|
140 |
+
return apply_filters('em_events_delete', in_array(false, $results), $event_ids);
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Output a set of matched of events. You can pass on an array of EM_Events as well, in this event you can pass args in second param.
|
146 |
+
* Note that you can pass a 'pagination' boolean attribute to enable pagination, default is enabled (true).
|
147 |
+
* @param array $args
|
148 |
+
* @param array $secondary_args
|
149 |
+
* @return string
|
150 |
+
*/
|
151 |
+
function output( $args ){
|
152 |
+
global $EM_Event;
|
153 |
+
$EM_Event_old = $EM_Event; //When looping, we can replace EM_Event global with the current event in the loop
|
154 |
+
//get page number if passed on by request (still needs pagination enabled to have effect)
|
155 |
+
if( !array_key_exists('page',$args) && !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ){
|
156 |
+
$page = $args['page'] = $_REQUEST['pno'];
|
157 |
+
}
|
158 |
+
//Can be either an array for the get search or an array of EM_Event objects
|
159 |
+
if( is_object(current($args)) && get_class((current($args))) == 'EM_Event' ){
|
160 |
+
$func_args = func_get_args();
|
161 |
+
$events = $func_args[0];
|
162 |
+
$args = (!empty($func_args[1]) && is_array($func_args[1])) ? $func_args[1] : array();
|
163 |
+
$args = apply_filters('em_events_output_args', self::get_default_search($args), $events);
|
164 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
165 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
166 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
167 |
+
$events_count = count($events);
|
168 |
+
}else{
|
169 |
+
//Firstly, let's check for a limit/offset here, because if there is we need to remove it and manually do this
|
170 |
+
$args = apply_filters('em_events_output_args', self::get_default_search($args));
|
171 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
172 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
173 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
174 |
+
$args_count = $args;
|
175 |
+
$args_count['limit'] = false;
|
176 |
+
$args_count['offset'] = false;
|
177 |
+
$args_count['page'] = false;
|
178 |
+
$events_count = self::count($args_count);
|
179 |
+
$events = self::get( $args );
|
180 |
+
}
|
181 |
+
//What format shall we output this to, or use default
|
182 |
+
$format = ( empty($args['format']) ) ? get_option( 'dbem_event_list_item_format' ) : $args['format'] ;
|
183 |
+
|
184 |
+
$output = "";
|
185 |
+
$events = apply_filters('em_events_output_events', $events);
|
186 |
+
if ( $events_count > 0 ) {
|
187 |
+
foreach ( $events as $EM_Event ) {
|
188 |
+
$output .= $EM_Event->output($format);
|
189 |
+
}
|
190 |
+
//Add headers and footers to output
|
191 |
+
if( $format == get_option ( 'dbem_event_list_item_format' ) ){
|
192 |
+
$format_header = ( get_option( 'dbem_event_list_item_format_header') == '' ) ? '':get_option ( 'dbem_event_list_item_format_header' );
|
193 |
+
$format_footer = ( get_option ( 'dbem_event_list_item_format_footer' ) == '' ) ? '':get_option ( 'dbem_event_list_item_format_footer' );
|
194 |
+
}else{
|
195 |
+
$format_header = ( !empty($args['format_header']) ) ? $args['format_header']:'';
|
196 |
+
$format_footer = ( !empty($args['format_footer']) ) ? $args['format_footer']:'';
|
197 |
+
}
|
198 |
+
$output = $format_header . $output . $format_footer;
|
199 |
+
//Pagination (if needed/requested)
|
200 |
+
if( !empty($args['pagination']) && !empty($limit) && $events_count > $limit ){
|
201 |
+
$output .= apply_filters('em_events_output_pagination', self::get_pagination_links($args, $events_count, 'search_events', self::get_default_search()), '', $events_count, $limit, $page);
|
202 |
+
}
|
203 |
+
} else {
|
204 |
+
$output = get_option ( 'dbem_no_events_message' );
|
205 |
+
}
|
206 |
+
|
207 |
+
//TODO check if reference is ok when restoring object, due to changes in php5 v 4
|
208 |
+
$EM_Event = $EM_Event_old;
|
209 |
+
$output = apply_filters('em_events_output', $output, $events, $args);
|
210 |
+
return $output;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Generate a grouped list of events by year, month, week or day.
|
215 |
+
* @since 5.4.4.2
|
216 |
+
* @param array $args
|
217 |
+
* @return string
|
218 |
+
*/
|
219 |
+
function output_grouped( $args = array() ){
|
220 |
+
//Reset some args to include pagination for if pagination is requested.
|
221 |
+
$args['limit'] = isset($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit');
|
222 |
+
$args['page'] = (!empty($args['page']) && is_numeric($args['page']) )? $args['page'] : 1;
|
223 |
+
$args['page'] = (!empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) )? $_REQUEST['pno'] : $args['page'];
|
224 |
+
$args['offset'] = ($args['page']-1) * $args['limit'];
|
225 |
+
$args['orderby'] = 'event_start_date,event_start_time,event_name'; // must override this to display events in right cronology.
|
226 |
+
|
227 |
+
$args['mode'] = !empty($args['mode']) ? $args['mode'] : get_option('dbem_event_list_groupby');
|
228 |
+
$args['date_format'] = !empty($args['date_format']) ? $args['date_format'] : get_option('dbem_event_list_groupby_format');
|
229 |
+
//Reset some vars for counting events and displaying set arrays of events
|
230 |
+
$atts = (array) $args;
|
231 |
+
$atts['pagination'] = false;
|
232 |
+
$atts['limit'] = false;
|
233 |
+
$atts['page'] = false;
|
234 |
+
$atts['offset'] = false;
|
235 |
+
//decide what form of dates to show
|
236 |
+
$events_count = self::count($atts);
|
237 |
+
ob_start();
|
238 |
+
if( $events_count > 0 ){
|
239 |
+
$EM_Events = self::get($args);
|
240 |
+
switch ( $args['mode'] ){
|
241 |
+
case 'yearly':
|
242 |
+
//go through the events and put them into a monthly array
|
243 |
+
$format = (!empty($args['date_format'])) ? $args['date_format']:'Y';
|
244 |
+
$events_dates = array();
|
245 |
+
foreach($EM_Events as $EM_Event){
|
246 |
+
$events_dates[date_i18n($format,$EM_Event->start)][] = $EM_Event;
|
247 |
+
}
|
248 |
+
foreach ($events_dates as $year => $events){
|
249 |
+
echo '<h2>'.$year.'</h2>';
|
250 |
+
echo self::output($events, $atts);
|
251 |
+
}
|
252 |
+
break;
|
253 |
+
case 'monthly':
|
254 |
+
//go through the events and put them into a monthly array
|
255 |
+
$format = (!empty($args['date_format'])) ? $args['date_format']:'M Y';
|
256 |
+
$events_dates = array();
|
257 |
+
foreach($EM_Events as $EM_Event){
|
258 |
+
$events_dates[date_i18n($format, $EM_Event->start)][] = $EM_Event;
|
259 |
+
}
|
260 |
+
foreach ($events_dates as $month => $events){
|
261 |
+
echo '<h2>'.$month.'</h2>';
|
262 |
+
echo self::output($events, $atts);
|
263 |
+
}
|
264 |
+
break;
|
265 |
+
case 'weekly':
|
266 |
+
$format = (!empty($args['date_format'])) ? $args['date_format']:get_option('date_format');
|
267 |
+
$events_dates = array();
|
268 |
+
foreach($EM_Events as $EM_Event){
|
269 |
+
$start_of_week = get_option('start_of_week');
|
270 |
+
$day_of_week = date('w',$EM_Event->start);
|
271 |
+
$day_of_week = date('w',$EM_Event->start);
|
272 |
+
$offset = $day_of_week - $start_of_week;
|
273 |
+
if($offset<0){ $offset += 7; }
|
274 |
+
$offset = $offset * 60*60*24; //days in seconds
|
275 |
+
$start_day = strtotime($EM_Event->start_date);
|
276 |
+
$events_dates[$start_day - $offset][] = $EM_Event;
|
277 |
+
}
|
278 |
+
foreach ($events_dates as $event_day_ts => $events){
|
279 |
+
echo '<h2>'.date_i18n($format,$event_day_ts).' - '.date_i18n($format,$event_day_ts+(60*60*24*6)).'</h2>';
|
280 |
+
echo self::output($events, $atts);
|
281 |
+
}
|
282 |
+
break;
|
283 |
+
default: //daily
|
284 |
+
//go through the events and put them into a daily array
|
285 |
+
$format = (!empty($args['date_format'])) ? $args['date_format']:get_option('date_format');
|
286 |
+
$events_dates = array();
|
287 |
+
foreach($EM_Events as $EM_Event){
|
288 |
+
$events_dates[strtotime($EM_Event->start_date)][] = $EM_Event;
|
289 |
+
}
|
290 |
+
foreach ($events_dates as $event_day_ts => $events){
|
291 |
+
echo '<h2>'.date_i18n($format,$event_day_ts).'</h2>';
|
292 |
+
echo self::output($events, $atts);
|
293 |
+
}
|
294 |
+
break;
|
295 |
+
}
|
296 |
+
if( !empty($args['limit']) && $events_count > $args['limit'] && (!empty($args['pagination']) || !isset($args['pagination'])) ){
|
297 |
+
//Show the pagination links (unless there's less than $limit events)
|
298 |
+
echo apply_filters('em_events_output_pagination', self::get_pagination_links($args, $events_count, 'search_events_grouped', self::get_default_search()), '', $events_count, $args['limit'], $args['page']);
|
299 |
+
}
|
300 |
+
}else{
|
301 |
+
echo get_option ( 'dbem_no_events_message' );
|
302 |
+
}
|
303 |
+
return ob_get_clean();
|
304 |
+
}
|
305 |
+
|
306 |
+
function can_manage($event_ids){
|
307 |
+
global $wpdb;
|
308 |
+
if( current_user_can('edit_others_events') ){
|
309 |
+
return apply_filters('em_events_can_manage', true, $event_ids);
|
310 |
+
}
|
311 |
+
if( EM_Object::array_is_numeric($event_ids) ){
|
312 |
+
$condition = implode(" OR event_id=", $event_ids);
|
313 |
+
//we try to find any of these events that don't belong to this user
|
314 |
+
$results = $wpdb->get_var("SELECT COUNT(*) FROM ". EM_EVENTS_TABLE ." WHERE event_owner != '". get_current_user_id() ."' event_id=$condition;");
|
315 |
+
return apply_filters('em_events_can_manage', ($results == 0), $event_ids);
|
316 |
+
}
|
317 |
+
return apply_filters('em_events_can_manage', false, $event_ids);
|
318 |
+
}
|
319 |
+
|
320 |
+
public static function get_post_search($args = array(), $filter = false){
|
321 |
+
return apply_filters('em_events_get_post_search', parent::get_post_search($args, $filter));
|
322 |
+
}
|
323 |
+
|
324 |
+
/* Overrides EM_Object method to apply a filter to result
|
325 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
|
326 |
+
*/
|
327 |
+
function build_sql_conditions( $args = array() ){
|
328 |
+
self::$context = EM_POST_TYPE_EVENT;
|
329 |
+
$conditions = parent::build_sql_conditions($args);
|
330 |
+
if( !empty($args['search']) ){
|
331 |
+
$like_search = array('event_name',EM_EVENTS_TABLE.'.post_content','location_name','location_address','location_town','location_postcode','location_state','location_country','location_region');
|
332 |
+
$conditions['search'] = "(".implode(" LIKE '%{$args['search']}%' OR ", $like_search). " LIKE '%{$args['search']}%')";
|
333 |
+
}
|
334 |
+
$conditions['status'] = "(`event_status` >= 0 )"; //shows pending & published if not defined
|
335 |
+
if( array_key_exists('status',$args) ){
|
336 |
+
if( is_numeric($args['status']) ){
|
337 |
+
$conditions['status'] = "(`event_status`={$args['status']})"; //pending or published
|
338 |
+
}elseif( $args['status'] == 'pending' ){
|
339 |
+
$conditions['status'] = "(`event_status`=0)"; //pending
|
340 |
+
}elseif( $args['status'] == 'publish' ){
|
341 |
+
$conditions['status'] = "(`event_status`=1)"; //published
|
342 |
+
}elseif( $args['status'] === null || $args['status'] == 'draft' ){
|
343 |
+
$conditions['status'] = "(`event_status` IS NULL )"; //show draft items
|
344 |
+
}elseif( $args['status'] == 'trash' ){
|
345 |
+
$conditions['status'] = "(`event_status` = -1 )"; //show trashed items
|
346 |
+
}
|
347 |
+
}
|
348 |
+
//private events
|
349 |
+
if( empty($args['private']) ){
|
350 |
+
$conditions['private'] = "(`event_private`=0)";
|
351 |
+
}elseif( !empty($args['private_only']) ){
|
352 |
+
$conditions['private_only'] = "(`event_private`=1)";
|
353 |
+
}
|
354 |
+
if( EM_MS_GLOBAL && !empty($args['blog']) ){
|
355 |
+
if( is_numeric($args['blog']) ){
|
356 |
+
if( is_main_site($args['blog']) ){
|
357 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']} OR ".EM_EVENTS_TABLE.".blog_id IS NULL)";
|
358 |
+
}else{
|
359 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']})";
|
360 |
+
}
|
361 |
+
}else{
|
362 |
+
if( !is_array($args['blog']) && preg_match('/^([\-0-9],?)+$/', $args['blog']) ){
|
363 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id IN ({$args['blog']}) )";
|
364 |
+
}elseif( is_array($args['blog']) && self::array_is_numeric($args['blog']) ){
|
365 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id IN (".implode(',',$args['blog']).") )";
|
366 |
+
}
|
367 |
+
}
|
368 |
+
}
|
369 |
+
if( $args['bookings'] === 'user' && is_user_logged_in()){
|
370 |
+
//get bookings of user
|
371 |
+
$EM_Person = new EM_Person(get_current_user_id());
|
372 |
+
$booking_ids = $EM_Person->get_bookings(true);
|
373 |
+
if( count($booking_ids) > 0 ){
|
374 |
+
$conditions['bookings'] = "(event_id IN (SELECT event_id FROM ".EM_BOOKINGS_TABLE." WHERE booking_id IN (".implode(',',$booking_ids).")))";
|
375 |
+
}else{
|
376 |
+
$conditions['bookings'] = "(event_id = 0)";
|
377 |
+
}
|
378 |
+
}
|
379 |
+
//post search
|
380 |
+
if( !empty($args['post_id'])){
|
381 |
+
if( is_array($args['post_id']) ){
|
382 |
+
$conditions['post_id'] = "(".EM_EVENTS_TABLE.".post_id IN (".implode(',',$args['post_id'])."))";
|
383 |
+
}else{
|
384 |
+
$conditions['post_id'] = "(".EM_EVENTS_TABLE.".post_id={$args['post_id']})";
|
385 |
+
}
|
386 |
+
}
|
387 |
+
return apply_filters( 'em_events_build_sql_conditions', $conditions, $args );
|
388 |
+
}
|
389 |
+
|
390 |
+
/* Overrides EM_Object method to apply a filter to result
|
391 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
|
392 |
+
*/
|
393 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
394 |
+
self::$context = EM_POST_TYPE_EVENT;
|
395 |
+
return apply_filters( 'em_events_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order')), $args, $accepted_fields, $default_order );
|
396 |
+
}
|
397 |
+
|
398 |
+
/*
|
399 |
+
* Adds custom Events search defaults
|
400 |
+
* @param array $array
|
401 |
+
* @return array
|
402 |
+
* @uses EM_Object#get_default_search()
|
403 |
+
*/
|
404 |
+
function get_default_search( $array = array() ){
|
405 |
+
self::$context = EM_POST_TYPE_EVENT;
|
406 |
+
$defaults = array(
|
407 |
+
'orderby' => get_option('dbem_events_default_orderby'),
|
408 |
+
'order' => get_option('dbem_events_default_order'),
|
409 |
+
'bookings' => false, //if set to true, only events with bookings enabled are returned
|
410 |
+
'status' => 1, //approved events only
|
411 |
+
'format_header' => '', //events can have custom html above the list
|
412 |
+
'format_footer' => '', //events can have custom html below the list
|
413 |
+
'town' => false,
|
414 |
+
'state' => false,
|
415 |
+
'country' => false,
|
416 |
+
'region' => false,
|
417 |
+
'blog' => get_current_blog_id(),
|
418 |
+
'private' => current_user_can('read_private_events'),
|
419 |
+
'private_only' => false,
|
420 |
+
'post_id' => false
|
421 |
+
);
|
422 |
+
if( EM_MS_GLOBAL && !is_admin() ){
|
423 |
+
if( empty($array['blog']) && is_main_site() && get_site_option('dbem_ms_global_events') ){
|
424 |
+
$array['blog'] = false;
|
425 |
+
}
|
426 |
+
}
|
427 |
+
if( is_admin() ){
|
428 |
+
//figure out default owning permissions
|
429 |
+
$defaults['owner'] = !current_user_can('edit_others_events') ? get_current_user_id() : false;
|
430 |
+
if( !array_key_exists('status', $array) && current_user_can('edit_others_events') ){
|
431 |
+
$defaults['status'] = false; //by default, admins see pending and live events
|
432 |
+
}
|
433 |
+
}
|
434 |
+
return apply_filters('em_events_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
|
435 |
+
}
|
436 |
+
}
|
437 |
Â
?>
|
classes/em-location-post-admin.php
ADDED
@@ -0,0 +1,169 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class EM_Location_Post_Admin{
|
3 |
+
function init(){
|
4 |
+
global $pagenow;
|
5 |
+
if($pagenow == 'post.php' || $pagenow == 'post-new.php' ){ //only needed if editing post
|
6 |
+
add_action('admin_head', array('EM_Location_Post_Admin','admin_head'));
|
7 |
+
}
|
8 |
+
//Meta Boxes
|
9 |
+
add_action('add_meta_boxes', array('EM_Location_Post_Admin','meta_boxes'));
|
10 |
+
//Save/Edit actions
|
11 |
+
add_filter('wp_insert_post_data',array('EM_Location_Post_Admin','wp_insert_post_data'),100,2); //validate post meta before saving is done
|
12 |
+
add_action('save_post',array('EM_Location_Post_Admin','save_post'),1,1); //set to 1 so metadata gets saved ASAP
|
13 |
+
add_action('before_delete_post',array('EM_Location_Post_Admin','before_delete_post'),10,1);
|
14 |
+
add_action('trashed_post',array('EM_Location_Post_Admin','trashed_post'),10,1);
|
15 |
+
add_action('untrash_post',array('EM_Location_Post_Admin','untrash_post'),10,1);
|
16 |
+
add_action('untrashed_post',array('EM_Location_Post_Admin','untrashed_post'),10,1);
|
17 |
+
//Notices
|
18 |
+
add_action('admin_notices',array('EM_Location_Post_Admin','admin_notices'));
|
19 |
+
add_action('post_updated_messages',array('EM_Location_Post_Admin','admin_notices_filter'),1,1);
|
20 |
+
}
|
21 |
+
|
22 |
+
function admin_head(){
|
23 |
+
global $post, $EM_Location;
|
24 |
+
if( !empty($post) && $post->post_type == EM_POST_TYPE_LOCATION ){
|
25 |
+
$EM_Location = em_get_location($post);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
function admin_notices(){
|
30 |
+
//When editing
|
31 |
+
global $post, $EM_Notices;
|
32 |
+
if( !empty($post) && $post->post_type == EM_POST_TYPE_LOCATION){
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
function admin_notices_filter($messages){
|
37 |
+
//When editing
|
38 |
+
global $post, $EM_Notices;
|
39 |
+
if( $post->post_type == EM_POST_TYPE_LOCATION ){
|
40 |
+
if ( $EM_Notices->count_errors() > 0 ) {
|
41 |
+
unset($_GET['message']);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
return $messages;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Hooks in just before a post is saves and does a quick post meta validation.
|
49 |
+
* This prevents the location from being temporarily published and firing hooks that indicate this before we come in on save_post and properly save data.
|
50 |
+
* @param array $data
|
51 |
+
* @param array $postarr
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
+
public static function wp_insert_post_data( $data, $postarr ){
|
55 |
+
global $wpdb, $EM_Event, $EM_Location, $EM_Notices;
|
56 |
+
$post_type = $data['post_type'];
|
57 |
+
$post_ID = !empty($postarr['ID']) ? $postarr['ID'] : false;
|
58 |
+
$is_post_type = $post_type == EM_POST_TYPE_LOCATION;
|
59 |
+
$saving_status = !in_array($data['post_status'], array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
60 |
+
$untrashing = $post_ID && defined('UNTRASHING_'.$post_ID);
|
61 |
+
if( !$untrashing && $is_post_type && $saving_status ){
|
62 |
+
if( !empty($_REQUEST['_emnonce']) && wp_verify_nonce($_REQUEST['_emnonce'], 'edit_location') ){
|
63 |
+
//this is only run if we know form data was submitted, hence the nonce
|
64 |
+
$EM_Location = em_get_location();
|
65 |
+
//Handle Errors by making post draft
|
66 |
+
$get_meta = $EM_Location->get_post_meta();
|
67 |
+
$validate_meta = $EM_Location->validate_meta();
|
68 |
+
if( !$get_meta || !$validate_meta ) $data['post_status'] = 'draft';
|
69 |
+
}
|
70 |
+
}
|
71 |
+
return $data;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Once the post is saved, saves EM meta data
|
76 |
+
* @param int $post_id
|
77 |
+
*/
|
78 |
+
function save_post($post_id){
|
79 |
+
global $wpdb, $EM_Location, $EM_Notices;
|
80 |
+
$saving_status = !in_array(get_post_status($post_id), array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
81 |
+
$is_post_type = get_post_type($post_id) == EM_POST_TYPE_LOCATION;
|
82 |
+
if(!defined('UNTRASHING_'.$post_id) && $is_post_type && $saving_status){
|
83 |
+
if( !empty($_REQUEST['_emnonce']) && wp_verify_nonce($_REQUEST['_emnonce'], 'edit_location')){
|
84 |
+
$EM_Location = em_get_location($post_id, 'post_id');
|
85 |
+
do_action('em_location_save_pre', $EM_Location);
|
86 |
+
$get_meta = $EM_Location->get_post_meta();
|
87 |
+
$save_meta = $EM_Location->save_meta();
|
88 |
+
//Handle Errors by making post draft
|
89 |
+
if( !$get_meta || !$save_meta ){
|
90 |
+
$EM_Location->set_status(null, true);
|
91 |
+
$EM_Notices->add_error( '<strong>'.sprintf(__('Your %s details are incorrect and cannot be published, please correct these errors first:','dbem'),__('location','dbem')).'</strong>', true); //Always seems to redirect, so we make it static
|
92 |
+
$EM_Notices->add_error($EM_Location->get_errors(), true); //Always seems to redirect, so we make it static
|
93 |
+
apply_filters('em_location_save', false , $EM_Location);
|
94 |
+
}else{
|
95 |
+
apply_filters('em_location_save', true , $EM_Location);
|
96 |
+
}
|
97 |
+
}else{
|
98 |
+
//do a quick and dirty update
|
99 |
+
$EM_Location = new EM_Location($post_id, 'post_id');
|
100 |
+
do_action('em_location_save_pre', $EM_Location);
|
101 |
+
//check for existence of index
|
102 |
+
$loc_truly_exists = $EM_Location->location_id > 0 && $wpdb->get_var('SELECT location_id FROM '.EM_LOCATIONS_TABLE." WHERE location_id={$EM_Location->location_id}") == $EM_Location->location_id;
|
103 |
+
if(empty($EM_Location->location_id) || !$loc_truly_exists){ $EM_Location->save_meta(); }
|
104 |
+
//continue
|
105 |
+
$EM_Location->get_previous_status(); //before we save anything
|
106 |
+
$location_status = $EM_Location->get_status(true);
|
107 |
+
$where_array = array($EM_Location->location_name, $EM_Location->location_slug, $EM_Location->location_private, $EM_Location->location_id);
|
108 |
+
$sql = $wpdb->prepare("UPDATE ".EM_LOCATIONS_TABLE." SET location_name=%s, location_slug=%s, location_private=%d, location_status={$location_status} WHERE location_id=%d", $where_array);
|
109 |
+
$wpdb->query($sql);
|
110 |
+
apply_filters('em_location_save', true , $EM_Location);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
function before_delete_post($post_id){
|
116 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
117 |
+
$EM_Location = em_get_location($post_id,'post_id');
|
118 |
+
$EM_Location->delete_meta();
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
function trashed_post($post_id){
|
123 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
124 |
+
global $EM_Notices;
|
125 |
+
$EM_Location = em_get_location($post_id,'post_id');
|
126 |
+
$EM_Location->set_status(-1);
|
127 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
function untrash_post($post_id){
|
132 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
133 |
+
//set a constant so we know this event doesn't need 'saving'
|
134 |
+
if(!defined('UNTRASHING_'.$post_id)) define('UNTRASHING_'.$post_id, true);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
function untrashed_post($post_id){
|
139 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
140 |
+
global $EM_Notices;
|
141 |
+
$EM_Location = new EM_Location($post_id,'post_id');
|
142 |
+
$EM_Location->set_status($EM_Location->get_status());
|
143 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
function meta_boxes(){
|
148 |
+
add_meta_box('em-location-where', __('Where','dbem'), array('EM_Location_Post_Admin','meta_box_where'),EM_POST_TYPE_LOCATION, 'normal','high');
|
149 |
+
//add_meta_box('em-location-metadump', __('EM_Location Meta Dump','dbem'), array('EM_Location_Post_Admin','meta_box_metadump'),EM_POST_TYPE_LOCATION, 'normal','high');
|
150 |
+
if( get_option('dbem_location_attributes_enabled') ){
|
151 |
+
add_meta_box('em-location-attributes', __('Attributes','dbem'), array('EM_Location_Post_Admin','meta_box_attributes'),EM_POST_TYPE_LOCATION, 'normal','default');
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
function meta_box_metadump(){
|
156 |
+
global $post,$EM_Location;
|
157 |
+
echo "<pre>"; print_r(get_post_custom($post->ID)); echo "</pre>";
|
158 |
+
echo "<pre>"; print_r($EM_Location); echo "</pre>";
|
159 |
+
}
|
160 |
+
function meta_box_where(){
|
161 |
+
?><input type="hidden" name="_emnonce" value="<?php echo wp_create_nonce('edit_location'); ?>" /><?php
|
162 |
+
em_locate_template('forms/location/where.php',true);
|
163 |
+
}
|
164 |
+
|
165 |
+
function meta_box_attributes(){
|
166 |
+
em_locate_template('forms/location/attributes.php',true);
|
167 |
+
}
|
168 |
+
}
|
169 |
+
add_action('admin_init',array('EM_Location_Post_Admin','init'));
|
classes/em-location-post.php
ADDED
@@ -0,0 +1,104 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class EM_Location_Post {
|
3 |
+
function init(){
|
4 |
+
//Front Side Modifiers
|
5 |
+
if( !is_admin() ){
|
6 |
+
//override single page with formats?
|
7 |
+
add_filter('the_content', array('EM_Location_Post','the_content'));
|
8 |
+
//display as page or other template?
|
9 |
+
if( get_option('dbem_cp_locations_template') ){
|
10 |
+
add_filter('single_template',array('EM_Location_Post','single_template'));
|
11 |
+
}
|
12 |
+
//add classes to body and post_class()
|
13 |
+
if( get_option('dbem_cp_locations_post_class') ){
|
14 |
+
add_filter('post_class', array('EM_Location_Post','post_class'), 10, 3);
|
15 |
+
}
|
16 |
+
if( get_option('dbem_cp_locations_body_class') ){
|
17 |
+
add_filter('body_class', array('EM_Location_Post','body_class'), 10, 3);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
add_action('parse_query', array('EM_Location_Post','parse_query'));
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Overrides the default post format of a location and can display a location as a page, which uses the page.php template.
|
25 |
+
* @param string $template
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
function single_template($template){
|
29 |
+
global $post;
|
30 |
+
if( !locate_template('single-'.EM_POST_TYPE_LOCATION.'.php') && $post->post_type == EM_POST_TYPE_LOCATION ){
|
31 |
+
//do we have a default template to choose for events?
|
32 |
+
if( get_option('dbem_cp_locations_template') == 'page' ){
|
33 |
+
$post_templates = array('page.php','index.php');
|
34 |
+
}else{
|
35 |
+
$post_templates = array(get_option('dbem_cp_locations_template'));
|
36 |
+
}
|
37 |
+
if( !empty($post_templates) ){
|
38 |
+
$post_template = locate_template($post_templates,false);
|
39 |
+
if( !empty($post_template) ) $template = $post_template;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
return $template;
|
43 |
+
}
|
44 |
+
|
45 |
+
function post_class( $classes, $class, $post_id ){
|
46 |
+
$post = get_post($post_id);
|
47 |
+
if( $post->post_type == EM_POST_TYPE_LOCATION ){
|
48 |
+
foreach( explode(' ', get_option('dbem_cp_locations_post_class')) as $class ){
|
49 |
+
$classes[] = esc_attr($class);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $classes;
|
53 |
+
}
|
54 |
+
|
55 |
+
function body_class( $classes ){
|
56 |
+
if( em_is_location_page() ){
|
57 |
+
foreach( explode(' ', get_option('dbem_cp_locations_body_class')) as $class ){
|
58 |
+
$classes[] = esc_attr($class);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
return $classes;
|
62 |
+
}
|
63 |
+
|
64 |
+
function the_content( $content ){
|
65 |
+
global $post, $EM_Location;
|
66 |
+
if( $post->post_type == EM_POST_TYPE_LOCATION ){
|
67 |
+
if( is_archive() || is_search() ){
|
68 |
+
if( get_option('dbem_cp_locations_archive_formats') ){
|
69 |
+
$EM_Location = em_get_location($post);
|
70 |
+
$content = $EM_Location->output(get_option('dbem_location_list_item_format'));
|
71 |
+
}
|
72 |
+
}else{
|
73 |
+
if( get_option('dbem_cp_locations_formats') && !post_password_required() ){
|
74 |
+
$EM_Location = em_get_location($post);
|
75 |
+
ob_start();
|
76 |
+
em_locate_template('templates/location-single.php',true);
|
77 |
+
$content = ob_get_clean();
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
return $content;
|
82 |
+
}
|
83 |
+
|
84 |
+
function parse_query(){
|
85 |
+
global $wp_query;
|
86 |
+
if( !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == EM_POST_TYPE_LOCATION ){
|
87 |
+
if( is_admin() ){
|
88 |
+
$wp_query->query_vars['orderby'] = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby']:'title';
|
89 |
+
$wp_query->query_vars['order'] = (!empty($_REQUEST['order'])) ? $_REQUEST['order']:'ASC';
|
90 |
+
}else{
|
91 |
+
if( empty($wp_query->query_vars['location']) ) {
|
92 |
+
if( get_option('dbem_locations_default_archive_orderby') == 'title'){
|
93 |
+
$wp_query->query_vars['orderby'] = 'title';
|
94 |
+
}else{
|
95 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
96 |
+
$wp_query->query_vars['meta_key'] = get_option('dbem_locations_default_archive_orderby','_location_country');
|
97 |
+
}
|
98 |
+
$wp_query->query_vars['order'] = get_option('dbem_locations_default_archive_orderby','ASC');
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
EM_Location_Post::init();
|
classes/em-location-posts-admin.php
ADDED
@@ -0,0 +1,84 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class EM_Location_Posts_Admin{
|
3 |
+
function init(){
|
4 |
+
global $pagenow;
|
5 |
+
if($pagenow == 'edit.php' && !empty($_REQUEST['post_type']) && $_REQUEST['post_type'] == EM_POST_TYPE_LOCATION ){ //only needed if editing post
|
6 |
+
//hide some cols by default:
|
7 |
+
$screen = 'edit-'.EM_POST_TYPE_LOCATION;
|
8 |
+
$hidden = get_user_option( 'manage' . $screen . 'columnshidden' );
|
9 |
+
if( !$hidden ){
|
10 |
+
$hidden = array('location-id');
|
11 |
+
update_user_option(get_current_user_id(), "manage{$screen}columnshidden", $hidden, true);
|
12 |
+
}
|
13 |
+
add_action('admin_head', array('EM_Location_Posts_Admin','admin_head'));
|
14 |
+
}
|
15 |
+
add_filter('manage_edit-'.EM_POST_TYPE_LOCATION.'_columns' , array('EM_Location_Posts_Admin','columns_add'));
|
16 |
+
add_filter('manage_'.EM_POST_TYPE_LOCATION.'_posts_custom_column' , array('EM_Location_Posts_Admin','columns_output'),10,2 );
|
17 |
+
}
|
18 |
+
|
19 |
+
function admin_head(){
|
20 |
+
//quick hacks to make event admin table make more sense for events
|
21 |
+
?>
|
22 |
+
<script type="text/javascript">
|
23 |
+
jQuery(document).ready( function($){
|
24 |
+
$('.inline-edit-date').prev().css('display','none').next().css('display','none').next().css('display','none');
|
25 |
+
});
|
26 |
+
</script>
|
27 |
+
<style>
|
28 |
+
table.fixed{ table-layout:auto !important; }
|
29 |
+
.tablenav select[name="m"] { display:none; }
|
30 |
+
</style>
|
31 |
+
<?php
|
32 |
+
}
|
33 |
+
|
34 |
+
function admin_menu(){
|
35 |
+
global $menu, $submenu;
|
36 |
+
// Add a submenu to the custom top-level menu:
|
37 |
+
$plugin_pages = array();
|
38 |
+
$plugin_pages[] = add_submenu_page('edit.php?post_type='.EM_POST_TYPE_EVENT, __('Locations', 'dbem'), __('Locations', 'dbem'), 'edit_locations', 'events-manager-locations', "edit.php?post_type=event");
|
39 |
+
$plugin_pages = apply_filters('em_create_locationss_submenu',$plugin_pages);
|
40 |
+
}
|
41 |
+
|
42 |
+
function columns_add($columns) {
|
43 |
+
//prepend ID after checkbox
|
44 |
+
if( array_key_exists('cb', $columns) ){
|
45 |
+
$cb = $columns['cb'];
|
46 |
+
unset($columns['cb']);
|
47 |
+
$id_array = array('cb'=>$cb, 'location-id' => sprintf(__('%s ID','dbem'),__('Location','dbem')));
|
48 |
+
}else{
|
49 |
+
$id_array = array('location-id' => sprintf(__('%s ID','dbem'),__('Location','dbem')));
|
50 |
+
}
|
51 |
+
unset($columns['author']);
|
52 |
+
unset($columns['date']);
|
53 |
+
unset($columns['comments']);
|
54 |
+
return array_merge($id_array, $columns, array(
|
55 |
+
'address' => __('Address','dbem'),
|
56 |
+
'town' => __('Town','dbem'),
|
57 |
+
'state' => __('State','dbem'),
|
58 |
+
'country' => __('Country','dbem')
|
59 |
+
));
|
60 |
+
}
|
61 |
+
|
62 |
+
function columns_output( $column ) {
|
63 |
+
global $post;
|
64 |
+
$post = em_get_location($post);
|
65 |
+
switch ( $column ) {
|
66 |
+
case 'location-id':
|
67 |
+
echo $post->location_id;
|
68 |
+
break;
|
69 |
+
case 'address':
|
70 |
+
echo $post->location_address;
|
71 |
+
break;
|
72 |
+
case 'town':
|
73 |
+
echo $post->location_town;
|
74 |
+
break;
|
75 |
+
case 'state':
|
76 |
+
echo $post->location_state;
|
77 |
+
break;
|
78 |
+
case 'country':
|
79 |
+
echo $post->location_country;
|
80 |
+
break;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
add_action('admin_init', array('EM_Location_Posts_Admin','init'));
|
classes/em-location.php
CHANGED
@@ -1,307 +1,906 @@
|
|
1 |
-
<?php
|
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 |
-
var $
|
30 |
-
var $
|
31 |
-
var $
|
32 |
-
var $
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
if($
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
$
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
$
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
$
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
$
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
$
|
305 |
-
|
306 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
307 |
Â
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* gets a location
|
4 |
+
* @param mixed $id
|
5 |
+
* @param mixed $search_by
|
6 |
+
* @return EM_Location
|
7 |
+
*/
|
8 |
+
function em_get_location($id = false, $search_by = 'location_id') {
|
9 |
+
if( is_object($id) && get_class($id) == 'EM_Location' ){
|
10 |
+
return apply_filters('em_get_location', $id);
|
11 |
+
}else{
|
12 |
+
return apply_filters('em_get_location', new EM_Location($id,$search_by));
|
13 |
+
}
|
14 |
+
}
|
15 |
+
/**
|
16 |
+
* Object that holds location info and related functions
|
17 |
+
* @author marcus
|
18 |
+
*/
|
19 |
+
class EM_Location extends EM_Object {
|
20 |
+
//DB Fields
|
21 |
+
var $location_id = '';
|
22 |
+
var $post_id = '';
|
23 |
+
var $blog_id = '';
|
24 |
+
var $location_slug = '';
|
25 |
+
var $location_name = '';
|
26 |
+
var $location_address = '';
|
27 |
+
var $location_town = '';
|
28 |
+
var $location_state = '';
|
29 |
+
var $location_postcode = '';
|
30 |
+
var $location_region = '';
|
31 |
+
var $location_country = '';
|
32 |
+
var $location_latitude = 0;
|
33 |
+
var $location_longitude = 0;
|
34 |
+
var $post_content = '';
|
35 |
+
var $location_owner = '';
|
36 |
+
var $location_status = 0;
|
37 |
+
//Other Vars
|
38 |
+
var $fields = array(
|
39 |
+
'location_id' => array('name'=>'id','type'=>'%d'),
|
40 |
+
'post_id' => array('name'=>'post_id','type'=>'%d'),
|
41 |
+
'blog_id' => array('name'=>'blog_id','type'=>'%d'),
|
42 |
+
'location_slug' => array('name'=>'slug','type'=>'%s', 'null'=>true),
|
43 |
+
'location_name' => array('name'=>'name','type'=>'%s', 'null'=>true),
|
44 |
+
'location_address' => array('name'=>'address','type'=>'%s','null'=>true),
|
45 |
+
'location_town' => array('name'=>'town','type'=>'%s','null'=>true),
|
46 |
+
'location_state' => array('name'=>'state','type'=>'%s','null'=>true),
|
47 |
+
'location_postcode' => array('name'=>'postcode','type'=>'%s','null'=>true),
|
48 |
+
'location_region' => array('name'=>'region','type'=>'%s','null'=>true),
|
49 |
+
'location_country' => array('name'=>'country','type'=>'%s','null'=>true),
|
50 |
+
'location_latitude' => array('name'=>'latitude','type'=>'%f','null'=>true),
|
51 |
+
'location_longitude' => array('name'=>'longitude','type'=>'%f','null'=>true),
|
52 |
+
'post_content' => array('name'=>'description','type'=>'%s', 'null'=>true),
|
53 |
+
'location_owner' => array('name'=>'owner','type'=>'%d', 'null'=>true),
|
54 |
+
'location_status' => array('name'=>'status','type'=>'%d', 'null'=>true)
|
55 |
+
);
|
56 |
+
var $post_fields = array('post_id','location_slug','location_name','post_content','location_owner');
|
57 |
+
var $location_attributes = array();
|
58 |
+
var $image_url = '';
|
59 |
+
var $required_fields = array();
|
60 |
+
var $feedback_message = "";
|
61 |
+
var $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
|
62 |
+
var $errors = array();
|
63 |
+
/**
|
64 |
+
* previous status of location
|
65 |
+
* @access protected
|
66 |
+
* @var mixed
|
67 |
+
*/
|
68 |
+
var $previous_status = false;
|
69 |
+
|
70 |
+
/* Post Variables - copied out of post object for easy IDE reference */
|
71 |
+
var $ID;
|
72 |
+
var $post_author;
|
73 |
+
var $post_date;
|
74 |
+
var $post_date_gmt;
|
75 |
+
var $post_title;
|
76 |
+
var $post_excerpt;
|
77 |
+
var $post_status;
|
78 |
+
var $comment_status;
|
79 |
+
var $ping_status;
|
80 |
+
var $post_password;
|
81 |
+
var $post_name;
|
82 |
+
var $to_ping;
|
83 |
+
var $pinged;
|
84 |
+
var $post_modified;
|
85 |
+
var $post_modified_gmt;
|
86 |
+
var $post_content_filtered;
|
87 |
+
var $post_parent;
|
88 |
+
var $guid;
|
89 |
+
var $menu_order;
|
90 |
+
var $post_type;
|
91 |
+
var $post_mime_type;
|
92 |
+
var $comment_count;
|
93 |
+
var $ancestors;
|
94 |
+
var $filter;
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Gets data from POST (default), supplied array, or from the database if an ID is supplied
|
99 |
+
* @param $location_data
|
100 |
+
* @param $search_by can be set to post_id or a number for a blog id if in ms mode with global tables, default is location_id
|
101 |
+
* @return null
|
102 |
+
*/
|
103 |
+
function __construct($id = false, $search_by = 'location_id' ) {
|
104 |
+
global $wpdb;
|
105 |
+
//Initialize
|
106 |
+
$this->required_fields = array("location_address" => __('The location address', 'dbem'), "location_town" => __('The location town', 'dbem'), "location_country" => __('The country', 'dbem'));
|
107 |
+
//Get the post_id/location_id
|
108 |
+
$is_post = !empty($id->ID) && $id->post_type == EM_POST_TYPE_LOCATION;
|
109 |
+
if( $is_post || absint($id) > 0 ){ //only load info if $id is a number
|
110 |
+
$location_post = false;
|
111 |
+
if($search_by == 'location_id' && !$is_post){
|
112 |
+
//search by location_id, get post_id and blog_id (if in ms mode) and load the post
|
113 |
+
$results = $wpdb->get_row($wpdb->prepare("SELECT post_id, blog_id FROM ".EM_LOCATIONS_TABLE." WHERE location_id=%d",$id), ARRAY_A);
|
114 |
+
if( !empty($results['post_id']) ){
|
115 |
+
$this->post_id = $results['post_id'];
|
116 |
+
if( is_multisite() ){
|
117 |
+
if( empty($results['blog_id']) || (EM_MS_GLOBAL && get_site_option('dbem_ms_mainblog_locations')) ){
|
118 |
+
$results['blog_id'] = get_current_site()->blog_id;
|
119 |
+
}
|
120 |
+
$location_post = get_blog_post($results['blog_id'], $results['post_id']);
|
121 |
+
$search_by = $results['blog_id'];
|
122 |
+
}else{
|
123 |
+
$location_post = get_post($results['post_id']);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}else{
|
127 |
+
if(!$is_post){
|
128 |
+
if( EM_MS_GLOBAL && get_site_option('dbem_ms_mainblog_locations') ){
|
129 |
+
//blog_id will always be the main blog id if global locations are restricted only to the main blog
|
130 |
+
$search_by = get_current_site()->blog_id;
|
131 |
+
}
|
132 |
+
if( is_numeric($search_by) && is_multisite() ){
|
133 |
+
//we've been given a blog_id, so we're searching for a post id
|
134 |
+
$location_post = get_blog_post($search_by, $id);
|
135 |
+
}else{
|
136 |
+
//search for the post id only
|
137 |
+
$location_post = get_post($id);
|
138 |
+
}
|
139 |
+
}else{
|
140 |
+
$location_post = $id;
|
141 |
+
}
|
142 |
+
$this->post_id = !empty($id->ID) ? $id->ID : $id;
|
143 |
+
}
|
144 |
+
$this->load_postdata($location_post, $search_by);
|
145 |
+
}
|
146 |
+
$this->compat_keys();
|
147 |
+
do_action('em_location', $this, $id, $search_by);
|
148 |
+
}
|
149 |
+
|
150 |
+
function load_postdata($location_post, $search_by = false){
|
151 |
+
if( is_object($location_post) ){
|
152 |
+
if( $location_post->post_status != 'auto-draft' ){
|
153 |
+
if( is_numeric($search_by) && is_multisite() ){
|
154 |
+
// if in multisite mode, switch blogs quickly to get the right post meta.
|
155 |
+
switch_to_blog($search_by);
|
156 |
+
$location_meta = get_post_custom($location_post->ID);
|
157 |
+
restore_current_blog();
|
158 |
+
$this->blog_id = $search_by;
|
159 |
+
}else{
|
160 |
+
$location_meta = get_post_custom($location_post->ID);
|
161 |
+
}
|
162 |
+
//Get custom fields
|
163 |
+
foreach($location_meta as $location_meta_key => $location_meta_val){
|
164 |
+
$found = false;
|
165 |
+
foreach($this->fields as $field_name => $field_info){
|
166 |
+
if( $location_meta_key == '_'.$field_name){
|
167 |
+
$this->$field_name = $location_meta_val[0];
|
168 |
+
$found = true;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
if(!$found && $location_meta_key[0] != '_'){
|
172 |
+
$this->location_attributes[$location_meta_key] = ( count($location_meta_val) > 1 ) ? $location_meta_val:$location_meta_val[0];
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
//load post data - regardless
|
177 |
+
$this->post_id = $location_post->ID;
|
178 |
+
$this->location_name = $location_post->post_title;
|
179 |
+
$this->location_slug = $location_post->post_name;
|
180 |
+
$this->location_owner = $location_post->post_author;
|
181 |
+
$this->post_content = $location_post->post_content;
|
182 |
+
foreach( $location_post as $key => $value ){ //merge the post data into location object
|
183 |
+
$this->$key = $value;
|
184 |
+
}
|
185 |
+
$this->get_status();
|
186 |
+
}elseif( !empty($this->post_id) ){
|
187 |
+
//we have an orphan... show it, so that we can at least remove it on the front-end
|
188 |
+
global $wpdb;
|
189 |
+
$location_array = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".EM_LOCATIONS_TABLE." WHERE post_id=%d",$this->post_id), ARRAY_A);
|
190 |
+
if( is_array($location_array) ){
|
191 |
+
$this->orphaned_location = true;
|
192 |
+
$this->post_id = $this->ID = $event_array['post_id'] = null; //reset post_id because it doesn't really exist
|
193 |
+
$this->to_object($location_array);
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Retrieve event information via POST (used in situations where posts aren't submitted via WP)
|
200 |
+
* @param boolean $validate whether or not to run validation, default is true
|
201 |
+
* @return boolean
|
202 |
+
*/
|
203 |
+
function get_post($validate = true){
|
204 |
+
global $allowedtags;
|
205 |
+
do_action('em_location_get_post_pre', $this);
|
206 |
+
$this->location_name = ( !empty($_POST['location_name']) ) ? htmlspecialchars_decode(wp_kses_data(htmlspecialchars_decode(stripslashes($_POST['location_name'])))):'';
|
207 |
+
$this->post_content = ( !empty($_POST['content']) ) ? wp_kses( stripslashes($_POST['content']), $allowedtags):'';
|
208 |
+
$this->get_post_meta(false);
|
209 |
+
$result = $validate ? $this->validate():true; //validate both post and meta, otherwise return true
|
210 |
+
$this->compat_keys();
|
211 |
+
return apply_filters('em_location_get_post', $result, $this);
|
212 |
+
}
|
213 |
+
/**
|
214 |
+
* Retrieve event post meta information via POST, which should be always be called when saving the event custom post via WP.
|
215 |
+
* @param boolean $validate whether or not to run validation, default is true
|
216 |
+
* @return mixed
|
217 |
+
*/
|
218 |
+
function get_post_meta($validate = true){
|
219 |
+
//We are getting the values via POST or GET
|
220 |
+
do_action('em_location_get_post_meta_pre', $this);
|
221 |
+
$this->location_address = ( !empty($_POST['location_address']) ) ? wp_kses(stripslashes($_POST['location_address']), array()):'';
|
222 |
+
$this->location_town = ( !empty($_POST['location_town']) ) ? wp_kses(stripslashes($_POST['location_town']), array()):'';
|
223 |
+
$this->location_state = ( !empty($_POST['location_state']) ) ? wp_kses(stripslashes($_POST['location_state']), array()):'';
|
224 |
+
$this->location_postcode = ( !empty($_POST['location_postcode']) ) ? wp_kses(stripslashes($_POST['location_postcode']), array()):'';
|
225 |
+
$this->location_region = ( !empty($_POST['location_region']) ) ? wp_kses(stripslashes($_POST['location_region']), array()):'';
|
226 |
+
$this->location_country = ( !empty($_POST['location_country']) ) ? wp_kses(stripslashes($_POST['location_country']), array()):'';
|
227 |
+
$this->location_latitude = ( !empty($_POST['location_latitude']) && is_numeric($_POST['location_latitude']) ) ? $_POST['location_latitude']:'';
|
228 |
+
$this->location_longitude = ( !empty($_POST['location_longitude']) && is_numeric($_POST['location_longitude']) ) ? $_POST['location_longitude']:'';
|
229 |
+
//Sort out event attributes - note that custom post meta now also gets inserted here automatically (and is overwritten by these attributes)
|
230 |
+
if(get_option('dbem_location_attributes_enabled')){
|
231 |
+
global $allowedtags;
|
232 |
+
if( !is_array($this->location_attributes) ){ $this->location_attributes = array(); }
|
233 |
+
$location_available_attributes = em_get_attributes(true); //lattributes only
|
234 |
+
if( !empty($_POST['em_attributes']) && is_array($_POST['em_attributes']) ){
|
235 |
+
foreach($_POST['em_attributes'] as $att_key => $att_value ){
|
236 |
+
if( (in_array($att_key, $location_available_attributes['names']) || array_key_exists($att_key, $this->location_attributes) ) ){
|
237 |
+
$att_vals = count($location_available_attributes['values'][$att_key]);
|
238 |
+
if( $att_vals == 0 || ($att_vals > 0 && in_array($att_value, $location_available_attributes['values'][$att_key])) ){
|
239 |
+
$this->location_attributes[$att_key] = stripslashes($att_value);
|
240 |
+
}elseif($att_vals > 0){
|
241 |
+
$this->location_attributes[$att_key] = stripslashes(wp_kses($location_available_attributes['values'][$att_key][0], $allowedtags));
|
242 |
+
}
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
}
|
247 |
+
$result = $validate ? $this->validate_meta():true; //post returns null
|
248 |
+
$this->compat_keys();
|
249 |
+
return apply_filters('em_location_get_post_meta',$result,$this);
|
250 |
+
}
|
251 |
+
|
252 |
+
function validate(){
|
253 |
+
$validate_post = true;
|
254 |
+
if( empty($this->location_name) ){
|
255 |
+
$validate_post = false;
|
256 |
+
$this->add_error( __('Location name','dbem').__(" is required.", "dbem") );
|
257 |
+
}
|
258 |
+
$validate_image = $this->image_validate();
|
259 |
+
$validate_meta = $this->validate_meta();
|
260 |
+
return apply_filters('em_location_validate', $validate_post && $validate_image && $validate_meta, $this );
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Validates the location. Should be run during any form submission or saving operation.
|
265 |
+
* @return boolean
|
266 |
+
*/
|
267 |
+
function validate_meta(){
|
268 |
+
//check required fields
|
269 |
+
foreach ( $this->required_fields as $field => $description) {
|
270 |
+
if( $field == 'location_country' && !array_key_exists($this->location_country, em_get_countries()) ){
|
271 |
+
//country specific checking
|
272 |
+
$this->add_error( $this->required_fields['location_country'].__(" is required.", "dbem") );
|
273 |
+
}elseif ( $this->$field == "" ) {
|
274 |
+
$this->add_error( $description.__(" is required.", "dbem") );
|
275 |
+
}
|
276 |
+
}
|
277 |
+
return apply_filters('em_location_validate_meta', ( count($this->errors) == 0 ), $this);
|
278 |
+
}
|
279 |
+
|
280 |
+
function save(){
|
281 |
+
global $wpdb, $current_user, $blog_id;
|
282 |
+
//TODO shuffle filters into right place
|
283 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){ $this->ms_global_switch(); }
|
284 |
+
if( !$this->can_manage('edit_locations', 'edit_others_locations') && !( get_option('dbem_events_anonymous_submissions') && empty($this->location_id)) ){
|
285 |
+
return apply_filters('em_location_save', false, $this);
|
286 |
+
}
|
287 |
+
remove_action('save_post',array('EM_Location_Post_Admin','save_post'),10,1); //disable the default save post action, we'll do it manually this way
|
288 |
+
do_action('em_location_save_pre', $this);
|
289 |
+
$post_array = array();
|
290 |
+
//Deal with updates to a location
|
291 |
+
if( !empty($this->post_id) ){
|
292 |
+
//get the full array of post data so we don't overwrite anything.
|
293 |
+
if( EM_MS_GLOBAL ){
|
294 |
+
if( !empty($this->blog_id) ){
|
295 |
+
$post_array = (array) get_blog_post($this->blog_id, $this->post_id);
|
296 |
+
}else{
|
297 |
+
$post_array = (array) get_blog_post(get_current_site()->blog_id, $this->post_id);
|
298 |
+
}
|
299 |
+
}else{
|
300 |
+
$post_array = (array) get_post($this->post_id);
|
301 |
+
}
|
302 |
+
}
|
303 |
+
//Overwrite new post info
|
304 |
+
$post_array['post_type'] = EM_POST_TYPE_LOCATION;
|
305 |
+
$post_array['post_title'] = $this->location_name;
|
306 |
+
$post_array['post_content'] = $this->post_content;
|
307 |
+
//decide on post status
|
308 |
+
if( count($this->errors) == 0 ){
|
309 |
+
if( EM_MS_GLOBAL && !is_main_site() && get_site_option('dbem_ms_mainblog_locations') ){
|
310 |
+
//if in global ms mode and user is a valid role to publish on their blog, then we will publish the location on the main blog
|
311 |
+
restore_current_blog();
|
312 |
+
$post_array['post_status'] = $this->can_manage('publish_locations') ? 'publish':'pending';
|
313 |
+
EM_Object::ms_global_switch(); //switch 'back' to main blog
|
314 |
+
}else{
|
315 |
+
$post_array['post_status'] = $this->can_manage('publish_locations') ? 'publish':'pending';
|
316 |
+
}
|
317 |
+
}else{
|
318 |
+
$post_array['post_status'] = 'draft';
|
319 |
+
}
|
320 |
+
//Anonymous submission
|
321 |
+
if( !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->location_id) ){
|
322 |
+
$post_array['post_author'] = get_option('dbem_events_anonymous_user');
|
323 |
+
if( !is_numeric($post_array['post_author']) ) $post_array['post_author'] = 0;
|
324 |
+
}
|
325 |
+
//Save post and continue with meta
|
326 |
+
$post_id = wp_insert_post($post_array);
|
327 |
+
$post_save = false;
|
328 |
+
$meta_save = false;
|
329 |
+
if( !is_wp_error($post_id) && !empty($post_id) ){
|
330 |
+
$post_save = true;
|
331 |
+
//refresh this event with wp post
|
332 |
+
$post_data = get_post($post_id);
|
333 |
+
$this->post_id = $post_id;
|
334 |
+
$this->location_slug = $post_data->post_name;
|
335 |
+
$this->location_owner = $post_data->post_author;
|
336 |
+
$this->post_status = $post_data->post_status;
|
337 |
+
$this->get_status();
|
338 |
+
//now save the meta
|
339 |
+
$meta_save = $this->save_meta();
|
340 |
+
//save the image
|
341 |
+
$this->image_upload();
|
342 |
+
$image_save = (count($this->errors) == 0);
|
343 |
+
}elseif(is_wp_error($post_id)){
|
344 |
+
//location not saved, add an error
|
345 |
+
$this->add_error($post_id->get_error_message());
|
346 |
+
}
|
347 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){ $this->ms_global_switch_back(); }
|
348 |
+
return apply_filters('em_location_save', $post_save && $meta_save && $image_save, $this);
|
349 |
+
}
|
350 |
+
|
351 |
+
function save_meta(){
|
352 |
+
//echo "<pre>"; print_r($this); echo "</pre>"; die();
|
353 |
+
global $wpdb, $current_user;
|
354 |
+
if( $this->can_manage('edit_locations','edit_others_locations') || ( get_option('dbem_events_anonymous_submissions') && empty($this->location_id)) ){
|
355 |
+
do_action('em_location_save_meta_pre', $this);
|
356 |
+
//Set Blog ID if in multisite mode
|
357 |
+
if( EM_MS_GLOBAL && get_site_option('dbem_ms_mainblog_locations') ){
|
358 |
+
$this->blog_id = get_current_site()->blog_id; //global locations restricted to main blog must have main site id
|
359 |
+
}elseif( is_multisite() && empty($this->blog_id) ){
|
360 |
+
$this->blog_id = get_current_blog_id();
|
361 |
+
}
|
362 |
+
//Update Post Meta
|
363 |
+
foreach( array_keys($this->fields) as $key ){
|
364 |
+
if( !in_array($key, $this->post_fields) ){
|
365 |
+
update_post_meta($this->post_id, '_'.$key, $this->$key);
|
366 |
+
}
|
367 |
+
}
|
368 |
+
//Update Post Attributes
|
369 |
+
foreach($this->location_attributes as $location_attribute_key => $location_attribute){
|
370 |
+
update_post_meta($this->post_id, $location_attribute_key, $location_attribute);
|
371 |
+
}
|
372 |
+
$this->get_status();
|
373 |
+
$this->location_status = (count($this->errors) == 0) ? $this->location_status:null; //set status at this point, it's either the current status, or if validation fails, null
|
374 |
+
//Save to em_locations table
|
375 |
+
$location_array = $this->to_array(true);
|
376 |
+
unset($location_array['location_id']);
|
377 |
+
//decide whether or not event is private at this point
|
378 |
+
$location_array['location_private'] = ( $this->post_status == 'private' ) ? 1:0;
|
379 |
+
//check if location truly exists, meaning the location_id is actually a valid location id
|
380 |
+
if( !empty($this->location_id) ){
|
381 |
+
if( !empty($this->orphaned_location) && !empty($this->post_id) ){
|
382 |
+
//we're dealing with an orphaned event in wp_em_locations table, so we want to update the post_id and give it a post parent
|
383 |
+
$loc_truly_exists = true;
|
384 |
+
}else{
|
385 |
+
$loc_truly_exists = $wpdb->get_var('SELECT post_id FROM '.EM_LOCATIONS_TABLE." WHERE location_id={$this->location_id}") == $this->post_id;
|
386 |
+
}
|
387 |
+
}else{
|
388 |
+
$loc_truly_exists = false;
|
389 |
+
}
|
390 |
+
//save all the meta
|
391 |
+
if( empty($this->location_id) || !$loc_truly_exists ){
|
392 |
+
$this->previous_status = 0; //for sure this was previously status 0
|
393 |
+
if ( !$wpdb->insert(EM_LOCATIONS_TABLE, $location_array) ){
|
394 |
+
$this->add_error( sprintf(__('Something went wrong saving your %s to the index table. Please inform a site administrator about this.','dbem'),__('location','dbem')));
|
395 |
+
}else{
|
396 |
+
//success, so link the event with the post via an event id meta value for easy retrieval
|
397 |
+
$this->location_id = $wpdb->insert_id;
|
398 |
+
update_post_meta($this->post_id, '_location_id', $this->location_id);
|
399 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Location','dbem'));
|
400 |
+
}
|
401 |
+
}else{
|
402 |
+
$this->get_previous_status();
|
403 |
+
if ( $wpdb->update(EM_LOCATIONS_TABLE, $location_array, array('location_id'=>$this->location_id)) === false ){
|
404 |
+
$this->add_error( sprintf(__('Something went wrong updating your %s to the index table. Please inform a site administrator about this.','dbem'),__('location','dbem')));
|
405 |
+
}else{
|
406 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Location','dbem'));
|
407 |
+
//Also set the status here if status != previous status
|
408 |
+
if( $this->previous_status != $this->get_status() ) $this->set_status($this->get_status());
|
409 |
+
}
|
410 |
+
}
|
411 |
+
}else{
|
412 |
+
$this->add_error( sprintf(__('You do not have permission to create/edit %s.','dbem'), __('locations','dbem')) );
|
413 |
+
}
|
414 |
+
$this->compat_keys();
|
415 |
+
return apply_filters('em_location_save_meta', count($this->errors) == 0, $this);
|
416 |
+
}
|
417 |
+
|
418 |
+
function delete($force_delete = false){
|
419 |
+
$result = false;
|
420 |
+
if( $this->can_manage('delete_locations','delete_others_locations') ){
|
421 |
+
if( !is_admin() ){
|
422 |
+
include_once('em-location-post-admin.php');
|
423 |
+
if( !defined('EM_LOCATION_DELETE_INCLUDE') ){
|
424 |
+
EM_Location_Post_Admin::init();
|
425 |
+
define('EM_LOCATION_DELETE_INCLUDE',true);
|
426 |
+
}
|
427 |
+
}
|
428 |
+
do_action('em_location_delete_pre', $this);
|
429 |
+
if( $force_delete ){
|
430 |
+
$result = wp_delete_post($this->post_id,$force_delete);
|
431 |
+
}else{
|
432 |
+
$result = wp_trash_post($this->post_id);
|
433 |
+
if( !$result && $this->post_status == 'trash' && $this->location_status != -1 ){
|
434 |
+
//we're probably dealing with a trashed post already, which will return a false with wp_trash_post, but the location_status is null from < v5.4.1 so refresh it
|
435 |
+
$this->set_status(-1);
|
436 |
+
$result = true;
|
437 |
+
}
|
438 |
+
}
|
439 |
+
if( !$result && !empty($this->orphaned_location) ){
|
440 |
+
//this is an orphaned event, so the wp delete posts would have never worked, so we just delete the row in our locations table
|
441 |
+
$result = $this->delete_meta();
|
442 |
+
}
|
443 |
+
}
|
444 |
+
return apply_filters('em_location_delete', $result != false, $this);
|
445 |
+
}
|
446 |
+
|
447 |
+
function delete_meta(){
|
448 |
+
global $wpdb;
|
449 |
+
$result = false;
|
450 |
+
if( $this->can_manage('delete_locations','delete_others_locations') ){
|
451 |
+
do_action('em_location_delete_meta_pre', $this);
|
452 |
+
$result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". EM_LOCATIONS_TABLE ." WHERE location_id=%d", $this->location_id) );
|
453 |
+
}
|
454 |
+
return apply_filters('em_location_delete_meta', $result !== false, $this);
|
455 |
+
}
|
456 |
+
|
457 |
+
function is_published(){
|
458 |
+
return apply_filters('em_location_is_published', ($this->post_status == 'publish' || $this->post_status == 'private'), $this);
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Change the status of the location. This will save to the Database too.
|
463 |
+
* @param int $status
|
464 |
+
* @param boolean $set_post_status
|
465 |
+
* @return string
|
466 |
+
*/
|
467 |
+
function set_status($status, $set_post_status = false){
|
468 |
+
global $wpdb;
|
469 |
+
if($status === null){
|
470 |
+
$set_status='NULL';
|
471 |
+
if($set_post_status){
|
472 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $this->post_id ) );
|
473 |
+
}
|
474 |
+
$this->post_status = 'draft';
|
475 |
+
}elseif( $status == -1 ){ //trashed post
|
476 |
+
$set_status = -1;
|
477 |
+
if($set_post_status){
|
478 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => 'trash' ), array( 'ID' => $this->post_id ) );
|
479 |
+
}
|
480 |
+
$this->post_status = 'trash'; //set post status in this instance
|
481 |
+
}else{
|
482 |
+
$set_status = $status ? 1:0;
|
483 |
+
$post_status = $set_status ? 'publish':'pending';
|
484 |
+
if($set_post_status){
|
485 |
+
if($this->post_status == 'pending' && empty($this->post_name)){
|
486 |
+
$this->post_name = sanitize_title($this->post_title);
|
487 |
+
}
|
488 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => $post_status, 'post_name' => $this->post_name ), array( 'ID' => $this->post_id ) );
|
489 |
+
}
|
490 |
+
$this->post_status = $post_status;
|
491 |
+
}
|
492 |
+
$this->previous_status = $wpdb->get_var('SELECT location_status FROM '.EM_LOCATIONS_TABLE.' WHERE location_id='.$this->location_id); //get status from db, not post_status, as posts get saved quickly
|
493 |
+
$result = $wpdb->query($wpdb->prepare("UPDATE ".EM_LOCATIONS_TABLE." SET location_status=$set_status AND location_slug=%s WHERE location_id=%d", array($this->post_name, $this->location_id)));
|
494 |
+
$this->get_status();
|
495 |
+
return apply_filters('em_location_set_status', $result !== false, $status, $this);
|
496 |
+
}
|
497 |
+
|
498 |
+
function get_status($db = false){
|
499 |
+
switch( $this->post_status ){
|
500 |
+
case 'private':
|
501 |
+
$this->location_private = 1;
|
502 |
+
$this->location_status = $status = 1;
|
503 |
+
break;
|
504 |
+
case 'publish':
|
505 |
+
$this->location_private = 0;
|
506 |
+
$this->location_status = $status = 1;
|
507 |
+
break;
|
508 |
+
case 'pending':
|
509 |
+
$this->location_private = 0;
|
510 |
+
$this->location_status = $status = 0;
|
511 |
+
break;
|
512 |
+
case 'trash':
|
513 |
+
$this->location_private = 0;
|
514 |
+
$this->location_status = $status = -1;
|
515 |
+
break;
|
516 |
+
default: //draft or unknown
|
517 |
+
$this->location_private = 0;
|
518 |
+
$status = $db ? 'NULL':null;
|
519 |
+
$this->location_status = null;
|
520 |
+
break;
|
521 |
+
}
|
522 |
+
return $status;
|
523 |
+
}
|
524 |
+
|
525 |
+
function get_previous_status( $force = false ){
|
526 |
+
global $wpdb;
|
527 |
+
if( $this->previous_status === false || $force ){
|
528 |
+
$this->previous_status = $wpdb->get_var('SELECT location_status FROM '.EM_LOCATIONS_TABLE.' WHERE location_id='.$this->location_id); //get status from db, not post_status
|
529 |
+
}
|
530 |
+
return $this->previous_status;
|
531 |
+
}
|
532 |
+
|
533 |
+
function load_similar($criteria){
|
534 |
+
global $wpdb;
|
535 |
+
if( !empty($criteria['location_name']) && !empty($criteria['location_name']) && !empty($criteria['location_name']) ){
|
536 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
537 |
+
$prepared_sql = $wpdb->prepare("SELECT * FROM $locations_table WHERE location_name = %s AND location_address = %s AND location_town = %s AND location_state = %s AND location_postcode = %s AND location_country = %s", stripcslashes($criteria['location_name']), stripcslashes($criteria['location_address']), stripcslashes($criteria['location_town']), stripcslashes($criteria['location_state']), stripcslashes($criteria['location_postcode']), stripcslashes($criteria['location_country']) );
|
538 |
+
//$wpdb->show_errors(true);
|
539 |
+
$location = $wpdb->get_row($prepared_sql, ARRAY_A);
|
540 |
+
if( is_array($location) ){
|
541 |
+
$this->to_object($location);
|
542 |
+
}
|
543 |
+
return apply_filters('em_location_load_similar', $location, $this);
|
544 |
+
}
|
545 |
+
return apply_filters('em_location_load_similar', false, $this);
|
546 |
+
}
|
547 |
+
|
548 |
+
function has_events(){
|
549 |
+
global $wpdb;
|
550 |
+
$events_table = EM_EVENTS_TABLE;
|
551 |
+
$sql = "SELECT count(event_id) as events_no FROM $events_table WHERE location_id = {$this->location_id}";
|
552 |
+
$affected_events = $wpdb->get_row($sql);
|
553 |
+
return apply_filters('em_location_has_events', (count($affected_events) > 0), $this);
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* Can the user manage this location?
|
558 |
+
*/
|
559 |
+
function can_manage( $owner_capability = false, $admin_capability = false, $user_to_check = false ){
|
560 |
+
if( $this->location_id == '' && !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') ){
|
561 |
+
$user_to_check = get_option('dbem_events_anonymous_user');
|
562 |
+
}
|
563 |
+
if( $admin_capability && EM_MS_GLOBAL && get_site_option('dbem_ms_mainblog_locations') ){
|
564 |
+
//if in global mode with locations restricted to main blog, we check capabilities against the main blog
|
565 |
+
$this->ms_global_switch();
|
566 |
+
$return = parent::can_manage($owner_capability, $admin_capability, $user_to_check);
|
567 |
+
$this->ms_global_switch_back();
|
568 |
+
}else{
|
569 |
+
$return = parent::can_manage($owner_capability, $admin_capability, $user_to_check);
|
570 |
+
}
|
571 |
+
return apply_filters('em_location_can_manage', $return, $this, $owner_capability, $admin_capability, $user_to_check);
|
572 |
+
}
|
573 |
+
|
574 |
+
function get_permalink(){
|
575 |
+
if( EM_MS_GLOBAL ){
|
576 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){
|
577 |
+
$link = get_blog_permalink( get_current_site()->blog_id, $this->post_id);
|
578 |
+
}else{
|
579 |
+
if( get_site_option('dbem_ms_global_locations_links') && !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id() ){
|
580 |
+
//linking directly to the blog, we should be on the main blog here
|
581 |
+
$link = get_blog_permalink( $this->blog_id, $this->post_id);
|
582 |
+
}elseif( !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id() ){
|
583 |
+
if( get_option('dbem_locations_page') ){
|
584 |
+
$link = trailingslashit(get_permalink(get_option('dbem_locations_page')).get_site_option('dbem_ms_locations_slug',EM_LOCATION_SLUG).'/'.$this->location_slug.'-'.$this->location_id);
|
585 |
+
}else{
|
586 |
+
$link = trailingslashit(home_url()).EM_POST_TYPE_LOCATION_SLUG.'/'.get_site_option('dbem_ms_events_slug',EM_LOCATION_SLUG).'/'.$this->location_slug.'-'.$this->location_id;
|
587 |
+
}
|
588 |
+
}
|
589 |
+
}
|
590 |
+
}
|
591 |
+
if( empty($link) ){
|
592 |
+
$link = get_post_permalink($this->post_id);
|
593 |
+
}
|
594 |
+
return apply_filters('em_location_get_permalink', $link, $this); ;
|
595 |
+
}
|
596 |
+
|
597 |
+
function get_edit_url(){
|
598 |
+
if( $this->can_manage('edit_locations','edit_others_locations') ){
|
599 |
+
if( EM_MS_GLOBAL ){
|
600 |
+
global $current_site, $current_blog;
|
601 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){
|
602 |
+
//location stored as post on main blog, but can be edited either in sub-blog admin area or if not on main blog
|
603 |
+
if( get_blog_option($this->blog_id, 'dbem_edit_locations_page') && !is_admin() ){
|
604 |
+
$link = em_add_get_params(get_blog_permalink($this->blog_id, get_blog_option($this->blog_id, 'dbem_edit_locations_page')), array('action'=>'edit','location_id'=>$this->location_id), false);
|
605 |
+
}
|
606 |
+
if( (is_main_site() || empty($link)) && get_blog_option($current_site->blog_id, 'dbem_edit_locations_page') && !is_admin() ){ //if editing on main site and edit page exists, stay on same site
|
607 |
+
$link = em_add_get_params(get_blog_permalink(get_option('dbem_edit_locations_page')), array('action'=>'edit','location_id'=>$this->location_id), false);
|
608 |
+
}
|
609 |
+
if( empty($link) && !is_main_site() ){
|
610 |
+
$link = get_admin_url($current_blog->blog_id, "edit.php?post_type=event&page=locations&action=edit&location_id={$this->location_id}");
|
611 |
+
}elseif( empty($link) && is_main_site() ){
|
612 |
+
$link = get_admin_url($current_site->blog_id, "post.php?post={$this->post_id}&action=edit");
|
613 |
+
}
|
614 |
+
}else{
|
615 |
+
//location stored as post on blog where location was created
|
616 |
+
if( get_blog_option($this->blog_id, 'dbem_edit_locations_page') && !is_admin() ){
|
617 |
+
$link = em_add_get_params(get_blog_permalink($this->blog_id, get_blog_option($this->blog_id, 'dbem_edit_locations_page')), array('action'=>'edit','location_id'=>$this->location_id), false);
|
618 |
+
}
|
619 |
+
if( (is_main_site() || empty($link)) && get_blog_option($current_site->blog_id, 'dbem_edit_locations_page') && !is_admin() ){ //if editing on main site and edit page exists, stay on same site
|
620 |
+
$link = em_add_get_params(get_blog_permalink($current_site->blog_id, get_blog_option($current_site->blog_id, 'dbem_edit_locations_page')), array('action'=>'edit','location_id'=>$this->location_id), false);
|
621 |
+
}
|
622 |
+
if( empty($link)){
|
623 |
+
$link = get_admin_url($this->blog_id, "post.php?post={$this->post_id}&action=edit");
|
624 |
+
}
|
625 |
+
}
|
626 |
+
}else{
|
627 |
+
if( get_option('dbem_edit_locations_page') && !is_admin() ){
|
628 |
+
$link = em_add_get_params(get_permalink(get_option('dbem_edit_locations_page')), array('action'=>'edit','location_id'=>$this->location_id), false);
|
629 |
+
}
|
630 |
+
if( empty($link))
|
631 |
+
$link = admin_url()."post.php?post={$this->post_id}&action=edit";
|
632 |
+
}
|
633 |
+
return apply_filters('em_location_get_edit_url', $link, $this);
|
634 |
+
}
|
635 |
+
}
|
636 |
+
|
637 |
+
function output_single($target = 'html'){
|
638 |
+
$format = get_option ( 'dbem_single_location_format' );
|
639 |
+
return apply_filters('em_location_output_single', $this->output($format, $target), $this, $target);
|
640 |
+
}
|
641 |
+
|
642 |
+
function output($format, $target="html") {
|
643 |
+
$location_string = $format;
|
644 |
+
//First let's do some conditional placeholder removals
|
645 |
+
for ($i = 0 ; $i < EM_CONDITIONAL_RECURSIONS; $i++){ //you can add nested recursions by modifying this setting in your wp_options table
|
646 |
+
preg_match_all('/\{([a-zA-Z0-9_]+)\}(.+?)\{\/\1\}/s', $location_string, $conditionals);
|
647 |
+
if( count($conditionals[0]) > 0 ){
|
648 |
+
//Check if the language we want exists, if not we take the first language there
|
649 |
+
foreach($conditionals[1] as $key => $condition){
|
650 |
+
$show_condition = false;
|
651 |
+
if ($condition == 'has_loc_image'){
|
652 |
+
//does this event have an image?
|
653 |
+
$show_condition = ( $this->get_image_url() != '' );
|
654 |
+
}elseif ($condition == 'no_loc_image'){
|
655 |
+
//does this event have an image?
|
656 |
+
$show_condition = ( $this->get_image_url() == '' );
|
657 |
+
}
|
658 |
+
$show_condition = apply_filters('em_location_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
|
659 |
+
if($show_condition){
|
660 |
+
//calculate lengths to delete placeholders
|
661 |
+
$placeholder_length = strlen($condition)+2;
|
662 |
+
$replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key])-($placeholder_length *2 +1));
|
663 |
+
}else{
|
664 |
+
$replacement = '';
|
665 |
+
}
|
666 |
+
$location_string = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $location_string);
|
667 |
+
}
|
668 |
+
}
|
669 |
+
}
|
670 |
+
//This is for the custom attributes
|
671 |
+
preg_match_all('/#_LATT\{([^}]+)\}(\{([^}]+)\})?/', $location_string, $results);
|
672 |
+
foreach($results[0] as $resultKey => $result) {
|
673 |
+
//Strip string of placeholder and just leave the reference
|
674 |
+
$attRef = substr( substr($result, 0, strpos($result, '}')), 7 );
|
675 |
+
$attString = '';
|
676 |
+
if( is_array($this->location_attributes) && array_key_exists($attRef, $this->location_attributes) && !empty($this->location_attributes[$attRef]) ){
|
677 |
+
$attString = $this->location_attributes[$attRef];
|
678 |
+
}elseif( !empty($results[3][$resultKey]) ){
|
679 |
+
//Check to see if we have a second set of braces;
|
680 |
+
$attString = $results[3][$resultKey];
|
681 |
+
}
|
682 |
+
$attString = apply_filters('em_location_output_placeholder', $attString, $this, $result, $target);
|
683 |
+
$location_string = str_replace($result, $attString ,$location_string );
|
684 |
+
}
|
685 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $location_string, $placeholders);
|
686 |
+
$replaces = array();
|
687 |
+
foreach($placeholders[1] as $key => $result) {
|
688 |
+
$replace = '';
|
689 |
+
$full_result = $placeholders[0][$key];
|
690 |
+
switch( $result ){
|
691 |
+
case '#_LOCATIONID':
|
692 |
+
$replace = $this->location_id;
|
693 |
+
break;
|
694 |
+
case '#_LOCATIONPOSTID':
|
695 |
+
$replace = $this->post_id;
|
696 |
+
break;
|
697 |
+
case '#_NAME': //Depricated
|
698 |
+
case '#_LOCATION': //Depricated
|
699 |
+
case '#_LOCATIONNAME':
|
700 |
+
$replace = $this->location_name;
|
701 |
+
break;
|
702 |
+
case '#_ADDRESS': //Depricated
|
703 |
+
case '#_LOCATIONADDRESS':
|
704 |
+
$replace = $this->location_address;
|
705 |
+
break;
|
706 |
+
case '#_TOWN': //Depricated
|
707 |
+
case '#_LOCATIONTOWN':
|
708 |
+
$replace = $this->location_town;
|
709 |
+
break;
|
710 |
+
case '#_LOCATIONSTATE':
|
711 |
+
$replace = $this->location_state;
|
712 |
+
break;
|
713 |
+
case '#_LOCATIONPOSTCODE':
|
714 |
+
$replace = $this->location_postcode;
|
715 |
+
break;
|
716 |
+
case '#_LOCATIONREGION':
|
717 |
+
$replace = $this->location_region;
|
718 |
+
break;
|
719 |
+
case '#_LOCATIONCOUNTRY':
|
720 |
+
$replace = $this->get_country();
|
721 |
+
break;
|
722 |
+
case '#_LOCATIONFULLLINE':
|
723 |
+
$replace = $this->location_address;
|
724 |
+
$replace .= empty($this->location_town) ? '':', '.$this->location_town;
|
725 |
+
$replace .= empty($this->location_state) ? '':', '.$this->location_state;
|
726 |
+
$replace .= empty($this->location_postcode) ? '':', '.$this->location_postcode;
|
727 |
+
$replace .= empty($this->location_region) ? '':', '.$this->location_region;
|
728 |
+
break;
|
729 |
+
case '#_LOCATIONFULLBR':
|
730 |
+
$replace = $this->location_address;
|
731 |
+
$replace .= empty($this->location_town) ? '':'<br />'.$this->location_town;
|
732 |
+
$replace .= empty($this->location_state) ? '':'<br />'.$this->location_state;
|
733 |
+
$replace .= empty($this->location_postcode) ? '':'<br />'.$this->location_postcode;
|
734 |
+
$replace .= empty($this->location_region) ? '':'<br />'.$this->location_region;
|
735 |
+
break;
|
736 |
+
case '#_MAP': //Depricated (but will remain)
|
737 |
+
case '#_LOCATIONMAP':
|
738 |
+
ob_start();
|
739 |
+
$args = array();
|
740 |
+
if( !empty($placeholders[3][$key]) ){
|
741 |
+
$dimensions = explode(',', $placeholders[3][$key]);
|
742 |
+
if(!empty($dimensions[0])) $args['width'] = $dimensions[0];
|
743 |
+
if(!empty($dimensions[1])) $args['height'] = $dimensions[1];
|
744 |
+
}
|
745 |
+
$template = em_locate_template('placeholders/locationmap.php', true, array('args'=>$args,'EM_Location'=>$this));
|
746 |
+
$replace = ob_get_clean();
|
747 |
+
break;
|
748 |
+
case '#_LOCATIONLONGITUDE':
|
749 |
+
$replace = $this->location_longitude;
|
750 |
+
break;
|
751 |
+
case '#_LOCATIONLATITUDE':
|
752 |
+
$replace = $this->location_latitude;
|
753 |
+
break;
|
754 |
+
case '#_DESCRIPTION': //Depricated
|
755 |
+
case '#_EXCERPT': //Depricated
|
756 |
+
case '#_LOCATIONNOTES':
|
757 |
+
case '#_LOCATIONEXCERPT':
|
758 |
+
$replace = $this->post_content;
|
759 |
+
if($result == "#_EXCERPT" || $result == "#_LOCATIONEXCERPT"){
|
760 |
+
if( !empty($this->post_excerpt) ){
|
761 |
+
$replace = $this->post_excerpt;
|
762 |
+
}else{
|
763 |
+
$excerpt_length = 55;
|
764 |
+
$excerpt_more = apply_filters('em_excerpt_more', ' ' . '[...]');
|
765 |
+
if( !empty($placeholders[3][$key]) ){
|
766 |
+
$trim = true;
|
767 |
+
$ph_args = explode(',', $placeholders[3][$key]);
|
768 |
+
if( is_numeric($ph_args[0]) ) $excerpt_length = $ph_args[0];
|
769 |
+
if( !empty($ph_args[1]) ) $excerpt_more = $ph_args[1];
|
770 |
+
}
|
771 |
+
if ( preg_match('/<!--more(.*?)?-->/', $replace, $matches) ) {
|
772 |
+
$content = explode($matches[0], $replace, 2);
|
773 |
+
$replace = force_balance_tags($content[0]);
|
774 |
+
}
|
775 |
+
if( !empty($trim) ){
|
776 |
+
//shorten content by supplied number - copied from wp_trim_excerpt
|
777 |
+
$replace = strip_shortcodes( $replace );
|
778 |
+
$replace = str_replace(']]>', ']]>', $replace);
|
779 |
+
$replace = wp_trim_words( $replace, $excerpt_length, $excerpt_more );
|
780 |
+
}
|
781 |
+
}
|
782 |
+
}
|
783 |
+
break;
|
784 |
+
case '#_LOCATIONIMAGEURL':
|
785 |
+
case '#_LOCATIONIMAGE':
|
786 |
+
if($this->get_image_url() != ''){
|
787 |
+
$image_url = esc_url($this->get_image_url());
|
788 |
+
if($result == '#_LOCATIONIMAGEURL'){
|
789 |
+
$replace = $this->get_image_url();
|
790 |
+
}else{
|
791 |
+
if( empty($placeholders[3][$key]) ){
|
792 |
+
$replace = "<img src='".$image_url."' alt='".esc_attr($this->location_name)."'/>";
|
793 |
+
}else{
|
794 |
+
$image_size = explode(',', $placeholders[3][$key]);
|
795 |
+
if( $this->array_is_numeric($image_size) && count($image_size) > 1 ){
|
796 |
+
if( get_option('dbem_disable_timthumb') ){
|
797 |
+
if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){
|
798 |
+
//location belongs to another blog, so switch blog then call the default wp fucntion
|
799 |
+
switch_to_blog($this->blog_id);
|
800 |
+
$replace = get_the_post_thumbnail($this->ID, $image_size);
|
801 |
+
restore_current_blog();
|
802 |
+
}else{
|
803 |
+
$replace = get_the_post_thumbnail($this->ID, $image_size);
|
804 |
+
}
|
805 |
+
}else{
|
806 |
+
global $blog_id;
|
807 |
+
if ( is_multisite() && $blog_id > 0) {
|
808 |
+
$imageParts = explode('/blogs.dir/', $image_url);
|
809 |
+
if (isset($imageParts[1])) {
|
810 |
+
$image_url = network_site_url('/wp-content/blogs.dir/'. $blog_id. '/' . $imageParts[1]);
|
811 |
+
}
|
812 |
+
}
|
813 |
+
$width = ($image_size[0]) ? 'width="'.esc_attr($image_size[0]).'"':'';
|
814 |
+
$height = ($image_size[1]) ? 'height="'.esc_attr($image_size[1]).'"':'';
|
815 |
+
$replace = "<img src='".esc_url(em_get_thumbnail_url($image_url, $image_size[0], $image_size[1]))."' alt='".esc_attr($this->location_name)."' $width $height />";
|
816 |
+
}
|
817 |
+
}else{
|
818 |
+
$replace = "<img src='".$image_url."' alt='".esc_attr($this->location_name)."'/>";
|
819 |
+
}
|
820 |
+
}
|
821 |
+
}
|
822 |
+
}
|
823 |
+
break;
|
824 |
+
case '#_LOCATIONURL':
|
825 |
+
case '#_LOCATIONLINK':
|
826 |
+
case '#_LOCATIONPAGEURL': //Depricated
|
827 |
+
$link = esc_url($this->get_permalink());
|
828 |
+
$replace = ($result == '#_LOCATIONURL' || $result == '#_LOCATIONPAGEURL') ? $link : '<a href="'.$link.'" title="'.esc_attr($this->location_name).'">'.esc_html($this->location_name).'</a>';
|
829 |
+
break;
|
830 |
+
case '#_LOCATIONEDITURL':
|
831 |
+
case '#_LOCATIONEDITLINK':
|
832 |
+
if( $this->can_manage('edit_locations','edit_others_locations') ){
|
833 |
+
$link = esc_url($this->get_edit_url());
|
834 |
+
$replace = ($result == '#_LOCATIONEDITURL') ? $link : '<a href="'.$link.'" title="'.esc_attr($this->location_name).'">'.esc_html(sprintf(__('Edit Location','dbem'))).'</a>';
|
835 |
+
}
|
836 |
+
break;
|
837 |
+
case '#_PASTEVENTS': //Depricated
|
838 |
+
case '#_LOCATIONPASTEVENTS':
|
839 |
+
case '#_NEXTEVENTS': //Depricated
|
840 |
+
case '#_LOCATIONNEXTEVENTS':
|
841 |
+
case '#_ALLEVENTS': //Depricated
|
842 |
+
case '#_LOCATIONALLEVENTS':
|
843 |
+
//TODO: add limit to lists of events
|
844 |
+
//convert depreciated placeholders for compatability
|
845 |
+
$result = ($result == '#_PASTEVENTS') ? '#_LOCATIONPASTEVENTS':$result;
|
846 |
+
$result = ($result == '#_NEXTEVENTS') ? '#_LOCATIONNEXTEVENTS':$result;
|
847 |
+
$result = ($result == '#_ALLEVENTS') ? '#_LOCATIONALLEVENTS':$result;
|
848 |
+
//forget it ever happened? :/
|
849 |
+
if ( $result == '#_LOCATIONPASTEVENTS'){ $scope = 'past'; }
|
850 |
+
elseif ( $result == '#_LOCATIONNEXTEVENTS' ){ $scope = 'future'; }
|
851 |
+
else{ $scope = 'all'; }
|
852 |
+
$events_count = EM_Events::count( array('location'=>$this->location_id, 'scope'=>$scope) );
|
853 |
+
if ( $events_count > 0 ){
|
854 |
+
$args = array('location'=>$this->location_id, 'scope'=>$scope, 'pagination'=>1, 'ajax'=>0);
|
855 |
+
$args['format_header'] = get_option('dbem_location_event_list_item_header_format');
|
856 |
+
$args['format_footer'] = get_option('dbem_location_event_list_item_footer_format');
|
857 |
+
$args['format'] = get_option('dbem_location_event_list_item_format');
|
858 |
+
$args['limit'] = get_option('dbem_location_event_list_limit');
|
859 |
+
$args['page'] = (!empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) )? $_REQUEST['pno'] : 1;
|
860 |
+
$replace = EM_Events::output($args);
|
861 |
+
} else {
|
862 |
+
$replace = get_option('dbem_location_event_list_item_header_format').get_option('dbem_location_no_events_message').get_option('dbem_location_event_list_item_footer_format');
|
863 |
+
}
|
864 |
+
break;
|
865 |
+
case '#_LOCATIONNEXTEVENT':
|
866 |
+
$events = EM_Events::get( array('location'=>$this->location_id, 'scope'=>'future', 'limit'=>1, 'orderby'=>'event_start_date,event_start_time') );
|
867 |
+
$replace = get_option('dbem_location_no_event_message');
|
868 |
+
foreach($events as $EM_Event){
|
869 |
+
$replace = $EM_Event->output(get_option('dbem_location_event_single_format'));
|
870 |
+
}
|
871 |
+
break;
|
872 |
+
default:
|
873 |
+
$replace = $full_result;
|
874 |
+
break;
|
875 |
+
}
|
876 |
+
$replaces[$full_result] = apply_filters('em_location_output_placeholder', $replace, $this, $full_result, $target);
|
877 |
+
}
|
878 |
+
//sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
|
879 |
+
krsort($replaces);
|
880 |
+
foreach($replaces as $full_result => $replacement){
|
881 |
+
if( !in_array($full_result, array('#_DESCRIPTION','#_LOCATIONNOTES')) ){
|
882 |
+
$location_string = str_replace($full_result, $replacement , $location_string );
|
883 |
+
}else{
|
884 |
+
$desc_replace[$full_result] = $replacement;
|
885 |
+
}
|
886 |
+
}
|
887 |
+
|
888 |
+
//Finally, do the location notes, so that previous placeholders don't get replaced within the content, which may use shortcodes
|
889 |
+
if( !empty($desc_replace) ){
|
890 |
+
foreach($desc_replace as $full_result => $replacement){
|
891 |
+
$location_string = str_replace($full_result, $replacement , $location_string );
|
892 |
+
}
|
893 |
+
}
|
894 |
+
|
895 |
+
return apply_filters('em_location_output', $location_string, $this, $format, $target);
|
896 |
+
}
|
897 |
+
|
898 |
+
function get_country(){
|
899 |
+
$countries = em_get_countries();
|
900 |
+
if( !empty($countries[$this->location_country]) ){
|
901 |
+
return apply_filters('em_location_get_country', $countries[$this->location_country], $this);
|
902 |
+
}
|
903 |
+
return apply_filters('em_location_get_country', false, $this);
|
904 |
+
|
905 |
+
}
|
906 |
Â
}
|
classes/em-locations.php
CHANGED
@@ -1,213 +1,306 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Static class which will help bulk add/edit/retrieve/manipulate arrays of EM_Location objects.
|
4 |
-
* Optimized for specifically retreiving locations (whether eventful or not). If you want event data AND location information for each event, use EM_Events
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
class EM_Locations extends EM_Object {
|
8 |
-
|
9 |
-
|
10 |
-
*
|
11 |
-
* @param boolean $
|
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 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
$
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
$
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
$
|
183 |
-
'
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
$
|
208 |
-
}
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Static class which will help bulk add/edit/retrieve/manipulate arrays of EM_Location objects.
|
4 |
+
* Optimized for specifically retreiving locations (whether eventful or not). If you want event data AND location information for each event, use EM_Events
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class EM_Locations extends EM_Object {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Returns an array of EM_Location objects
|
11 |
+
* @param boolean $eventful
|
12 |
+
* @param boolean $return_objects
|
13 |
+
* @return array
|
14 |
+
*/
|
15 |
+
function get( $args = array(), $count=false ){
|
16 |
+
global $wpdb;
|
17 |
+
$events_table = EM_EVENTS_TABLE;
|
18 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
19 |
+
$locations = array();
|
20 |
+
|
21 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
22 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
23 |
+
//We can just get all the events here and return them
|
24 |
+
$sql = "SELECT * FROM $locations_table WHERE location_id=".implode(" OR location_id=", $args);
|
25 |
+
$results = $wpdb->get_results($sql,ARRAY_A);
|
26 |
+
$events = array();
|
27 |
+
foreach($results as $result){
|
28 |
+
$locations[$result['location_id']] = new EM_Location($result);
|
29 |
+
}
|
30 |
+
return apply_filters('em_locations_get', $locations, $args); //We return all the events matched as an EM_Event array.
|
31 |
+
}elseif( is_numeric($args) ){
|
32 |
+
//return an event in the usual array format
|
33 |
+
return apply_filters('em_locations_get', array(new EM_Location($args)), $args);
|
34 |
+
}elseif( is_array($args) && is_object(current($args)) && get_class((current($args))) == 'EM_Location' ){
|
35 |
+
return apply_filters('em_locations_get', $args, $args);
|
36 |
+
}
|
37 |
+
|
38 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
39 |
+
$args = self::get_default_search($args);
|
40 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
41 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
42 |
+
|
43 |
+
//Get the default conditions
|
44 |
+
$conditions = self::build_sql_conditions($args);
|
45 |
+
|
46 |
+
//Put it all together
|
47 |
+
$EM_Location = new EM_Location(0); //Empty class for strict message avoidance
|
48 |
+
$fields = $locations_table .".". implode(", {$locations_table}.", array_keys($EM_Location->fields));
|
49 |
+
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
50 |
+
|
51 |
+
//Get ordering instructions
|
52 |
+
$EM_Event = new EM_Event(); //blank event for below
|
53 |
+
$accepted_fields = $EM_Location->get_fields(true);
|
54 |
+
$accepted_fields = array_merge($EM_Event->get_fields(true),$accepted_fields);
|
55 |
+
$orderby = self::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order'));
|
56 |
+
//Now, build orderby sql
|
57 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
|
58 |
+
|
59 |
+
$fields = ( $count ) ? $locations_table.'.location_id':$locations_table.'.post_id';
|
60 |
+
if( EM_MS_GLOBAL ){
|
61 |
+
$selectors = ( $count ) ? 'COUNT('.$locations_table.'.location_id)':$locations_table.'.post_id, '.$locations_table.'.blog_id';
|
62 |
+
}else{
|
63 |
+
$selectors = ( $count ) ? 'COUNT('.$locations_table.'.location_id)':$locations_table.'.post_id';
|
64 |
+
}
|
65 |
+
//Create the SQL statement and execute
|
66 |
+
$sql = "
|
67 |
+
SELECT $selectors FROM $locations_table
|
68 |
+
LEFT JOIN $events_table ON {$locations_table}.location_id={$events_table}.location_id
|
69 |
+
$where
|
70 |
+
GROUP BY {$locations_table}.location_id
|
71 |
+
$orderby_sql
|
72 |
+
$limit $offset
|
73 |
+
";
|
74 |
+
|
75 |
+
//If we're only counting results, return the number of results
|
76 |
+
if( $count ){
|
77 |
+
return apply_filters('em_locations_get_array', count($wpdb->get_col($sql)), $args);
|
78 |
+
}
|
79 |
+
$results = $wpdb->get_results($sql, ARRAY_A);
|
80 |
+
|
81 |
+
//If we want results directly in an array, why not have a shortcut here?
|
82 |
+
if( $args['array'] == true ){
|
83 |
+
return apply_filters('em_locations_get_array', $results, $args);
|
84 |
+
}
|
85 |
+
|
86 |
+
if( EM_MS_GLOBAL ){
|
87 |
+
foreach ( $results as $location ){
|
88 |
+
if( empty($location['blog_id']) ) $location['blog_id'] = get_current_site()->blog_id;
|
89 |
+
$locations[] = em_get_location($location['post_id'], $location['blog_id']);
|
90 |
+
}
|
91 |
+
}else{
|
92 |
+
foreach ( $results as $location ){
|
93 |
+
$locations[] = em_get_location($location['post_id'], 'post_id');
|
94 |
+
}
|
95 |
+
}
|
96 |
+
return apply_filters('em_locations_get', $locations, $args);
|
97 |
+
}
|
98 |
+
|
99 |
+
function count( $args = array() ){
|
100 |
+
return apply_filters('em_locations_count', self::get($args, true), $args);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Output a set of matched of events
|
105 |
+
* @param array $args
|
106 |
+
* @return string
|
107 |
+
*/
|
108 |
+
function output( $args ){
|
109 |
+
global $EM_Location;
|
110 |
+
$EM_Location_old = $EM_Location; //When looping, we can replace EM_Location global with the current event in the loop
|
111 |
+
//Can be either an array for the get search or an array of EM_Location objects
|
112 |
+
if( !array_key_exists('page',$args) && !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ){
|
113 |
+
$page = $args['page'] = $_REQUEST['pno'];
|
114 |
+
}
|
115 |
+
if( is_object(current($args)) && get_class((current($args))) == 'EM_Location' ){
|
116 |
+
$func_args = func_get_args();
|
117 |
+
$locations = $func_args[0];
|
118 |
+
$args = (!empty($func_args[1])) ? $func_args[1] : array();
|
119 |
+
$args = apply_filters('em_locations_output_args', self::get_default_search($args), $locations);
|
120 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
121 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
122 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
123 |
+
$locations_count = count($locations);
|
124 |
+
}else{
|
125 |
+
$args = apply_filters('em_locations_output_args', self::get_default_search($args) );
|
126 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
127 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
128 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
129 |
+
$args_count = $args;
|
130 |
+
$args_count['limit'] = 0;
|
131 |
+
$args_count['offset'] = 0;
|
132 |
+
$args_count['page'] = 1;
|
133 |
+
$locations_count = self::count($args_count);
|
134 |
+
$locations = self::get( $args );
|
135 |
+
}
|
136 |
+
//What format shall we output this to, or use default
|
137 |
+
$format = ( $args['format'] == '' ) ? get_option( 'dbem_location_list_item_format' ) : $args['format'] ;
|
138 |
+
|
139 |
+
$output = "";
|
140 |
+
$locations = apply_filters('em_locations_output_locations', $locations);
|
141 |
+
if ( count($locations) > 0 ) {
|
142 |
+
foreach ( $locations as $EM_Location ) {
|
143 |
+
$output .= $EM_Location->output($format);
|
144 |
+
}
|
145 |
+
//Add headers and footers to output
|
146 |
+
if( $format == get_option ( 'dbem_location_list_item_format' ) ){
|
147 |
+
$single_event_format_header = get_option ( 'dbem_location_list_item_format_header' );
|
148 |
+
$single_event_format_footer = get_option ( 'dbem_location_list_item_format_footer' );
|
149 |
+
$output = $single_event_format_header . $output . $single_event_format_footer;
|
150 |
+
}
|
151 |
+
//Pagination (if needed/requested)
|
152 |
+
if( !empty($args['pagination']) && !empty($limit) && $locations_count >= $limit ){
|
153 |
+
$output .= apply_filters('em_locations_output_pagination', self::get_pagination_links($args, $locations_count, 'search_locations', self::get_default_search()), '', $locations_count, $limit, $page);
|
154 |
+
}
|
155 |
+
} else {
|
156 |
+
$output = get_option ( 'dbem_no_locations_message' );
|
157 |
+
}
|
158 |
+
//FIXME check if reference is ok when restoring object, due to changes in php5 v 4
|
159 |
+
$EM_Location_old= $EM_Location;
|
160 |
+
return apply_filters('em_locations_output', $output, $locations, $args);
|
161 |
+
}
|
162 |
+
|
163 |
+
function delete( $args = array() ){
|
164 |
+
$locations = array();
|
165 |
+
if( !is_object(current($args)) ){
|
166 |
+
//we've been given an array or search arguments to find the relevant locations to delete
|
167 |
+
$locations = self::get($args);
|
168 |
+
}elseif( get_class(current($args)) == 'EM_Location' ){
|
169 |
+
//we're deleting an array of locations
|
170 |
+
$locations = $args;
|
171 |
+
}
|
172 |
+
$results = array();
|
173 |
+
foreach ( $locations as $EM_Location ){
|
174 |
+
$results[] = $EM_Location->delete();
|
175 |
+
}
|
176 |
+
return apply_filters('em_locations_delete', in_array(false, $results), $locations);
|
177 |
+
}
|
178 |
+
|
179 |
+
public static function get_post_search($args = array(), $filter = false, $request = array()){
|
180 |
+
$return = parent::get_post_search($args, $filter, $request);
|
181 |
+
//remove unwanted arguments or if not explicitly requested
|
182 |
+
if( empty($_REQUEST['scope']) && empty($request['scope']) && !empty($return['scope']) ){
|
183 |
+
unset($return['scope']);
|
184 |
+
}
|
185 |
+
return apply_filters('em_locations_get_post_search', $return);
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Builds an array of SQL query conditions based on regularly used arguments
|
190 |
+
* @param array $args
|
191 |
+
* @return array
|
192 |
+
*/
|
193 |
+
function build_sql_conditions( $args = array(), $count=false ){
|
194 |
+
self::$context = EM_POST_TYPE_LOCATION;
|
195 |
+
global $wpdb;
|
196 |
+
$events_table = EM_EVENTS_TABLE;
|
197 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
198 |
+
|
199 |
+
$conditions = parent::build_sql_conditions($args);
|
200 |
+
//search locations
|
201 |
+
if( !empty($args['search']) ){
|
202 |
+
$like_search = array($locations_table.'.post_content','location_name','location_address','location_town','location_postcode','location_state','location_region','location_country');
|
203 |
+
$conditions['search'] = "(".implode(" LIKE '%{$args['search']}%' OR ", $like_search). " LIKE '%{$args['search']}%')";
|
204 |
+
}
|
205 |
+
//eventful locations
|
206 |
+
if( true == $args['eventful'] ){
|
207 |
+
$conditions['eventful'] = "{$events_table}.event_id IS NOT NULL AND event_status=1";
|
208 |
+
}elseif( true == $args['eventless'] ){
|
209 |
+
$conditions['eventless'] = "{$events_table}.event_id IS NULL";
|
210 |
+
}
|
211 |
+
//owner lookup
|
212 |
+
if( !empty($args['owner']) && is_numeric($args['owner'])){
|
213 |
+
$conditions['owner'] = "location_owner=".$args['owner'];
|
214 |
+
}elseif( !empty($args['owner']) && $args['owner'] == 'me' && is
|