Version Description
- fixed Multilingual settings not saving default language setting if other than english
- fixed typo in performance optimization settings
- fixed warning of undefined ID on archive pages when enqueuing scripts
- fixed special characters being converted to entities in non-html emails
- fixed typo in options for category/location event list placeholders
- corrected Slovak translation, thanks to Julius Pastierik
- added British translation, thanks to Jeff Cole
- added some code to booking form js to prevent JS conflicts with JetPack's reCaptcha
- added base64 encoding/decoding to em_notice cookies for improved compatibility
- fixed potential php warning in EM_Tickets class
- event spaces show as blank rather than 0 on input form (aesthetic change in line with the field help text)
- added alphabetical ordering to category and countries ddms in search form and admin event categories ddm
- fixed XSS vulnerabilities - http://em.cm/xss
- fixed em_is_category_page() and added check for specific categories (like is_tax() second parameter), added em_is_tag_page() with checks for specific tags
- added #_EVENTPRICERANGEALL and fixed #_EVENTPRICERANGE showing if booking closed but unavailable tickets set to true (docs need revising)
- improved speed of event shortcode by adding global event object
- added ordering of locations by name and other location table fields in event queries such as events_list shortcode
- added some missing classes to event form 'when' section
Download this release
Release Info
Developer | netweblogic |
Plugin | Events Manager |
Version | 5.3.4 |
Comparing to | |
See all releases |
Code changes from version 3.0.98 to 5.3.4
- 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 +517 -287
- admin/em-categories.php +0 -177
- admin/em-docs.php +335 -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 +54 -0
- admin/em-ms-options.php +219 -0
- admin/em-options.php +1904 -443
- admin/em-people.php +0 -192
- buddypress/bp-em-activity.php +128 -0
- buddypress/bp-em-core.php +332 -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 +706 -378
- classes/em-bookings-table.php +641 -0
- classes/em-bookings.php +647 -487
- classes/em-calendar.php +381 -366
- classes/em-categories-taxonomy.php +115 -0
- classes/em-categories.php +320 -156
- classes/em-category-taxonomy.php +135 -0
- classes/em-category.php +236 -151
- classes/em-event-post-admin.php +377 -0
- classes/em-event-post.php +289 -0
- classes/em-event-posts-admin.php +280 -0
- classes/em-event.php +2198 -1005
- classes/em-events.php +396 -253
- classes/em-location-post-admin.php +134 -0
- classes/em-location-post.php +69 -0
- classes/em-location-posts-admin.php +84 -0
- classes/em-location.php +802 -306
- classes/em-locations.php +309 -212
- classes/em-mailer.php +133 -79
- classes/em-map.php +0 -60
- classes/em-notices.php +238 -0
- classes/em-object.php +814 -485
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'), 'activate_plugins', "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'), 'activate_plugins', "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
|
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.','em-pro'),'<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>','em-pro'),'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 <strong>Events Manager</strong> events 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' ), 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,518 @@
|
|
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 |
-
|
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 |
-
|
117 |
-
|
118 |
-
|
119 |
-
<p
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
<?php echo $
|
124 |
-
<?php
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
<h2><?php _e('
|
139 |
-
<?php
|
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 |
+
if( !empty($_REQUEST['_wpnonce']) ){ $_REQUEST['_wpnonce'] = $_GET['_wpnonce'] = $_POST['_wpnonce'] = esc_attr($_REQUEST['_wpnonce']); } //XSS fix just in case here too
|
33 |
+
if( !empty($_REQUEST['action']) && substr($_REQUEST['action'],0,7) != 'booking' ){ //actions not starting with booking_
|
34 |
+
do_action('em_bookings_'.$_REQUEST['action']);
|
35 |
+
}elseif( !empty($_REQUEST['booking_id']) ){
|
36 |
+
em_bookings_single();
|
37 |
+
}elseif( !empty($_REQUEST['person_id']) ){
|
38 |
+
em_bookings_person();
|
39 |
+
}elseif( !empty($_REQUEST['event_id']) ){
|
40 |
+
em_bookings_event();
|
41 |
+
}elseif( !empty($_REQUEST['ticket_id']) ){
|
42 |
+
em_bookings_ticket();
|
43 |
+
}else{
|
44 |
+
em_bookings_dashboard();
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Generates the bookings dashboard, showing information on all events
|
50 |
+
*/
|
51 |
+
function em_bookings_dashboard(){
|
52 |
+
global $EM_Notices;
|
53 |
+
?>
|
54 |
+
<div class='wrap em-bookings-dashboard'>
|
55 |
+
<?php if( is_admin() ): ?>
|
56 |
+
<div id='icon-users' class='icon32'>
|
57 |
+
<br/>
|
58 |
+
</div>
|
59 |
+
<h2>
|
60 |
+
<?php _e('Event Bookings Dashboard', 'dbem'); ?>
|
61 |
+
</h2>
|
62 |
+
<?php else: echo $EM_Notices; ?>
|
63 |
+
<?php endif; ?>
|
64 |
+
<div class="em-bookings-recent">
|
65 |
+
<?php if( is_admin() ): ?>
|
66 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
67 |
+
<?php endif; ?>
|
68 |
+
<h2><?php _e('Recent Bookings','dbem'); ?></h2>
|
69 |
+
<?php
|
70 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
71 |
+
$EM_Bookings_Table->status = get_option('dbem_bookings_approval') ? 'needs-attention':'confirmed';
|
72 |
+
$EM_Bookings_Table->output();
|
73 |
+
?>
|
74 |
+
</div>
|
75 |
+
<br class="clear" />
|
76 |
+
<div class="em-bookings-events">
|
77 |
+
<?php if( is_admin() ): ?>
|
78 |
+
<div class="icon32" id="events"><br></div>
|
79 |
+
<?php endif; ?>
|
80 |
+
<h2><?php _e('Events With Bookings Enabled','dbem'); ?></h2>
|
81 |
+
<?php em_bookings_events_table(); ?>
|
82 |
+
<?php do_action('em_bookings_dashboard'); ?>
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
<?php
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Shows all booking data for a single event
|
90 |
+
*/
|
91 |
+
function em_bookings_event(){
|
92 |
+
global $EM_Event,$EM_Person,$EM_Notices;
|
93 |
+
//check that user can access this page
|
94 |
+
if( is_object($EM_Event) && !$EM_Event->can_manage('manage_bookings','manage_others_bookings') ){
|
95 |
+
?>
|
96 |
+
<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>
|
97 |
+
<?php
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
$localised_start_date = date_i18n('D d M Y', $EM_Event->start);
|
101 |
+
$localised_end_date = date_i18n('D d M Y', $EM_Event->end);
|
102 |
+
?>
|
103 |
+
<div class='wrap'>
|
104 |
+
<div id='icon-users' class='icon32'>
|
105 |
+
<br/>
|
106 |
+
</div>
|
107 |
+
<h2>
|
108 |
+
<?php echo sprintf(__('Manage %s Bookings', 'dbem'), "'{$EM_Event->event_name}'"); ?>
|
109 |
+
<a href="<?php echo $EM_Event->get_permalink(); ?>" class="button add-new-h2"><?php echo sprintf(__('View %s','dbem'), __('Event', 'dbem')) ?></a>
|
110 |
+
<a href="<?php echo $EM_Event->get_edit_url(); ?>" class="button add-new-h2"><?php echo sprintf(__('Edit %s','dbem'), __('Event', 'dbem')) ?></a>
|
111 |
+
<?php if( locate_template('plugins/events-manager/templates/csv-event-bookings.php', false) ): ?>
|
112 |
+
<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>
|
113 |
+
<?php endif; ?>
|
114 |
+
<?php do_action('em_admin_event_booking_options_buttons'); ?>
|
115 |
+
</h2>
|
116 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
117 |
+
<div>
|
118 |
+
<p><strong><?php _e('Event Name','dbem'); ?></strong> : <?php echo ($EM_Event->event_name); ?></p>
|
119 |
+
<p>
|
120 |
+
<strong><?php _e('Availability','dbem'); ?></strong> :
|
121 |
+
<?php echo $EM_Event->get_bookings()->get_booked_spaces() . '/'. $EM_Event->get_spaces() ." ". __('Spaces confirmed','dbem'); ?>
|
122 |
+
<?php if( get_option('dbem_bookings_approval_reserved') ): ?>
|
123 |
+
, <?php echo $EM_Event->get_bookings()->get_available_spaces() . '/'. $EM_Event->get_spaces() ." ". __('Available spaces','dbem'); ?>
|
124 |
+
<?php endif; ?>
|
125 |
+
</p>
|
126 |
+
<p>
|
127 |
+
<strong><?php _e('Date','dbem'); ?></strong> :
|
128 |
+
<?php echo $localised_start_date; ?>
|
129 |
+
<?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
|
130 |
+
<?php echo substr ( $EM_Event->event_start_time, 0, 5 ) . " - " . substr ( $EM_Event->event_end_time, 0, 5 ); ?>
|
131 |
+
</p>
|
132 |
+
<p>
|
133 |
+
<strong><?php _e('Location','dbem'); ?></strong> :
|
134 |
+
<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>
|
135 |
+
</p>
|
136 |
+
</div>
|
137 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
138 |
+
<h2><?php _e('Bookings','dbem'); ?></h2>
|
139 |
+
<?php
|
140 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
141 |
+
$EM_Bookings_Table->status = 'all';
|
142 |
+
$EM_Bookings_Table->output();
|
143 |
+
?>
|
144 |
+
<?php do_action('em_bookings_event_footer', $EM_Event); ?>
|
145 |
+
</div>
|
146 |
+
<?php
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Shows a ticket view
|
151 |
+
*/
|
152 |
+
function em_bookings_ticket(){
|
153 |
+
global $EM_Ticket,$EM_Notices;
|
154 |
+
$EM_Event = $EM_Ticket->get_event();
|
155 |
+
//check that user can access this page
|
156 |
+
if( is_object($EM_Ticket) && !$EM_Ticket->can_manage() ){
|
157 |
+
?>
|
158 |
+
<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>
|
159 |
+
<?php
|
160 |
+
return false;
|
161 |
+
}
|
162 |
+
?>
|
163 |
+
<div class='wrap'>
|
164 |
+
<div id='icon-users' class='icon32'>
|
165 |
+
<br/>
|
166 |
+
</div>
|
167 |
+
<h2>
|
168 |
+
<?php echo sprintf(__('Ticket for %s', 'dbem'), "'{$EM_Event->name}'"); ?>
|
169 |
+
<a href="<?php echo $EM_Event->get_edit_url(); ?>" class="button add-new-h2"><?php _e('View/Edit Event','dbem') ?></a>
|
170 |
+
<a href="<?php echo $EM_Event->get_bookings_url(); ?>" class="button add-new-h2"><?php _e('View Event Bookings','dbem') ?></a>
|
171 |
+
</h2>
|
172 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
173 |
+
<div>
|
174 |
+
<table>
|
175 |
+
<tr><td><?php echo __('Name','dbem'); ?></td><td></td><td><?php echo $EM_Ticket->ticket_name; ?></td></tr>
|
176 |
+
<tr><td><?php echo __('Description','dbem'); ?> </td><td></td><td><?php echo ($EM_Ticket->ticket_description) ? $EM_Ticket->ticket_description : '-'; ?></td></tr>
|
177 |
+
<tr><td><?php echo __('Price','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_price) ? $EM_Ticket->ticket_price : '-'; ?></td></tr>
|
178 |
+
<tr><td><?php echo __('Spaces','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_spaces) ? $EM_Ticket->ticket_spaces : '-'; ?></td></tr>
|
179 |
+
<tr><td><?php echo __('Min','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_min) ? $EM_Ticket->ticket_min : '-'; ?></td></tr>
|
180 |
+
<tr><td><?php echo __('Max','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_max) ? $EM_Ticket->ticket_max : '-'; ?></td></tr>
|
181 |
+
<tr><td><?php echo __('Start','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_start) ? $EM_Ticket->ticket_start : '-'; ?></td></tr>
|
182 |
+
<tr><td><?php echo __('End','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->ticket_end) ? $EM_Ticket->ticket_end : '-'; ?></td></tr>
|
183 |
+
<?php do_action('em_booking_admin_ticket_row', $EM_Ticket); ?>
|
184 |
+
</table>
|
185 |
+
</div>
|
186 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
187 |
+
<h2><?php _e('Bookings','dbem'); ?></h2>
|
188 |
+
<?php
|
189 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
190 |
+
$EM_Bookings_Table->status = get_option('dbem_bookings_approval') ? 'needs-attention':'confirmed';
|
191 |
+
$EM_Bookings_Table->output();
|
192 |
+
?>
|
193 |
+
<?php do_action('em_bookings_ticket_footer', $EM_Ticket); ?>
|
194 |
+
</div>
|
195 |
+
<?php
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Shows a single booking for a single person.
|
200 |
+
*/
|
201 |
+
function em_bookings_single(){
|
202 |
+
global $EM_Booking, $EM_Notices;
|
203 |
+
//check that user can access this page
|
204 |
+
if( is_object($EM_Booking) && !$EM_Booking->can_manage() ){
|
205 |
+
?>
|
206 |
+
<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>
|
207 |
+
<?php
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
?>
|
211 |
+
<div class='wrap' id="em-bookings-admin-booking">
|
212 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
213 |
+
<h2>
|
214 |
+
<?php _e('Edit Booking', 'dbem'); ?>
|
215 |
+
</h2>
|
216 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
217 |
+
<div id="poststuff" class="metabox-holder">
|
218 |
+
<div id="post-body">
|
219 |
+
<div id="post-body-content">
|
220 |
+
<div class="stuffbox">
|
221 |
+
<h3>
|
222 |
+
<?php _e ( 'Event Details', 'dbem' ); ?>
|
223 |
+
</h3>
|
224 |
+
<div class="inside">
|
225 |
+
<?php
|
226 |
+
$EM_Event = $EM_Booking->get_event();
|
227 |
+
$localised_start_date = date_i18n(get_option('dbem_date_format'), $EM_Event->start);
|
228 |
+
$localised_end_date = date_i18n(get_option('dbem_date_format'), $EM_Event->end);
|
229 |
+
?>
|
230 |
+
<table>
|
231 |
+
<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>
|
232 |
+
<tr>
|
233 |
+
<td><strong><?php _e('Date/Time','dbem'); ?> </strong></td>
|
234 |
+
<td>
|
235 |
+
<?php echo $localised_start_date; ?>
|
236 |
+
<?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
|
237 |
+
<?php echo substr ( $EM_Event->start_time, 0, 5 ) . " - " . substr ( $EM_Event->end_time, 0, 5 ); ?>
|
238 |
+
</td>
|
239 |
+
</tr>
|
240 |
+
</table>
|
241 |
+
<?php do_action('em_bookings_admin_booking_event', $EM_Event); ?>
|
242 |
+
</div>
|
243 |
+
</div>
|
244 |
+
<div class="stuffbox">
|
245 |
+
<h3>
|
246 |
+
<?php _e ( 'Personal Details', 'dbem' ); ?>
|
247 |
+
</h3>
|
248 |
+
<div class="inside">
|
249 |
+
<?php echo $EM_Booking->get_person()->display_summary(); ?>
|
250 |
+
<?php do_action('em_bookings_admin_booking_person', $EM_Booking); ?>
|
251 |
+
</div>
|
252 |
+
</div>
|
253 |
+
<div class="stuffbox">
|
254 |
+
<h3>
|
255 |
+
<?php _e ( 'Booking Details', 'dbem' ); ?>
|
256 |
+
</h3>
|
257 |
+
<div class="inside">
|
258 |
+
<?php
|
259 |
+
$EM_Event = $EM_Booking->get_event();
|
260 |
+
$localised_start_date = date_i18n(get_option('date_format'), $EM_Event->start);
|
261 |
+
$localised_end_date = date_i18n(get_option('date_format'), $EM_Event->end);
|
262 |
+
$shown_tickets = array();
|
263 |
+
?>
|
264 |
+
<div>
|
265 |
+
<form action="" method="post" class="em-booking-single-status-info">
|
266 |
+
<strong><?php _e('Status','dbem'); ?> : </strong>
|
267 |
+
<?php echo $EM_Booking->get_status(); ?>
|
268 |
+
<input type="button" class="em-booking-submit-status-modify" id="em-booking-submit-status-modify" value="<?php _e('Change', 'dbem'); ?>" />
|
269 |
+
<input type="submit" class="em-booking-resend-email" id="em-booking-resend-email" value="<?php _e('Resend Email', 'dbem'); ?>" />
|
270 |
+
<input type='hidden' name='action' value='booking_resend_email'/>
|
271 |
+
<input type='hidden' name='booking_id' value='<?php echo $EM_Booking->booking_id; ?>'/>
|
272 |
+
<input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
|
273 |
+
<input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_resend_email_'.$EM_Booking->booking_id); ?>'/>
|
274 |
+
</form>
|
275 |
+
<form action="" method="post" class="em-booking-single-status-edit">
|
276 |
+
<strong><?php _e('Status','dbem'); ?> : </strong>
|
277 |
+
<select name="booking_status">
|
278 |
+
<?php foreach($EM_Booking->status_array as $status => $status_name): ?>
|
279 |
+
<option value="<?php echo esc_attr($status); ?>" <?php if($status == $EM_Booking->booking_status){ echo 'selected="selected"'; } ?>><?php echo esc_html($status_name); ?></option>
|
280 |
+
<?php endforeach; ?>
|
281 |
+
</select>
|
282 |
+
<input type="checkbox" checked="checked" name="send_email" value="1" />
|
283 |
+
<?php _e('Send Email','dbem'); ?>
|
284 |
+
<input type="submit" class="em-booking-submit-status" id="em-booking-submit-status" value="<?php _e('Submit Changes', 'dbem'); ?>" />
|
285 |
+
<input type="button" class="em-booking-submit-status-cancel" id="em-booking-submit-status-cancel" value="<?php _e('Cancel', 'dbem'); ?>" />
|
286 |
+
<input type='hidden' name='action' value='booking_set_status'/>
|
287 |
+
<input type='hidden' name='booking_id' value='<?php echo $EM_Booking->booking_id; ?>'/>
|
288 |
+
<input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
|
289 |
+
<input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_set_status_'.$EM_Booking->booking_id); ?>'/>
|
290 |
+
<br /><em><?php _e('<strong>Notes:</strong> Ticket availability not taken into account when approving new bookings (i.e. you can overbook).','dbem'); ?></em>
|
291 |
+
</form>
|
292 |
+
</div>
|
293 |
+
<form action="" method="post" class="em-booking-form">
|
294 |
+
<table class="em-tickets-bookings-table" cellpadding="0" cellspacing="0">
|
295 |
+
<thead>
|
296 |
+
<tr>
|
297 |
+
<th><?php _e('Ticket Type','dbem'); ?></th>
|
298 |
+
<th><?php _e('Spaces','dbem'); ?></th>
|
299 |
+
<th><?php _e('Price','dbem'); ?></th>
|
300 |
+
</tr>
|
301 |
+
</thead>
|
302 |
+
<tbody>
|
303 |
+
<?php foreach($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking): ?>
|
304 |
+
<tr>
|
305 |
+
<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>
|
306 |
+
<td>
|
307 |
+
<span class="em-booking-single-info"><?php echo $EM_Ticket_Booking->get_spaces(); ?></span>
|
308 |
+
<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>
|
309 |
+
</td>
|
310 |
+
<td><?php echo $EM_Ticket_Booking->get_price(true,true); ?></td>
|
311 |
+
</tr>
|
312 |
+
<?php
|
313 |
+
$shown_tickets[] = $EM_Ticket_Booking->ticket_id;
|
314 |
+
do_action('em_bookings_admin_ticket_row', $EM_Ticket_Booking->get_ticket(), $EM_Booking);
|
315 |
+
?>
|
316 |
+
<?php endforeach; ?>
|
317 |
+
<?php if( count($shown_tickets) < count($EM_Event->get_bookings()->get_tickets()->tickets)): ?><tr>
|
318 |
+
<?php foreach($EM_Event->get_bookings()->get_tickets()->tickets as $EM_Ticket): ?>
|
319 |
+
<?php if( !in_array($EM_Ticket->ticket_id, $shown_tickets) ): ?>
|
320 |
+
<tr>
|
321 |
+
<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>
|
322 |
+
<td>
|
323 |
+
<span class="em-booking-single-info">0</span>
|
324 |
+
<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>
|
325 |
+
</td>
|
326 |
+
<td><?php echo em_get_currency_symbol() ?>0.00</td>
|
327 |
+
</tr>
|
328 |
+
<?php do_action('em_bookings_admin_ticket_row', $EM_Ticket, $EM_Booking); ?>
|
329 |
+
<?php endif; ?>
|
330 |
+
<?php endforeach; ?>
|
331 |
+
<?php endif; ?>
|
332 |
+
</tbody>
|
333 |
+
<tfoot>
|
334 |
+
<?php do_action('em_bookings_admin_ticket_totals_header'); ?>
|
335 |
+
<tr>
|
336 |
+
<th><?php _e('Total Price','dbem'); ?></th>
|
337 |
+
<th><?php echo sprintf(__('%d Spaces','dbem'), $EM_Booking->get_spaces()); ?></th>
|
338 |
+
<th><?php echo $EM_Booking->get_price(true, true); ?></th>
|
339 |
+
</tr>
|
340 |
+
<?php if( !get_option('dbem_bookings_tax_auto_add') && is_numeric(get_option('dbem_bookings_tax')) && get_option('dbem_bookings_tax') > 0 ): ?>
|
341 |
+
<tr>
|
342 |
+
<th><?php _e('Tax','dbem'); ?></th>
|
343 |
+
<th><?php echo get_option('dbem_bookings_tax') ?>%</th>
|
344 |
+
<th><?php echo em_get_currency_formatted($EM_Booking->get_price() * (get_option('dbem_bookings_tax')/100),2); ?></th>
|
345 |
+
</tr>
|
346 |
+
<tr>
|
347 |
+
<th><?php _e('Total Price (inc. tax)','dbem'); ?></th>
|
348 |
+
<th> </th>
|
349 |
+
<th><?php echo $EM_Booking->get_price(false, true, true); ?></th>
|
350 |
+
</tr>
|
351 |
+
<?php endif; ?>
|
352 |
+
<?php do_action('em_bookings_admin_ticket_totals_footer'); ?>
|
353 |
+
</tfoot>
|
354 |
+
</table>
|
355 |
+
<table class="em-form-fields" cellspacing="0" cellpadding="0">
|
356 |
+
<?php if( !has_action('em_bookings_single_custom') ): //default behaviour ?>
|
357 |
+
<tr>
|
358 |
+
<th><?php _e('Comment','dbem'); ?></th>
|
359 |
+
<td>
|
360 |
+
<span class="em-booking-single-info"><?php echo $EM_Booking->booking_comment; ?></span>
|
361 |
+
<div class="em-booking-single-edit"><textarea name="booking_comment"><?php echo $EM_Booking->booking_comment; ?></textarea></div>
|
362 |
+
</td>
|
363 |
+
</tr>
|
364 |
+
<?php else: do_action('em_bookings_single_custom',$EM_Booking); //do your own thing, e.g. pro ?>
|
365 |
+
<?php endif; ?>
|
366 |
+
</table>
|
367 |
+
<p class="em-booking-single-info">
|
368 |
+
<input type="button" class="em-booking-submit-modify" id="em-booking-submit-modify" value="<?php _e('Modify Booking', 'dbem'); ?>" />
|
369 |
+
</p>
|
370 |
+
<p class="em-booking-single-edit">
|
371 |
+
<em><?php _e('<strong>Notes:</strong> Ticket availability not taken into account (i.e. you can overbook). Emails are not resent automatically.','dbem'); ?></em>
|
372 |
+
<br /><br />
|
373 |
+
<input type="submit" class="em-booking-submit" id="em-booking-submit" value="<?php _e('Submit Changes', 'dbem'); ?>" />
|
374 |
+
<input type="button" class="em-booking-submit-cancel" id="em-booking-submit-cancel" value="<?php _e('Cancel', 'dbem'); ?>" />
|
375 |
+
<input type='hidden' name='action' value='booking_save'/>
|
376 |
+
<input type='hidden' name='booking_id' value='<?php echo $EM_Booking->booking_id; ?>'/>
|
377 |
+
<input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
|
378 |
+
<input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_save_'.$EM_Booking->booking_id); ?>'/>
|
379 |
+
</p>
|
380 |
+
</form>
|
381 |
+
<script type="text/javascript">
|
382 |
+
jQuery(document).ready( function($){
|
383 |
+
$('#em-booking-submit-modify').click(function(){
|
384 |
+
$('.em-booking-single-info').hide();
|
385 |
+
$('.em-booking-single-edit').show();
|
386 |
+
});
|
387 |
+
$('#em-booking-submit-cancel').click(function(){
|
388 |
+
$('.em-booking-single-info').show();
|
389 |
+
$('.em-booking-single-edit').hide();
|
390 |
+
});
|
391 |
+
$('.em-booking-single-info').show();
|
392 |
+
$('.em-booking-single-edit').hide();
|
393 |
+
|
394 |
+
$('#em-booking-submit-status-modify').click(function(){
|
395 |
+
$('.em-booking-single-status-info').hide();
|
396 |
+
$('.em-booking-single-status-edit').show();
|
397 |
+
});
|
398 |
+
$('#em-booking-submit-status-cancel').click(function(){
|
399 |
+
$('.em-booking-single-status-info').show();
|
400 |
+
$('.em-booking-single-status-edit').hide();
|
401 |
+
});
|
402 |
+
$('.em-booking-single-status-info').show();
|
403 |
+
$('.em-booking-single-status-edit').hide();
|
404 |
+
});
|
405 |
+
</script>
|
406 |
+
</div>
|
407 |
+
</div>
|
408 |
+
<div id="em-booking-notes" class="stuffbox">
|
409 |
+
<h3>
|
410 |
+
<?php _e ( 'Booking Notes', 'dbem' ); ?>
|
411 |
+
</h3>
|
412 |
+
<div class="inside">
|
413 |
+
<p><?php _e('You can add private notes below for internal reference that only event managers will see.','dbem'); ?></p>
|
414 |
+
<?php foreach( $EM_Booking->get_notes() as $note ):
|
415 |
+
$user = new EM_Person($note['author']);
|
416 |
+
?>
|
417 |
+
<div>
|
418 |
+
<?php echo date(get_option('date_format'), $note['timestamp']) .' - '. $user->get_name(); ?> <?php _e('wrote','dbem'); ?>:
|
419 |
+
<p style="background:#efefef; padding:5px;"><?php echo nl2br($note['note']); ?></p>
|
420 |
+
</div>
|
421 |
+
<?php endforeach; ?>
|
422 |
+
<form method="post" action="" style="padding:5px;">
|
423 |
+
<textarea class="widefat" rows="5" name="booking_note"></textarea>
|
424 |
+
<input type="hidden" name="action" value="bookings_add_note" />
|
425 |
+
<input type="submit" value="Add Note" />
|
426 |
+
</form>
|
427 |
+
</div>
|
428 |
+
</div>
|
429 |
+
<?php do_action('em_bookings_single_metabox_footer', $EM_Booking); ?>
|
430 |
+
</div>
|
431 |
+
</div>
|
432 |
+
</div>
|
433 |
+
<br style="clear:both;" />
|
434 |
+
<?php do_action('em_bookings_single_footer', $EM_Booking); ?>
|
435 |
+
</div>
|
436 |
+
<?php
|
437 |
+
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Shows all bookings made by one person.
|
442 |
+
*/
|
443 |
+
function em_bookings_person(){
|
444 |
+
global $EM_Person, $EM_Notices;
|
445 |
+
$EM_Person->get_bookings();
|
446 |
+
$has_booking = false;
|
447 |
+
foreach($EM_Person->get_bookings() as $EM_Booking){
|
448 |
+
if($EM_Booking->can_manage('manage_bookings','manage_others_bookings')){
|
449 |
+
$has_booking = true;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
if( !$has_booking && !current_user_can('manage_others_bookings') ){
|
453 |
+
?>
|
454 |
+
<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>
|
455 |
+
<?php
|
456 |
+
return false;
|
457 |
+
}
|
458 |
+
?>
|
459 |
+
<div class='wrap'>
|
460 |
+
<div id='icon-users' class='icon32'>
|
461 |
+
<br/>
|
462 |
+
</div>
|
463 |
+
<h2>
|
464 |
+
<?php _e('Manage Person\'s Booking', 'dbem'); ?>
|
465 |
+
<?php if( current_user_can('edit_users') ) : ?>
|
466 |
+
<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>
|
467 |
+
<?php endif; ?>
|
468 |
+
<?php if( current_user_can('delete_users') ) : ?>
|
469 |
+
<a href="<?php echo wp_nonce_url( "users.php?action=delete&user=$EM_Person->ID", 'bulk-users' ); ?>" class="button add-new-h2"><?php _e('Delete User','dbem') ?></a>
|
470 |
+
<?php endif; ?>
|
471 |
+
</h2>
|
472 |
+
<?php if( !is_admin() ) echo $EM_Notices; ?>
|
473 |
+
<?php do_action('em_bookings_person_header'); ?>
|
474 |
+
<div id="poststuff" class="metabox-holder has-right-sidebar">
|
475 |
+
<div id="post-body">
|
476 |
+
<div id="post-body-content">
|
477 |
+
<div id="event_name" class="stuffbox">
|
478 |
+
<h3>
|
479 |
+
<?php _e ( 'Personal Details', 'dbem' ); ?>
|
480 |
+
</h3>
|
481 |
+
<div class="inside">
|
482 |
+
<?php echo $EM_Person->display_summary(); ?>
|
483 |
+
</div>
|
484 |
+
</div>
|
485 |
+
</div>
|
486 |
+
</div>
|
487 |
+
</div>
|
488 |
+
<br style="clear:both;" />
|
489 |
+
<?php do_action('em_bookings_person_body_1'); ?>
|
490 |
+
<div class="icon32" id="icon-bookings"><br></div>
|
491 |
+
<h2><?php _e('Past And Present Bookings','dbem'); ?></h2>
|
492 |
+
<?php
|
493 |
+
$EM_Bookings_Table = new EM_Bookings_Table();
|
494 |
+
$EM_Bookings_Table->status = 'all';
|
495 |
+
$EM_Bookings_Table->scope = 'all';
|
496 |
+
$EM_Bookings_Table->output();
|
497 |
+
?>
|
498 |
+
<?php do_action('em_bookings_person_footer', $EM_Person); ?>
|
499 |
+
</div>
|
500 |
+
<?php
|
501 |
+
}
|
502 |
+
|
503 |
+
function em_printable_booking_report() {
|
504 |
+
global $EM_Event;
|
505 |
+
//check that user can access this page
|
506 |
+
if( isset($_GET['page']) && $_GET['page']=='events-manager-bookings' && isset($_GET['action']) && $_GET['action'] == 'bookings_report' && is_object($EM_Event)){
|
507 |
+
if( is_object($EM_Event) && !$EM_Event->can_manage('edit_events','edit_others_events') ){
|
508 |
+
?>
|
509 |
+
<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>
|
510 |
+
<?php
|
511 |
+
return false;
|
512 |
+
}
|
513 |
+
em_locate_template('templates/bookings-event-printable.php', true);
|
514 |
+
die();
|
515 |
+
}
|
516 |
+
}
|
517 |
+
add_action('admin_init', 'em_printable_booking_report');
|
518 |
Â
?>
|
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,336 @@
|
|
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 on 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/categories-and-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 |
+
'#_CONTACTPHONE' => array( 'desc' => 'Phone number of the contact person for this event. Can be set in the user profile page.' ),
|
150 |
+
'#_CONTACTAVATAR' => array( 'desc' => 'Contact person\'s avatar.' ),
|
151 |
+
'#_CONTACTPROFILELINK' => array( 'desc' => 'Contact person\'s "Profile" link. Only works with BuddyPress enabled.' ),
|
152 |
+
'#_CONTACTPROFILEURL' => array( 'desc' => 'Contact person\'s profile url. Only works with BuddyPress enabled.' ),
|
153 |
+
'#_CONTACTID' => array( 'desc' => 'Contact person\'s WordPress user ID.'),
|
154 |
+
'#_CONTACTMETA' => array( 'desc' => 'Display any user meta of a WordPress account by including the meta key, e.g. #_CONTACTMETA{dbem_phone}'),
|
155 |
+
)
|
156 |
+
),
|
157 |
+
'iCal/Calendar' => array(
|
158 |
+
'placeholders' => array(
|
159 |
+
'#_EVENTICALURL' => array( 'desc' => 'Displays the URL of the event ical feed (ics file format).' ),
|
160 |
+
'#_EVENTICALLINK' => array( 'desc' => 'Displays an html link to the event ical feed (ics file format).' ),
|
161 |
+
'#_EVENTGCALURL' => array( 'desc' => 'Displays URL which would take the user to Google Calendar and pre-fill their add new event form.' ),
|
162 |
+
'#_EVENTGCALLINK' => array( 'desc' => 'Displays a button which would take the user to Google Calendar and pre-fill their add new event form.' )
|
163 |
+
)
|
164 |
+
),
|
165 |
+
),
|
166 |
+
'categories' => array(
|
167 |
+
'Category Details' => array(
|
168 |
+
'desc' => 'You can use these when displaying categories or for showing the first available category in an event format.',
|
169 |
+
'placeholders' => array(
|
170 |
+
'#_CATEGORYNAME' => array( 'desc' => 'Shows the category name.' ),
|
171 |
+
'#_CATEGORYID' => array( 'desc' => 'Shows the category ID.' ),
|
172 |
+
'#_CATEGORYSLUG' => array( 'desc' => 'Shows the category slug.' ),
|
173 |
+
'#_CATEGORYIMAGE' => array( 'desc' => 'Shows the category image, if available.' ),
|
174 |
+
'#_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>' ),
|
175 |
+
'#_CATEGORYIMAGEURL' => array( 'desc' => 'Shows the category image url, if available.' ),
|
176 |
+
'#_CATEGORYNOTES' => array( 'desc' => 'Shows the location description.' )
|
177 |
+
)
|
178 |
+
),
|
179 |
+
'Related Events' => array(
|
180 |
+
'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.',
|
181 |
+
'placeholders' => array(
|
182 |
+
'#_CATEGORYPASTEVENTS' => array( 'desc' => 'Will show a list of all past events at this category.' ),
|
183 |
+
'#_CATEGORYNEXTEVENTS' => array( 'desc' => 'Will show a list of all future events at this category.' ),
|
184 |
+
'#_CATEGORYALLEVENTS' => array( 'desc' => 'Will show a list of all events at this category.' )
|
185 |
+
)
|
186 |
+
)
|
187 |
+
),
|
188 |
+
'locations' => array(
|
189 |
+
'Location Details' => array(
|
190 |
+
'desc' => '',
|
191 |
+
'placeholders' => array(
|
192 |
+
'#_LOCATIONID' => array( 'desc' => 'Shows the event ID number in the wp_em_locations table.' ),
|
193 |
+
'#_LOCATIONPOSTID' => array( 'desc' => 'Shows the location corresponding Post ID in the wp_posts table.' ),
|
194 |
+
'#_LOCATIONNAME' => array( 'desc' => 'Displays the location name.' ),
|
195 |
+
'#_LOCATIONADDRESS' => array( 'desc' => 'Displays the address.' ),
|
196 |
+
'#_LOCATIONTOWN' => array( 'desc' => 'Displays the town.' ),
|
197 |
+
'#_LOCATIONSTATE' => array( 'desc' => 'Displays the state/county.' ),
|
198 |
+
'#_LOCATIONPOSTCODE' => array( 'desc' => 'Displays the postcode.' ),
|
199 |
+
'#_LOCATIONREGION' => array( 'desc' => 'Displays the region.' ),
|
200 |
+
'#_LOCATIONCOUNTRY' => array( 'desc' => 'Displays the country.' ),
|
201 |
+
'#_LOCATIONLONGITUDE' => array( 'desc' => 'Displays the longitude, used for locating in Google Maps.' ),
|
202 |
+
'#_LOCATIONLATITUDE' => array( 'desc' => 'Displays the latitude, used for locating in Google Maps.' ),
|
203 |
+
'#_LOCATIONMAP' => array( 'desc' => 'Displays a google map showing where the event is located (Will not show if maps are disabled in the settings page)' ),
|
204 |
+
'#_LOCATIONNOTES' => array( 'desc' => 'Shows the location description.' ),
|
205 |
+
'#_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).' ),
|
206 |
+
'#_LOCATIONIMAGE' => array( 'desc' => 'Shows the location image.' ),
|
207 |
+
'#_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>' ),
|
208 |
+
'#_LOCATIONIMAGEURL' => array( 'desc' => 'Shows the location image url, if available.' ),
|
209 |
+
'#_LOCATIONFULLLINE' => array( 'desc' => 'Shows a comma-seperated line of location information, ommitting blanks (format of address, town, state, postcode, region' ),
|
210 |
+
'#_LOCATIONFULLBR' => array( 'desc' => 'Shows a line-break (br tag) seperated location information, ommitting blanks (format of address, town, state, postcode, region' ),
|
211 |
+
)
|
212 |
+
),
|
213 |
+
'Custom Attributes' => array(
|
214 |
+
'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/categories-and-attributes/">our online documentation</a> for more info on attributes.',
|
215 |
+
'placeholders' => array(
|
216 |
+
'#_LATT{key}' => array('desc'=> 'This key will appear as an option when adding attributes to your location.'),
|
217 |
+
'#_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.'),
|
218 |
+
'#_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.'),
|
219 |
+
)
|
220 |
+
),
|
221 |
+
'Links' => array(
|
222 |
+
'placeholders' => array(
|
223 |
+
'#_LOCATIONURL' => array( 'desc' => 'Simply prints the location URL. You can use this placeholder to build your own customised links.' ),
|
224 |
+
'#_LOCATIONLINK' => array( 'desc' => 'Displays the location name with a link to the location page.' ),
|
225 |
+
'#_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.' ),
|
226 |
+
'#_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.' )
|
227 |
+
)
|
228 |
+
),
|
229 |
+
'Related Events' => array(
|
230 |
+
'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.',
|
231 |
+
'placeholders' => array(
|
232 |
+
'#_LOCATIONPASTEVENTS' => array( 'desc' => 'Will show a list of all past events at this location.' ),
|
233 |
+
'#_LOCATIONNEXTEVENTS' => array( 'desc' => 'Will show a list of all future events at this location.' ),
|
234 |
+
'#_LOCATIONALLEVENTS' => array( 'desc' => 'Will show a list of all events at this location.' ),
|
235 |
+
'#_LOCATIONNEXTEVENT' => array( 'desc' => 'Will show a link to the next event at this location, or the no events message.' ),
|
236 |
+
)
|
237 |
+
),
|
238 |
+
),
|
239 |
+
'bookings' => array(
|
240 |
+
'Individual Booking Information' => array(
|
241 |
+
'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.',
|
242 |
+
'placeholders' => array(
|
243 |
+
'#_BOOKINGID' => array( 'desc' => 'The unique ID of this booking, useful if you are making your own customizations to this plugin.' ),
|
244 |
+
'#_BOOKINGNAME' => array( 'desc' => 'Name of person who made the booking.' ),
|
245 |
+
'#_BOOKINGEMAIL' => array( 'desc' => 'Email of person who made the booking.' ),
|
246 |
+
'#_BOOKINGPHONE' => array( 'desc' => 'Phone number of person who made the booking.' ),
|
247 |
+
'#_BOOKINGSPACES' => array( 'desc' => 'Number of spaces the person has booked.' ),
|
248 |
+
'#_BOOKINGCOMMENT' => array( 'desc' => 'Any specific comments made by the person who made the booking.' ),
|
249 |
+
'#_BOOKINGTICKETNAME' => array( 'desc' => 'Name of the ticket booked. Useful in single ticket mode, if multiple tickets are booked a random ticket is used.' ),
|
250 |
+
'#_BOOKINGTICKETDESCRIPTION' => array( 'desc' => 'Description of the ticket booked. Useful in single ticket mode, if multiple tickets are booked a random ticket is used.' ),
|
251 |
+
'#_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.' ),
|
252 |
+
'#_BOOKINGTICKETS' => array( 'desc' => 'A list of booked tickets. You can modify this by using template files and modifying templates/emails/bookingtickets.php' ),
|
253 |
+
'#_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/') ),
|
254 |
+
'#_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/') ),
|
255 |
+
'#_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/') ),
|
256 |
+
'#_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!
|
257 |
+
)
|
258 |
+
),
|
259 |
+
'Pricing Information' => array(
|
260 |
+
'desc' => '',
|
261 |
+
'placeholders' => array(
|
262 |
+
'#_BOOKINGPRICE' => array( 'desc' => 'Displays booking total price (tax inclusion depends on your booking settings).' ),
|
263 |
+
'#_BOOKINGPRICETAX' => array( 'desc' => 'Displays booking total tax.' ),
|
264 |
+
'#_BOOKINGPRICEWITHOUTTAX' => array( 'desc' => 'Displays booking total without tax.' ),
|
265 |
+
'#_BOOKINGPRICEWITHTAX' => array( 'desc' => 'Displays booking total with tax.' ),
|
266 |
+
)
|
267 |
+
),
|
268 |
+
'Ticket Information' => array(
|
269 |
+
'desc' => '',
|
270 |
+
'placeholders' => array(
|
271 |
+
'#_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)' ),
|
272 |
+
'#_BOOKINGTICKETDESCRIPTION' => array( 'desc' => 'Shows the description of the first ticket booked (useful in single ticket mode/events).' ),
|
273 |
+
'#_BOOKINGTICKETPRICE' => array( 'desc' => 'Shows the price of the first ticket booked, tax inclusion depending on your booking settings (useful in single ticket mode/events).' ),
|
274 |
+
'#_BOOKINGTICKETTAX' => array( 'desc' => 'Shows the tax of the first ticket booked (useful in single ticket mode/events).' ),
|
275 |
+
'#_BOOKINGTICKETPRICEWITHTAX' => array( 'desc' => 'Shows the price including tax of the first ticket booked (useful in single ticket mode/events).' ),
|
276 |
+
'#_BOOKINGTICKETPRICEWITHOUTTAX' => array( 'desc' => 'Shows the price excluding tax of the first ticket booked (useful in single ticket mode/events).' ),
|
277 |
+
)
|
278 |
+
),
|
279 |
+
'Links' => array(
|
280 |
+
'desc' => 'People are able to manage their bookings. Below are some placeholder which automatically provides correctly formatted urls',
|
281 |
+
'placeholders' => array(
|
282 |
+
'#_BOOKINGLISTURL' => array( 'desc' => 'URL to page showing that users booked events.' )
|
283 |
+
)
|
284 |
+
),
|
285 |
+
'Gateway-Specific Information' => array(
|
286 |
+
'desc' => 'Information pertaining to speicifc gateways. '. sprintf('Requires <a href="%s">Events Manager Pro</a>','http://wp-events-plugin.com/features/'),
|
287 |
+
'placeholders' => array(
|
288 |
+
'#_BOOKINGTXNID' => array( 'desc' => '<em>Online Payments Only</em> - Prints the transaction ID of this booking if available.' )
|
289 |
+
)
|
290 |
+
),
|
291 |
+
'Coupon Information' => array(
|
292 |
+
'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/'),
|
293 |
+
'placeholders' => array(
|
294 |
+
'#_BOOKINGCOUPON' => array('desc' => 'Displays the coupon code followed by the amount/percentage discounted.'),
|
295 |
+
'#_BOOKINGCOUPONCODE' => array('desc' => 'Displays the coupon code used.'),
|
296 |
+
'#_BOOKINGCOUPONNAME' => array('desc' => 'Displays the name given to this coupon.'),
|
297 |
+
'#_BOOKINGCOUPONDISCOUNT' => array('desc' => 'Displays amount/percentage discounted (e.g. 25% Off).'),
|
298 |
+
'#_BOOKINGCOUPONDESCRIPTION' => array('desc' => 'Displays the coupon description.'),
|
299 |
+
)
|
300 |
+
),
|
301 |
+
),
|
302 |
+
),
|
303 |
+
//TODO add capabilites explanations
|
304 |
+
'capabilities' => array()
|
305 |
+
);
|
306 |
+
}
|
307 |
+
}
|
308 |
+
add_action('init', 'em_docs_init');
|
309 |
+
|
310 |
+
function em_docs_placeholders($atts){
|
311 |
+
ob_start();
|
312 |
+
?>
|
313 |
+
<div class="em-docs">
|
314 |
+
<?php
|
315 |
+
global $EM_Documentation;
|
316 |
+
$type = $atts['type'];
|
317 |
+
$data = $EM_Documentation['placeholders'][$type];
|
318 |
+
foreach($data as $sectionTitle => $details) : ?>
|
319 |
+
<div>
|
320 |
+
<h3><?php echo $sectionTitle; ?></h3>
|
321 |
+
<?php if( !empty($details['desc']) ): ?>
|
322 |
+
<p><?php echo $details['desc']; ?></p>
|
323 |
+
<?php endif; ?>
|
324 |
+
<dl>
|
325 |
+
<?php foreach($details['placeholders'] as $placeholder => $desc ): ?>
|
326 |
+
<dt><b><?php echo $placeholder; ?></b></dt>
|
327 |
+
<dd><?php echo $desc['desc']; ?></dd>
|
328 |
+
<?php endforeach; ?>
|
329 |
+
</dl>
|
330 |
+
</div>
|
331 |
+
<?php endforeach; ?>
|
332 |
+
</div>
|
333 |
+
<?php
|
334 |
+
return ob_get_clean();
|
335 |
+
}
|
336 |
Â
?>
|
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,54 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
EM_Object::ms_global_switch();
|
10 |
+
//Take actions
|
11 |
+
if( !empty($_REQUEST['action']) && ($_REQUEST['action'] == "edit" || $_REQUEST['action'] == "location_save")) {
|
12 |
+
em_admin_location();
|
13 |
+
} else {
|
14 |
+
// no action, just a locations list
|
15 |
+
em_admin_locations();
|
16 |
+
}
|
17 |
+
EM_Object::ms_global_switch_back();
|
18 |
+
}
|
19 |
+
|
20 |
+
function em_admin_locations($message='', $fill_fields = false) {
|
21 |
+
global $current_site;
|
22 |
+
?>
|
23 |
+
<div class='wrap'>
|
24 |
+
<div id='icon-edit' class='icon32'>
|
25 |
+
<br/>
|
26 |
+
</div>
|
27 |
+
<h2>
|
28 |
+
<?php _e('Locations', 'dbem'); ?>
|
29 |
+
</h2>
|
30 |
+
<?php em_locations_admin(array('url' => $_SERVER['REQUEST_URI'])); ?>
|
31 |
+
</div>
|
32 |
+
<?php
|
33 |
+
}
|
34 |
+
|
35 |
+
function em_admin_location($message = "") {
|
36 |
+
global $EM_Location, $EM_Notices;
|
37 |
+
if( empty($EM_Location) || !is_object($EM_Location) ){
|
38 |
+
$title = __('Add location', 'dbem');
|
39 |
+
$EM_Location = new EM_Location();
|
40 |
+
}else{
|
41 |
+
$title = __('Edit location', 'dbem');
|
42 |
+
}
|
43 |
+
?>
|
44 |
+
<div class='wrap'>
|
45 |
+
<div id='icon-edit' class='icon32'>
|
46 |
+
<br/>
|
47 |
+
</div>
|
48 |
+
<h2><?php echo $title ?></h2>
|
49 |
+
<?php em_location_form(); ?>
|
50 |
+
</div>
|
51 |
+
<?php
|
52 |
+
}
|
53 |
+
|
54 |
+
?>
|
admin/em-ms-options.php
ADDED
@@ -0,0 +1,219 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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'); ?></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.'); ?></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 |
+
$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>';
|
69 |
+
//Do some multisite checking here for reuse
|
70 |
+
?>
|
71 |
+
<script type="text/javascript" charset="utf-8">
|
72 |
+
jQuery(document).ready(function($){
|
73 |
+
var close_text = '<?php _e('Collapse All','dbem'); ?>';
|
74 |
+
var open_text = '<?php _e('Expand All','dbem'); ?>';
|
75 |
+
var open_close = $('<a href="#" style="display:block; float:right; clear:right; margin:10px;">'+open_text+'</a>');
|
76 |
+
$('#em-options-title').before(open_close);
|
77 |
+
open_close.click( function(e){
|
78 |
+
e.preventDefault();
|
79 |
+
if($(this).text() == close_text){
|
80 |
+
$(".postbox").addClass('closed');
|
81 |
+
$(this).text(open_text);
|
82 |
+
}else{
|
83 |
+
$(".postbox").removeClass('closed');
|
84 |
+
$(this).text(close_text);
|
85 |
+
}
|
86 |
+
});
|
87 |
+
$(".postbox > h3").click(function(){ $(this).parent().toggleClass('closed'); });
|
88 |
+
$(".postbox").addClass('closed');
|
89 |
+
//MS Mode selection hiders
|
90 |
+
$('input[name="dbem_ms_global_table"]').change(function(){ //global
|
91 |
+
if( $('input:radio[name="dbem_ms_global_table"]:checked').val() == 1 ){
|
92 |
+
$("tbody.em-global-options").show();
|
93 |
+
$('input:radio[name="dbem_ms_mainblog_locations"]:checked').trigger('change');
|
94 |
+
}else{
|
95 |
+
$("tbody.em-global-options").hide();
|
96 |
+
}
|
97 |
+
}).first().trigger('change');
|
98 |
+
//events
|
99 |
+
$('input[name="dbem_ms_global_events"]').change(function(){
|
100 |
+
if( $('input:radio[name="dbem_ms_global_events"]:checked').val() == 1 ){
|
101 |
+
$("tr#dbem_ms_global_events_links_row").show();
|
102 |
+
$('input:radio[name="dbem_ms_global_events_links"]:checked').trigger('change');
|
103 |
+
}else{
|
104 |
+
$("tr#dbem_ms_global_events_links_row, tr#dbem_ms_events_slug_row").hide();
|
105 |
+
}
|
106 |
+
}).first().trigger('change');
|
107 |
+
$('input[name="dbem_ms_global_events_links"]').change(function(){
|
108 |
+
if( $('input:radio[name="dbem_ms_global_events_links"]:checked').val() == 1 ){
|
109 |
+
$("tr#dbem_ms_events_slug_row").hide();
|
110 |
+
}else{
|
111 |
+
$("tr#dbem_ms_events_slug_row").show();
|
112 |
+
}
|
113 |
+
}).first().trigger('change');
|
114 |
+
//locations
|
115 |
+
$('input[name="dbem_ms_mainblog_locations"]').change(function(){
|
116 |
+
if( $('input:radio[name="dbem_ms_mainblog_locations"]:checked').val() == 1 ){
|
117 |
+
$("tbody.em-global-locations").hide();
|
118 |
+
}else{
|
119 |
+
$("tbody.em-global-locations").show();
|
120 |
+
}
|
121 |
+
}).first().trigger('change');
|
122 |
+
$('input[name="dbem_ms_global_locations"]').change(function(){
|
123 |
+
if( $('input:radio[name="dbem_ms_global_locations"]:checked').val() == 1 ){
|
124 |
+
$("tr#dbem_ms_global_locations_links_row").show();
|
125 |
+
$('input:radio[name="dbem_ms_global_locations_links"]:checked').trigger('change');
|
126 |
+
}else{
|
127 |
+
$("tr#dbem_ms_global_locations_links_row, tr#dbem_ms_locations_slug_row").hide();
|
128 |
+
}
|
129 |
+
}).first().trigger('change');
|
130 |
+
$('input[name="dbem_ms_global_locations_links"]').change(function(){
|
131 |
+
if( $('input:radio[name="dbem_ms_global_locations_links"]:checked').val() == 1 ){
|
132 |
+
$("tr#dbem_ms_locations_slug_row").hide();
|
133 |
+
}else{
|
134 |
+
$("tr#dbem_ms_locations_slug_row").show();
|
135 |
+
}
|
136 |
+
});
|
137 |
+
});
|
138 |
+
</script>
|
139 |
+
<style type="text/css">.postbox h3 { cursor:pointer; }</style>
|
140 |
+
<div class="wrap">
|
141 |
+
<div id='icon-options-general' class='icon32'><br /></div>
|
142 |
+
<h2 class="nav-tab-wrapper">
|
143 |
+
<a href="#" id="em-menu-general" class="nav-tab nav-tab-active"><?php _e('General','dbem'); ?></a>
|
144 |
+
</h2>
|
145 |
+
<h3 id="em-options-title"><?php _e ( 'Event Manager Options', 'dbem' ); ?></h3>
|
146 |
+
<?php echo $EM_Notices; ?>
|
147 |
+
<form id="em-options-form" method="post" action="">
|
148 |
+
<div class="metabox-holder">
|
149 |
+
<!-- // TODO Move style in css -->
|
150 |
+
<div class='postbox-container' style='width: 99.5%'>
|
151 |
+
<div id="">
|
152 |
+
|
153 |
+
<div class="em-menu-general em-menu-group">
|
154 |
+
<div class="postbox " >
|
155 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Multi Site Options', 'dbem' ); ?></span></h3>
|
156 |
+
<div class="inside">
|
157 |
+
<table class="form-table">
|
158 |
+
<?php
|
159 |
+
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' ) );
|
160 |
+
?>
|
161 |
+
<tbody class="em-global-options">
|
162 |
+
<?php
|
163 |
+
global $current_site;
|
164 |
+
$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.');
|
165 |
+
$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' );
|
166 |
+
$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');
|
167 |
+
$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.');
|
168 |
+
$options_page_link = get_admin_url($current_site->blog_id, 'edit.php?post_type=event&page=events-manager-options#pages');
|
169 |
+
?><tr><td><strong><?php echo sprintf(__('%s Options','dbem'),__('Event','dbem')); ?></strong></td></tr><?php
|
170 |
+
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')) );
|
171 |
+
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) );
|
172 |
+
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 );
|
173 |
+
?><tr><td><strong><?php echo sprintf(__('%s Options','dbem'),__('Location','dbem')); ?></strong></td></tr><?php
|
174 |
+
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') );
|
175 |
+
?>
|
176 |
+
</tbody>
|
177 |
+
<tbody class="em-global-options em-global-locations">
|
178 |
+
<?php
|
179 |
+
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')) );
|
180 |
+
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) );
|
181 |
+
em_options_input_text ( sprintf(__( 'Global %s slug', 'dbem' ),__('event','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 );
|
182 |
+
?>
|
183 |
+
</tbody>
|
184 |
+
<?php echo $save_button; ?>
|
185 |
+
</table>
|
186 |
+
|
187 |
+
</div> <!-- . inside -->
|
188 |
+
</div> <!-- .postbox -->
|
189 |
+
|
190 |
+
<?php
|
191 |
+
//including shared MS/non-MS boxes
|
192 |
+
em_admin_option_box_caps();
|
193 |
+
em_admin_option_box_image_sizes();
|
194 |
+
em_admin_option_box_email();
|
195 |
+
em_admin_option_box_uninstall();
|
196 |
+
?>
|
197 |
+
|
198 |
+
<?php do_action('em_ms_options_page_footer'); ?>
|
199 |
+
</div> <!-- .em-menu-general -->
|
200 |
+
|
201 |
+
<div class="em-menu-pages em-menu-group" style="display:none;">
|
202 |
+
|
203 |
+
</div> <!-- .em-menu-pages -->
|
204 |
+
|
205 |
+
<p class="submit">
|
206 |
+
<input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
|
207 |
+
<input type="hidden" name="em-submitted" value="1" />
|
208 |
+
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('events-manager-options'); ?>" />
|
209 |
+
</p>
|
210 |
+
|
211 |
+
</div> <!-- .metabox-sortables -->
|
212 |
+
</div> <!-- .postbox-container -->
|
213 |
+
|
214 |
+
</div> <!-- .metabox-holder -->
|
215 |
+
</form>
|
216 |
+
</div>
|
217 |
+
<?php
|
218 |
+
}
|
219 |
+
?>
|
admin/em-options.php
CHANGED
@@ -1,444 +1,1905 @@
|
|
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('activate_plugins') && !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' && !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">
|
250 |
+
jQuery(document).ready(function($){
|
251 |
+
//Meta Box Options
|
252 |
+
var close_text = '<?php _e('Collapse All','dbem'); ?>';
|
253 |
+
var open_text = '<?php _e('Expand All','dbem'); ?>';
|
254 |
+
var open_close = $('<a href="#" style="display:block; float:right; clear:right; margin:10px;">'+open_text+'</a>');
|
255 |
+
$('#em-options-title').before(open_close);
|
256 |
+
open_close.click( function(e){
|
257 |
+
e.preventDefault();
|
258 |
+
if($(this).text() == close_text){
|
259 |
+
$(".postbox").addClass('closed');
|
260 |
+
$(this).text(open_text);
|
261 |
+
}else{
|
262 |
+
$(".postbox").removeClass('closed');
|
263 |
+
$(this).text(close_text);
|
264 |
+
}
|
265 |
+
});
|
266 |
+
$(".postbox > h3").click(function(){ $(this).parent().toggleClass('closed'); });
|
267 |
+
$(".postbox").addClass('closed');
|
268 |
+
//Navigation Tabs
|
269 |
+
$('.nav-tab-wrapper .nav-tab').click(function(){
|
270 |
+
$('.nav-tab-wrapper .nav-tab').removeClass('nav-tab-active');
|
271 |
+
el = $(this);
|
272 |
+
elid = el.attr('id');
|
273 |
+
$('.em-menu-group').hide();
|
274 |
+
$('.'+elid).show();
|
275 |
+
el.addClass('nav-tab-active');
|
276 |
+
$(".postbox").addClass('closed');
|
277 |
+
open_close.text(open_text);
|
278 |
+
});
|
279 |
+
var navUrl = document.location.toString();
|
280 |
+
if (navUrl.match('#')) { //anchor-based navigation
|
281 |
+
var current_tab = 'a#em-menu-' + navUrl.split('#')[1];
|
282 |
+
$(current_tab).trigger('click');
|
283 |
+
}
|
284 |
+
$('.nav-tab-link').click(function(){ $($(this).attr('rel')).trigger('click'); }); //links to mimick tabs
|
285 |
+
//Page Options
|
286 |
+
$('input[name="dbem_cp_events_has_archive"]').change(function(){ //event archives
|
287 |
+
if( $('input:radio[name="dbem_cp_events_has_archive"]:checked').val() == 1 ){
|
288 |
+
$('tbody.em-event-archive-sub-options').show();
|
289 |
+
}else{
|
290 |
+
$('tbody.em-event-archive-sub-options').hide();
|
291 |
+
}
|
292 |
+
}).trigger('change');
|
293 |
+
$('select[name="dbem_events_page"]').change(function(){
|
294 |
+
if( $('select[name="dbem_events_page"]').val() == 0 ){
|
295 |
+
$('tbody.em-event-page-options').hide();
|
296 |
+
}else{
|
297 |
+
$('tbody.em-event-page-options').show();
|
298 |
+
}
|
299 |
+
}).trigger('change');
|
300 |
+
$('input[name="dbem_cp_locations_has_archive"]').change(function(){ //location archives
|
301 |
+
if( $('input:radio[name="dbem_cp_locations_has_archive"]:checked').val() == 1 ){
|
302 |
+
$('tbody.em-location-archive-sub-options').show();
|
303 |
+
}else{
|
304 |
+
$('tbody.em-location-archive-sub-options').hide();
|
305 |
+
}
|
306 |
+
}).trigger('change');
|
307 |
+
//For rewrite titles
|
308 |
+
$('input:radio[name=dbem_disable_title_rewrites]').live('change',function(){
|
309 |
+
checked_check = $('input:radio[name=dbem_disable_title_rewrites]:checked');
|
310 |
+
if( checked_check.val() == 1 ){
|
311 |
+
$('#dbem_title_html_row').show();
|
312 |
+
}else{
|
313 |
+
$('#dbem_title_html_row').hide();
|
314 |
+
}
|
315 |
+
});
|
316 |
+
$('input:radio[name=dbem_disable_title_rewrites]').trigger('change');
|
317 |
+
//ML Stuff
|
318 |
+
$('.em-translatable').click(function(){
|
319 |
+
$(this).nextAll('.em-ml-options').toggle();
|
320 |
+
});
|
321 |
+
});
|
322 |
+
</script>
|
323 |
+
<style type="text/css">.postbox h3 { cursor:pointer; }</style>
|
324 |
+
<div class="wrap">
|
325 |
+
<div id='icon-options-general' class='icon32'><br /></div>
|
326 |
+
<h2 class="nav-tab-wrapper">
|
327 |
+
<a href="#general" id="em-menu-general" class="nav-tab nav-tab-active"><?php _e('General','dbem'); ?></a>
|
328 |
+
<a href="#pages" id="em-menu-pages" class="nav-tab"><?php _e('Pages','dbem'); ?></a>
|
329 |
+
<a href="#formats" id="em-menu-formats" class="nav-tab"><?php _e('Formatting','dbem'); ?></a>
|
330 |
+
<?php if( get_option('dbem_rsvp_enabled') ): ?>
|
331 |
+
<a href="#bookings" id="em-menu-bookings" class="nav-tab"><?php _e('Bookings','dbem'); ?></a>
|
332 |
+
<?php endif; ?>
|
333 |
+
<a href="#emails" id="em-menu-emails" class="nav-tab"><?php _e('Emails','dbem'); ?></a>
|
334 |
+
</h2>
|
335 |
+
<h3 id="em-options-title"><?php _e ( 'Event Manager Options', 'dbem' ); ?></h3>
|
336 |
+
<form id="em-options-form" method="post" action="">
|
337 |
+
<div class="metabox-holder">
|
338 |
+
<!-- // TODO Move style in css -->
|
339 |
+
<div class='postbox-container' style='width: 99.5%'>
|
340 |
+
<div id="">
|
341 |
+
|
342 |
+
<div class="em-menu-general em-menu-group">
|
343 |
+
|
344 |
+
<!-- GENERAL OPTIONS -->
|
345 |
+
<div class="postbox " >
|
346 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'General Options', 'dbem' ); ?> </span></h3>
|
347 |
+
<div class="inside">
|
348 |
+
<table class="form-table">
|
349 |
+
<?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' ) ); ?>
|
350 |
+
<tr>
|
351 |
+
<td colspan="2">
|
352 |
+
<h4><?php echo sprintf(__('%s Settings','dbem'),__('Event','dbem')); ?></h4>
|
353 |
+
</td>
|
354 |
+
</tr>
|
355 |
+
<?php
|
356 |
+
em_options_radio_binary ( __( 'Enable recurrence?', 'dbem' ), 'dbem_recurrence_enabled', __( 'Select yes to enable the recurrence features feature','dbem' ) );
|
357 |
+
em_options_radio_binary ( __( 'Enable bookings?', 'dbem' ), 'dbem_rsvp_enabled', __( 'Select yes to allow bookings and tickets for events.','dbem' ) );
|
358 |
+
em_options_radio_binary ( __( 'Enable tags?', 'dbem' ), 'dbem_tags_enabled', __( 'Select yes to enable the tag features','dbem' ) );
|
359 |
+
if( !(EM_MS_GLOBAL && !is_main_site()) ){
|
360 |
+
em_options_radio_binary ( __( 'Enable categories?', 'dbem' ), 'dbem_categories_enabled', __( 'Select yes to enable the category features','dbem' ) );
|
361 |
+
if( get_option('dbem_categories_enabled') ){
|
362 |
+
/*default category*/
|
363 |
+
$category_options = array();
|
364 |
+
$category_options[0] = __('no default category','dbem');
|
365 |
+
$EM_Categories = EM_Categories::get();
|
366 |
+
foreach($EM_Categories as $EM_Category){
|
367 |
+
$category_options[$EM_Category->id] = $EM_Category->name;
|
368 |
+
}
|
369 |
+
echo "<tr><td>".__( 'Default Category', 'dbem' )."</td><td>";
|
370 |
+
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'=>''));
|
371 |
+
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>";
|
372 |
+
echo "</td></tr>";
|
373 |
+
}
|
374 |
+
}
|
375 |
+
em_options_radio_binary ( sprintf(__( 'Enable %s attributes?', 'dbem' ),__('event','dbem')), 'dbem_attributes_enabled', __( 'Select yes to enable the attributes feature','dbem' ) );
|
376 |
+
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' ) );
|
377 |
+
if( get_option('dbem_attributes_enabled') ){
|
378 |
+
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') );
|
379 |
+
}
|
380 |
+
if( get_option('dbem_locations_enabled') ){
|
381 |
+
/*default location*/
|
382 |
+
$location_options = array();
|
383 |
+
$location_options[0] = __('no default location','dbem');
|
384 |
+
$EM_Locations = EM_Locations::get();
|
385 |
+
foreach($EM_Locations as $EM_Location){
|
386 |
+
$location_options[$EM_Location->location_id] = $EM_Location->location_name;
|
387 |
+
}
|
388 |
+
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') );
|
389 |
+
|
390 |
+
/*default location country*/
|
391 |
+
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') );
|
392 |
+
}
|
393 |
+
?>
|
394 |
+
<tr>
|
395 |
+
<td colspan="2">
|
396 |
+
<h4><?php echo sprintf(__('%s Settings','dbem'),__('Location','dbem')); ?></h4>
|
397 |
+
</td>
|
398 |
+
</tr>
|
399 |
+
<?php
|
400 |
+
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' ) );
|
401 |
+
if( get_option('dbem_locations_enabled') ){
|
402 |
+
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' ) );
|
403 |
+
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' ) );
|
404 |
+
em_options_radio_binary ( sprintf(__( 'Enable %s attributes?', 'dbem' ),__('location','dbem')), 'dbem_location_attributes_enabled', __( 'Select yes to enable the attributes feature','dbem' ) );
|
405 |
+
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' ) );
|
406 |
+
if( get_option('dbem_location_attributes_enabled') ){
|
407 |
+
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') );
|
408 |
+
}
|
409 |
+
}
|
410 |
+
?>
|
411 |
+
<tr>
|
412 |
+
<td colspan="2">
|
413 |
+
<h4><?php echo sprintf(__('%s Settings','dbem'),__('Other','dbem')); ?></h4>
|
414 |
+
</td>
|
415 |
+
</tr>
|
416 |
+
<?php
|
417 |
+
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' ) );
|
418 |
+
echo $save_button;
|
419 |
+
?>
|
420 |
+
</table>
|
421 |
+
|
422 |
+
</div> <!-- . inside -->
|
423 |
+
</div> <!-- .postbox -->
|
424 |
+
|
425 |
+
<?php if ( !is_multisite() ){ em_admin_option_box_image_sizes(); } ?>
|
426 |
+
|
427 |
+
<?php if ( !is_multisite() || (is_super_admin() && !get_site_option('dbem_ms_global_caps')) ){ em_admin_option_box_caps(); } ?>
|
428 |
+
|
429 |
+
<div class="postbox" >
|
430 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Submission Forms', 'dbem' ); ?></span></h3>
|
431 |
+
<div class="inside">
|
432 |
+
<table class="form-table">
|
433 |
+
<tr><td colspan="2">
|
434 |
+
<?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>'); ?>
|
435 |
+
</td></tr>
|
436 |
+
<?php
|
437 |
+
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' ) );
|
438 |
+
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' ) );
|
439 |
+
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 );
|
440 |
+
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 );
|
441 |
+
?>
|
442 |
+
<tr><td colspan="2">
|
443 |
+
<strong><?php echo sprintf(__('Anonymous event submissions','dbem'), '<code>[event_form]</code>'); ?></strong>
|
444 |
+
</td></tr>
|
445 |
+
<?php
|
446 |
+
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' ) );
|
447 |
+
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' ) );
|
448 |
+
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 );
|
449 |
+
?>
|
450 |
+
<?php echo $save_button; ?>
|
451 |
+
</table>
|
452 |
+
</div> <!-- . inside -->
|
453 |
+
</div> <!-- .postbox -->
|
454 |
+
|
455 |
+
<?php do_action('em_options_page_footer'); ?>
|
456 |
+
|
457 |
+
<div class="postbox" >
|
458 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Performance Optimization', 'dbem' ); ?> (<?php _e('Advanced','dbem'); ?>) <em>Beta</em></span></h3>
|
459 |
+
<div class="inside">
|
460 |
+
<?php
|
461 |
+
$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');
|
462 |
+
?>
|
463 |
+
<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>
|
464 |
+
<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>
|
465 |
+
<table class="form-table">
|
466 |
+
<tr><td colspan="2">
|
467 |
+
<strong><?php _e('JavaScript Files','dbem'); ?></strong>
|
468 |
+
<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/'); ?>
|
469 |
+
</td></tr>
|
470 |
+
<?php
|
471 |
+
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' ) );
|
472 |
+
?>
|
473 |
+
<tbody id="dbem-js-limit-options">
|
474 |
+
<tr><td colspan="2">
|
475 |
+
<?php
|
476 |
+
_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');
|
477 |
+
echo $performance_opt_page_instructions;
|
478 |
+
?>
|
479 |
+
</td></tr>
|
480 |
+
<?php
|
481 |
+
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 );
|
482 |
+
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' ) );
|
483 |
+
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' ) );
|
484 |
+
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' ) );
|
485 |
+
?>
|
486 |
+
</tbody>
|
487 |
+
<tr><td colspan="2" style="font-weight:bold;">
|
488 |
+
<?php _e('CSS File','dbem'); ?>
|
489 |
+
</td></tr>
|
490 |
+
<?php
|
491 |
+
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' ) );
|
492 |
+
?>
|
493 |
+
<tbody id="dbem-css-limit-options">
|
494 |
+
<tr><td colspan="2">
|
495 |
+
<?php echo $performance_opt_page_instructions; ?>
|
496 |
+
</td></tr>
|
497 |
+
<?php
|
498 |
+
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 );
|
499 |
+
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 );
|
500 |
+
?>
|
501 |
+
</tbody>
|
502 |
+
<?php
|
503 |
+
?>
|
504 |
+
<tr><td colspan="2">
|
505 |
+
<strong><?php _e('Thumbnails','dbem'); ?></strong>
|
506 |
+
<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'); ?>
|
507 |
+
</td></tr>
|
508 |
+
<?php
|
509 |
+
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' ) );
|
510 |
+
?>
|
511 |
+
<?php echo $save_button; ?>
|
512 |
+
</table>
|
513 |
+
<script type="text/javascript">
|
514 |
+
jQuery(document).ready(function($){
|
515 |
+
$('input:radio[name="dbem_js_limit"]').change(function(){
|
516 |
+
if( $('input:radio[name="dbem_js_limit"]:checked').val() == 1 ){
|
517 |
+
$('tbody#dbem-js-limit-options').show();
|
518 |
+
}else{
|
519 |
+
$('tbody#dbem-js-limit-options').hide();
|
520 |
+
}
|
521 |
+
}).trigger('change');
|
522 |
+
});
|
523 |
+
jQuery(document).ready(function($){
|
524 |
+
$('input:radio[name="dbem_css_limit"]').change(function(){
|
525 |
+
if( $('input:radio[name="dbem_css_limit"]:checked').val() == 1 ){
|
526 |
+
$('tbody#dbem-css-limit-options').show();
|
527 |
+
}else{
|
528 |
+
$('tbody#dbem-css-limit-options').hide();
|
529 |
+
}
|
530 |
+
}).trigger('change');
|
531 |
+
});
|
532 |
+
</script>
|
533 |
+
</div> <!-- . inside -->
|
534 |
+
</div> <!-- .postbox -->
|
535 |
+
|
536 |
+
<?php if ( !is_multisite() ) { em_admin_option_box_uninstall(); } ?>
|
537 |
+
|
538 |
+
<?php if( get_option('dbem_migrate_images') ): ?>
|
539 |
+
<div class="postbox " >
|
540 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span>Migrate Images From Version 4</span></h3>
|
541 |
+
<div class="inside">
|
542 |
+
<?php /* Not translating as it's temporary */ ?>
|
543 |
+
<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>
|
544 |
+
<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>
|
545 |
+
<p>
|
546 |
+
<a href="<?php echo $_SERVER['REQUEST_URI'] ?>&em_migrate_images=1&_wpnonce=<?php echo wp_create_nonce('em_migrate_images'); ?>" />Migrate Images</a><br />
|
547 |
+
<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>
|
548 |
+
</p>
|
549 |
+
</div> <!-- . inside -->
|
550 |
+
</div> <!-- .postbox -->
|
551 |
+
<?php endif; ?>
|
552 |
+
</div> <!-- .em-menu-general -->
|
553 |
+
|
554 |
+
<!-- PAGE OPTIONS -->
|
555 |
+
<div class="em-menu-pages em-menu-group" style="display:none;">
|
556 |
+
<?php
|
557 |
+
$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' );
|
558 |
+
$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'));
|
559 |
+
$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'>Formating</a> tab above without having to edit your theme files.")
|
560 |
+
?>
|
561 |
+
<div class="postbox " >
|
562 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('Permalink Slugs','dbem')); ?></span></h3>
|
563 |
+
<div class="inside">
|
564 |
+
<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>
|
565 |
+
<table class="form-table">
|
566 |
+
<?php
|
567 |
+
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 );
|
568 |
+
if( get_option('dbem_locations_enabled') ){
|
569 |
+
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 );
|
570 |
+
}
|
571 |
+
if( get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site()) ){
|
572 |
+
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 );
|
573 |
+
}
|
574 |
+
if( get_option('dbem_tags_enabled') ){
|
575 |
+
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 );
|
576 |
+
}
|
577 |
+
echo $save_button;
|
578 |
+
?>
|
579 |
+
</table>
|
580 |
+
</div> <!-- . inside -->
|
581 |
+
</div> <!-- .postbox -->
|
582 |
+
|
583 |
+
<div class="postbox " >
|
584 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s Pages','dbem'),__('Event','dbem')); ?></span></h3>
|
585 |
+
<div class="inside">
|
586 |
+
<table class="form-table">
|
587 |
+
<?php
|
588 |
+
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')) );
|
589 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_events_formats', sprintf($format_override_tip,__('events','dbem')));
|
590 |
+
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')));
|
591 |
+
echo $save_button;
|
592 |
+
?>
|
593 |
+
</table>
|
594 |
+
</div> <!-- . inside -->
|
595 |
+
</div> <!-- .postbox -->
|
596 |
+
|
597 |
+
<div class="postbox " >
|
598 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s List/Archives','dbem'),__('Event','dbem')); ?></span></h3>
|
599 |
+
<div class="inside">
|
600 |
+
<table class="form-table">
|
601 |
+
<tr>
|
602 |
+
<td><?php echo sprintf(__( 'Events page', 'dbem' )); ?></td>
|
603 |
+
<td>
|
604 |
+
<?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')) )); ?>
|
605 |
+
<br />
|
606 |
+
<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>
|
607 |
+
</td>
|
608 |
+
</tr>
|
609 |
+
<tbody class="em-event-page-options">
|
610 |
+
<?php
|
611 |
+
em_options_radio_binary ( __( 'Show events search?', 'dbem' ), 'dbem_events_page_search', __( "If set to yes, a search form will appear just above your list of events.", 'dbem' ) );
|
612 |
+
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') );
|
613 |
+
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' ) );
|
614 |
+
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' ) );
|
615 |
+
?>
|
616 |
+
</tbody>
|
617 |
+
<tr>
|
618 |
+
<td colspan="2">
|
619 |
+
<h4><?php echo sprintf(__('WordPress %s Archives','dbem'), __('Event','dbem')); ?></h4>
|
620 |
+
<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'), __('Event','dbem'), '<code>'.home_url().'/'.get_option('dbem_cp_events_slug',EM_POST_TYPE_EVENT_SLUG).'/</code>', __('events','dbem')); ?></p>
|
621 |
+
<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). You can have both at the same time, but you must ensure that your page and %s slugs are different.'), __('events','dbem'), __('event','dbem')); ?></p>
|
622 |
+
</td>
|
623 |
+
</tr>
|
624 |
+
<tbody class="em-event-archive-options">
|
625 |
+
<?php
|
626 |
+
em_options_radio_binary ( __( 'Enable Archives?', 'dbem' ), 'dbem_cp_events_has_archive', __( "Allow WordPress post-style archives.", 'dbem' ) );
|
627 |
+
?>
|
628 |
+
</tbody>
|
629 |
+
<tbody class="em-event-archive-options em-event-archive-sub-options">
|
630 |
+
<tr valign="top">
|
631 |
+
<th scope="row"><?php _e('Default event archive ordering','dbem'); ?></th>
|
632 |
+
<td>
|
633 |
+
<select name="dbem_events_default_archive_orderby" >
|
634 |
+
<?php
|
635 |
+
$event_archive_orderby_options = apply_filters('em_settings_events_default_archive_orderby_ddm', array(
|
636 |
+
'_start_ts' => __('Order by start date, start time','dbem'),
|
637 |
+
'title' => __('Order by name','dbem')
|
638 |
+
));
|
639 |
+
?>
|
640 |
+
<?php foreach($event_archive_orderby_options as $key => $value) : ?>
|
641 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
642 |
+
<?php echo $value; ?>
|
643 |
+
</option>
|
644 |
+
<?php endforeach; ?>
|
645 |
+
</select>
|
646 |
+
<select name="dbem_events_default_archive_order" >
|
647 |
+
<?php
|
648 |
+
$ascending = __('Ascending','dbem');
|
649 |
+
$descending = __('Descending','dbem');
|
650 |
+
$event_archive_order_options = apply_filters('em_settings_events_default_archive_order_ddm', array(
|
651 |
+
'ASC' => __('Ascending','dbem'),
|
652 |
+
'DESC' => __('Descending','dbem')
|
653 |
+
));
|
654 |
+
?>
|
655 |
+
<?php foreach( $event_archive_order_options as $key => $value) : ?>
|
656 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
657 |
+
<?php echo $value; ?>
|
658 |
+
</option>
|
659 |
+
<?php endforeach; ?>
|
660 |
+
</select>
|
661 |
+
<br/>
|
662 |
+
<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>
|
663 |
+
</td>
|
664 |
+
</tr>
|
665 |
+
</tbody>
|
666 |
+
<tr>
|
667 |
+
<td colspan="2">
|
668 |
+
<h4><?php echo _e('General settings','dbem'); ?></h4>
|
669 |
+
</td>
|
670 |
+
</tr>
|
671 |
+
<?php
|
672 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_events_archive_formats', sprintf($format_override_tip,__('events','dbem')));
|
673 |
+
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' ) );
|
674 |
+
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')) );
|
675 |
+
?>
|
676 |
+
<tr>
|
677 |
+
<td colspan="2">
|
678 |
+
<h4><?php echo sprintf(__('Default %s list options','dbem'), __('event','dbem')); ?></h4>
|
679 |
+
<p><?php _e('These can be overriden when using shortcode or template tags.','dbem'); ?></p>
|
680 |
+
</td>
|
681 |
+
</tr>
|
682 |
+
<tr valign="top" id='dbem_events_default_orderby_row'>
|
683 |
+
<th scope="row"><?php _e('Default event list ordering','dbem'); ?></th>
|
684 |
+
<td>
|
685 |
+
<select name="dbem_events_default_orderby" >
|
686 |
+
<?php
|
687 |
+
$orderby_options = apply_filters('em_settings_events_default_orderby_ddm', array(
|
688 |
+
'event_start_date,event_start_time,event_name' => __('Order by start date, start time, then event name','dbem'),
|
689 |
+
'event_name,event_start_date,event_start_time' => __('Order by name, start date, then start time','dbem'),
|
690 |
+
'event_name,event_end_date,event_end_time' => __('Order by name, end date, then end time','dbem'),
|
691 |
+
'event_end_date,event_end_time,event_name' => __('Order by end date, end time, then event name','dbem'),
|
692 |
+
));
|
693 |
+
?>
|
694 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
695 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_orderby')) ? "selected='selected'" : ''; ?>>
|
696 |
+
<?php echo $value; ?>
|
697 |
+
</option>
|
698 |
+
<?php endforeach; ?>
|
699 |
+
</select>
|
700 |
+
<select name="dbem_events_default_order" >
|
701 |
+
<?php
|
702 |
+
$ascending = __('Ascending','dbem');
|
703 |
+
$descending = __('Descending','dbem');
|
704 |
+
$order_options = apply_filters('em_settings_events_default_order_ddm', array(
|
705 |
+
'ASC' => __('All Ascending','dbem'),
|
706 |
+
'DESC,ASC,ASC' => __("$descending, $ascending, $ascending",'dbem'),
|
707 |
+
'DESC,DESC,ASC' => __("$descending, $descending, $ascending",'dbem'),
|
708 |
+
'DESC' => __('All Descending','dbem'),
|
709 |
+
'ASC,DESC,ASC' => __("$ascending, $descending, $ascending",'dbem'),
|
710 |
+
'ASC,DESC,DESC' => __("$ascending, $descending, $descending",'dbem'),
|
711 |
+
'ASC,ASC,DESC' => __("$ascending, $ascending, $descending",'dbem'),
|
712 |
+
'DESC,ASC,DESC' => __("$descending, $ascending, $descending",'dbem'),
|
713 |
+
));
|
714 |
+
?>
|
715 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
716 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_order')) ? "selected='selected'" : ''; ?>>
|
717 |
+
<?php echo $value; ?>
|
718 |
+
</option>
|
719 |
+
<?php endforeach; ?>
|
720 |
+
</select>
|
721 |
+
<br/>
|
722 |
+
<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>
|
723 |
+
</td>
|
724 |
+
</tr>
|
725 |
+
<tr valign="top" id='dbem_events_display_time_limit'>
|
726 |
+
<th scope="row"><?php _e('Event list scope','dbem'); ?></th>
|
727 |
+
<td>
|
728 |
+
<select name="dbem_events_page_scope" >
|
729 |
+
<?php foreach( em_get_scopes() as $key => $value) : ?>
|
730 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_page_scope')) ? "selected='selected'" : ''; ?>>
|
731 |
+
<?php echo $value; ?>
|
732 |
+
</option>
|
733 |
+
<?php endforeach; ?>
|
734 |
+
</select>
|
735 |
+
<br />
|
736 |
+
<em><?php _e('Only show events starting within a certain time limit on the events page. Default is future events with no end time limit.','dbem'); ?></em>
|
737 |
+
</td>
|
738 |
+
</tr>
|
739 |
+
<?php
|
740 |
+
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' ) );
|
741 |
+
echo $save_button;
|
742 |
+
?>
|
743 |
+
</table>
|
744 |
+
</div> <!-- . inside -->
|
745 |
+
</div> <!-- .postbox -->
|
746 |
+
|
747 |
+
<?php if( get_option('dbem_locations_enabled') ): ?>
|
748 |
+
<div class="postbox " >
|
749 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s Pages','dbem'),__('Location','dbem')); ?></span></h3>
|
750 |
+
<div class="inside">
|
751 |
+
<table class="form-table">
|
752 |
+
<?php
|
753 |
+
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')) );
|
754 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_locations_formats', sprintf($format_override_tip,__('locations','dbem')));
|
755 |
+
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')));
|
756 |
+
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>') );
|
757 |
+
echo $save_button;
|
758 |
+
?>
|
759 |
+
</table>
|
760 |
+
</div> <!-- . inside -->
|
761 |
+
</div> <!-- .postbox -->
|
762 |
+
|
763 |
+
<div class="postbox " >
|
764 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s List/Archives','dbem'),__('Location','dbem')); ?></span></h3>
|
765 |
+
<div class="inside">
|
766 |
+
<table class="form-table">
|
767 |
+
<tr>
|
768 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Locations','dbem')); ?></td>
|
769 |
+
<td>
|
770 |
+
<?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')) )); ?>
|
771 |
+
<br />
|
772 |
+
<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>
|
773 |
+
</td>
|
774 |
+
</tr>
|
775 |
+
<tr>
|
776 |
+
<td colspan="2">
|
777 |
+
<h4><?php echo sprintf(__('WordPress %s Archives','dbem'), __('Location','dbem')); ?></h4>
|
778 |
+
<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'), __('Location','dbem'), '<code>'.home_url().'/'.get_option('dbem_cp_events_slug',EM_POST_TYPE_EVENT_SLUG).'/</code>', __('locations','dbem')); ?></p>
|
779 |
+
<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 compatability). You can have both at the same time, but you must ensure that your page and %s slugs are different.'), __('locations','dbem'), __('location','dbem')); ?></p>
|
780 |
+
</td>
|
781 |
+
</tr>
|
782 |
+
<tbody class="em-location-archive-options">
|
783 |
+
<?php
|
784 |
+
em_options_radio_binary ( __( 'Enable Archives?', 'dbem' ), 'dbem_cp_locations_has_archive', __( "Allow WordPress post-style archives.", 'dbem' ) );
|
785 |
+
?>
|
786 |
+
</tbody>
|
787 |
+
<tbody class="em-location-archive-options em-location-archive-sub-options">
|
788 |
+
<tr valign="top">
|
789 |
+
<th scope="row"><?php _e('Default archive ordering','dbem'); ?></th>
|
790 |
+
<td>
|
791 |
+
<select name="dbem_locations_default_archive_orderby" >
|
792 |
+
<?php
|
793 |
+
$orderby_options = apply_filters('em_settings_locations_default_archive_orderby_ddm', array(
|
794 |
+
'_country' => sprintf(__('Order by %s','dbem'),__('Country','dbem')),
|
795 |
+
'_town' => sprintf(__('Order by %s','dbem'),__('Town','dbem')),
|
796 |
+
'title' => sprintf(__('Order by %s','dbem'),__('Name','dbem'))
|
797 |
+
));
|
798 |
+
?>
|
799 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
800 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
801 |
+
<?php echo $value; ?>
|
802 |
+
</option>
|
803 |
+
<?php endforeach; ?>
|
804 |
+
</select>
|
805 |
+
<select name="dbem_locations_default_archive_order" >
|
806 |
+
<?php
|
807 |
+
$ascending = __('Ascending','dbem');
|
808 |
+
$descending = __('Descending','dbem');
|
809 |
+
$order_options = apply_filters('em_settings_locations_default_archive_order_ddm', array(
|
810 |
+
'ASC' => __('Ascending','dbem'),
|
811 |
+
'DESC' => __('Descending','dbem')
|
812 |
+
));
|
813 |
+
?>
|
814 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
815 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
816 |
+
<?php echo $value; ?>
|
817 |
+
</option>
|
818 |
+
<?php endforeach; ?>
|
819 |
+
</select>
|
820 |
+
</td>
|
821 |
+
</tr>
|
822 |
+
</tbody>
|
823 |
+
<tr>
|
824 |
+
<td colspan="2">
|
825 |
+
<h4><?php echo _e('General settings','dbem'); ?></h4>
|
826 |
+
</td>
|
827 |
+
</tr>
|
828 |
+
<?php
|
829 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_locations_archive_formats', sprintf($format_override_tip,__('locations','dbem')));
|
830 |
+
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')) );
|
831 |
+
?>
|
832 |
+
<tr>
|
833 |
+
<td colspan="2">
|
834 |
+
<h4><?php echo sprintf(__('Default %s list options','dbem'), __('location','dbem')); ?></h4>
|
835 |
+
<p><?php _e('These can be overriden when using shortcode or template tags.','dbem'); ?></p>
|
836 |
+
</td>
|
837 |
+
</tr>
|
838 |
+
<tr valign="top" id='dbem_locations_default_orderby_row'>
|
839 |
+
<th scope="row"><?php _e('Default list ordering','dbem'); ?></th>
|
840 |
+
<td>
|
841 |
+
<select name="dbem_locations_default_orderby" >
|
842 |
+
<?php
|
843 |
+
$orderby_options = apply_filters('em_settings_locations_default_orderby_ddm', array(
|
844 |
+
'location_country' => sprintf(__('Order by %s','dbem'),__('Country','dbem')),
|
845 |
+
'location_town' => sprintf(__('Order by %s','dbem'),__('Town','dbem')),
|
846 |
+
'location_name' => sprintf(__('Order by %s','dbem'),__('Name','dbem'))
|
847 |
+
));
|
848 |
+
?>
|
849 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
850 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_orderby')) ? "selected='selected'" : ''; ?>>
|
851 |
+
<?php echo $value; ?>
|
852 |
+
</option>
|
853 |
+
<?php endforeach; ?>
|
854 |
+
</select>
|
855 |
+
<select name="dbem_locations_default_order" >
|
856 |
+
<?php
|
857 |
+
$ascending = __('Ascending','dbem');
|
858 |
+
$descending = __('Descending','dbem');
|
859 |
+
$order_options = apply_filters('em_settings_locations_default_order_ddm', array(
|
860 |
+
'ASC' => __('Ascending','dbem'),
|
861 |
+
'DESC' => __('Descending','dbem')
|
862 |
+
));
|
863 |
+
?>
|
864 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
865 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_locations_default_order')) ? "selected='selected'" : ''; ?>>
|
866 |
+
<?php echo $value; ?>
|
867 |
+
</option>
|
868 |
+
<?php endforeach; ?>
|
869 |
+
</select>
|
870 |
+
</td>
|
871 |
+
</tr>
|
872 |
+
<?php
|
873 |
+
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')) );
|
874 |
+
echo $save_button;
|
875 |
+
?>
|
876 |
+
</table>
|
877 |
+
</div> <!-- . inside -->
|
878 |
+
</div> <!-- .postbox -->
|
879 |
+
<?php endif; ?>
|
880 |
+
|
881 |
+
<?php if( get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site()) ): ?>
|
882 |
+
<div class="postbox " >
|
883 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo __('Event Categories','dbem'); ?></span></h3>
|
884 |
+
<div class="inside">
|
885 |
+
<table class="form-table">
|
886 |
+
<tr>
|
887 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Categories','dbem')); ?></td>
|
888 |
+
<td>
|
889 |
+
<?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')) )); ?>
|
890 |
+
<br />
|
891 |
+
<em><?php echo sprintf(__( 'This option allows you to select which page to use as the %s page.','dbem' ),__('categories','dbem'),__('categories','dbem')); ?></em>
|
892 |
+
</td>
|
893 |
+
</tr>
|
894 |
+
<tr>
|
895 |
+
<td colspan="2">
|
896 |
+
<h4><?php echo _e('General settings','dbem'); ?></h4>
|
897 |
+
</td>
|
898 |
+
</tr>
|
899 |
+
<?php
|
900 |
+
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'));
|
901 |
+
?>
|
902 |
+
<tr valign="top">
|
903 |
+
<th scope="row"><?php _e('Default archive ordering','dbem'); ?></th>
|
904 |
+
<td>
|
905 |
+
<select name="dbem_categories_default_archive_orderby" >
|
906 |
+
<?php foreach($event_archive_orderby_options as $key => $value) : ?>
|
907 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
908 |
+
<?php echo $value; ?>
|
909 |
+
</option>
|
910 |
+
<?php endforeach; ?>
|
911 |
+
</select>
|
912 |
+
<select name="dbem_categories_default_archive_order" >
|
913 |
+
<?php foreach( $event_archive_order_options as $key => $value) : ?>
|
914 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
915 |
+
<?php echo $value; ?>
|
916 |
+
</option>
|
917 |
+
<?php endforeach; ?>
|
918 |
+
</select>
|
919 |
+
<br /><?php echo __('When listing events for a category, this order is applied.', 'dbem'); ?>
|
920 |
+
</td>
|
921 |
+
</tr>
|
922 |
+
<tr>
|
923 |
+
<td colspan="2">
|
924 |
+
<h4><?php echo sprintf(__('Default %s list options','dbem'), __('category','dbem')); ?></h4>
|
925 |
+
<p><?php _e('These can be overriden when using shortcode or template tags.','dbem'); ?></p>
|
926 |
+
</td>
|
927 |
+
</tr>
|
928 |
+
<tr valign="top" id='dbem_categories_default_orderby_row'>
|
929 |
+
<th scope="row"><?php _e('Default list ordering','dbem'); ?></th>
|
930 |
+
<td>
|
931 |
+
<select name="dbem_categories_default_orderby" >
|
932 |
+
<?php
|
933 |
+
$orderby_options = apply_filters('em_settings_categories_default_orderby_ddm', array(
|
934 |
+
'id' => sprintf(__('Order by %s','dbem'),__('ID','dbem')),
|
935 |
+
'count' => sprintf(__('Order by %s','dbem'),__('Count','dbem')),
|
936 |
+
'name' => sprintf(__('Order by %s','dbem'),__('Name','dbem')),
|
937 |
+
'slug' => sprintf(__('Order by %s','dbem'),__('Slug','dbem')),
|
938 |
+
'term_group' => sprintf(__('Order by %s','dbem'),'term_group'),
|
939 |
+
));
|
940 |
+
?>
|
941 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
942 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_orderby')) ? "selected='selected'" : ''; ?>>
|
943 |
+
<?php echo $value; ?>
|
944 |
+
</option>
|
945 |
+
<?php endforeach; ?>
|
946 |
+
</select>
|
947 |
+
<select name="dbem_categories_default_order" >
|
948 |
+
<?php
|
949 |
+
$ascending = __('Ascending','dbem');
|
950 |
+
$descending = __('Descending','dbem');
|
951 |
+
$order_options = apply_filters('em_settings_categories_default_order_ddm', array(
|
952 |
+
'ASC' => __('Ascending','dbem'),
|
953 |
+
'DESC' => __('Descending','dbem')
|
954 |
+
));
|
955 |
+
?>
|
956 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
957 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_categories_default_order')) ? "selected='selected'" : ''; ?>>
|
958 |
+
<?php echo $value; ?>
|
959 |
+
</option>
|
960 |
+
<?php endforeach; ?>
|
961 |
+
</select>
|
962 |
+
<br /><?php echo __('When listing categories, this order is applied.', 'dbem'); ?>
|
963 |
+
</td>
|
964 |
+
</tr>
|
965 |
+
<?php
|
966 |
+
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')) );
|
967 |
+
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>') );
|
968 |
+
echo $save_button;
|
969 |
+
?>
|
970 |
+
</table>
|
971 |
+
</div> <!-- . inside -->
|
972 |
+
</div> <!-- .postbox -->
|
973 |
+
<?php endif; ?>
|
974 |
+
|
975 |
+
<?php if( get_option('dbem_tags_enabled') ): //disabled for now, will add tag stuff later ?>
|
976 |
+
<div class="postbox " >
|
977 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo __('Event Tags','dbem'); ?></span></h3>
|
978 |
+
<div class="inside">
|
979 |
+
<table class="form-table">
|
980 |
+
<?php
|
981 |
+
em_options_radio_binary ( __( 'Override with Formats?', 'dbem' ), 'dbem_cp_tags_formats', sprintf($format_override_tip,__('tags','dbem')));
|
982 |
+
?>
|
983 |
+
<tr valign="top">
|
984 |
+
<th scope="row"><?php _e('Default archive ordering','dbem'); ?></th>
|
985 |
+
<td>
|
986 |
+
<select name="dbem_tags_default_archive_orderby" >
|
987 |
+
<?php foreach($event_archive_orderby_options as $key => $value) : ?>
|
988 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_tags_default_archive_orderby')) ? "selected='selected'" : ''; ?>>
|
989 |
+
<?php echo $value; ?>
|
990 |
+
</option>
|
991 |
+
<?php endforeach; ?>
|
992 |
+
</select>
|
993 |
+
<select name="dbem_tags_default_archive_order" >
|
994 |
+
<?php foreach( $event_archive_order_options as $key => $value) : ?>
|
995 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_tags_default_archive_order')) ? "selected='selected'" : ''; ?>>
|
996 |
+
<?php echo $value; ?>
|
997 |
+
</option>
|
998 |
+
<?php endforeach; ?>
|
999 |
+
</select>
|
1000 |
+
</td>
|
1001 |
+
</tr>
|
1002 |
+
<?php echo $save_button; ?>
|
1003 |
+
</table>
|
1004 |
+
</div> <!-- . inside -->
|
1005 |
+
</div> <!-- .postbox -->
|
1006 |
+
<?php endif; ?>
|
1007 |
+
|
1008 |
+
<div class="postbox " >
|
1009 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__('%s Pages','dbem'),__('Other','dbem')); ?></span></h3>
|
1010 |
+
<div class="inside">
|
1011 |
+
<p><?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.'); ?></p>
|
1012 |
+
<table class="form-table">
|
1013 |
+
<?php
|
1014 |
+
$other_pages_tip = 'Using the %s shortcode, you can allow users to manage %s outside the admin area.';
|
1015 |
+
?>
|
1016 |
+
<tr><td colspan="2"><h4><?php echo _e('My Bookings','dbem'); ?></h4></td></tr>
|
1017 |
+
<tr>
|
1018 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('My bookings','dbem')); ?></td>
|
1019 |
+
<td>
|
1020 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_my_bookings_page', 'selected'=>get_option('dbem_my_bookings_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1021 |
+
<br />
|
1022 |
+
<em><?php echo sprintf(__('Users can view their bookings for other events on this page.','dbem' ),'<code>[my_bookings]</code>',__('bookings','dbem')); ?></em>
|
1023 |
+
</td>
|
1024 |
+
</tr>
|
1025 |
+
<tr valign="top" id='dbem_bookings_default_orderby_row'>
|
1026 |
+
<th scope="row"><?php _e('Default list ordering','dbem'); ?></th>
|
1027 |
+
<td>
|
1028 |
+
<select name="dbem_bookings_default_orderby" >
|
1029 |
+
<?php
|
1030 |
+
$orderby_options = apply_filters('em_settings_bookings_default_orderby_ddm', array(
|
1031 |
+
'event_name' => sprintf(__('Order by %s','dbem'),__('Event Name','dbem')),
|
1032 |
+
'event_start_date' => sprintf(__('Order by %s','dbem'),__('Start Date','dbem')),
|
1033 |
+
'booking_date' => sprintf(__('Order by %s','dbem'),__('Booking Date','dbem'))
|
1034 |
+
));
|
1035 |
+
?>
|
1036 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
1037 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_bookings_default_orderby')) ? "selected='selected'" : ''; ?>>
|
1038 |
+
<?php echo $value; ?>
|
1039 |
+
</option>
|
1040 |
+
<?php endforeach; ?>
|
1041 |
+
</select>
|
1042 |
+
<select name="dbem_bookings_default_order" >
|
1043 |
+
<?php
|
1044 |
+
$ascending = __('Ascending','dbem');
|
1045 |
+
$descending = __('Descending','dbem');
|
1046 |
+
$order_options = apply_filters('em_settings_bookings_default_order_ddm', array(
|
1047 |
+
'ASC' => __('Ascending','dbem'),
|
1048 |
+
'DESC' => __('Descending','dbem')
|
1049 |
+
));
|
1050 |
+
?>
|
1051 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
1052 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_bookings_default_order')) ? "selected='selected'" : ''; ?>>
|
1053 |
+
<?php echo $value; ?>
|
1054 |
+
</option>
|
1055 |
+
<?php endforeach; ?>
|
1056 |
+
</select>
|
1057 |
+
</td>
|
1058 |
+
</tr>
|
1059 |
+
<tr><td colspan="2"><h4><?php echo _e('Front-end management pages','dbem'); ?></h4></td></tr>
|
1060 |
+
<tr><td colspan="2"><?php echo _e('Users can create and edit events and locations, as well as managing bookings for their events.','dbem'); ?></td></tr>
|
1061 |
+
<tr>
|
1062 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Edit events','dbem')); ?></td>
|
1063 |
+
<td>
|
1064 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_edit_events_page', 'selected'=>get_option('dbem_edit_events_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1065 |
+
<br />
|
1066 |
+
<em><?php echo sprintf(__('Users can view, add and edit their %s on this page.','dbem'),__('events','dbem')); ?></em>
|
1067 |
+
</td>
|
1068 |
+
</tr>
|
1069 |
+
<tr>
|
1070 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Edit locations','dbem')); ?></td>
|
1071 |
+
<td>
|
1072 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_edit_locations_page', 'selected'=>get_option('dbem_edit_locations_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1073 |
+
<br />
|
1074 |
+
<em><?php echo sprintf(__('Users can view, add and edit their %s on this page.','dbem'),__('locations','dbem')); ?></em>
|
1075 |
+
</td>
|
1076 |
+
</tr>
|
1077 |
+
<tr>
|
1078 |
+
<td><?php echo sprintf(__( '%s page', 'dbem' ),__('Manage bookings','dbem')); ?></td>
|
1079 |
+
<td>
|
1080 |
+
<?php wp_dropdown_pages(array('name'=>'dbem_edit_bookings_page', 'selected'=>get_option('dbem_edit_bookings_page'), 'show_option_none'=>'['.__('None', 'dbem').']' )); ?>
|
1081 |
+
<br />
|
1082 |
+
<em><?php _e('Users can manage bookings for their events on this page.','dbem'); ?></em>
|
1083 |
+
</td>
|
1084 |
+
</tr>
|
1085 |
+
<?php echo $save_button; ?>
|
1086 |
+
</table>
|
1087 |
+
</div> <!-- . inside -->
|
1088 |
+
</div> <!-- .postbox -->
|
1089 |
+
|
1090 |
+
<?php do_action('em_options_page_footer_pages'); ?>
|
1091 |
+
|
1092 |
+
</div> <!-- .em-menu-pages -->
|
1093 |
+
|
1094 |
+
<!-- FORMAT OPTIONS -->
|
1095 |
+
<div class="em-menu-formats em-menu-group" style="display:none;">
|
1096 |
+
<div class="postbox " >
|
1097 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Events', 'dbem' ); ?> </span></h3>
|
1098 |
+
<div class="inside">
|
1099 |
+
<table class="form-table">
|
1100 |
+
<tr><td colspan="2">
|
1101 |
+
<strong><?php echo sprintf(__('%s Page','dbem'),__('Events','dbem')); ?></strong>
|
1102 |
+
<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>
|
1103 |
+
</td></tr>
|
1104 |
+
<?php
|
1105 |
+
$grouby_modes = array(0=>__('None','dbem'), 'yearly'=>__('Yearly','dbem'), 'monthly'=>__('Monthly','dbem'), 'weekly'=>__('Weekly','dbem'), 'daily'=>__('Daily','dbem'));
|
1106 |
+
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'));
|
1107 |
+
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'));
|
1108 |
+
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' ) );
|
1109 |
+
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 );
|
1110 |
+
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' ) );
|
1111 |
+
em_options_input_text ( __( 'No events message', 'dbem' ), 'dbem_no_events_message', __( 'The message displayed when no events are available.', 'dbem' ) );
|
1112 |
+
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' ) );
|
1113 |
+
?>
|
1114 |
+
<tr><td><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1115 |
+
<?php
|
1116 |
+
if( EM_MS_GLOBAL ){
|
1117 |
+
em_options_input_text ( __( 'Single event page title format', 'dbem' ), 'dbem_event_page_title_format', __( 'The format of a single event page title.', 'dbem' ).$events_placeholder_tip );
|
1118 |
+
}
|
1119 |
+
em_options_textarea ( __( 'Default single event format', 'dbem' ), 'dbem_single_event_format', __( 'The format of a single event page.', 'dbem' ).$events_placeholder_tip );
|
1120 |
+
echo $save_button;
|
1121 |
+
?>
|
1122 |
+
</table>
|
1123 |
+
</div> <!-- . inside -->
|
1124 |
+
</div> <!-- .postbox -->
|
1125 |
+
|
1126 |
+
<div class="postbox " >
|
1127 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Search Form', 'dbem' ); ?> </span></h3>
|
1128 |
+
<div class="inside">
|
1129 |
+
<table class="form-table">
|
1130 |
+
<?php
|
1131 |
+
em_options_input_text ( __( 'Search button text', 'dbem' ), 'dbem_serach_form_submit' );
|
1132 |
+
em_options_radio_binary ( __( 'Show text search?', 'dbem' ), 'dbem_search_form_text', '' );
|
1133 |
+
em_options_input_text ( __( 'Text search label', 'dbem' ), 'dbem_search_form_text_label', __('Appears within the input box.','dbem') );
|
1134 |
+
em_options_radio_binary ( __( 'Show date range?', 'dbem' ), 'dbem_search_form_dates', '' );
|
1135 |
+
em_options_radio_binary ( __( 'Show categories?', 'dbem' ), 'dbem_search_form_categories', '' );
|
1136 |
+
em_options_input_text ( __( 'Categories label', 'dbem' ), 'dbem_search_form_categories_label', __('Appears as the first default search option.','dbem') );
|
1137 |
+
em_options_radio_binary ( __( 'Show countries?', 'dbem' ), 'dbem_search_form_countries', '' );
|
1138 |
+
em_options_input_text ( __( 'All countries text', 'dbem' ), 'dbem_search_form_countries_label', __('Appears as the first default search option.','dbem') );
|
1139 |
+
em_options_radio_binary ( __( 'Show regions?', 'dbem' ), 'dbem_search_form_regions', '' );
|
1140 |
+
em_options_input_text ( __( 'All regions text', 'dbem' ), 'dbem_search_form_regions_label', __('Appears as the first default search option.','dbem') );
|
1141 |
+
em_options_radio_binary ( __( 'Show states?', 'dbem' ), 'dbem_search_form_states', '' );
|
1142 |
+
em_options_input_text ( __( 'All states text', 'dbem' ), 'dbem_search_form_states_label', __('Appears as the first default search option.','dbem') );
|
1143 |
+
em_options_radio_binary ( __( 'Show towns/cities?', 'dbem' ), 'dbem_search_form_towns', '' );
|
1144 |
+
em_options_input_text ( __( 'All towns/cities text', 'dbem' ), 'dbem_search_form_towns_label', __('Appears as the first default search option.','dbem') );
|
1145 |
+
echo $save_button;
|
1146 |
+
?>
|
1147 |
+
</table>
|
1148 |
+
</div> <!-- . inside -->
|
1149 |
+
</div> <!-- .postbox -->
|
1150 |
+
|
1151 |
+
<div class="postbox " >
|
1152 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Date/Time', 'dbem' ); ?> </span></h3>
|
1153 |
+
<div class="inside">
|
1154 |
+
<p><?php echo sprintf(__('Date and Time formats follow the <a href="%s">WordPress time formatting conventions</a>', 'dbem'), 'http://codex.wordpress.org/Formatting_Date_and_Time'); ?></p>
|
1155 |
+
<table class="form-table">
|
1156 |
+
<?php
|
1157 |
+
em_options_input_text ( __( 'Date Format', 'dbem' ), 'dbem_date_format', sprintf(__('For use with the %s placeholder'),'<code>#_EVENTDATES</code>') );
|
1158 |
+
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') );
|
1159 |
+
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')) );
|
1160 |
+
em_options_input_text ( __( 'Time Format', 'dbem' ), 'dbem_time_format', sprintf(__('For use with the %s placeholder'),'<code>#_EVENTTIMES</code>') );
|
1161 |
+
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')) );
|
1162 |
+
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>') );
|
1163 |
+
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' ) );
|
1164 |
+
echo $save_button;
|
1165 |
+
?>
|
1166 |
+
</table>
|
1167 |
+
</div> <!-- . inside -->
|
1168 |
+
</div> <!-- .postbox -->
|
1169 |
+
|
1170 |
+
<div class="postbox " >
|
1171 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Calendar', 'dbem' ); ?></span></h3>
|
1172 |
+
<div class="inside">
|
1173 |
+
<table class="form-table">
|
1174 |
+
<?php
|
1175 |
+
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' ) );
|
1176 |
+
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' ) );
|
1177 |
+
?>
|
1178 |
+
<tr><td colspan="2"><strong><?php _e('Small Calendar','dbem'); ?></strong></td></tr>
|
1179 |
+
<?php
|
1180 |
+
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 );
|
1181 |
+
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' ) );
|
1182 |
+
em_options_radio_binary( __( 'Abbreviated weekdays', 'dbem' ), 'dbem_small_calendar_abbreviated_weekdays', __( 'The calendar headings uses abbreviated weekdays') );
|
1183 |
+
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 );
|
1184 |
+
?>
|
1185 |
+
<tr><td colspan="2"><strong><?php _e('Full Calendar','dbem'); ?></strong></td></tr>
|
1186 |
+
<?php
|
1187 |
+
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 );
|
1188 |
+
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') );
|
1189 |
+
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);
|
1190 |
+
?>
|
1191 |
+
<tr><td colspan="2"><strong><?php echo __('Calendar Day Event List Settings','dbem'); ?></strong></td></tr>
|
1192 |
+
<tr valign="top" id='dbem_display_calendar_orderby_row'>
|
1193 |
+
<th scope="row"><?php _e('Default event list ordering','dbem'); ?></th>
|
1194 |
+
<td>
|
1195 |
+
<select name="dbem_display_calendar_orderby" >
|
1196 |
+
<?php
|
1197 |
+
$orderby_options = apply_filters('dbem_display_calendar_orderby_ddm', array(
|
1198 |
+
'event_name,event_start_time' => __('Order by event name, then event start time','dbem'),
|
1199 |
+
'event_start_time,event_name' => __('Order by event start time, then event name','dbem')
|
1200 |
+
));
|
1201 |
+
?>
|
1202 |
+
<?php foreach($orderby_options as $key => $value) : ?>
|
1203 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_display_calendar_orderby')) ? "selected='selected'" : ''; ?>>
|
1204 |
+
<?php echo $value; ?>
|
1205 |
+
</option>
|
1206 |
+
<?php endforeach; ?>
|
1207 |
+
</select>
|
1208 |
+
<select name="dbem_display_calendar_order" >
|
1209 |
+
<?php
|
1210 |
+
$ascending = __('Ascending','dbem');
|
1211 |
+
$descending = __('Descending','dbem');
|
1212 |
+
$order_options = apply_filters('dbem_display_calendar_order_ddm', array(
|
1213 |
+
'ASC' => __('All Ascending','dbem'),
|
1214 |
+
'DESC,ASC' => "$descending, $ascending",
|
1215 |
+
'DESC,DESC' => "$descending, $descending",
|
1216 |
+
'DESC' => __('All Descending','dbem')
|
1217 |
+
));
|
1218 |
+
?>
|
1219 |
+
<?php foreach( $order_options as $key => $value) : ?>
|
1220 |
+
<option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_display_calendar_order')) ? "selected='selected'" : ''; ?>>
|
1221 |
+
<?php echo $value; ?>
|
1222 |
+
</option>
|
1223 |
+
<?php endforeach; ?>
|
1224 |
+
</select>
|
1225 |
+
<br/>
|
1226 |
+
<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>
|
1227 |
+
</td>
|
1228 |
+
</tr>
|
1229 |
+
<?php
|
1230 |
+
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' ) );
|
1231 |
+
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' ) );
|
1232 |
+
?>
|
1233 |
+
<tr><td><strong><?php echo sprintf(__('iCal Feed Settings','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1234 |
+
<?php
|
1235 |
+
em_options_input_text ( __( 'iCal Title', 'dbem' ), 'dbem_ical_description_format', __( 'The title that will appear in the calendar.', 'dbem' ).$events_placeholder_tip );
|
1236 |
+
em_options_input_text ( __( 'iCal Limit', 'dbem' ), 'dbem_ical_limit', __( 'Limits the number of future events shown (0 = unlimited).', 'dbem' ) );
|
1237 |
+
echo $save_button;
|
1238 |
+
?>
|
1239 |
+
</table>
|
1240 |
+
</div> <!-- . inside -->
|
1241 |
+
</div> <!-- .postbox -->
|
1242 |
+
|
1243 |
+
<?php if( get_option('dbem_locations_enabled') ): ?>
|
1244 |
+
<div class="postbox " >
|
1245 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Locations', 'dbem' ); ?> </span></h3>
|
1246 |
+
<div class="inside">
|
1247 |
+
<table class="form-table">
|
1248 |
+
<tr><td><strong><?php echo sprintf(__('%s Page','dbem'),__('Locations','dbem')); ?></strong></td></tr>
|
1249 |
+
<?php
|
1250 |
+
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')) );
|
1251 |
+
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 );
|
1252 |
+
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')) );
|
1253 |
+
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')) );
|
1254 |
+
?>
|
1255 |
+
<tr><td><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Location','dbem')); ?></strong></td></tr>
|
1256 |
+
<?php
|
1257 |
+
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 );
|
1258 |
+
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 );
|
1259 |
+
?>
|
1260 |
+
<tr><td><strong><?php echo sprintf(__('%s List Formats','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1261 |
+
<?php
|
1262 |
+
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' ) );
|
1263 |
+
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' ).$locations_placeholder_tip, '<code>#_LOCATIONNEXTEVENTS</code>, <code>#_LOCATIONPASTEVENTS</code>, <code>#_LOCATIONALLEVENTS</code>') );
|
1264 |
+
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' ) );
|
1265 |
+
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>') );
|
1266 |
+
echo $save_button;
|
1267 |
+
?>
|
1268 |
+
</table>
|
1269 |
+
</div> <!-- . inside -->
|
1270 |
+
</div> <!-- .postbox -->
|
1271 |
+
<?php endif; ?>
|
1272 |
+
|
1273 |
+
<?php if( get_option('dbem_categories_enabled') && !(EM_MS_GLOBAL && !is_main_site()) ): ?>
|
1274 |
+
<div class="postbox " >
|
1275 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Categories', 'dbem' ); ?> </span></h3>
|
1276 |
+
<div class="inside">
|
1277 |
+
<table class="form-table">
|
1278 |
+
<tr><td><strong><?php echo sprintf(__('%s Page','dbem'),__('Categories','dbem')); ?></strong></td></tr>
|
1279 |
+
<?php
|
1280 |
+
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')) );
|
1281 |
+
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 );
|
1282 |
+
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')) );
|
1283 |
+
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')) );
|
1284 |
+
?>
|
1285 |
+
<tr><td><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Category','dbem')); ?></strong></td></tr>
|
1286 |
+
<?php
|
1287 |
+
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 );
|
1288 |
+
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 );
|
1289 |
+
?>
|
1290 |
+
<tr><td><strong><?php echo sprintf(__('%s List Formats','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1291 |
+
<?php
|
1292 |
+
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' ) );
|
1293 |
+
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' ).$categories_placeholder_tip, '<code>#_CATEGORYPASTEVENTS</code>, <code>#_CATEGORYNEXTEVENTS</code>, <code>#_CATEGORYALLEVENTS</code>') );
|
1294 |
+
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' ) );
|
1295 |
+
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>') );
|
1296 |
+
echo $save_button;
|
1297 |
+
?>
|
1298 |
+
</table>
|
1299 |
+
</div> <!-- . inside -->
|
1300 |
+
</div> <!-- .postbox -->
|
1301 |
+
<?php endif; ?>
|
1302 |
+
|
1303 |
+
<?php if( get_option('dbem_tags_enabled') ): ?>
|
1304 |
+
<div class="postbox " >
|
1305 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Tags', 'dbem' ); ?> </span></h3>
|
1306 |
+
<div class="inside">
|
1307 |
+
<table class="form-table">
|
1308 |
+
<tr><td><strong><?php echo sprintf(__('Single %s Page','dbem'),__('Tag','dbem')); ?></strong></td></tr>
|
1309 |
+
<?php
|
1310 |
+
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 );
|
1311 |
+
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 );
|
1312 |
+
?>
|
1313 |
+
<tr><td><strong><?php echo sprintf(__('%s List Formats','dbem'),__('Event','dbem')); ?></strong></td></tr>
|
1314 |
+
<?php
|
1315 |
+
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' ) );
|
1316 |
+
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 );
|
1317 |
+
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' ) );
|
1318 |
+
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' ) );
|
1319 |
+
echo $save_button;
|
1320 |
+
?>
|
1321 |
+
</table>
|
1322 |
+
</div> <!-- . inside -->
|
1323 |
+
</div> <!-- .postbox -->
|
1324 |
+
<?php endif; ?>
|
1325 |
+
|
1326 |
+
<div class="postbox " >
|
1327 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'RSS', 'dbem' ); ?> </span></h3>
|
1328 |
+
<div class="inside">
|
1329 |
+
<table class="form-table">
|
1330 |
+
<?php
|
1331 |
+
em_options_input_text ( __( 'RSS main title', 'dbem' ), 'dbem_rss_main_title', __( 'The main title of your RSS events feed.', 'dbem' ).$events_placeholder_tip );
|
1332 |
+
em_options_input_text ( __( 'RSS main description', 'dbem' ), 'dbem_rss_main_description', __( 'The main description of your RSS events feed.', 'dbem' ) );
|
1333 |
+
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 );
|
1334 |
+
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 );
|
1335 |
+
echo $save_button;
|
1336 |
+
?>
|
1337 |
+
</table>
|
1338 |
+
</div> <!-- . inside -->
|
1339 |
+
</div> <!-- .postbox -->
|
1340 |
+
|
1341 |
+
<div class="postbox " >
|
1342 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Maps', 'dbem' ); ?> </span></h3>
|
1343 |
+
<div class="inside">
|
1344 |
+
<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/'); ?>
|
1345 |
+
<table class='form-table'>
|
1346 |
+
<?php $gmap_is_active = get_option ( 'dbem_gmap_is_active' ); ?>
|
1347 |
+
<tr valign="top">
|
1348 |
+
<th scope="row"><?php _e ( 'Enable Google Maps integration?', 'dbem' ); ?></th>
|
1349 |
+
<td>
|
1350 |
+
<?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'":''; ?> />
|
1351 |
+
<?php _e ( 'No' ); ?> <input name="dbem_gmap_is_active" type="radio" value="0" <?php echo ($gmap_is_active) ? '':"checked='checked'"; ?> /><br />
|
1352 |
+
<em><?php _e ( 'Check this option to enable Goggle Map integration.', 'dbem' )?></em>
|
1353 |
+
</td>
|
1354 |
+
</tr>
|
1355 |
+
<tr><td colspan="2">
|
1356 |
+
<strong><?php _e('Global Map Format','dbem'); ?></strong>
|
1357 |
+
<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>
|
1358 |
+
</td></tr>
|
1359 |
+
<?php
|
1360 |
+
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 );
|
1361 |
+
?>
|
1362 |
+
<tr><td colspan="2">
|
1363 |
+
<strong><?php _e('Single Location/Event Map Format','dbem'); ?></strong>
|
1364 |
+
<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>
|
1365 |
+
</td></tr>
|
1366 |
+
<?php
|
1367 |
+
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 );
|
1368 |
+
echo $save_button;
|
1369 |
+
?>
|
1370 |
+
</table>
|
1371 |
+
</div> <!-- . inside -->
|
1372 |
+
</div> <!-- .postbox -->
|
1373 |
+
|
1374 |
+
<?php do_action('em_options_page_footer_formats'); ?>
|
1375 |
+
|
1376 |
+
</div> <!-- .em-menu-formats -->
|
1377 |
+
|
1378 |
+
<?php if( get_option('dbem_rsvp_enabled') ): ?>
|
1379 |
+
<!-- BOOKING OPTIONS -->
|
1380 |
+
<div class="em-menu-bookings em-menu-group" style="display:none;">
|
1381 |
+
|
1382 |
+
<div class="postbox " >
|
1383 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('General','dbem')); ?> </span></h3>
|
1384 |
+
<div class="inside">
|
1385 |
+
<table class='form-table'>
|
1386 |
+
<?php
|
1387 |
+
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' ) );
|
1388 |
+
em_options_radio_binary ( __( 'Approval Required?', 'dbem' ), 'dbem_bookings_approval', __( 'Bookings will not be confirmed until the event administrator approves it.', 'dbem' ) );
|
1389 |
+
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' ) );
|
1390 |
+
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' ) );
|
1391 |
+
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' ) );
|
1392 |
+
em_options_radio_binary ( __( 'Allow double bookings?', 'dbem' ), 'dbem_bookings_double', __( 'If enabled, users can book an event more than once.', 'dbem' ) );
|
1393 |
+
echo $save_button;
|
1394 |
+
?>
|
1395 |
+
</table>
|
1396 |
+
</div> <!-- . inside -->
|
1397 |
+
</div> <!-- .postbox -->
|
1398 |
+
|
1399 |
+
<div class="postbox " >
|
1400 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('Pricing','dbem')); ?> </span></h3>
|
1401 |
+
<div class="inside">
|
1402 |
+
<table class='form-table'>
|
1403 |
+
<?php
|
1404 |
+
/* Tax & Currency */
|
1405 |
+
em_options_select ( __( 'Currency', 'dbem' ), 'dbem_bookings_currency', em_get_currencies()->names, __( 'Choose your currency for displaying event pricing.', 'dbem' ) );
|
1406 |
+
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>' );
|
1407 |
+
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>' );
|
1408 |
+
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>');
|
1409 |
+
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' ) );
|
1410 |
+
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' ) );
|
1411 |
+
echo $save_button;
|
1412 |
+
?>
|
1413 |
+
</table>
|
1414 |
+
</div> <!-- . inside -->
|
1415 |
+
</div> <!-- .postbox -->
|
1416 |
+
|
1417 |
+
<div class="postbox " >
|
1418 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e( 'Customize Feedback Messages', 'dbem' ); ?> </span></h3>
|
1419 |
+
<div class="inside">
|
1420 |
+
<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>
|
1421 |
+
<table class='form-table'>
|
1422 |
+
<tr><td colspan='2'><h4><?php _e('My Bookings messages','dbem') ?></h4></td></tr>
|
1423 |
+
<?php
|
1424 |
+
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' ) );
|
1425 |
+
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' ) );
|
1426 |
+
?>
|
1427 |
+
<tr><td colspan='2'><h4><?php _e('Booking form texts/messages','dbem') ?></h4></td></tr>
|
1428 |
+
<?php
|
1429 |
+
em_options_input_text ( __( 'Bookings disabled', 'dbem' ), 'dbem_bookings_form_msg_disabled', __( 'An event with no bookings.', 'dbem' ) );
|
1430 |
+
em_options_input_text ( __( 'Bookings closed', 'dbem' ), 'dbem_bookings_form_msg_closed', __( 'Bookings have closed (e.g. event has started).', 'dbem' ) );
|
1431 |
+
em_options_input_text ( __( 'Fully booked', 'dbem' ), 'dbem_bookings_form_msg_full', __( 'Event is fully booked.', 'dbem' ) );
|
1432 |
+
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' ) );
|
1433 |
+
em_options_input_text ( __( 'Manage bookings link text', 'dbem' ), 'dbem_bookings_form_msg_bookings_link', __( 'Link text used for link to user bookings.', 'dbem' ) );
|
1434 |
+
?>
|
1435 |
+
<tr><td colspan='2'><h4><?php _e('Booking form feedback messages','dbem') ?></h4></td></tr>
|
1436 |
+
<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>
|
1437 |
+
<?php
|
1438 |
+
em_options_input_text ( __( 'Successful booking', 'dbem' ), 'dbem_booking_feedback', __( 'When a booking is registered and confirmed.', 'dbem' ) );
|
1439 |
+
em_options_input_text ( __( 'Successful pending booking', 'dbem' ), 'dbem_booking_feedback_pending', __( 'When a booking is registered but pending.', 'dbem' ) );
|
1440 |
+
em_options_input_text ( __( 'Not enough spaces', 'dbem' ), 'dbem_booking_feedback_full', __( 'When a booking cannot be made due to lack of spaces.', 'dbem' ) );
|
1441 |
+
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' ) );
|
1442 |
+
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' ) );
|
1443 |
+
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' ) );
|
1444 |
+
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' ) );
|
1445 |
+
em_options_input_text ( __( 'Already booked', 'dbem' ), 'dbem_booking_feedback_already_booked', __( 'If the user made a previous booking and cannot double-book.', 'dbem' ) );
|
1446 |
+
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');
|
1447 |
+
?>
|
1448 |
+
<tr><td colspan='2'><h4><?php _e('Booking button feedback messages','dbem') ?></h4></td></tr>
|
1449 |
+
<tr><td colspan='2'><?php echo sprintf(__('When the %s placeholder, the below texts will be used.','dbem'),'<code>#_BOOKINGBUTTON</code>'); ?></td></tr>
|
1450 |
+
<?php
|
1451 |
+
em_options_input_text ( __( 'User can book', 'dbem' ), 'dbem_booking_button_msg_book', '');
|
1452 |
+
em_options_input_text ( __( 'Booking in progress', 'dbem' ), 'dbem_booking_button_msg_booking', '');
|
1453 |
+
em_options_input_text ( __( 'Booking complete', 'dbem' ), 'dbem_booking_button_msg_booked', '');
|
1454 |
+
em_options_input_text ( __( 'Booking error', 'dbem' ), 'dbem_booking_button_msg_error', '');
|
1455 |
+
em_options_input_text ( __( 'Event fully booked', 'dbem' ), 'dbem_booking_button_msg_full', '');
|
1456 |
+
em_options_input_text ( __( 'Cancel', 'dbem' ), 'dbem_booking_button_msg_cancel', '');
|
1457 |
+
em_options_input_text ( __( 'Cancelation in progress', 'dbem' ), 'dbem_booking_button_msg_canceling', '');
|
1458 |
+
em_options_input_text ( __( 'Cancelation complete', 'dbem' ), 'dbem_booking_button_msg_cancelled', '');
|
1459 |
+
em_options_input_text ( __( 'Cancelation error', 'dbem' ), 'dbem_booking_button_msg_cancel_error', '');
|
1460 |
+
|
1461 |
+
echo $save_button;
|
1462 |
+
?>
|
1463 |
+
</table>
|
1464 |
+
</div> <!-- . inside -->
|
1465 |
+
</div> <!-- .postbox -->
|
1466 |
+
|
1467 |
+
<div class="postbox " >
|
1468 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('Booking Form','dbem')); ?> </span></h3>
|
1469 |
+
<div class="inside">
|
1470 |
+
<table class='form-table'>
|
1471 |
+
<?php
|
1472 |
+
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' ) );
|
1473 |
+
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>') );
|
1474 |
+
do_action('em_options_booking_form_options');
|
1475 |
+
echo $save_button;
|
1476 |
+
?>
|
1477 |
+
</table>
|
1478 |
+
</div> <!-- . inside -->
|
1479 |
+
</div> <!-- .postbox -->
|
1480 |
+
|
1481 |
+
<div class="postbox " >
|
1482 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php echo sprintf(__( '%s Options', 'dbem' ),__('Ticket','dbem')); ?> </span></h3>
|
1483 |
+
<div class="inside">
|
1484 |
+
<table class='form-table'>
|
1485 |
+
<?php
|
1486 |
+
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' ) );
|
1487 |
+
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' ) );
|
1488 |
+
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' ) );
|
1489 |
+
em_options_radio_binary ( __( 'Show multiple tickets if logged out?', 'dbem' ), 'dbem_bookings_tickets_show_loggedout', __( 'If logged out, a user will be asked to register in order to book. However, we can show available tickets if you have more than one ticket.', 'dbem' ) );
|
1490 |
+
$ticket_orders = array(
|
1491 |
+
'ticket_price DESC, ticket_name ASC'=>__('Ticket Price (Descending)','dbem'),
|
1492 |
+
'ticket_price ASC, ticket_name ASC'=>__('Ticket Price (Ascending)','dbem'),
|
1493 |
+
'ticket_name ASC, ticket_price DESC'=>__('Ticket Name (Ascending)','dbem'),
|
1494 |
+
'ticket_name DESC, ticket_price DESC'=>__('Ticket Name (Descending)','dbem')
|
1495 |
+
);
|
1496 |
+
em_options_select ( __( 'Order Tickets By', 'dbem' ), 'dbem_bookings_tickets_orderby', $ticket_orders, __( 'Choose which order your tickets appear.', 'dbem' ) );
|
1497 |
+
echo $save_button;
|
1498 |
+
?>
|
1499 |
+
</table>
|
1500 |
+
</div> <!-- . inside -->
|
1501 |
+
</div> <!-- .postbox -->
|
1502 |
+
|
1503 |
+
<div class="postbox " >
|
1504 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e('No-User Booking Mode','dbem'); ?> </span></h3>
|
1505 |
+
<div class="inside">
|
1506 |
+
<table class='form-table'>
|
1507 |
+
<tr><td colspan='2'>
|
1508 |
+
<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>
|
1509 |
+
<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>
|
1510 |
+
<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>
|
1511 |
+
</td></tr>
|
1512 |
+
<?php
|
1513 |
+
em_options_radio_binary ( __( 'Enable No-User Booking Mode?', 'dbem' ), 'dbem_bookings_registration_disable', __( 'This disables user registrations for bookings.', 'dbem' ) );
|
1514 |
+
$current_user = array();
|
1515 |
+
if( get_option('dbem_bookings_registration_user') ){
|
1516 |
+
$user = get_user_by('id',get_option('dbem_bookings_registration_user'));
|
1517 |
+
$current_user[$user->ID] = $user->display_name;
|
1518 |
+
}
|
1519 |
+
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' ) );
|
1520 |
+
echo $save_button;
|
1521 |
+
?>
|
1522 |
+
</table>
|
1523 |
+
</div> <!-- . inside -->
|
1524 |
+
</div> <!-- .postbox -->
|
1525 |
+
|
1526 |
+
<?php do_action('em_options_page_footer_bookings'); ?>
|
1527 |
+
|
1528 |
+
</div> <!-- .em-menu-bookings -->
|
1529 |
+
<?php endif; ?>
|
1530 |
+
|
1531 |
+
<!-- EMAIL OPTIONS -->
|
1532 |
+
<div class="em-menu-emails em-menu-group" style="display:none;">
|
1533 |
+
|
1534 |
+
<?php if ( !is_multisite() ) { em_admin_option_box_email(); } ?>
|
1535 |
+
|
1536 |
+
<?php if( get_option('dbem_rsvp_enabled') ): ?>
|
1537 |
+
<div class="postbox " >
|
1538 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Booking Email Templates', 'dbem' ); ?> </span></h3>
|
1539 |
+
<div class="inside">
|
1540 |
+
<table class='form-table'>
|
1541 |
+
<?php
|
1542 |
+
$email_subject_tip = __('You can disable this email by leaving the subject blank.','dbem');
|
1543 |
+
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') );
|
1544 |
+
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' ) );
|
1545 |
+
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' ) );
|
1546 |
+
?>
|
1547 |
+
<tr><td colspan='2'><h4><?php _e('Contact person booking confirmed','dbem') ?></h4></td></tr>
|
1548 |
+
<tr><td colspan='2'><?php echo __('An email will be sent to the event contact when a booking is first made.','dbem').$bookings_placeholder_tip ?></td></tr>
|
1549 |
+
<?php
|
1550 |
+
em_options_input_text ( __( 'Contact person email subject', 'dbem' ), 'dbem_bookings_contact_email_subject', $email_subject_tip );
|
1551 |
+
em_options_textarea ( __( 'Contact person email', 'dbem' ), 'dbem_bookings_contact_email_body', '' );
|
1552 |
+
?>
|
1553 |
+
<tr><td colspan='2'><h4><?php _e('Contact person booking cancelled','dbem') ?></h4></td></tr>
|
1554 |
+
<tr><td colspan='2'><?php echo __('An email will be sent to the event contact if someone cancels their booking.','dbem').$bookings_placeholder_tip ?></td></tr>
|
1555 |
+
<?php
|
1556 |
+
em_options_input_text ( __( 'Contact person cancellation subject', 'dbem' ), 'dbem_contactperson_email_cancelled_subject', $email_subject_tip );
|
1557 |
+
em_options_textarea ( __( 'Contact person cancellation email', 'dbem' ), 'dbem_contactperson_email_cancelled_body', '' );
|
1558 |
+
?>
|
1559 |
+
<tr><td colspan='2'><h4><?php _e('Confirmed booking email','dbem') ?></h4></td></tr>
|
1560 |
+
<tr><td colspan='2'><?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 ?></td></tr>
|
1561 |
+
<?php
|
1562 |
+
em_options_input_text ( __( 'Booking confirmed email subject', 'dbem' ), 'dbem_bookings_email_confirmed_subject', $email_subject_tip );
|
1563 |
+
em_options_textarea ( __( 'Booking confirmed email', 'dbem' ), 'dbem_bookings_email_confirmed_body', '' );
|
1564 |
+
?>
|
1565 |
+
<tr><td colspan='2'><h4><?php _e('Pending booking email','dbem') ?></h4></td></tr>
|
1566 |
+
<tr><td colspan='2'><?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 ?></td></tr>
|
1567 |
+
<?php
|
1568 |
+
em_options_input_text ( __( 'Booking pending email subject', 'dbem' ), 'dbem_bookings_email_pending_subject', $email_subject_tip);
|
1569 |
+
em_options_textarea ( __( 'Booking pending email', 'dbem' ), 'dbem_bookings_email_pending_body','') ;
|
1570 |
+
?>
|
1571 |
+
<tr><td colspan='2'><h4><?php _e('Rejected booking email','dbem') ?></h4></td></tr>
|
1572 |
+
<tr><td colspan='2'><?php echo __( 'This will be sent automatically when a booking is rejected. Not relevant if bookings don\'t require approval.', 'dbem' ).$bookings_placeholder_tip ?></td></tr>
|
1573 |
+
<?php
|
1574 |
+
em_options_input_text ( __( 'Booking rejected email subject', 'dbem' ), 'dbem_bookings_email_rejected_subject', $email_subject_tip );
|
1575 |
+
em_options_textarea ( __( 'Booking rejected email', 'dbem' ), 'dbem_bookings_email_rejected_body', '' );
|
1576 |
+
?>
|
1577 |
+
<tr><td colspan='2'><h4><?php _e('Booking cancelled','dbem') ?></h4></td></tr>
|
1578 |
+
<tr><td colspan='2'><?php echo __('This will be sent when a user cancels their booking.','dbem').$bookings_placeholder_tip ?></td></tr>
|
1579 |
+
<?php
|
1580 |
+
em_options_input_text ( __( 'Booking cancelled email subject', 'dbem' ), 'dbem_bookings_email_cancelled_subject', $email_subject_tip );
|
1581 |
+
em_options_textarea ( __( 'Booking cancelled email', 'dbem' ), 'dbem_bookings_email_cancelled_body', '' );
|
1582 |
+
?>
|
1583 |
+
<?php echo $save_button; ?>
|
1584 |
+
</table>
|
1585 |
+
</div> <!-- . inside -->
|
1586 |
+
</div> <!-- .postbox -->
|
1587 |
+
<?php endif; ?>
|
1588 |
+
|
1589 |
+
<div class="postbox " >
|
1590 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Event Submission Templates', 'dbem' ); ?> </span></h3>
|
1591 |
+
<div class="inside">
|
1592 |
+
<table class='form-table'>
|
1593 |
+
<?php
|
1594 |
+
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') );
|
1595 |
+
?>
|
1596 |
+
<tr><td colspan='2'><strong><?php _e('Event Submitted','dbem') ?></strong></td></tr>
|
1597 |
+
<tr><td colspan='2'><?php echo __('An email will be sent to your administrator emails when an event is submitted and pending approval.','dbem').$bookings_placeholder_tip ?></td></tr>
|
1598 |
+
<?php
|
1599 |
+
em_options_input_text ( __( 'Event submitted subject', 'dbem' ), 'dbem_event_submitted_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1600 |
+
em_options_textarea ( __( 'Event submitted email', 'dbem' ), 'dbem_event_submitted_email_body', '' );
|
1601 |
+
?>
|
1602 |
+
<tr><td colspan='2'><strong><?php _e('Event Re-Submitted','dbem') ?></strong></td></tr>
|
1603 |
+
<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>
|
1604 |
+
<?php
|
1605 |
+
em_options_input_text ( __( 'Event resubmitted subject', 'dbem' ), 'dbem_event_resubmitted_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1606 |
+
em_options_textarea ( __( 'Event resubmitted email', 'dbem' ), 'dbem_event_resubmitted_email_body', '' );
|
1607 |
+
?>
|
1608 |
+
<tr><td colspan='2'><strong><?php _e('Event Published','dbem') ?></strong></td></tr>
|
1609 |
+
<tr><td colspan='2'><?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 ?></td></tr>
|
1610 |
+
<?php
|
1611 |
+
em_options_input_text ( __( 'Event published subject', 'dbem' ), 'dbem_event_published_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1612 |
+
em_options_textarea ( __( 'Event published email', 'dbem' ), 'dbem_event_published_email_body', '' );
|
1613 |
+
?>
|
1614 |
+
<tr><td colspan='2'><strong><?php _e('Event Approved','dbem') ?></strong></td></tr>
|
1615 |
+
<tr><td colspan='2'><?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 ?></td></tr>
|
1616 |
+
<?php
|
1617 |
+
em_options_input_text ( __( 'Event approved subject', 'dbem' ), 'dbem_event_approved_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1618 |
+
em_options_textarea ( __( 'Event approved email', 'dbem' ), 'dbem_event_approved_email_body', '' );
|
1619 |
+
?>
|
1620 |
+
<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>
|
1621 |
+
<?php
|
1622 |
+
em_options_input_text ( __( 'Event reapproved subject', 'dbem' ), 'dbem_event_reapproved_email_subject', __('If left blank, this email will not be sent.','dbem') );
|
1623 |
+
em_options_textarea ( __( 'Event reapproved email', 'dbem' ), 'dbem_event_reapproved_email_body', '' );
|
1624 |
+
?>
|
1625 |
+
<?php echo $save_button; ?>
|
1626 |
+
</table>
|
1627 |
+
</div> <!-- . inside -->
|
1628 |
+
</div> <!-- .postbox -->
|
1629 |
+
|
1630 |
+
<?php do_action('em_options_page_footer_emails'); ?>
|
1631 |
+
|
1632 |
+
</div><!-- .em-group-emails -->
|
1633 |
+
<?php /*
|
1634 |
+
<div class="postbox " >
|
1635 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Debug Modes', 'dbem' ); ?> </span></h3>
|
1636 |
+
<div class="inside">
|
1637 |
+
<table class='form-table'>
|
1638 |
+
<?php
|
1639 |
+
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' ) );
|
1640 |
+
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' ) );
|
1641 |
+
?>
|
1642 |
+
</table>
|
1643 |
+
</div> <!-- . inside -->
|
1644 |
+
</div> <!-- .postbox -->
|
1645 |
+
*/ ?>
|
1646 |
+
|
1647 |
+
<p class="submit">
|
1648 |
+
<input type="submit" id="dbem_options_submit" class="button-primary" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
|
1649 |
+
<input type="hidden" name="em-submitted" value="1" />
|
1650 |
+
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('events-manager-options'); ?>" />
|
1651 |
+
</p>
|
1652 |
+
|
1653 |
+
</div> <!-- .metabox-sortables -->
|
1654 |
+
</div> <!-- .postbox-container -->
|
1655 |
+
|
1656 |
+
</div> <!-- .metabox-holder -->
|
1657 |
+
</form>
|
1658 |
+
</div>
|
1659 |
+
<?php
|
1660 |
+
}
|
1661 |
+
|
1662 |
+
/**
|
1663 |
+
* Meta options box for image sizes. Shared in both MS and Normal options page, hence it's own function
|
1664 |
+
*/
|
1665 |
+
function em_admin_option_box_image_sizes(){
|
1666 |
+
global $save_button;
|
1667 |
+
?>
|
1668 |
+
<div class="postbox " >
|
1669 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Image Sizes', 'dbem' ); ?> </span></h3>
|
1670 |
+
<div class="inside">
|
1671 |
+
<table class='form-table'>
|
1672 |
+
<?php
|
1673 |
+
em_options_input_text ( __( 'Maximum width (px)', 'dbem' ), 'dbem_image_max_width', __( 'The maximum allowed width for images uploades', 'dbem' ) );
|
1674 |
+
em_options_input_text ( __( 'Minimum width (px)', 'dbem' ), 'dbem_image_min_width', __( 'The minimum allowed width for images uploades', 'dbem' ) );
|
1675 |
+
em_options_input_text ( __( 'Maximum height (px)', 'dbem' ), 'dbem_image_max_height', __( "The maximum allowed height for images uploaded, in pixels", 'dbem' ) );
|
1676 |
+
em_options_input_text ( __( 'Minimum height (px)', 'dbem' ), 'dbem_image_min_height', __( "The minimum allowed height for images uploaded, in pixels", 'dbem' ) );
|
1677 |
+
em_options_input_text ( __( 'Maximum size (bytes)', 'dbem' ), 'dbem_image_max_size', __( "The maximum allowed size for images uploaded, in bytes", 'dbem' ) );
|
1678 |
+
echo $save_button;
|
1679 |
+
?>
|
1680 |
+
</table>
|
1681 |
+
</div> <!-- . inside -->
|
1682 |
+
</div> <!-- .postbox -->
|
1683 |
+
<?php
|
1684 |
+
}
|
1685 |
+
|
1686 |
+
/**
|
1687 |
+
* Meta options box for email settings. Shared in both MS and Normal options page, hence it's own function
|
1688 |
+
*/
|
1689 |
+
function em_admin_option_box_email(){
|
1690 |
+
global $save_button;
|
1691 |
+
?>
|
1692 |
+
<div class="postbox " >
|
1693 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Email Settings', 'dbem' ); ?></span></h3>
|
1694 |
+
<div class="inside em-email-form">
|
1695 |
+
<p class="em-email-settings-check">
|
1696 |
+
<?php _e('Before you save your changes, you can quickly send yourself a test email by clicking this button.'); ?>
|
1697 |
+
<input type="button" id="em-admin-check-email" class="secondary-button" value="<?php _e('Test Email Settings','dbem'); ?>" />
|
1698 |
+
<input type="hidden" name="_check_email_nonce" value="<?php echo wp_create_nonce('check_email'); ?>" />
|
1699 |
+
<span id="em-email-settings-check-status"></span>
|
1700 |
+
</p>
|
1701 |
+
<table class="form-table">
|
1702 |
+
<?php
|
1703 |
+
em_options_input_text ( __( 'Notification sender name', 'dbem' ), 'dbem_mail_sender_name', __( "Insert the display name of the notification sender.", 'dbem' ) );
|
1704 |
+
em_options_input_text ( __( 'Notification sender address', 'dbem' ), 'dbem_mail_sender_address', __( "Insert the address of the notification sender.", 'dbem' ) );
|
1705 |
+
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' ) );
|
1706 |
+
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' ) );
|
1707 |
+
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' ) );
|
1708 |
+
?>
|
1709 |
+
<tbody class="em-email-settings-smtp">
|
1710 |
+
<?php
|
1711 |
+
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' ) );
|
1712 |
+
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' ) );
|
1713 |
+
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' ) );
|
1714 |
+
em_options_input_text ( __( 'SMTP username', 'dbem' ), 'dbem_smtp_username', __( "Insert the username to be used to access your SMTP server.", 'dbem' ) );
|
1715 |
+
em_options_input_password ( __( 'SMTP password', 'dbem' ), "dbem_smtp_password", __( "Insert the password to be used to access your SMTP server", 'dbem' ) );
|
1716 |
+
?>
|
1717 |
+
</tbody>
|
1718 |
+
<?php
|
1719 |
+
echo $save_button;
|
1720 |
+
?>
|
1721 |
+
</table>
|
1722 |
+
<script type="text/javascript" charset="utf-8">
|
1723 |
+
jQuery(document).ready(function($){
|
1724 |
+
$('#dbem_rsvp_mail_send_method_row select').change(function(){
|
1725 |
+
el = $(this);
|
1726 |
+
if( el.find(':selected').val() == 'smtp' ){
|
1727 |
+
$('.em-email-settings-smtp').show();
|
1728 |
+
}else{
|
1729 |
+
$('.em-email-settings-smtp').hide();
|
1730 |
+
}
|
1731 |
+
}).trigger('change');
|
1732 |
+
$('input#em-admin-check-email').click(function(e,el){
|
1733 |
+
var email_data = $('.em-email-form input').serialize();
|
1734 |
+
$.ajax({
|
1735 |
+
url: EM.ajaxurl,
|
1736 |
+
dataType: 'json',
|
1737 |
+
data: email_data+"&action=em_admin_test_email",
|
1738 |
+
success: function(data){
|
1739 |
+
if(data.result && data.message){
|
1740 |
+
$('#em-email-settings-check-status').css({'color':'green','display':'block'}).html(data.message);
|
1741 |
+
}else{
|
1742 |
+
var msg = (data.message) ? data.message:'Email not sent';
|
1743 |
+
$('#em-email-settings-check-status').css({'color':'red','display':'block'}).html(msg);
|
1744 |
+
}
|
1745 |
+
},
|
1746 |
+
error: function(){ $('#em-email-settings-check-status').css({'color':'red','display':'block'}).html('Server Error'); },
|
1747 |
+
beforeSend: function(){ $('input#em-admin-check-email').val('<?php _e('Checking...','dbem') ?>'); },
|
1748 |
+
complete: function(){ $('input#em-admin-check-email').val('<?php _e('Test Email Settings','dbem'); ?>'); }
|
1749 |
+
});
|
1750 |
+
});
|
1751 |
+
});
|
1752 |
+
</script>
|
1753 |
+
</div> <!-- . inside -->
|
1754 |
+
</div> <!-- .postbox -->
|
1755 |
+
<?php
|
1756 |
+
}
|
1757 |
+
|
1758 |
+
/**
|
1759 |
+
* Meta options box for user capabilities. Shared in both MS and Normal options page, hence it's own function
|
1760 |
+
*/
|
1761 |
+
function em_admin_option_box_caps(){
|
1762 |
+
global $save_button, $wpdb;
|
1763 |
+
?>
|
1764 |
+
<div class="postbox" >
|
1765 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'User Capabilities', 'dbem' ); ?></span></h3>
|
1766 |
+
<div class="inside">
|
1767 |
+
<table class="form-table">
|
1768 |
+
<tr><td colspan="2">
|
1769 |
+
<strong><?php _e('Warning: Changing these values may result in exposing previously hidden information to all users.', 'dbem')?></strong><br />
|
1770 |
+
</td></tr>
|
1771 |
+
<?php
|
1772 |
+
global $wp_roles;
|
1773 |
+
$cap_docs = array(
|
1774 |
+
sprintf(__('%s Capabilities','dbem'),__('Event','dbem')) => array(
|
1775 |
+
/* Event Capabilities */
|
1776 |
+
'publish_events' => sprintf(__('Users can publish %s and skip any admin approval','dbem'),__('events','dbem')),
|
1777 |
+
'delete_others_events' => sprintf(__('User can delete other users %s','dbem'),__('events','dbem')),
|
1778 |
+
'edit_others_events' => sprintf(__('User can edit other users %s','dbem'),__('events','dbem')),
|
1779 |
+
'delete_events' => sprintf(__('User can delete their own %s','dbem'),__('events','dbem')),
|
1780 |
+
'edit_events' => sprintf(__('User can create and edit %s','dbem'),__('events','dbem')),
|
1781 |
+
'read_private_events' => sprintf(__('User can view private %s','dbem'),__('events','dbem')),
|
1782 |
+
/*'read_events' => sprintf(__('User can view %s','dbem'),__('events','dbem')),*/
|
1783 |
+
),
|
1784 |
+
sprintf(__('%s Capabilities','dbem'),__('Recurring Event','dbem')) => array(
|
1785 |
+
/* Recurring Event Capabilties */
|
1786 |
+
'publish_recurring_events' => sprintf(__('Users can publish %s and skip any admin approval','dbem'),__('recurring events','dbem')),
|
1787 |
+
'delete_others_recurring_events' => sprintf(__('User can delete other users %s','dbem'),__('recurring events','dbem')),
|
1788 |
+
'edit_others_recurring_events' => sprintf(__('User can edit other users %s','dbem'),__('recurring events','dbem')),
|
1789 |
+
'delete_recurring_events' => sprintf(__('User can delete their own %s','dbem'),__('recurring events','dbem')),
|
1790 |
+
'edit_recurring_events' => sprintf(__('User can create and edit %s','dbem'),__('recurring events','dbem'))
|
1791 |
+
),
|
1792 |
+
sprintf(__('%s Capabilities','dbem'),__('Location','dbem')) => array(
|
1793 |
+
/* Location Capabilities */
|
1794 |
+
'publish_locations' => sprintf(__('Users can publish %s and skip any admin approval','dbem'),__('locations','dbem')),
|
1795 |
+
'delete_others_locations' => sprintf(__('User can delete other users %s','dbem'),__('locations','dbem')),
|
1796 |
+
'edit_others_locations' => sprintf(__('User can edit other users %s','dbem'),__('locations','dbem')),
|
1797 |
+
'delete_locations' => sprintf(__('User can delete their own %s','dbem'),__('locations','dbem')),
|
1798 |
+
'edit_locations' => sprintf(__('User can create and edit %s','dbem'),__('locations','dbem')),
|
1799 |
+
'read_private_locations' => sprintf(__('User can view private %s','dbem'),__('locations','dbem')),
|
1800 |
+
'read_others_locations' => __('User can use other user locations for their events.','dbem'),
|
1801 |
+
/*'read_locations' => sprintf(__('User can view %s','dbem'),__('locations','dbem')),*/
|
1802 |
+
),
|
1803 |
+
sprintf(__('%s Capabilities','dbem'),__('Other','dbem')) => array(
|
1804 |
+
/* Category Capabilities */
|
1805 |
+
'delete_event_categories' => sprintf(__('User can delete %s categories and tags.','dbem'),__('event','dbem')),
|
1806 |
+
'edit_event_categories' => sprintf(__('User can edit %s categories and tags.','dbem'),__('event','dbem')),
|
1807 |
+
/* Booking Capabilities */
|
1808 |
+
'manage_others_bookings' => __('User can manage other users individual bookings and event booking settings.','dbem'),
|
1809 |
+
'manage_bookings' => __('User can use and manage bookings with their events.','dbem'),
|
1810 |
+
'upload_event_images' => __('User can upload images along with their events and locations.','dbem')
|
1811 |
+
)
|
1812 |
+
);
|
1813 |
+
?>
|
1814 |
+
<tr><td colspan="2">
|
1815 |
+
<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>
|
1816 |
+
</td></tr>
|
1817 |
+
<tr><td colspan="2">
|
1818 |
+
<?php
|
1819 |
+
if( is_multisite() && is_network_admin() ){
|
1820 |
+
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') );
|
1821 |
+
}
|
1822 |
+
?>
|
1823 |
+
</td></tr>
|
1824 |
+
<tr><td colspan="2">
|
1825 |
+
<table class="em-caps-table" style="width:auto;" cellspacing="0" cellpadding="0">
|
1826 |
+
<thead>
|
1827 |
+
<tr>
|
1828 |
+
<td> </td>
|
1829 |
+
<?php
|
1830 |
+
$odd = 0;
|
1831 |
+
foreach(array_keys($cap_docs) as $capability_group){
|
1832 |
+
?><th class="<?php echo ( !is_int($odd/2) ) ? 'odd':''; ?>"><?php echo $capability_group ?></th><?php
|
1833 |
+
$odd++;
|
1834 |
+
}
|
1835 |
+
?>
|
1836 |
+
</tr>
|
1837 |
+
</thead>
|
1838 |
+
<tbody>
|
1839 |
+
<?php foreach($wp_roles->role_objects as $role): ?>
|
1840 |
+
<tr>
|
1841 |
+
<td class="cap"><strong><?php echo $role->name; ?></strong></td>
|
1842 |
+
<?php
|
1843 |
+
$odd = 0;
|
1844 |
+
foreach($cap_docs as $capability_group){
|
1845 |
+
?>
|
1846 |
+
<td class="<?php echo ( !is_int($odd/2) ) ? 'odd':''; ?>">
|
1847 |
+
<?php foreach($capability_group as $cap => $cap_help){ ?>
|
1848 |
+
<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"':''; ?> />
|
1849 |
+
<label for="<?php echo $role->name.'_'.$cap; ?>"><?php echo $cap; ?></label> <a href="#" title="<?php echo $cap_help; ?>">?</a>
|
1850 |
+
<br />
|
1851 |
+
<?php } ?>
|
1852 |
+
</td>
|
1853 |
+
<?php
|
1854 |
+
$odd++;
|
1855 |
+
}
|
1856 |
+
?>
|
1857 |
+
</tr>
|
1858 |
+
<?php endforeach; ?>
|
1859 |
+
</tbody>
|
1860 |
+
</table>
|
1861 |
+
</td></tr>
|
1862 |
+
<?php echo $save_button; ?>
|
1863 |
+
</table>
|
1864 |
+
</div> <!-- . inside -->
|
1865 |
+
</div> <!-- .postbox -->
|
1866 |
+
<?php
|
1867 |
+
}
|
1868 |
+
|
1869 |
+
function em_admin_option_box_uninstall(){
|
1870 |
+
global $save_button;
|
1871 |
+
if( is_multisite() ){
|
1872 |
+
$uninstall_url = admin_url().'network/admin.php?page=events-manager-options&action=uninstall&_wpnonce='.wp_create_nonce('em_uninstall_'.get_current_user_id().'_wpnonce');
|
1873 |
+
$reset_url = admin_url().'network/admin.php?page=events-manager-options&action=reset&_wpnonce='.wp_create_nonce('em_reset_'.get_current_user_id().'_wpnonce');
|
1874 |
+
$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');
|
1875 |
+
$check_devs = admin_url().'network/admin.php?page=events-manager-options&action=check_devs&_wpnonce='.wp_create_nonce('em_check_devs_wpnonce');
|
1876 |
+
}else{
|
1877 |
+
$uninstall_url = EM_ADMIN_URL.'&page=events-manager-options&action=uninstall&_wpnonce='.wp_create_nonce('em_uninstall_'.get_current_user_id().'_wpnonce');
|
1878 |
+
$reset_url = EM_ADMIN_URL.'&page=events-manager-options&action=reset&_wpnonce='.wp_create_nonce('em_reset_'.get_current_user_id().'_wpnonce');
|
1879 |
+
$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');
|
1880 |
+
$check_devs = EM_ADMIN_URL.'&page=events-manager-options&action=check_devs&_wpnonce='.wp_create_nonce('em_check_devs_wpnonce');
|
1881 |
+
}
|
1882 |
+
?>
|
1883 |
+
<div class="postbox" >
|
1884 |
+
<div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Admin Tools', 'dbem' ); ?> (<?php _e ( 'Advanced', 'dbem' ); ?>)</span></h3>
|
1885 |
+
<div class="inside">
|
1886 |
+
<h4 style="font-size:1.1em;"><?php _e ( 'Development Versions & Updates', 'dbem' ); ?></h4>
|
1887 |
+
<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!'); ?></p>
|
1888 |
+
<table class="form-table">
|
1889 |
+
<?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.') ); ?>
|
1890 |
+
</table>
|
1891 |
+
<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>
|
1892 |
+
<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>
|
1893 |
+
|
1894 |
+
<h4 style="font-size:1.1em;"><?php _e ( 'Uninstall/Reset', 'dbem' ); ?></h4>
|
1895 |
+
<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>
|
1896 |
+
<a href="<?php echo $uninstall_url; ?>" class="button-secondary"><?php _e('Uninstall','dbem'); ?></a>
|
1897 |
+
<a href="<?php echo $reset_url; ?>" class="button-secondary"><?php _e('Reset','dbem'); ?></a>
|
1898 |
+
|
1899 |
+
<?php do_action('em_options_page_panel_admin_tools'); ?>
|
1900 |
+
<?php echo $save_button; ?>
|
1901 |
+
</div>
|
1902 |
+
</div>
|
1903 |
+
<?php
|
1904 |
+
}
|
1905 |
Â
?>
|
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 |
-
?>
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 && empty($EM_Event->previous_status) ){
|
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,332 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
add_action('wp_enqueue_scripts','bp_em_enqueue_scripts',1);
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Delete events when you delete a user.
|
323 |
+
*/
|
324 |
+
function bp_em_remove_data( $user_id ) {
|
325 |
+
$EM_Events = EM_Events::get(array('scope'=>'all','owner'=>$user_id, 'status'=>false));
|
326 |
+
EM_Events::delete($EM_Events);
|
327 |
+
}
|
328 |
+
add_action( 'wpmu_delete_user', 'bp_em_remove_data', 1 );
|
329 |
+
add_action( 'delete_user', 'bp_em_remove_data', 1 );
|
330 |
+
|
331 |
+
define('EM_BP_LOADED',true); //so we know
|
332 |
+
?>
|
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_locate_template('templates/my-bookings.php',true);
|
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 |
+
_e( "Reschedule Events", 'dbem' )." '{$EM_Event->event_name}'";
|
48 |
+
}else{
|
49 |
+
_e ( "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,707 @@
|
|
1 |
-
<?php
|
2 |
-
class EM_Booking extends EM_Object{
|
3 |
-
//DB Fields
|
4 |
-
var $
|
5 |
-
var $event_id;
|
6 |
-
var $person_id;
|
7 |
-
var $
|
8 |
-
var $
|
9 |
-
var $
|
10 |
-
var $
|
11 |
-
var $
|
12 |
-
|
13 |
-
'
|
14 |
-
'
|
15 |
-
'
|
16 |
-
'
|
17 |
-
'
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
var $
|
24 |
-
var $
|
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 |
-
$result
|
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 |
Â
?>
|
1 |
+
<?php
|
2 |
+
class EM_Booking extends EM_Object{
|
3 |
+
//DB Fields
|
4 |
+
var $booking_id;
|
5 |
+
var $event_id;
|
6 |
+
var $person_id;
|
7 |
+
var $booking_price;
|
8 |
+
var $booking_spaces;
|
9 |
+
var $booking_comment;
|
10 |
+
var $booking_status = false;
|
11 |
+
var $booking_meta = array();
|
12 |
+
var $fields = array(
|
13 |
+
'booking_id' => array('name'=>'id','type'=>'%d'),
|
14 |
+
'event_id' => array('name'=>'event_id','type'=>'%d'),
|
15 |
+
'person_id' => array('name'=>'person_id','type'=>'%d'),
|
16 |
+
'booking_price' => array('name'=>'price','type'=>'%f'),
|
17 |
+
'booking_spaces' => array('name'=>'spaces','type'=>'%d'),
|
18 |
+
'booking_comment' => array('name'=>'comment','type'=>'%s'),
|
19 |
+
'booking_status' => array('name'=>'status','type'=>'%d'),
|
20 |
+
'booking_meta' => array('name'=>'meta','type'=>'%s')
|
21 |
+
);
|
22 |
+
//Other Vars
|
23 |
+
var $notes; //loaded from em_meta table in construct
|
24 |
+
var $timestamp;
|
25 |
+
var $person;
|
26 |
+
var $required_fields = array('booking_id', 'event_id', 'person_id', 'booking_spaces');
|
27 |
+
var $feedback_message = "";
|
28 |
+
var $errors = array();
|
29 |
+
/**
|
30 |
+
* Contains an array of custom fields for a booking. This is loaded from em_meta, where the booking_custom name contains arrays of data.
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
var $custom = array();
|
34 |
+
/**
|
35 |
+
* If saved in this instance, you can see what previous approval status was.
|
36 |
+
* @var int
|
37 |
+
*/
|
38 |
+
var $previous_status = false;
|
39 |
+
/**
|
40 |
+
* The booking approval status number corresponds to a state in this array.
|
41 |
+
* @var unknown_type
|
42 |
+
*/
|
43 |
+
var $status_array = array();
|
44 |
+
/**
|
45 |
+
* @var EM_Tickets
|
46 |
+
*/
|
47 |
+
var $tickets;
|
48 |
+
/**
|
49 |
+
* @var EM_Event
|
50 |
+
*/
|
51 |
+
var $event;
|
52 |
+
/**
|
53 |
+
* @var EM_Tickets_Bookings
|
54 |
+
*/
|
55 |
+
var $tickets_bookings;
|
56 |
+
/**
|
57 |
+
* If set to true, this booking can be managed by any logged in user.
|
58 |
+
* @var EM_Tickets_Bookings
|
59 |
+
*/
|
60 |
+
var $manage_override;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* 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.
|
64 |
+
* @param mixed $booking_data
|
65 |
+
* @return null
|
66 |
+
*/
|
67 |
+
function EM_Booking( $booking_data = false ){
|
68 |
+
//Get the person for this booking
|
69 |
+
global $wpdb;
|
70 |
+
if( $booking_data !== false ){
|
71 |
+
//Load booking data
|
72 |
+
$booking = array();
|
73 |
+
if( is_array($booking_data) ){
|
74 |
+
$booking = $booking_data;
|
75 |
+
}elseif( is_numeric($booking_data) ){
|
76 |
+
//Retreiving from the database
|
77 |
+
$sql = "SELECT * FROM ". EM_BOOKINGS_TABLE ." LEFT JOIN ". EM_META_TABLE ." ON object_id=booking_id WHERE booking_id ='$booking_data'";
|
78 |
+
$booking = $wpdb->get_row($sql, ARRAY_A);
|
79 |
+
}
|
80 |
+
//booking meta
|
81 |
+
$booking['booking_meta'] = (!empty($booking['booking_meta'])) ? unserialize($booking['booking_meta']):array();
|
82 |
+
//Save into the object
|
83 |
+
$this->to_object($booking);
|
84 |
+
$this->previous_status = $this->booking_status;
|
85 |
+
$this->get_person();
|
86 |
+
$this->timestamp = !empty($booking['booking_date']) ? strtotime($booking['booking_date']):false;
|
87 |
+
}
|
88 |
+
//Do it here so things appear in the po file.
|
89 |
+
$this->status_array = array(
|
90 |
+
0 => __('Pending','dbem'),
|
91 |
+
1 => __('Approved','dbem'),
|
92 |
+
2 => __('Rejected','dbem'),
|
93 |
+
3 => __('Cancelled','dbem'),
|
94 |
+
4 => __('Awaiting Online Payment','dbem'),
|
95 |
+
5 => __('Awaiting Payment','dbem')
|
96 |
+
);
|
97 |
+
$this->compat_keys();
|
98 |
+
do_action('em_booking', $this, $booking_data);
|
99 |
+
}
|
100 |
+
|
101 |
+
function get_notes(){
|
102 |
+
global $wpdb;
|
103 |
+
if( !is_array($this->notes) && !empty($this->booking_id) ){
|
104 |
+
$notes = $wpdb->get_results("SELECT * FROM ". EM_META_TABLE ." WHERE meta_key='booking-note' AND object_id ='{$this->booking_id}'", ARRAY_A);
|
105 |
+
$this->notes = array();
|
106 |
+
foreach($notes as $note){
|
107 |
+
$this->notes[] = unserialize($note['meta_value']);
|
108 |
+
}
|
109 |
+
}elseif( empty($this->booking_id) ){
|
110 |
+
$this->notes = array();
|
111 |
+
}
|
112 |
+
return $this->notes;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Saves the booking into the database, whether a new or existing booking
|
117 |
+
* @param $mail whether or not to email the user and contact people
|
118 |
+
* @return boolean
|
119 |
+
*/
|
120 |
+
function save($mail = true){
|
121 |
+
global $wpdb;
|
122 |
+
$table = EM_BOOKINGS_TABLE;
|
123 |
+
do_action('em_booking_save_pre',$this);
|
124 |
+
if( $this->validate() ){
|
125 |
+
if( $this->can_manage() ){
|
126 |
+
$this->person_id = (empty($this->person_id)) ? $this->get_person()->ID : $this->person_id;
|
127 |
+
//Step 1. Save the booking
|
128 |
+
$data = $this->to_array();
|
129 |
+
$data['booking_meta'] = serialize($data['booking_meta']);
|
130 |
+
if($this->booking_id != ''){
|
131 |
+
$update = true;
|
132 |
+
//update price and spaces
|
133 |
+
$this->get_spaces(true);
|
134 |
+
$this->get_price(true);
|
135 |
+
$where = array( 'booking_id' => $this->booking_id );
|
136 |
+
$result = $wpdb->update($table, $data, $where, $this->get_types($data));
|
137 |
+
$result = ($result !== false);
|
138 |
+
$this->feedback_message = __('Changes saved','dbem');
|
139 |
+
}else{
|
140 |
+
$update = false;
|
141 |
+
$result = $wpdb->insert($table, $data, $this->get_types($data));
|
142 |
+
$this->booking_id = $wpdb->insert_id;
|
143 |
+
$this->feedback_message = __('Your booking has been recorded','dbem');
|
144 |
+
}
|
145 |
+
//Step 2. Insert ticket bookings for this booking id if no errors so far
|
146 |
+
if( $result === false ){
|
147 |
+
$this->feedback_message = __('There was a problem saving the booking.', 'dbem');
|
148 |
+
$this->errors[] = __('There was a problem saving the booking.', 'dbem');
|
149 |
+
}else{
|
150 |
+
$tickets_bookings_result = $this->get_tickets_bookings()->save();
|
151 |
+
if( !$tickets_bookings_result ){
|
152 |
+
if( !$update ){
|
153 |
+
//delete the booking and tickets, instead of a transaction
|
154 |
+
$this->delete();
|
155 |
+
}
|
156 |
+
$this->errors[] = __('There was a problem saving the booking.', 'dbem');
|
157 |
+
$this->add_error( $this->get_tickets_bookings()->get_errors() );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
//Step 3. email if necessary
|
161 |
+
if ( count($this->errors) == 0 && $mail ) {
|
162 |
+
$this->email();
|
163 |
+
}
|
164 |
+
$this->compat_keys();
|
165 |
+
return apply_filters('em_booking_save', ( count($this->errors) == 0 ), $this);
|
166 |
+
}else{
|
167 |
+
$this->feedback_message = __('There was a problem saving the booking.', 'dbem');
|
168 |
+
if( !$this->can_manage() ){
|
169 |
+
$this->feedback_message = sprintf(__('You cannot manage this %s.', 'dbem'),__('Booking','dbem'));
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}else{
|
173 |
+
$this->feedback_message = __('There was a problem saving the booking.', 'dbem');
|
174 |
+
if( !$this->can_manage() ){
|
175 |
+
$this->feedback_message = sprintf(__('You cannot manage this %s.', 'dbem'),__('Booking','dbem'));
|
176 |
+
}
|
177 |
+
}
|
178 |
+
return apply_filters('em_booking_save', false, $this);
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Load an record into this object by passing an associative array of table criterie to search for.
|
183 |
+
* Returns boolean depending on whether a record is found or not.
|
184 |
+
* @param $search
|
185 |
+
* @return boolean
|
186 |
+
*/
|
187 |
+
function get($search) {
|
188 |
+
global $wpdb;
|
189 |
+
$conds = array();
|
190 |
+
foreach($search as $key => $value) {
|
191 |
+
if( array_key_exists($key, $this->fields) ){
|
192 |
+
$value = $wpdb->escape($value);
|
193 |
+
$conds[] = "`$key`='$value'";
|
194 |
+
}
|
195 |
+
}
|
196 |
+
$sql = "SELECT * FROM ". $wpdb->EM_BOOKINGS_TABLE ." WHERE " . implode(' AND ', $conds) ;
|
197 |
+
$result = $wpdb->get_row($sql, ARRAY_A);
|
198 |
+
if($result){
|
199 |
+
$this->to_object($result);
|
200 |
+
$this->person = new EM_Person($this->person_id);
|
201 |
+
return true;
|
202 |
+
}else{
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Get posted data and save it into the object (not db)
|
209 |
+
* @return boolean
|
210 |
+
*/
|
211 |
+
function get_post( $override_availability = false ){
|
212 |
+
$this->tickets_bookings = new EM_Tickets_Bookings($this->booking_id);
|
213 |
+
do_action('em_booking_get_post_pre',$this);
|
214 |
+
$result = array();
|
215 |
+
$this->event_id = $_REQUEST['event_id'];
|
216 |
+
if( isset($_REQUEST['em_tickets']) && is_array($_REQUEST['em_tickets']) && ($_REQUEST['em_tickets'] || $override_availability) ){
|
217 |
+
foreach( $_REQUEST['em_tickets'] as $ticket_id => $values){
|
218 |
+
//make sure ticket exists
|
219 |
+
if( !empty($values['spaces']) || $override_availability ){
|
220 |
+
$args = array('ticket_id'=>$ticket_id, 'ticket_booking_spaces'=>$values['spaces'], 'booking_id'=>$this->booking_id);
|
221 |
+
if($this->get_event()->get_bookings()->ticket_exists($ticket_id)){
|
222 |
+
$EM_Ticket_Booking = new EM_Ticket_Booking($args);
|
223 |
+
$EM_Ticket_Booking->booking = $this;
|
224 |
+
$this->tickets_bookings->add( $EM_Ticket_Booking, $override_availability );
|
225 |
+
}else{
|
226 |
+
$this->errors[]=__('You are trying to book a non-existent ticket for this event.','dbem');
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
$this->booking_comment = (!empty($_REQUEST['booking_comment'])) ? wp_kses_data(stripslashes($_REQUEST['booking_comment'])):'';
|
231 |
+
$this->get_spaces(true);
|
232 |
+
$this->get_price(true, false, false);
|
233 |
+
$this->get_person();
|
234 |
+
$this->compat_keys();
|
235 |
+
}
|
236 |
+
return apply_filters('em_booking_get_post',count($this->errors) == 0,$this);
|
237 |
+
}
|
238 |
+
|
239 |
+
function validate(){
|
240 |
+
//step 1, basic info
|
241 |
+
$basic = (
|
242 |
+
(empty($this->event_id) || is_numeric($this->event_id)) &&
|
243 |
+
(empty($this->person_id) || is_numeric($this->person_id)) &&
|
244 |
+
is_numeric($this->booking_spaces) && $this->booking_spaces > 0
|
245 |
+
);
|
246 |
+
//give some errors in step 1
|
247 |
+
if( $this->booking_spaces == 0 ){
|
248 |
+
$this->add_error(get_option('dbem_booking_feedback_min_space'));
|
249 |
+
}
|
250 |
+
//step 2, tickets bookings info
|
251 |
+
if( count($this->get_tickets_bookings()) > 0 ){
|
252 |
+
$ticket_validation = array();
|
253 |
+
foreach($this->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking){
|
254 |
+
if ( !$EM_Ticket_Booking->validate() ){
|
255 |
+
$ticket_validation[] = false;
|
256 |
+
$result = $basic && !in_array(false,$ticket_validation);
|
257 |
+
}
|
258 |
+
$this->errors = array_merge($this->errors, $EM_Ticket_Booking->get_errors());
|
259 |
+
}
|
260 |
+
$result = $basic && !in_array(false,$ticket_validation);
|
261 |
+
}else{
|
262 |
+
$result = false;
|
263 |
+
}
|
264 |
+
return apply_filters('em_booking_validate',$result,$this);
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Get the total number of spaces booked in THIS booking. Seting $force_refresh to true will recheck spaces, even if previously done so.
|
269 |
+
* @param unknown_type $force_refresh
|
270 |
+
* @return mixed
|
271 |
+
*/
|
272 |
+
function get_spaces( $force_refresh=false ){
|
273 |
+
if($this->booking_spaces == 0 || $force_refresh == true ){
|
274 |
+
$this->booking_spaces = $this->get_tickets_bookings()->get_spaces($force_refresh);
|
275 |
+
}
|
276 |
+
return apply_filters('em_booking_get_spaces',$this->booking_spaces,$this);
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Gets the total price for this whole booking. Seting $force_reset to true will recheck spaces, even if previously done so.
|
281 |
+
* @param boolean $force_refresh
|
282 |
+
* @param boolean $format
|
283 |
+
* @param boolean $add_tax
|
284 |
+
* @return float
|
285 |
+
*/
|
286 |
+
function get_price( $force_refresh=false, $format=false, $add_tax='x' ){
|
287 |
+
if($force_refresh || $this->booking_price == 0 || $add_tax !== 'x' || get_option('dbem_bookings_tax_auto_add')){
|
288 |
+
$this->booking_price = $this->get_tickets_bookings()->get_price($force_refresh, false, $add_tax);
|
289 |
+
$this->booking_price = apply_filters('em_booking_get_price', $this->booking_price, $this, $add_tax);
|
290 |
+
}
|
291 |
+
if($format){
|
292 |
+
return em_get_currency_formatted($this->booking_price);
|
293 |
+
}
|
294 |
+
return $this->booking_price;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Gets the event this booking belongs to and saves a refernece in the event property
|
299 |
+
* @return EM_Event
|
300 |
+
*/
|
301 |
+
function get_event(){
|
302 |
+
global $EM_Event;
|
303 |
+
if( is_object($this->event) && get_class($this->event)=='EM_Event' && $this->event->event_id == $this->event_id ){
|
304 |
+
return $this->event;
|
305 |
+
}elseif( is_object($EM_Event) && ( (is_object($this->event) && $this->event->event_id == $this->event_id) || empty($this->booking_id)) ){
|
306 |
+
$this->event = $EM_Event;
|
307 |
+
}else{
|
308 |
+
$this->event = new EM_Event($this->event_id, 'event_id');
|
309 |
+
}
|
310 |
+
return apply_filters('em_booking_get_event',$this->event);
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Gets the ticket object this booking belongs to, saves a reference in ticket property
|
315 |
+
* @return EM_Tickets
|
316 |
+
*/
|
317 |
+
function get_tickets(){
|
318 |
+
if( is_object($this->tickets) && get_class($this->tickets)=='EM_Tickets' ){
|
319 |
+
return apply_filters('em_booking_get_tickets', $this->tickets, $this);
|
320 |
+
}else{
|
321 |
+
$this->tickets = new EM_Tickets($this);
|
322 |
+
}
|
323 |
+
return apply_filters('em_booking_get_tickets', $this->tickets, $this);
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Gets the ticket object this booking belongs to, saves a reference in ticket property
|
328 |
+
* @return EM_Tickets_Bookings
|
329 |
+
*/
|
330 |
+
function get_tickets_bookings(){
|
331 |
+
global $wpdb;
|
332 |
+
if( !is_object($this->tickets_bookings) || get_class($this->tickets_bookings)!='EM_Tickets_Bookings'){
|
333 |
+
$this->tickets_bookings = new EM_Tickets_Bookings($this);
|
334 |
+
}
|
335 |
+
return apply_filters('em_booking_get_tickets_bookings', $this->tickets_bookings, $this);
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* @return EM_Person
|
340 |
+
*/
|
341 |
+
function get_person(){
|
342 |
+
global $EM_Person;
|
343 |
+
if( is_object($this->person) && get_class($this->person)=='EM_Person' && ($this->person->ID == $this->person_id || empty($this->person_id) ) ){
|
344 |
+
//This person is already included, so don't do anything
|
345 |
+
}elseif( is_object($EM_Person) && ($EM_Person->ID === $this->person_id || $this->booking_id == '') ){
|
346 |
+
$this->person = $EM_Person;
|
347 |
+
}elseif( is_numeric($this->person_id) ){
|
348 |
+
$this->person = new EM_Person($this->person_id);
|
349 |
+
}else{
|
350 |
+
$this->person = new EM_Person(0);
|
351 |
+
}
|
352 |
+
//if this user is the parent user of disabled registrations, replace user details here:
|
353 |
+
if( get_option('dbem_bookings_registration_disable') && $this->person->ID == get_option('dbem_bookings_registration_user') ){
|
354 |
+
//override any registration data into the person objet
|
355 |
+
if( !empty($this->booking_meta['registration']) ){
|
356 |
+
foreach($this->booking_meta['registration'] as $key => $value){
|
357 |
+
$this->person->$key = $value;
|
358 |
+
}
|
359 |
+
}
|
360 |
+
$this->person->user_email = ( !empty($this->booking_meta['registration']['user_email']) ) ? $this->booking_meta['registration']['user_email']:$this->person->user_email;
|
361 |
+
if( !empty($this->booking_meta['registration']['user_name']) ){
|
362 |
+
$name_string = explode(' ',$this->booking_meta['registration']['user_name']);
|
363 |
+
$this->booking_meta['registration']['first_name'] = array_shift($name_string);
|
364 |
+
$this->booking_meta['registration']['last_name'] = implode(' ', $name_string);
|
365 |
+
}
|
366 |
+
$this->person->user_firstname = ( !empty($this->booking_meta['registration']['first_name']) ) ? $this->booking_meta['registration']['first_name']:__('Guest User','dbem');
|
367 |
+
$this->person->first_name = $this->person->user_firstname;
|
368 |
+
$this->person->user_lastname = ( !empty($this->booking_meta['registration']['last_name']) ) ? $this->booking_meta['registration']['last_name']:'';
|
369 |
+
$this->person->last_name = $this->person->user_lastname;
|
370 |
+
$this->person->phone = ( !empty($this->booking_meta['registration']['dbem_phone']) ) ? $this->booking_meta['registration']['dbem_phone']:__('Not Supplied','dbem');
|
371 |
+
//build display name
|
372 |
+
$full_name = $this->person->user_firstname . " " . $this->person->user_lastname ;
|
373 |
+
$full_name = trim($full_name);
|
374 |
+
$display_name = ( empty($full_name) ) ? __('Guest User','dbem'):$full_name;
|
375 |
+
$this->person->display_name = $display_name;
|
376 |
+
}
|
377 |
+
return apply_filters('em_booking_get_person', $this->person, $this);
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Returns a string representation of the booking's status
|
382 |
+
* @return string
|
383 |
+
*/
|
384 |
+
function get_status(){
|
385 |
+
$status = ($this->booking_status == 0 && !get_option('dbem_bookings_approval') ) ? 1:$this->booking_status;
|
386 |
+
return apply_filters('em_booking_get_status', $this->status_array[$status], $this);
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* I wonder what this does....
|
391 |
+
* @return boolean
|
392 |
+
*/
|
393 |
+
function delete(){
|
394 |
+
global $wpdb;
|
395 |
+
$result = false;
|
396 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
397 |
+
$sql = $wpdb->prepare("DELETE FROM ". EM_BOOKINGS_TABLE . " WHERE booking_id=%d", $this->booking_id);
|
398 |
+
$result = $wpdb->query( $sql );
|
399 |
+
if( $result !== false ){
|
400 |
+
//delete the tickets too
|
401 |
+
$this->get_tickets_bookings()->delete();
|
402 |
+
$this->previous_status = $this->booking_status;
|
403 |
+
$this->booking_status = false;
|
404 |
+
$this->feedback_message = sprintf(__('%s deleted', 'dbem'), __('Booking','dbem'));
|
405 |
+
}else{
|
406 |
+
$this->add_error(sprintf(__('%s could not be deleted', 'dbem'), __('Booking','dbem')));
|
407 |
+
}
|
408 |
+
}
|
409 |
+
return apply_filters('em_booking_delete',( $result !== false ), $this);
|
410 |
+
}
|
411 |
+
|
412 |
+
function cancel($email = true){
|
413 |
+
if( $this->person->ID == get_current_user_id() ){
|
414 |
+
$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.
|
415 |
+
}
|
416 |
+
return $this->set_status(3, $email);
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Approve a booking.
|
421 |
+
* @return bool
|
422 |
+
*/
|
423 |
+
function approve($email = true, $ignore_spaces = false){
|
424 |
+
return $this->set_status(1, $email, $ignore_spaces);
|
425 |
+
}
|
426 |
+
/**
|
427 |
+
* Reject a booking and save
|
428 |
+
* @return bool
|
429 |
+
*/
|
430 |
+
function reject($email = true){
|
431 |
+
return $this->set_status(2, $email);
|
432 |
+
}
|
433 |
+
/**
|
434 |
+
* Unapprove a booking.
|
435 |
+
* @return bool
|
436 |
+
*/
|
437 |
+
function unapprove($email = true){
|
438 |
+
return $this->set_status(0, $email);
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* Change the status of the booking. This will save to the Database too.
|
443 |
+
* @param int $status
|
444 |
+
* @return boolean
|
445 |
+
*/
|
446 |
+
function set_status($status, $email = true, $ignore_spaces = false){
|
447 |
+
global $wpdb;
|
448 |
+
$action_string = strtolower($this->status_array[$status]);
|
449 |
+
//if we're approving we can't approve a booking if spaces are full, so check before it's approved.
|
450 |
+
if(!$ignore_spaces && $status == 1){
|
451 |
+
if( !$this->is_reserved() && $this->get_event()->get_bookings()->get_available_spaces() < $this->get_spaces() && !get_option('dbem_bookings_approval_overbooking') ){
|
452 |
+
$this->feedback_message = sprintf(__('Not approved, spaces full.','dbem'), $action_string);
|
453 |
+
$this->add_error($this->feedback_message);
|
454 |
+
return apply_filters('em_booking_set_status', false, $this);
|
455 |
+
}
|
456 |
+
}
|
457 |
+
$this->previous_status = $this->booking_status;
|
458 |
+
$this->booking_status = $status;
|
459 |
+
$result = $wpdb->query($wpdb->prepare('UPDATE '.EM_BOOKINGS_TABLE.' SET booking_status=%d WHERE booking_id=%d', array($status, $this->booking_id)));
|
460 |
+
if($result !== false){
|
461 |
+
$this->feedback_message = sprintf(__('Booking %s.','dbem'), $action_string);
|
462 |
+
if( $email ){
|
463 |
+
if( $this->email() ){
|
464 |
+
$this->feedback_message .= " ".__('Mail Sent.','dbem');
|
465 |
+
}elseif( $this->previous_status == 0 ){
|
466 |
+
//extra errors may be logged by email() in EM_Object
|
467 |
+
$this->feedback_message .= ' <span style="color:red">'.__('ERROR : Mail Not Sent.','dbem').'</span>';
|
468 |
+
$this->add_error(__('ERROR : Mail Not Sent.','dbem'));
|
469 |
+
$result = false;
|
470 |
+
}
|
471 |
+
}
|
472 |
+
}else{
|
473 |
+
//errors should be logged by save()
|
474 |
+
$this->feedback_message = sprintf(__('Booking could not be %s.','dbem'), $action_string);
|
475 |
+
$this->add_error(sprintf(__('Booking could not be %s.','dbem'), $action_string));
|
476 |
+
}
|
477 |
+
return apply_filters('em_booking_set_status', $result, $this);
|
478 |
+
}
|
479 |
+
|
480 |
+
function is_reserved(){
|
481 |
+
$result = false;
|
482 |
+
if( $this->booking_status == 0 && get_option('dbem_bookings_approval_reserved') ){
|
483 |
+
$result = true;
|
484 |
+
}elseif( $this->booking_status == 0 && !get_option('dbem_bookings_approval') ){
|
485 |
+
$result = true;
|
486 |
+
}elseif( $this->booking_status == 1 ){
|
487 |
+
$result = true;
|
488 |
+
}
|
489 |
+
return apply_filters('em_booking_is_reserved', $result, $this);
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* Add a booking note to this booking. returns wpdb result or false if use can't manage this event.
|
494 |
+
* @param string $note
|
495 |
+
* @return mixed
|
496 |
+
*/
|
497 |
+
function add_note( $note_text ){
|
498 |
+
global $wpdb;
|
499 |
+
if( $this->can_manage() ){
|
500 |
+
$this->get_notes();
|
501 |
+
$note = array('author'=>get_current_user_id(),'note'=>$note_text,'timestamp'=>current_time('timestamp'));
|
502 |
+
$this->notes[] = $note;
|
503 |
+
$this->feedback_message = __('Booking note successfully added.','dbem');
|
504 |
+
return $wpdb->insert(EM_META_TABLE, array('object_id'=>$this->booking_id, 'meta_key'=>'booking-note', 'meta_value'=> serialize($note)),array('%d','%s','%s'));
|
505 |
+
}
|
506 |
+
return false;
|
507 |
+
}
|
508 |
+
|
509 |
+
function output($format, $target="html") {
|
510 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $format, $placeholders);
|
511 |
+
foreach( $this->get_tickets() as $EM_Ticket){ break; } //Get first ticket for single ticket placeholders
|
512 |
+
$output_string = $format;
|
513 |
+
$replaces = array();
|
514 |
+
foreach($placeholders[1] as $key => $result) {
|
515 |
+
$replace = '';
|
516 |
+
$full_result = $placeholders[0][$key];
|
517 |
+
switch( $result ){
|
518 |
+
case '#_BOOKINGID':
|
519 |
+
$replace = $this->booking_id;
|
520 |
+
break;
|
521 |
+
case '#_RESPNAME' : //Depreciated
|
522 |
+
case '#_BOOKINGNAME':
|
523 |
+
$replace = $this->get_person()->get_name();
|
524 |
+
break;
|
525 |
+
case '#_RESPEMAIL' : //Depreciated
|
526 |
+
case '#_BOOKINGEMAIL':
|
527 |
+
$replace = $this->get_person()->user_email;
|
528 |
+
break;
|
529 |
+
case '#_RESPPHONE' : //Depreciated
|
530 |
+
case '#_BOOKINGPHONE':
|
531 |
+
$replace = $this->get_person()->phone;
|
532 |
+
break;
|
533 |
+
case '#_BOOKINGSPACES':
|
534 |
+
$replace = $this->get_spaces();
|
535 |
+
break;
|
536 |
+
case '#_BOOKINGLISTURL':
|
537 |
+
$replace = em_get_my_bookings_url();
|
538 |
+
break;
|
539 |
+
case '#_COMMENT' : //Depreciated
|
540 |
+
case '#_BOOKINGCOMMENT':
|
541 |
+
$replace = $this->booking_comment;
|
542 |
+
break;
|
543 |
+
case '#_BOOKINGPRICEWITHTAX':
|
544 |
+
$replace = em_get_currency_formatted($this->get_price(false,false,true));
|
545 |
+
break;
|
546 |
+
case '#_BOOKINGPRICEWITHOUTTAX':
|
547 |
+
$replace = em_get_currency_formatted($this->get_price(false,false,false));
|
548 |
+
break;
|
549 |
+
case '#_BOOKINGPRICETAX':
|
550 |
+
$replace = em_get_currency_formatted($this->get_price(false,false,false)*(get_option('dbem_bookings_tax')/100));
|
551 |
+
break;
|
552 |
+
case '#_BOOKINGPRICE':
|
553 |
+
$replace = em_get_currency_formatted($this->get_price());
|
554 |
+
break;
|
555 |
+
case '#_BOOKINGTICKETNAME':
|
556 |
+
$replace = $EM_Ticket->name;
|
557 |
+
break;
|
558 |
+
case '#_BOOKINGTICKETDESCRIPTION':
|
559 |
+
$replace = $EM_Ticket->description;
|
560 |
+
break;
|
561 |
+
case '#_BOOKINGTICKETPRICEWITHTAX':
|
562 |
+
$replace = em_get_currency_formatted($EM_Ticket->get_price(false,true));
|
563 |
+
break;
|
564 |
+
case '#_BOOKINGTICKETPRICEWITHOUTTAX':
|
565 |
+
$replace = em_get_currency_formatted($EM_Ticket->get_price(false,false));
|
566 |
+
break;
|
567 |
+
case '#_BOOKINGTICKETTAX':
|
568 |
+
$replace = em_get_currency_formatted($EM_Ticket->get_price(false,false)*(get_option('dbem_bookings_tax')/100));
|
569 |
+
break;
|
570 |
+
case '#_BOOKINGTICKETPRICE':
|
571 |
+
$replace = em_get_currency_formatted($EM_Ticket->get_price());
|
572 |
+
break;
|
573 |
+
case '#_BOOKINGTICKETS':
|
574 |
+
ob_start();
|
575 |
+
em_locate_template('emails/bookingtickets.php', true, array('EM_Booking'=>$this));
|
576 |
+
$replace = ob_get_clean();
|
577 |
+
break;
|
578 |
+
default:
|
579 |
+
$replace = $full_result;
|
580 |
+
break;
|
581 |
+
}
|
582 |
+
$replaces[$full_result] = apply_filters('em_booking_output_placeholder', $replace, $this, $full_result, $target);
|
583 |
+
}
|
584 |
+
//sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
|
585 |
+
krsort($replaces);
|
586 |
+
foreach($replaces as $full_result => $replacement){
|
587 |
+
$output_string = str_replace($full_result, $replacement , $output_string );
|
588 |
+
}
|
589 |
+
//run event output too, since this is never run from within events and will not infinitely loop
|
590 |
+
$output_string = $this->get_event()->output($output_string, $target);
|
591 |
+
return apply_filters('em_booking_output', $output_string, $this, $format, $target);
|
592 |
+
}
|
593 |
+
|
594 |
+
/**
|
595 |
+
* @param EM_Booking $EM_Booking
|
596 |
+
* @param EM_Event $event
|
597 |
+
* @return boolean
|
598 |
+
*/
|
599 |
+
function email( $email_admin = true, $force_resend = false ){
|
600 |
+
global $EM_Mailer;
|
601 |
+
$result = true;
|
602 |
+
|
603 |
+
//FIXME ticket logic needed
|
604 |
+
$EM_Event = $this->get_event(); //We NEED event details here.
|
605 |
+
$EM_Event->get_bookings(true); //refresh all bookings
|
606 |
+
|
607 |
+
//Make sure event matches booking, and that booking used to be approved.
|
608 |
+
if( $this->booking_status !== $this->previous_status || $force_resend ){
|
609 |
+
$msg = array( 'user'=> array('subject'=>'', 'body'=>''), 'admin'=> array('subject'=>'', 'body'=>'')); //blank msg template
|
610 |
+
|
611 |
+
//admin messages won't change whether pending or already approved
|
612 |
+
switch( $this->booking_status ){
|
613 |
+
case 0:
|
614 |
+
case 5: //TODO remove offline status from here and move to pro
|
615 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_pending_subject');
|
616 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_pending_body');
|
617 |
+
//admins should get something (if set to)
|
618 |
+
$msg['admin']['subject'] = get_option('dbem_bookings_contact_email_subject');
|
619 |
+
$msg['admin']['body'] = get_option('dbem_bookings_contact_email_body');
|
620 |
+
break;
|
621 |
+
case 1:
|
622 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_confirmed_subject');
|
623 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_confirmed_body');
|
624 |
+
//admins should get something (if set to)
|
625 |
+
$msg['admin']['subject'] = get_option('dbem_bookings_contact_email_subject');
|
626 |
+
$msg['admin']['body'] = get_option('dbem_bookings_contact_email_body');
|
627 |
+
break;
|
628 |
+
case 2:
|
629 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_rejected_subject');
|
630 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_rejected_body');
|
631 |
+
break;
|
632 |
+
case 3:
|
633 |
+
$msg['user']['subject'] = get_option('dbem_bookings_email_cancelled_subject');
|
634 |
+
$msg['user']['body'] = get_option('dbem_bookings_email_cancelled_body');
|
635 |
+
//admins should get something (if set to)
|
636 |
+
$msg['admin']['subject'] = get_option('dbem_contactperson_email_cancelled_subject');
|
637 |
+
$msg['admin']['body'] = get_option('dbem_contactperson_email_cancelled_body');
|
638 |
+
break;
|
639 |
+
}
|
640 |
+
//messages can be overriden just before being sent
|
641 |
+
$msg = apply_filters('em_booking_email_messages', $msg, $this);
|
642 |
+
$output_type = get_option('dbem_smtp_html') ? 'html':'email';
|
643 |
+
|
644 |
+
//Send user (booker) emails
|
645 |
+
if( !empty($msg['user']['subject']) ){
|
646 |
+
$msg['user']['subject'] = $this->output($msg['user']['subject'], 'raw');
|
647 |
+
$msg['user']['body'] = $this->output($msg['user']['body'], $output_type);
|
648 |
+
//Send to the person booking
|
649 |
+
if( !$this->email_send( $msg['user']['subject'], $msg['user']['body'], $this->get_person()->user_email) ){
|
650 |
+
$result = false;
|
651 |
+
}
|
652 |
+
}
|
653 |
+
|
654 |
+
//Send admin/contact emails if this isn't the event owner or an events admin
|
655 |
+
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
|
656 |
+
if( get_option('dbem_bookings_contact_email') == 1 || get_option('dbem_bookings_notify_admin') ){
|
657 |
+
//Only gets sent if this is a pending booking, unless approvals are disabled.
|
658 |
+
$msg['admin']['subject'] = $this->output($msg['admin']['subject'],'raw');
|
659 |
+
$msg['admin']['body'] = $this->output($msg['admin']['body'], $output_type);
|
660 |
+
//email contact
|
661 |
+
if( get_option('dbem_bookings_contact_email') == 1 ){
|
662 |
+
if( !$this->email_send( $msg['admin']['subject'], $msg['admin']['body'], $EM_Event->get_contact()->user_email) && current_user_can('activate_plugins')){
|
663 |
+
$this->errors[] = __('Confirmation email could not be sent to contact person. Registrant should have gotten their email (only admin see this warning).','dbem');
|
664 |
+
$result = false;
|
665 |
+
}
|
666 |
+
}
|
667 |
+
//email admin
|
668 |
+
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'))) ){
|
669 |
+
$admin_emails = get_option('dbem_bookings_notify_admin');
|
670 |
+
$admin_emails = explode(',', $admin_emails); //supply emails as array
|
671 |
+
foreach($admin_emails as $key => $email){ $admin_emails[$key] = trim($email); } //strip whitespace
|
672 |
+
if( !$this->email_send( $msg['admin']['subject'], $msg['admin']['body'], $admin_emails) ){
|
673 |
+
$this->errors[] = __('Confirmation email could not be sent to admin. Registrant should have gotten their email (only admin see this warning).','dbem');
|
674 |
+
$result = false;
|
675 |
+
}
|
676 |
+
}
|
677 |
+
}
|
678 |
+
}
|
679 |
+
}
|
680 |
+
return $result;
|
681 |
+
//TODO need error checking for booking mail send
|
682 |
+
}
|
683 |
+
|
684 |
+
/**
|
685 |
+
* Can the user manage this event?
|
686 |
+
*/
|
687 |
+
function can_manage(){
|
688 |
+
return $this->get_event()->can_manage('manage_bookings','manage_others_bookings') || empty($this->booking_id) || !empty($this->manage_override);
|
689 |
+
}
|
690 |
+
|
691 |
+
/**
|
692 |
+
* Returns this object in the form of an array
|
693 |
+
* @return array
|
694 |
+
*/
|
695 |
+
function to_array($person = false){
|
696 |
+
$booking = array();
|
697 |
+
//Core Data
|
698 |
+
$booking = parent::to_array();
|
699 |
+
//Person Data
|
700 |
+
if($person && is_object($this->person)){
|
701 |
+
$person = $this->person->to_array();
|
702 |
+
$booking = array_merge($booking, $person);
|
703 |
+
}
|
704 |
+
return $booking;
|
705 |
+
}
|
706 |
+
}
|
707 |
Â
?>
|
classes/em-bookings-table.php
ADDED
@@ -0,0 +1,641 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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.'); ?>">?</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 is_admin() ? 0:1; ?>" />
|
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().'">'. $this->events[$EM_Booking->event_id]->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(false,true,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 |
+
return $cols;
|
577 |
+
}
|
578 |
+
|
579 |
+
function get_row_csv($EM_Booking){
|
580 |
+
return $this->get_row($EM_Booking, true);
|
581 |
+
}
|
582 |
+
|
583 |
+
/**
|
584 |
+
* @param EM_Booking $EM_Booking
|
585 |
+
* @return mixed
|
586 |
+
*/
|
587 |
+
function get_booking_actions($EM_Booking){
|
588 |
+
$booking_actions = array();
|
589 |
+
switch($EM_Booking->booking_status){
|
590 |
+
case 0:
|
591 |
+
if( get_option('dbem_bookings_approval') ){
|
592 |
+
$booking_actions = array(
|
593 |
+
'approve' => '<a class="em-bookings-approve" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Approve','dbem').'</a>',
|
594 |
+
'reject' => '<a class="em-bookings-reject" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Reject','dbem').'</a>',
|
595 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
596 |
+
'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>',
|
597 |
+
);
|
598 |
+
break;
|
599 |
+
}//if approvals are off, treat as a 1
|
600 |
+
case 1:
|
601 |
+
$booking_actions = array(
|
602 |
+
'unapprove' => '<a class="em-bookings-unapprove" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_unapprove', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Unapprove','dbem').'</a>',
|
603 |
+
'reject' => '<a class="em-bookings-reject" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Reject','dbem').'</a>',
|
604 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
605 |
+
'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>',
|
606 |
+
);
|
607 |
+
break;
|
608 |
+
case 2:
|
609 |
+
$booking_actions = array(
|
610 |
+
'approve' => '<a class="em-bookings-approve" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Approve','dbem').'</a>',
|
611 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
612 |
+
'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>',
|
613 |
+
);
|
614 |
+
break;
|
615 |
+
case 3:
|
616 |
+
$booking_actions = array(
|
617 |
+
'approve' => '<a class="em-bookings-approve" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Approve','dbem').'</a>',
|
618 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
619 |
+
'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>',
|
620 |
+
);
|
621 |
+
break;
|
622 |
+
case 4:
|
623 |
+
$booking_actions = apply_filters('em_bookings_table_booking_actions_4',array(
|
624 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
625 |
+
), $EM_Booking);
|
626 |
+
break;
|
627 |
+
case 5:
|
628 |
+
$booking_actions = apply_filters('em_bookings_table_booking_actions_5',array(
|
629 |
+
'delete' => '<span class="trash"><a class="em-bookings-delete" href="'.em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Delete','dbem').'</a></span>',
|
630 |
+
), $EM_Booking);
|
631 |
+
break;
|
632 |
+
default:
|
633 |
+
$booking_actions = apply_filters('em_bookings_table_booking_actions_'.$EM_Booking->booking_status ,array(), $EM_Booking);
|
634 |
+
break;
|
635 |
+
|
636 |
+
}
|
637 |
+
if( !get_option('dbem_bookings_approval') ) unset($booking_actions['unapprove']);
|
638 |
+
return apply_filters('em_bookings_table_cols_col_action', $booking_actions, $EM_Booking);
|
639 |
+
}
|
640 |
+
}
|
641 |
+
?>
|
classes/em-bookings.php
CHANGED
@@ -1,488 +1,648 @@
|
|
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 |
-
$bookings
|
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 |
-
return (
|
116 |
-
}
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
return $this->
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
*
|
140 |
-
* @param
|
141 |
-
* @return
|
142 |
-
*/
|
143 |
-
function
|
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 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
*
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
return
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
*
|
318 |
-
* @return
|
319 |
-
*/
|
320 |
-
function
|
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 |
-
function
|
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 |
-
if(
|
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 |
+
$sql = "SELECT * FROM ". EM_BOOKINGS_TABLE ." WHERE event_id ='{$this->event_id}' ORDER BY booking_date";
|
38 |
+
$bookings = $wpdb->get_results($sql, ARRAY_A);
|
39 |
+
foreach ($bookings as $booking){
|
40 |
+
$this->bookings[] = new EM_Booking($booking);
|
41 |
+
}
|
42 |
+
$this->spaces = $this->get_spaces();
|
43 |
+
}elseif( is_array($data) ){
|
44 |
+
foreach( $data as $EM_Booking ){
|
45 |
+
if( get_class($EM_Booking) == 'EM_Booking'){
|
46 |
+
$this->bookings[] = $EM_Booking;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Add a booking into this event (or add spaces if person already booked this), checking that there's enough space for the event
|
54 |
+
* @param EM_Booking $EM_Booking
|
55 |
+
* @return boolean
|
56 |
+
*/
|
57 |
+
function add( $EM_Booking ){
|
58 |
+
global $wpdb,$EM_Mailer;
|
59 |
+
if ( $this->get_available_spaces() >= $EM_Booking->get_spaces(true) ) {
|
60 |
+
//Save the booking
|
61 |
+
$email = false;
|
62 |
+
//set status depending on approval settings
|
63 |
+
if( empty($EM_Booking->booking_status) ){ //if status is not set, give 1 or 0 depending on approval settings
|
64 |
+
$EM_Booking->booking_status = get_option('dbem_bookings_approval') ? 0:1;
|
65 |
+
}
|
66 |
+
$result = $EM_Booking->save(false);
|
67 |
+
if($result){
|
68 |
+
//Success
|
69 |
+
do_action('em_bookings_added', $EM_Booking);
|
70 |
+
$this->bookings[] = $EM_Booking;
|
71 |
+
$email = $EM_Booking->email();
|
72 |
+
if( get_option('dbem_bookings_approval') == 1 && $EM_Booking->booking_status == 0){
|
73 |
+
$this->feedback_message = get_option('dbem_booking_feedback_pending');
|
74 |
+
}else{
|
75 |
+
$this->feedback_message = get_option('dbem_booking_feedback');
|
76 |
+
}
|
77 |
+
if(!$email){
|
78 |
+
$EM_Booking->email_not_sent = true;
|
79 |
+
$this->feedback_message .= ' '.get_option('dbem_booking_feedback_nomail');
|
80 |
+
if( current_user_can('activate_plugins') ){
|
81 |
+
if( count($EM_Booking->get_errors()) > 0 ){
|
82 |
+
$this->feedback_message .= '<br/><strong>Errors:</strong> (only admins see this message)<br/><ul><li>'. implode('</li><li>', $EM_Booking->get_errors()).'</li></ul>';
|
83 |
+
}else{
|
84 |
+
$this->feedback_message .= '<br/><strong>No errors returned by mailer</strong> (only admins see this message)';
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
return apply_filters('em_bookings_add', true, $EM_Booking);
|
89 |
+
}else{
|
90 |
+
//Failure
|
91 |
+
$this->errors[] = "<strong>".get_option('dbem_booking_feedback_error')."</strong><br />". implode('<br />', $EM_Booking->errors);
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
$this->add_error(get_option('dbem_booking_feedback_full'));
|
95 |
+
}
|
96 |
+
return apply_filters('em_bookings_add', false, $EM_Booking);
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Get POST data and create a booking for each ticket requested. If successful, a booking object is returned, false if not.
|
101 |
+
* @return false|object
|
102 |
+
*/
|
103 |
+
function add_from_post(){
|
104 |
+
$EM_Booking = new EM_booking();
|
105 |
+
$result = $EM_Booking->get_post();
|
106 |
+
if($result){
|
107 |
+
$result = $this->add($EM_Booking);
|
108 |
+
if($result){
|
109 |
+
$result = $EM_Booking;
|
110 |
+
}
|
111 |
+
$this->feedback_message = sprintf(__('%s created.','dbem'),__('Booking','dbem'));
|
112 |
+
}else{
|
113 |
+
$this->errors = array_merge($this->errors, $EM_Booking->errors);
|
114 |
+
}
|
115 |
+
return apply_filters('em_bookings_add_from_post',$result,$EM_Booking,$this);
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* 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.
|
120 |
+
*/
|
121 |
+
function get_event(){
|
122 |
+
global $EM_Event;
|
123 |
+
if( is_object($EM_Event) && $EM_Event->event_id == $this->event_id ){
|
124 |
+
return $EM_Event;
|
125 |
+
}else{
|
126 |
+
if( is_numeric($this->event_id) && $this->event_id > 0 ){
|
127 |
+
return new EM_Event($this->event_id, 'event_id');
|
128 |
+
}elseif( count($this->bookings) > 0 ){
|
129 |
+
foreach($this->bookings as $EM_Booking){
|
130 |
+
/* @var $EM_Booking EM_Booking */
|
131 |
+
return new EM_Event($EM_Booking->event_id, 'event_id');
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
return new EM_Event($this->event_id);
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* 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.
|
140 |
+
* @param boolean $force_reload
|
141 |
+
* @return EM_Tickets
|
142 |
+
*/
|
143 |
+
function get_tickets( $force_reload = false ){
|
144 |
+
if( !is_object($this->tickets) || $force_reload ){
|
145 |
+
$this->tickets = new EM_Tickets($this->event_id);
|
146 |
+
}else{
|
147 |
+
$this->tickets->event_id = $this->event_id;
|
148 |
+
}
|
149 |
+
return apply_filters('em_bookings_get_tickets', $this->tickets, $this);
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Returns EM_Tickets object with available tickets
|
154 |
+
* @return EM_Tickets
|
155 |
+
*/
|
156 |
+
function get_available_tickets(){
|
157 |
+
$tickets = array();
|
158 |
+
foreach ($this->get_tickets() as $EM_Ticket){
|
159 |
+
/* @var $EM_Ticket EM_Ticket */
|
160 |
+
if( $EM_Ticket->is_available() ){
|
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_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(){
|
194 |
+
return count($this->get_available_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(){
|
209 |
+
//TODO extend booking options
|
210 |
+
$return = $this->has_open_time() && $this->has_space();
|
211 |
+
return apply_filters('em_bookings_is_open', $return, $this);
|
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 |
+
//FIXME there is a vulnerability where any user can approve/reject bookings if they know the ID
|
272 |
+
if( $this->array_is_numeric($booking_ids) ){
|
273 |
+
//Get all the bookings
|
274 |
+
$results = array();
|
275 |
+
$mails = array();
|
276 |
+
foreach( $booking_ids as $booking_id ){
|
277 |
+
$EM_Booking = new EM_Booking($booking_id);
|
278 |
+
if( !$EM_Booking->can_manage() ){
|
279 |
+
$this->feedback_message = __('Bookings %s. Mails Sent.', 'dbem');
|
280 |
+
return false;
|
281 |
+
}
|
282 |
+
$results[] = $EM_Booking->set_status($status);
|
283 |
+
}
|
284 |
+
if( !in_array('false',$results) ){
|
285 |
+
$this->feedback_message = __('Bookings %s. Mails Sent.', 'dbem');
|
286 |
+
return true;
|
287 |
+
}else{
|
288 |
+
//TODO Better error handling needed if some bookings fail approval/failure
|
289 |
+
$this->feedback_message = __('An error occurred.', 'dbem');
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
}elseif( is_numeric($booking_ids) || is_object($booking_ids) ){
|
293 |
+
$EM_Booking = ( is_object($booking_ids) && get_class($booking_ids) == 'EM_Booking') ? $booking_ids : new EM_Booking($booking_ids);
|
294 |
+
$result = $EM_Booking->set_status($status);
|
295 |
+
$this->feedback_message = $EM_Booking->feedback_message;
|
296 |
+
return $result;
|
297 |
+
}
|
298 |
+
return false;
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
/**
|
303 |
+
* 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.
|
304 |
+
* @param boolean $force_refresh
|
305 |
+
* @return int
|
306 |
+
*/
|
307 |
+
function get_spaces( $force_refresh=false ){
|
308 |
+
if($force_refresh || $this->spaces == 0){
|
309 |
+
$this->spaces = $this->get_tickets()->get_spaces();
|
310 |
+
}
|
311 |
+
//check overall events cap
|
312 |
+
if(!empty($this->get_event()->event_spaces) && $this->get_event()->event_spaces < $this->spaces) $this->spaces = $this->get_event()->event_spaces;
|
313 |
+
return apply_filters('em_booking_get_spaces',$this->spaces,$this);
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Returns number of available spaces for this event. If approval of bookings is on, will include pending bookings depending on em option.
|
318 |
+
* @return int
|
319 |
+
*/
|
320 |
+
function get_available_spaces(){
|
321 |
+
$spaces = $this->get_spaces();
|
322 |
+
$available_spaces = $spaces - $this->get_booked_spaces();
|
323 |
+
if( get_option('dbem_bookings_approval_reserved') ){ //deduct reserved/pending spaces from available spaces
|
324 |
+
$available_spaces -= $this->get_pending_spaces();
|
325 |
+
}
|
326 |
+
return apply_filters('em_booking_get_available_spaces', $available_spaces, $this);
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Returns number of booked spaces for this event. If approval of bookings is on, will return number of booked confirmed spaces.
|
331 |
+
* @return int
|
332 |
+
*/
|
333 |
+
function get_booked_spaces($force_refresh = false){
|
334 |
+
$booked_spaces = 0;
|
335 |
+
foreach ( $this->bookings as $EM_Booking ){
|
336 |
+
if( $EM_Booking->booking_status == 1 || (!get_option('dbem_bookings_approval') && $EM_Booking->booking_status == 0 ) ){
|
337 |
+
$booked_spaces += $EM_Booking->get_spaces($force_refresh);
|
338 |
+
}
|
339 |
+
}
|
340 |
+
return apply_filters('em_bookings_get_booked_spaces', $booked_spaces, $this);
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Gets number of pending spaces awaiting approval. Will return 0 if booking approval is not enabled.
|
345 |
+
* @return int
|
346 |
+
*/
|
347 |
+
function get_pending_spaces(){
|
348 |
+
if( get_option('dbem_bookings_approval') == 0 ){
|
349 |
+
return apply_filters('em_bookings_get_pending_spaces', 0, $this);
|
350 |
+
}
|
351 |
+
$pending = 0;
|
352 |
+
foreach ( $this->bookings as $booking ){
|
353 |
+
if($booking->booking_status == 0){
|
354 |
+
$pending += $booking->get_spaces();
|
355 |
+
}
|
356 |
+
}
|
357 |
+
return apply_filters('em_bookings_get_pending_spaces', $pending, $this);
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Gets number of bookings (not spaces). If booking approval is enabled, only the number of approved bookings will be shown.
|
362 |
+
* @return EM_Bookings
|
363 |
+
*/
|
364 |
+
function get_bookings( $all_bookings = false ){
|
365 |
+
$confirmed = array();
|
366 |
+
foreach ( $this->bookings as $booking ){
|
367 |
+
if( $booking->booking_status == 1 || (get_option('dbem_bookings_approval') == 0 && $booking->booking_status == 0) || $all_bookings ){
|
368 |
+
$confirmed[] = $booking;
|
369 |
+
}
|
370 |
+
}
|
371 |
+
$EM_Bookings = new EM_Bookings($confirmed);
|
372 |
+
return $EM_Bookings;
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Get pending bookings. If booking approval is disabled, will return no bookings.
|
377 |
+
* @return EM_Bookings
|
378 |
+
*/
|
379 |
+
function get_pending_bookings(){
|
380 |
+
if( get_option('dbem_bookings_approval') == 0 ){
|
381 |
+
return new EM_Bookings();
|
382 |
+
}
|
383 |
+
$pending = array();
|
384 |
+
foreach ( $this->bookings as $booking ){
|
385 |
+
if($booking->booking_status == 0){
|
386 |
+
$pending[] = $booking;
|
387 |
+
}
|
388 |
+
}
|
389 |
+
$EM_Bookings = new EM_Bookings($pending);
|
390 |
+
return $EM_Bookings;
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Get rejected bookings. If booking approval is disabled, will return no bookings.
|
395 |
+
* @return array EM_Bookings
|
396 |
+
*/
|
397 |
+
function get_rejected_bookings(){
|
398 |
+
$rejected = array();
|
399 |
+
foreach ( $this->bookings as $booking ){
|
400 |
+
if($booking->booking_status == 2){
|
401 |
+
$rejected[] = $booking;
|
402 |
+
}
|
403 |
+
}
|
404 |
+
$EM_Bookings = new EM_Bookings($rejected);
|
405 |
+
return $EM_Bookings;
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Get cancelled bookings.
|
410 |
+
* @return array EM_Booking
|
411 |
+
*/
|
412 |
+
function get_cancelled_bookings(){
|
413 |
+
$cancelled = array();
|
414 |
+
foreach ( $this->bookings as $booking ){
|
415 |
+
if($booking->booking_status == 3){
|
416 |
+
$cancelled[] = $booking;
|
417 |
+
}
|
418 |
+
}
|
419 |
+
$EM_Bookings = new EM_Bookings($cancelled);
|
420 |
+
return $EM_Bookings;
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Checks if a person with similar details has booked for this before
|
425 |
+
* @param $person_id
|
426 |
+
* @return EM_Booking
|
427 |
+
*/
|
428 |
+
function find_previous_booking($EM_Booking){
|
429 |
+
//First see if we have a similar person on record that's making this booking
|
430 |
+
$EM_Booking->person->load_similar();
|
431 |
+
//If person exists on record, see if they've booked this event before, if so return the booking.
|
432 |
+
if( is_numeric($EM_Booking->person->ID) && $EM_Booking->person->ID > 0 ){
|
433 |
+
$EM_Booking->person_id = $EM_Booking->person->ID;
|
434 |
+
foreach ($this->bookings as $booking){
|
435 |
+
if( $booking->person_id == $EM_Booking->person->ID ){
|
436 |
+
return $booking;
|
437 |
+
}
|
438 |
+
}
|
439 |
+
}
|
440 |
+
return false;
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Checks to see if user has a booking for this event
|
445 |
+
* @param unknown_type $user_id
|
446 |
+
*/
|
447 |
+
function has_booking( $user_id = false ){
|
448 |
+
if( $user_id === false ){
|
449 |
+
$user_id = get_current_user_id();
|
450 |
+
}
|
451 |
+
if( is_numeric($user_id) && $user_id > 0 ){
|
452 |
+
foreach ($this->bookings as $EM_Booking){
|
453 |
+
if( $EM_Booking->person->ID == $user_id && !in_array($EM_Booking->booking_status, array(2,3)) ){
|
454 |
+
return apply_filters('em_bookings_has_booking', $EM_Booking, $this);
|
455 |
+
}
|
456 |
+
}
|
457 |
+
}
|
458 |
+
return apply_filters('em_bookings_has_booking', false, $this);
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Get bookings that match the array of arguments passed.
|
463 |
+
* @return array
|
464 |
+
* @static
|
465 |
+
*/
|
466 |
+
function get( $args = array(), $count = false ){
|
467 |
+
global $wpdb,$current_user;
|
468 |
+
$bookings_table = EM_BOOKINGS_TABLE;
|
469 |
+
$events_table = EM_EVENTS_TABLE;
|
470 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
471 |
+
|
472 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
473 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
474 |
+
//We can just get all the events here and return them
|
475 |
+
$sql = "
|
476 |
+
SELECT * FROM $bookings_table b
|
477 |
+
LEFT JOIN $events_table e ON e.event_id=b.event_id
|
478 |
+
WHERE booking_id".implode(" OR booking_id=", $args);
|
479 |
+
$results = $wpdb->get_results(apply_filters('em_bookings_get_sql',$sql),ARRAY_A);
|
480 |
+
$bookings = array();
|
481 |
+
foreach($results as $result){
|
482 |
+
$bookings[] = new EM_Booking($result);
|
483 |
+
}
|
484 |
+
return $bookings; //We return all the bookings matched as an EM_Booking array.
|
485 |
+
}
|
486 |
+
|
487 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
488 |
+
$args = self::get_default_search($args);
|
489 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
490 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
491 |
+
|
492 |
+
//Get the default conditions
|
493 |
+
$conditions = self::build_sql_conditions($args);
|
494 |
+
//Put it all together
|
495 |
+
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
496 |
+
|
497 |
+
//Get ordering instructions
|
498 |
+
$EM_Booking = new EM_Booking();
|
499 |
+
$accepted_fields = $EM_Booking->get_fields(true);
|
500 |
+
$orderby = self::build_sql_orderby($args, $accepted_fields);
|
501 |
+
//Now, build orderby sql
|
502 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
|
503 |
+
//Selector
|
504 |
+
$selectors = ( $count ) ? 'COUNT(*)':'*';
|
505 |
+
|
506 |
+
//Create the SQL statement and execute
|
507 |
+
$sql = "
|
508 |
+
SELECT $selectors FROM $bookings_table
|
509 |
+
LEFT JOIN $events_table ON {$events_table}.event_id={$bookings_table}.event_id
|
510 |
+
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
511 |
+
$where
|
512 |
+
$orderby_sql
|
513 |
+
$limit $offset
|
514 |
+
";
|
515 |
+
//If we're only counting results, return the number of results
|
516 |
+
if( $count ){
|
517 |
+
return apply_filters('em_bookings_get_count', $wpdb->get_var($sql), $args);
|
518 |
+
}
|
519 |
+
$results = $wpdb->get_results( apply_filters('em_events_get_sql',$sql, $args), ARRAY_A);
|
520 |
+
|
521 |
+
//If we want results directly in an array, why not have a shortcut here?
|
522 |
+
if( $args['array'] == true ){
|
523 |
+
return $results;
|
524 |
+
}
|
525 |
+
|
526 |
+
//Make returned results EM_Booking objects
|
527 |
+
$results = (is_array($results)) ? $results:array();
|
528 |
+
$bookings = array();
|
529 |
+
foreach ( $results as $booking ){
|
530 |
+
$bookings[] = new EM_Booking($booking);
|
531 |
+
}
|
532 |
+
$EM_Bookings = new EM_Bookings($bookings);
|
533 |
+
return apply_filters('em_bookings_get', $EM_Bookings);
|
534 |
+
}
|
535 |
+
|
536 |
+
function count( $args = array() ){
|
537 |
+
return self::get($args, true);
|
538 |
+
}
|
539 |
+
|
540 |
+
|
541 |
+
//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.
|
542 |
+
function export_csv() {
|
543 |
+
global $EM_Event;
|
544 |
+
if($EM_Event->event_id != $this->event_id ){
|
545 |
+
$event = $this->get_event();
|
546 |
+
$event_name = $event->name;
|
547 |
+
}else{
|
548 |
+
$event_name = $EM_Event->name;
|
549 |
+
}
|
550 |
+
// The name of the file on the user's pc
|
551 |
+
$file_name = sanitize_title($event_name). "-bookings.csv";
|
552 |
+
|
553 |
+
header("Content-Type: application/octet-stream");
|
554 |
+
header("Content-Disposition: Attachment; filename=$file_name");
|
555 |
+
em_locate_template('templates/csv-event-bookings.php', true);
|
556 |
+
exit();
|
557 |
+
}
|
558 |
+
|
559 |
+
/* Overrides EM_Object method to apply a filter to result
|
560 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
|
561 |
+
*/
|
562 |
+
function build_sql_conditions( $args = array() ){
|
563 |
+
$conditions = apply_filters( 'em_bookings_build_sql_conditions', parent::build_sql_conditions($args), $args );
|
564 |
+
if( is_numeric($args['status']) ){
|
565 |
+
$conditions['status'] = 'booking_status='.$args['status'];
|
566 |
+
}elseif( is_array($args['status']) && count($args['status']) > 0 ){
|
567 |
+
$conditions['status'] = 'booking_status IN ('.implode(',',$args['status']).')';
|
568 |
+
}elseif( !is_array($args['status']) && preg_match('/^([0-9],?)+$/', $args['status']) ){
|
569 |
+
$conditions['status'] = 'booking_status IN ('.$args['status'].')';
|
570 |
+
}
|
571 |
+
if( is_numeric($args['person']) && current_user_can('manage_others_bookings') ){
|
572 |
+
$conditions['person'] = EM_BOOKINGS_TABLE.'.person_id='.$args['person'];
|
573 |
+
}
|
574 |
+
if( EM_MS_GLOBAL && !empty($args['blog']) && is_numeric($args['blog']) ){
|
575 |
+
if( is_main_site($args['blog']) ){
|
576 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']} OR ".EM_EVENTS_TABLE.".blog_id IS NULL)";
|
577 |
+
}else{
|
578 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']})";
|
579 |
+
}
|
580 |
+
}
|
581 |
+
if( is_numeric($args['ticket_id']) ){
|
582 |
+
$EM_Ticket = new EM_Ticket($args['ticket_id']);
|
583 |
+
if( $EM_Ticket->can_manage() ){
|
584 |
+
$conditions['ticket'] = EM_BOOKINGS_TABLE.'.booking_id IN (SELECT booking_id FROM '.EM_TICKETS_BOOKINGS_TABLE." WHERE ticket_id='{$args['ticket_id']}')";
|
585 |
+
}
|
586 |
+
}
|
587 |
+
return apply_filters('em_bookings_build_sql_conditions', $conditions, $args);
|
588 |
+
}
|
589 |
+
|
590 |
+
/* Overrides EM_Object method to apply a filter to result
|
591 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
|
592 |
+
*/
|
593 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
594 |
+
return apply_filters( 'em_bookings_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order')), $args, $accepted_fields, $default_order );
|
595 |
+
}
|
596 |
+
|
597 |
+
/*
|
598 |
+
* Adds custom Events search defaults
|
599 |
+
* @param array $array
|
600 |
+
* @return array
|
601 |
+
* @uses EM_Object#get_default_search()
|
602 |
+
*/
|
603 |
+
function get_default_search( $array = array() ){
|
604 |
+
$defaults = array(
|
605 |
+
'status' => false,
|
606 |
+
'person' => true, //to add later, search by person's bookings...
|
607 |
+
'blog' => get_current_blog_id(),
|
608 |
+
'ticket_id' => false
|
609 |
+
);
|
610 |
+
if( true || is_admin() ){
|
611 |
+
//figure out default owning permissions
|
612 |
+
if( !current_user_can('edit_others_events') ){
|
613 |
+
$defaults['owner'] = get_current_user_id();
|
614 |
+
}else{
|
615 |
+
$defaults['owner'] = false;
|
616 |
+
}
|
617 |
+
}
|
618 |
+
if( EM_MS_GLOBAL && !is_admin() ){
|
619 |
+
if( empty($array['blog']) && is_main_site() && get_site_option('dbem_ms_global_events') ){
|
620 |
+
$array['blog'] = false;
|
621 |
+
}
|
622 |
+
}
|
623 |
+
return apply_filters('em_bookings_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
|
624 |
+
}
|
625 |
+
|
626 |
+
//Iterator Implementation
|
627 |
+
public function rewind(){
|
628 |
+
reset($this->bookings);
|
629 |
+
}
|
630 |
+
public function current(){
|
631 |
+
$var = current($this->bookings);
|
632 |
+
return $var;
|
633 |
+
}
|
634 |
+
public function key(){
|
635 |
+
$var = key($this->bookings);
|
636 |
+
return $var;
|
637 |
+
}
|
638 |
+
public function next(){
|
639 |
+
$var = next($this->bookings);
|
640 |
+
return $var;
|
641 |
+
}
|
642 |
+
public function valid(){
|
643 |
+
$key = key($this->bookings);
|
644 |
+
$var = ($key !== NULL && $key !== FALSE);
|
645 |
+
return $var;
|
646 |
+
}
|
647 |
+
}
|
648 |
Â
?>
|
classes/em-calendar.php
CHANGED
@@ -1,366 +1,381 @@
|
|
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 |
-
// the
|
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 |
-
|
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 |
-
* Helper function to create a link querystring from array which contains arguments with only values that aren't defuaults.
|
331 |
-
*/
|
332 |
-
function get_link_args($args = array(), $html_entities=true){
|
333 |
-
unset($args['month']); unset($args['year']);
|
334 |
-
$default_args = self::get_default_search(array());
|
335 |
-
foreach($default_args as $arg_key => $arg_value){
|
336 |
-
if( !isset($args[$arg_key]) || $args[$arg_key] == $arg_value ){
|
337 |
-
unset($args[$arg_key]);
|
338 |
-
}
|
339 |
-
}
|
340 |
-
$qs_array = array();
|
341 |
-
foreach($args as $key => $value){
|
342 |
-
if(is_array($value)){
|
343 |
-
$value = implode(',',$value);
|
344 |
-
}
|
345 |
-
$qs_array[] = "$key=".urlencode($value);
|
346 |
-
}
|
347 |
-
return ($html_entities) ? implode('&', $qs_array) : implode('&', $qs_array);
|
348 |
-
}
|
349 |
-
|
350 |
-
|
351 |
-
function get_default_search($array=array()){
|
352 |
-
//These defaults aren't for db queries, but flags for what to display in calendar output
|
353 |
-
$defaults = array(
|
354 |
-
'full' => 0, //Will display a full calendar with event names
|
355 |
-
'long_events' => 0, //Events that last longer than a day
|
356 |
-
'scope' => '
|
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 |
+
$original_args = $args;
|
16 |
+
$args = self::get_default_search($args);
|
17 |
+
$full = $args['full']; //For ZDE, don't delete pls
|
18 |
+
$month = $args['month'];
|
19 |
+
$year = $args['year'];
|
20 |
+
$long_events = $args['long_events'];
|
21 |
+
|
22 |
+
$week_starts_on_sunday = get_option('dbem_week_starts_sunday');
|
23 |
+
$start_of_week = get_option('start_of_week');
|
24 |
+
|
25 |
+
if( !(is_numeric($month) && $month <= 12 && $month > 0) ) {
|
26 |
+
$month = date('m');
|
27 |
+
}
|
28 |
+
if( !( is_numeric($year) ) ){
|
29 |
+
$year = date('Y');
|
30 |
+
}
|
31 |
+
|
32 |
+
// Get the first day of the month
|
33 |
+
$month_start = mktime(0,0,0,$month, 1, $year);
|
34 |
+
$calendar_array['month_start'] = $month_start;
|
35 |
+
|
36 |
+
// Get friendly month name
|
37 |
+
$month_name = date('M',$month_start);
|
38 |
+
// Figure out which day of the week
|
39 |
+
// the month starts on.
|
40 |
+
$month_start_day = date('D', $month_start);
|
41 |
+
|
42 |
+
switch($month_start_day){
|
43 |
+
case "Sun": $offset = 0; break;
|
44 |
+
case "Mon": $offset = 1; break;
|
45 |
+
case "Tue": $offset = 2; break;
|
46 |
+
case "Wed": $offset = 3; break;
|
47 |
+
case "Thu": $offset = 4; break;
|
48 |
+
case "Fri": $offset = 5; break;
|
49 |
+
case "Sat": $offset = 6; break;
|
50 |
+
}
|
51 |
+
//We need to go back to the WP defined day when the week started, in case the event day is near the end
|
52 |
+
$offset -= $start_of_week;
|
53 |
+
if($offset<0)
|
54 |
+
$offset += 7;
|
55 |
+
|
56 |
+
// determine how many days are in the last month.
|
57 |
+
$month_last = $month-1;
|
58 |
+
$month_next = $month+1;
|
59 |
+
$calendar_array['month_next'] = $month_next;
|
60 |
+
$year_last = $year;
|
61 |
+
$year_next = $year;
|
62 |
+
$calendar_array['year_next'] = $year_next;
|
63 |
+
|
64 |
+
if($month == 1) {
|
65 |
+
$month_last = 12;
|
66 |
+
$year_last = $year -1;
|
67 |
+
}elseif($month == 12){
|
68 |
+
$month_next = 1;
|
69 |
+
$year_next = $year + 1;
|
70 |
+
}
|
71 |
+
$calendar_array['month_last'] = $month_last;
|
72 |
+
$calendar_array['year_last'] = $year_last;
|
73 |
+
|
74 |
+
$num_days_last = self::days_in_month($month_last, $year_last);
|
75 |
+
|
76 |
+
// determine how many days are in the current month.
|
77 |
+
$num_days_current = self::days_in_month($month, $year);
|
78 |
+
// Build an array for the current days
|
79 |
+
// in the month
|
80 |
+
for($i = 1; $i <= $num_days_current; $i++){
|
81 |
+
$num_days_array[] = mktime(0,0,0,$month, $i, $year);
|
82 |
+
}
|
83 |
+
// Build an array for the number of days
|
84 |
+
// in last month
|
85 |
+
for($i = 1; $i <= $num_days_last; $i++){
|
86 |
+
$num_days_last_array[] = mktime(0,0,0,$month_last, $i, $year_last);
|
87 |
+
}
|
88 |
+
// If the $offset from the starting day of the
|
89 |
+
// week happens to be Sunday, $offset would be 0,
|
90 |
+
// so don't need an offset correction.
|
91 |
+
|
92 |
+
if($offset > 0){
|
93 |
+
$offset_correction = array_slice($num_days_last_array, -$offset, $offset);
|
94 |
+
$new_count = array_merge($offset_correction, $num_days_array);
|
95 |
+
$offset_count = count($offset_correction);
|
96 |
+
} else { // The else statement is to prevent building the $offset array.
|
97 |
+
$offset_count = 0;
|
98 |
+
$new_count = $num_days_array;
|
99 |
+
}
|
100 |
+
// count how many days we have with the two
|
101 |
+
// previous arrays merged together
|
102 |
+
$current_num = count($new_count);
|
103 |
+
|
104 |
+
// Since we will have 5 HTML table rows (TR)
|
105 |
+
// with 7 table data entries (TD)
|
106 |
+
// we need to fill in 35 TDs
|
107 |
+
// so, we will have to figure out
|
108 |
+
// how many days to appened to the end
|
109 |
+
// of the final array to make it 35 days.
|
110 |
+
if($current_num > 35){
|
111 |
+
$num_weeks = 6;
|
112 |
+
$outset = (42 - $current_num);
|
113 |
+
} elseif($current_num < 35){
|
114 |
+
$num_weeks = 5;
|
115 |
+
$outset = (35 - $current_num);
|
116 |
+
}
|
117 |
+
if($current_num == 35){
|
118 |
+
$num_weeks = 5;
|
119 |
+
$outset = 0;
|
120 |
+
}
|
121 |
+
// Outset Correction
|
122 |
+
for($i = 1; $i <= $outset; $i++){
|
123 |
+
$new_count[] = mktime(0,0,0,$month_next, $i, $year_next);
|
124 |
+
}
|
125 |
+
// Now let's "chunk" the $all_days array
|
126 |
+
// into weeks. Each week has 7 days
|
127 |
+
// so we will array_chunk it into 7 days.
|
128 |
+
$weeks = array_chunk($new_count, 7);
|
129 |
+
|
130 |
+
//Get an array of arguments that don't include default valued args
|
131 |
+
$link_args = self::get_link_args($args);
|
132 |
+
|
133 |
+
$previous_url = "?ajaxCalendar=1&mo={$month_last}&yr={$year_last}&{$link_args}";
|
134 |
+
$next_url = "?ajaxCalendar=1&mo={$month_next}&yr={$year_next}&{$link_args}";
|
135 |
+
|
136 |
+
$weekdays = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
|
137 |
+
if(!empty($args['full'])) {
|
138 |
+
if( get_option('dbem_full_calendar_abbreviated_weekdays') ) $weekdays = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
|
139 |
+
$day_initials_length = get_option('dbem_full_calendar_initials_length');
|
140 |
+
} else {
|
141 |
+
if ( get_option('dbem_small_calendar_abbreviated_weekdays') ) $weekdays = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
|
142 |
+
$day_initials_length = get_option('dbem_small_calendar_initials_length');
|
143 |
+
}
|
144 |
+
|
145 |
+
for( $n = 0; $n < $start_of_week; $n++ ) {
|
146 |
+
$last_day = array_shift($weekdays);
|
147 |
+
$weekdays[]= $last_day;
|
148 |
+
}
|
149 |
+
|
150 |
+
$days_initials_array = array();
|
151 |
+
foreach($weekdays as $weekday) {
|
152 |
+
$days_initials_array[] = self::translate_and_trim($weekday, $day_initials_length);
|
153 |
+
}
|
154 |
+
|
155 |
+
$calendar_array['links'] = array( 'previous_url'=>$previous_url, 'next_url'=>$next_url);
|
156 |
+
$calendar_array['row_headers'] = $days_initials_array;
|
157 |
+
|
158 |
+
// Now we break each key of the array
|
159 |
+
// into a week and create a new table row for each
|
160 |
+
// week with the days of that week in the table data
|
161 |
+
|
162 |
+
$i = 0;
|
163 |
+
$current_date = date('Y-m-d', current_time('timestamp'));
|
164 |
+
$week_count = 0;
|
165 |
+
foreach ( $weeks as $week ) {
|
166 |
+
foreach ( $week as $d ) {
|
167 |
+
$date = date('Y-m-d', $d);
|
168 |
+
$calendar_array['cells'][$date] = array('date'=>$d); //set it up so we have the exact array of dates to be filled
|
169 |
+
if ($i < $offset_count) { //if it is PREVIOUS month
|
170 |
+
$calendar_array['cells'][$date]['type'] = 'pre';
|
171 |
+
}
|
172 |
+
if (($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)) { // if it is THIS month
|
173 |
+
if ( $current_date == $date ){
|
174 |
+
$calendar_array['cells'][$date]['type'] = 'today';
|
175 |
+
}
|
176 |
+
} elseif (($outset > 0)) { //if it is NEXT month
|
177 |
+
if (($i >= ($num_weeks * 7) - $outset)) {
|
178 |
+
$calendar_array['cells'][$date]['type'] = 'post';
|
179 |
+
}
|
180 |
+
}
|
181 |
+
$i ++;
|
182 |
+
}
|
183 |
+
$week_count++;
|
184 |
+
}
|
185 |
+
|
186 |
+
// query the database for events in this time span
|
187 |
+
if ($month == 1) {
|
188 |
+
$month_pre=12;
|
189 |
+
$month_post=2;
|
190 |
+
$year_pre=$year-1;
|
191 |
+
$year_post=$year;
|
192 |
+
} elseif($month == 12) {
|
193 |
+
$month_pre=11;
|
194 |
+
$month_post=1;
|
195 |
+
$year_pre=$year;
|
196 |
+
$year_post=$year+1;
|
197 |
+
} else {
|
198 |
+
$month_pre=$month-1;
|
199 |
+
$month_post=$month+1;
|
200 |
+
$year_pre=$year;
|
201 |
+
$year_post=$year;
|
202 |
+
}
|
203 |
+
$args['year'] = array($year_pre, $year_post);
|
204 |
+
$args['month'] = array($month_pre, $month_post);
|
205 |
+
$events = EM_Events::get($args);
|
206 |
+
|
207 |
+
$event_format = get_option('dbem_full_calendar_event_format');
|
208 |
+
$event_title_format = get_option('dbem_small_calendar_event_title_format');
|
209 |
+
$event_title_separator_format = get_option('dbem_small_calendar_event_title_separator');
|
210 |
+
|
211 |
+
$eventful_days= array();
|
212 |
+
if($events){
|
213 |
+
//Go through the events and slot them into the right d-m index
|
214 |
+
foreach($events as $event) {
|
215 |
+
$event = apply_filters('em_calendar_output_loop_start', $event);
|
216 |
+
if( $long_events ){
|
217 |
+
//If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day
|
218 |
+
$event_start_date = strtotime($event->start_date);
|
219 |
+
$event_end_date = mktime(0,0,0,$month_post,date('t', $event_start_date),$year_post );
|
220 |
+
if( $event_end_date == '' ) $event_end_date = $event_start_date;
|
221 |
+
while( $event_start_date <= $event->end ){
|
222 |
+
//Ensure date is within event dates, if so add to eventful days array
|
223 |
+
$event_eventful_date = date('Y-m-d', $event_start_date);
|
224 |
+
if( array_key_exists($event_eventful_date, $eventful_days) && is_array($eventful_days[$event_eventful_date]) ){
|
225 |
+
$eventful_days[$event_eventful_date][] = $event;
|
226 |
+
} else {
|
227 |
+
$eventful_days[$event_eventful_date] = array($event);
|
228 |
+
}
|
229 |
+
$event_start_date += (86400); //add a day
|
230 |
+
}
|
231 |
+
}else{
|
232 |
+
//Only show events on the day that they start
|
233 |
+
if( isset($eventful_days[$event->event_start_date]) && is_array($eventful_days[$event->event_start_date]) ){
|
234 |
+
$eventful_days[$event->event_start_date][] = $event;
|
235 |
+
} else {
|
236 |
+
$eventful_days[$event->event_start_date] = array($event);
|
237 |
+
}
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
//generate a link argument string containing event search only
|
242 |
+
$day_link_args = self::get_link_args( array_intersect_key($original_args, EM_Events::get_post_search($args, true) ));
|
243 |
+
foreach($eventful_days as $day_key => $events) {
|
244 |
+
if( array_key_exists($day_key, $calendar_array['cells']) ){
|
245 |
+
//Get link title for this date
|
246 |
+
$events_titles = array();
|
247 |
+
foreach($events as $event) {
|
248 |
+
if( !get_option('dbem_display_calendar_events_limit') || count($events_titles) < get_option('dbem_display_calendar_events_limit') ){
|
249 |
+
$events_titles[] = $event->output($event_title_format);
|
250 |
+
}else{
|
251 |
+
$events_titles[] = get_option('dbem_display_calendar_events_limit_msg');
|
252 |
+
break;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
$calendar_array['cells'][$day_key]['link_title'] = implode( $event_title_separator_format, $events_titles);
|
256 |
+
|
257 |
+
//Get the link to this calendar day
|
258 |
+
global $wp_rewrite;
|
259 |
+
if( count($events) > 1 || !get_option('dbem_calendar_direct_links') ){
|
260 |
+
if( get_option("dbem_events_page") > 0 ){
|
261 |
+
$event_page_link = get_permalink(get_option("dbem_events_page")); //PAGE URI OF EM
|
262 |
+
}else{
|
263 |
+
if( $wp_rewrite->using_permalinks() ){
|
264 |
+
$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.
|
265 |
+
}else{
|
266 |
+
$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.
|
267 |
+
}
|
268 |
+
}
|
269 |
+
if( $wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS') ){
|
270 |
+
$calendar_array['cells'][$day_key]['link'] = trailingslashit($event_page_link).$day_key."/";
|
271 |
+
if( !empty($day_link_args) ){
|
272 |
+
$calendar_array['cells'][$day_key]['link'] .= '?'.$day_link_args;
|
273 |
+
}
|
274 |
+
}else{
|
275 |
+
$joiner = (stristr($event_page_link, "?")) ? "&" : "?";
|
276 |
+
$calendar_array['cells'][$day_key]['link'] = $event_page_link.$joiner."calendar_day=".$day_key;
|
277 |
+
if( !empty($day_link_args) ){
|
278 |
+
$calendar_array['cells'][$day_key]['link'] .= '&'.$day_link_args;
|
279 |
+
}
|
280 |
+
}
|
281 |
+
}else{
|
282 |
+
foreach($events as $EM_Event){
|
283 |
+
$calendar_array['cells'][$day_key]['link'] = $EM_Event->get_permalink();
|
284 |
+
}
|
285 |
+
}
|
286 |
+
//Add events to array
|
287 |
+
$calendar_array['cells'][$day_key]['events'] = $events;
|
288 |
+
}
|
289 |
+
}
|
290 |
+
return apply_filters('em_calendar_get',$calendar_array, $args);
|
291 |
+
}
|
292 |
+
|
293 |
+
function output($args = array(), $wrapper = true) {
|
294 |
+
//Let month and year REQUEST override for non-JS users
|
295 |
+
if( !empty($_REQUEST['mo']) || !empty($args['mo']) ){
|
296 |
+
$args['month'] = ($_REQUEST['mo']) ? $_REQUEST['mo']:$args['mo'];
|
297 |
+
}
|
298 |
+
if( !empty($_REQUEST['yr']) || !empty($args['yr']) ){
|
299 |
+
$args['year'] = (!empty($_REQUEST['yr'])) ? $_REQUEST['yr']:$args['yr'];
|
300 |
+
}
|
301 |
+
$calendar_array = self::get($args);
|
302 |
+
$template = (!empty($args['full'])) ? 'templates/calendar-full.php':'templates/calendar-small.php';
|
303 |
+
ob_start();
|
304 |
+
em_locate_template($template, true, array('calendar'=>$calendar_array,'args'=>$args));
|
305 |
+
if($wrapper){
|
306 |
+
$calendar = '<div id="em-calendar-'.rand(100,200).'" class="em-calendar-wrapper">'.ob_get_clean().'</div>';
|
307 |
+
}else{
|
308 |
+
$calendar = ob_get_clean();
|
309 |
+
}
|
310 |
+
return apply_filters('em_calendar_output', $calendar, $args);
|
311 |
+
}
|
312 |
+
|
313 |
+
|
314 |
+
function days_in_month($month, $year) {
|
315 |
+
return date('t', mktime(0,0,0,$month,1,$year));
|
316 |
+
}
|
317 |
+
|
318 |
+
function translate_and_trim($string, $length = 1) {
|
319 |
+
if( $length > 0 ){
|
320 |
+
if(function_exists('mb_substr')){ //fix for diacritic calendar names
|
321 |
+
return mb_substr(__($string,'dbem'), 0, $length, 'UTF-8');
|
322 |
+
}else{
|
323 |
+
return substr(__($string,'dbem'), 0, $length);
|
324 |
+
}
|
325 |
+
}
|
326 |
+
return __($string,'dbem');
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Helper function to create a link querystring from array which contains arguments with only values that aren't defuaults.
|
331 |
+
*/
|
332 |
+
function get_link_args($args = array(), $html_entities=true){
|
333 |
+
unset($args['month']); unset($args['year']);
|
334 |
+
$default_args = self::get_default_search(array());
|
335 |
+
foreach($default_args as $arg_key => $arg_value){
|
336 |
+
if( !isset($args[$arg_key]) || $args[$arg_key] == $arg_value ){
|
337 |
+
unset($args[$arg_key]);
|
338 |
+
}
|
339 |
+
}
|
340 |
+
$qs_array = array();
|
341 |
+
foreach($args as $key => $value){
|
342 |
+
if(is_array($value)){
|
343 |
+
$value = implode(',',$value);
|
344 |
+
}
|
345 |
+
$qs_array[] = "$key=".urlencode($value);
|
346 |
+
}
|
347 |
+
return ($html_entities) ? implode('&', $qs_array) : implode('&', $qs_array);
|
348 |
+
}
|
349 |
+
|
350 |
+
|
351 |
+
function get_default_search($array=array()){
|
352 |
+
//These defaults aren't for db queries, but flags for what to display in calendar output
|
353 |
+
$defaults = array(
|
354 |
+
'full' => 0, //Will display a full calendar with event names
|
355 |
+
'long_events' => 0, //Events that last longer than a day
|
356 |
+
'scope' => 'future',
|
357 |
+
'status' => 1, //approved events only
|
358 |
+
'town' => false,
|
359 |
+
'state' => false,
|
360 |
+
'country' => false,
|
361 |
+
'region' => false,
|
362 |
+
'blog' => get_current_blog_id(),
|
363 |
+
'orderby' => get_option('dbem_display_calendar_orderby'),
|
364 |
+
'order' => get_option('dbem_display_calendar_order')
|
365 |
+
);
|
366 |
+
if(is_multisite()){
|
367 |
+
global $bp;
|
368 |
+
if( !is_main_site() && !array_key_exists('blog',$array) ){
|
369 |
+
//not the main blog, force single blog search
|
370 |
+
$array['blog'] = get_current_blog_id();
|
371 |
+
}elseif( empty($array['blog']) && get_site_option('dbem_ms_global_events') ) {
|
372 |
+
$array['blog'] = false;
|
373 |
+
}
|
374 |
+
}
|
375 |
+
$atts = parent::get_default_search($defaults, $array);
|
376 |
+
$atts['full'] = ($atts['full']==true) ? 1:0;
|
377 |
+
$atts['long_events'] = ($atts['long_events']==true) ? 1:0;
|
378 |
+
return apply_filters('em_calendar_get_default_search', $atts, $array, $defaults);
|
379 |
+
}
|
380 |
+
}
|
381 |
+
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,321 @@
|
|
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 |
+
//Can be either an array for the get search or an array of EM_Category objects
|
142 |
+
if( is_object(current($args)) && get_class((current($args))) == 'EM_Category' ){
|
143 |
+
$func_args = func_get_args();
|
144 |
+
$categories = $func_args[0];
|
145 |
+
$args = (!empty($func_args[1])) ? $func_args[1] : array();
|
146 |
+
$args = apply_filters('em_categories_output_args', self::get_default_search($args), $categories);
|
147 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
148 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
149 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
150 |
+
}else{
|
151 |
+
$args = apply_filters('em_categories_output_args', self::get_default_search($args) );
|
152 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
153 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
154 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
155 |
+
$args['limit'] = false;
|
156 |
+
$args['offset'] = false;
|
157 |
+
$args['page'] = false;
|
158 |
+
$categories = self::get( $args );
|
159 |
+
}
|
160 |
+
//What format shall we output this to, or use default
|
161 |
+
$format = ( $args['format'] == '' ) ? get_option( 'dbem_categories_list_item_format' ) : $args['format'] ;
|
162 |
+
|
163 |
+
$output = "";
|
164 |
+
$categories_count = count($categories);
|
165 |
+
$categories = apply_filters('em_categories_output_categories', $categories);
|
166 |
+
if ( count($categories) > 0 ) {
|
167 |
+
$category_count = 0;
|
168 |
+
$categories_shown = 0;
|
169 |
+
foreach ( $categories as $EM_Category ) {
|
170 |
+
if( ($categories_shown < $limit || empty($limit)) && ($category_count >= $offset || $offset === 0) ){
|
171 |
+
$output .= $EM_Category->output($format);
|
172 |
+
$categories_shown++;
|
173 |
+
}
|
174 |
+
$category_count++;
|
175 |
+
}
|
176 |
+
//Add headers and footers to output
|
177 |
+
if( $format == get_option ( 'dbem_categories_list_item_format' ) ){
|
178 |
+
$single_event_format_header = get_option ( 'dbem_categories_list_item_format_header' );
|
179 |
+
$single_event_format_header = ( $single_event_format_header != '' ) ? $single_event_format_header : "<ul class='em-categories-list'>";
|
180 |
+
$single_event_format_footer = get_option ( 'dbem_categories_list_item_format_footer' );
|
181 |
+
$single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
|
182 |
+
$output = $single_event_format_header . $output . $single_event_format_footer;
|
183 |
+
}
|
184 |
+
//Pagination (if needed/requested)
|
185 |
+
if( !empty($args['pagination']) && !empty($limit) && $categories_count >= $limit ){
|
186 |
+
//Show the pagination links (unless there's less than 10 events, or the custom limit)
|
187 |
+
$page_link_template = preg_replace('/(&|\?)pno=\d+/i','',$_SERVER['REQUEST_URI']);
|
188 |
+
$page_link_template = em_add_get_params($page_link_template, array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing
|
189 |
+
$output .= apply_filters('em_events_output_pagination', em_paginate( $page_link_template, $categories_count, $limit, $page), $page_link_template, $categories_count, $limit, $page);
|
190 |
+
}
|
191 |
+
} else {
|
192 |
+
$output = get_option ( 'dbem_no_categories_message' );
|
193 |
+
}
|
194 |
+
//FIXME check if reference is ok when restoring object, due to changes in php5 v 4
|
195 |
+
$EM_Category_old= $EM_Category;
|
196 |
+
return apply_filters('em_categories_output', $output, $categories, $args);
|
197 |
+
}
|
198 |
+
|
199 |
+
function has( $search ){
|
200 |
+
if( is_numeric($search) ){
|
201 |
+
foreach($this->categories as $EM_Category){
|
202 |
+
if($EM_Category->term_id == $search) return apply_filters('em_categories_has', true, $search, $this);
|
203 |
+
}
|
204 |
+
}else{
|
205 |
+
foreach($this->categories as $EM_Category){
|
206 |
+
if($EM_Category->slug == $search) return apply_filters('em_categories_has', true, $search, $this);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
return apply_filters('em_categories_has', false, $search, $this);
|
210 |
+
}
|
211 |
+
|
212 |
+
function get_first(){
|
213 |
+
foreach($this->categories as $EM_Category){
|
214 |
+
return $EM_Category;
|
215 |
+
}
|
216 |
+
return false;
|
217 |
+
}
|
218 |
+
|
219 |
+
function get_ids(){
|
220 |
+
$ids = array();
|
221 |
+
foreach($this->categories as $EM_Category){
|
222 |
+
if( !empty($EM_Category->term_id) ){
|
223 |
+
$ids[] = $EM_Category->term_id;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
return $ids;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Gets the event for this object, or a blank event if none exists
|
231 |
+
* @return EM_Event
|
232 |
+
*/
|
233 |
+
function get_event(){
|
234 |
+
if( is_numeric($this->event_id) ){
|
235 |
+
return em_get_event($this->event_id);
|
236 |
+
}else{
|
237 |
+
return new EM_Event();
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
/* Overrides EM_Object method to apply a filter to result. Categories won't accept many arguments as you tend to search with events for much else.
|
242 |
+
* @see wp-content/plugins/categories-manager/classes/EM_Object#build_sql_conditions()
|
243 |
+
*/
|
244 |
+
function build_sql_conditions( $args = array() ){
|
245 |
+
global $wpdb;
|
246 |
+
$events_table = EM_EVENTS_TABLE;
|
247 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
248 |
+
|
249 |
+
$temp_conditions = parent::build_sql_conditions($args);
|
250 |
+
$conditions = array();
|
251 |
+
if( !empty($temp_conditions['category']) ){
|
252 |
+
$conditions['category'] = $temp_conditions['category'];
|
253 |
+
}
|
254 |
+
return apply_filters( 'em_categories_build_sql_conditions', $conditions, $args );
|
255 |
+
}
|
256 |
+
|
257 |
+
/* Overrides EM_Object method to apply a filter to result
|
258 |
+
* @see wp-content/plugins/categories-manager/classes/EM_Object#build_sql_orderby()
|
259 |
+
*/
|
260 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
261 |
+
return apply_filters( 'em_categories_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_categories_default_order')), $args, $accepted_fields, $default_order );
|
262 |
+
}
|
263 |
+
|
264 |
+
/*
|
265 |
+
* Adds custom categories search defaults
|
266 |
+
* @param array $array
|
267 |
+
* @return array
|
268 |
+
* @uses EM_Object#get_default_search()
|
269 |
+
*/
|
270 |
+
function get_default_search( $array = array() ){
|
271 |
+
$defaults = array(
|
272 |
+
//added from get_terms, so they don't get filtered out
|
273 |
+
'orderby' => 'name', 'order' => 'ASC',
|
274 |
+
'hide_empty' => false, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(),
|
275 |
+
'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
|
276 |
+
'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
|
277 |
+
'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core'
|
278 |
+
);
|
279 |
+
return apply_filters('em_categories_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* will return the default search parameter to use according to permission settings
|
284 |
+
* @return string
|
285 |
+
*/
|
286 |
+
function get_default_search_owner(){
|
287 |
+
//by default, we only get categories the owner can manage
|
288 |
+
$defaults = array('owner'=>false);
|
289 |
+
//by default, we only get categories the owner can manage
|
290 |
+
if( !current_user_can('edit_categories') ){
|
291 |
+
$defaults['owner'] = get_current_user_id();
|
292 |
+
break;
|
293 |
+
}else{
|
294 |
+
$defaults['owner'] = false;
|
295 |
+
break;
|
296 |
+
}
|
297 |
+
return $defaults['owner'];
|
298 |
+
}
|
299 |
+
|
300 |
+
//Iterator Implementation
|
301 |
+
public function rewind(){
|
302 |
+
reset($this->categories);
|
303 |
+
}
|
304 |
+
public function current(){
|
305 |
+
$var = current($this->categories);
|
306 |
+
return $var;
|
307 |
+
}
|
308 |
+
public function key(){
|
309 |
+
$var = key($this->categories);
|
310 |
+
return $var;
|
311 |
+
}
|
312 |
+
public function next(){
|
313 |
+
$var = next($this->categories);
|
314 |
+
return $var;
|
315 |
+
}
|
316 |
+
public function valid(){
|
317 |
+
$key = key($this->categories);
|
318 |
+
$var = ($key !== NULL && $key !== FALSE);
|
319 |
+
return $var;
|
320 |
+
}
|
321 |
Â
}
|
classes/em-category-taxonomy.php
ADDED
@@ -0,0 +1,135 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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;
|
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->posts[0]->post_title = $wp_query->queried_object->post_title = $EM_Category->output(get_option('dbem_category_page_title_format'));
|
23 |
+
}else{
|
24 |
+
//we don't have a categories page, so we create a fake page
|
25 |
+
$wp_query->posts = array();
|
26 |
+
$wp_query->posts[0] = new stdClass();
|
27 |
+
$wp_query->posts[0]->post_title = $wp_query->queried_object->post_title = $EM_Category->output(get_option('dbem_category_page_title_format'));
|
28 |
+
$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');
|
29 |
+
foreach($post_array as $post_array_item){
|
30 |
+
$wp_query->posts[0]->$post_array_item = '';
|
31 |
+
}
|
32 |
+
$wp_query->post = $wp_query->posts[0];
|
33 |
+
$wp_query->post_count = 1;
|
34 |
+
$wp_query->found_posts = 1;
|
35 |
+
$wp_query->max_num_pages = 1;
|
36 |
+
//tweak flags for determining page type
|
37 |
+
$wp_query->is_tax = 0;
|
38 |
+
$wp_query->is_page = 1;
|
39 |
+
$wp_query->is_single = 0;
|
40 |
+
$wp_query->is_singular = 1;
|
41 |
+
$wp_query->is_archive = 0;
|
42 |
+
}
|
43 |
+
add_filter('the_content', array('EM_Category_Taxonomy','the_content')); //come in slightly early and consider other plugins
|
44 |
+
$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
|
45 |
+
$template = locate_template(array('page.php','index.php'),false); //category becomes a page
|
46 |
+
}
|
47 |
+
return $template;
|
48 |
+
}
|
49 |
+
|
50 |
+
function the_content($content){
|
51 |
+
global $wp_query, $EM_Category, $post, $em_category_id;
|
52 |
+
if( !empty($wp_query->em_category_id) || ($post->ID == get_option('dbem_categories_page') && !empty($em_category_id)) ){
|
53 |
+
$EM_Category = empty($wp_query->em_category_id) ? em_get_category($em_category_id):em_get_category($wp_query->em_category_id);
|
54 |
+
ob_start();
|
55 |
+
em_locate_template('templates/category-single.php',true);
|
56 |
+
return ob_get_clean();
|
57 |
+
}
|
58 |
+
return $content;
|
59 |
+
}
|
60 |
+
|
61 |
+
function parse_query( ){
|
62 |
+
global $wp_query;
|
63 |
+
if( is_tax(EM_TAXONOMY_CATEGORY) ){
|
64 |
+
//Scope is future
|
65 |
+
$today = strtotime(date('Y-m-d', current_time('timestamp')));
|
66 |
+
if( get_option('dbem_events_current_are_past') ){
|
67 |
+
$wp_query->query_vars['meta_query'][] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '>=' );
|
68 |
+
}else{
|
69 |
+
$wp_query->query_vars['meta_query'][] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
70 |
+
}
|
71 |
+
if( get_option('dbem_categories_default_archive_orderby') == 'title'){
|
72 |
+
$wp_query->query_vars['orderby'] = 'title';
|
73 |
+
}else{
|
74 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
75 |
+
$wp_query->query_vars['meta_key'] = get_option('dbem_categories_default_archive_orderby','_start_ts');
|
76 |
+
}
|
77 |
+
$wp_query->query_vars['order'] = get_option('dbem_categories_default_archive_order','ASC');
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
EM_Category_Taxonomy::init();
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Create an array of Categories. Copied from Walker_CategoryDropdown, but makes it possible for the selected argument to be an array.
|
85 |
+
*
|
86 |
+
* @package WordPress
|
87 |
+
* @since 2.1.0
|
88 |
+
* @uses Walker
|
89 |
+
*/
|
90 |
+
class EM_Walker_CategoryMultiselect extends Walker {
|
91 |
+
/**
|
92 |
+
* @see Walker::$tree_type
|
93 |
+
* @since 2.1.0
|
94 |
+
* @var string
|
95 |
+
*/
|
96 |
+
var $tree_type = 'event-category';
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @see Walker::$db_fields
|
100 |
+
* @since 2.1.0
|
101 |
+
* @todo Decouple this
|
102 |
+
* @var array
|
103 |
+
*/
|
104 |
+
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
|
105 |
+
|
106 |
+
function __construct(){
|
107 |
+
$tree_type = EM_TAXONOMY_CATEGORY;
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* @see Walker::start_el()
|
111 |
+
* @since 2.1.0
|
112 |
+
*
|
113 |
+
* @param string $output Passed by reference. Used to append additional content.
|
114 |
+
* @param object $category Category data object.
|
115 |
+
* @param int $depth Depth of category. Used for padding.
|
116 |
+
* @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist.
|
117 |
+
*/
|
118 |
+
function start_el(&$output, $category, $depth, $args) {
|
119 |
+
$pad = str_repeat(' ', $depth * 3);
|
120 |
+
|
121 |
+
$cat_name = apply_filters('list_cats', $category->name, $category);
|
122 |
+
$output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
|
123 |
+
if ( (is_array($args['selected']) && in_array($category->term_id, $args['selected'])) || ($category->term_id == $args['selected']) )
|
124 |
+
$output .= ' selected="selected"';
|
125 |
+
$output .= '>';
|
126 |
+
$output .= $pad.$cat_name;
|
127 |
+
if ( $args['show_count'] )
|
128 |
+
$output .= ' ('. $category->count .')';
|
129 |
+
if ( $args['show_last_update'] ) {
|
130 |
+
$format = 'Y-m-d';
|
131 |
+
$output .= ' ' . gmdate($format, $category->last_update_timestamp);
|
132 |
+
}
|
133 |
+
$output .= "</option>\n";
|
134 |
+
}
|
135 |
+
}
|
classes/em-category.php
CHANGED
@@ -1,152 +1,237 @@
|
|
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 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$this->
|
92 |
-
}
|
93 |
-
return
|
94 |
-
}
|
95 |
-
|
96 |
-
function
|
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 |
Â
?>
|
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 |
+
}else{
|
56 |
+
$category = get_term_by('id', $category_data, EM_TAXONOMY_CATEGORY);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
if( is_object($category) || is_array($category) ){
|
60 |
+
foreach($category as $key => $value){
|
61 |
+
$this->$key = $value;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
$this->id = $this->term_id; //backward compatability
|
65 |
+
$this->ms_global_switch_back();
|
66 |
+
do_action('em_category',$this, $category_data);
|
67 |
+
}
|
68 |
+
|
69 |
+
function get_color(){
|
70 |
+
if( empty($this->color) ){
|
71 |
+
global $wpdb;
|
72 |
+
$color = $wpdb->get_var('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$this->term_id}' AND meta_key='category-bgcolor' LIMIT 1");
|
73 |
+
$this->color = ($color != '') ? $color:'#FFFFFF';
|
74 |
+
}
|
75 |
+
return $this->color;
|
76 |
+
}
|
77 |
+
|
78 |
+
function get_image_url(){
|
79 |
+
if( empty($this->image_url) ){
|
80 |
+
global $wpdb;
|
81 |
+
$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");
|
82 |
+
$this->image_url = ($image_url != '') ? $image_url:'';
|
83 |
+
}
|
84 |
+
return $this->image_url;
|
85 |
+
}
|
86 |
+
|
87 |
+
function get_image_id(){
|
88 |
+
if( empty($this->image_id) ){
|
89 |
+
global $wpdb;
|
90 |
+
$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");
|
91 |
+
$this->image_id = ($image_id != '') ? $image_id:'';
|
92 |
+
}
|
93 |
+
return $this->image_id;
|
94 |
+
}
|
95 |
+
|
96 |
+
function get_url(){
|
97 |
+
if( empty($this->link) ){
|
98 |
+
$this->ms_global_switch();
|
99 |
+
$this->link = get_term_link($this->slug, EM_TAXONOMY_CATEGORY);
|
100 |
+
$this->ms_global_switch_back();
|
101 |
+
if ( is_wp_error($this->link) ) $this->link = '';
|
102 |
+
}
|
103 |
+
return $this->link;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Depreciated, don't use.
|
108 |
+
* @return mixed
|
109 |
+
*/
|
110 |
+
function has_events(){
|
111 |
+
global $wpdb;
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
function output_single($target = 'html'){
|
116 |
+
$format = get_option ( 'dbem_category_page_format' );
|
117 |
+
return apply_filters('em_category_output_single', $this->output($format, $target), $this, $target);
|
118 |
+
}
|
119 |
+
|
120 |
+
function output($format, $target="html") {
|
121 |
+
preg_match_all('/\{([a-zA-Z0-9_]+)\}([^{]+)\{\/[a-zA-Z0-9_]+\}/', $format, $conditionals);
|
122 |
+
if( count($conditionals[0]) > 0 ){
|
123 |
+
//Check if the language we want exists, if not we take the first language there
|
124 |
+
foreach($conditionals[1] as $key => $condition){
|
125 |
+
$format = str_replace($conditionals[0][$key], apply_filters('em_category_output_condition', '', $condition, $conditionals[0][$key], $this), $format);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
$category_string = $format;
|
129 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
|
130 |
+
foreach($placeholders[1] as $key => $result) {
|
131 |
+
$replace = '';
|
132 |
+
$full_result = $placeholders[0][$key];
|
133 |
+
switch( $result ){
|
134 |
+
case '#_CATEGORYNAME':
|
135 |
+
$replace = $this->name;
|
136 |
+
break;
|
137 |
+
case '#_CATEGORYID':
|
138 |
+
$replace = $this->term_id;
|
139 |
+
break;
|
140 |
+
case '#_CATEGORYNOTES':
|
141 |
+
case '#_CATEGORYDESCRIPTION':
|
142 |
+
$replace = $this->description;
|
143 |
+
break;
|
144 |
+
case '#_CATEGORYIMAGE':
|
145 |
+
case '#_CATEGORYIMAGEURL':
|
146 |
+
if( $this->get_image_url() != ''){
|
147 |
+
if($result == '#_CATEGORYIMAGEURL'){
|
148 |
+
$replace = $this->get_image_url();
|
149 |
+
}else{
|
150 |
+
if( empty($placeholders[3][$key]) ){
|
151 |
+
$replace = "<img src='".esc_url($this->get_image_url())."' alt='".esc_attr($this->name)."'/>";
|
152 |
+
}else{
|
153 |
+
$image_size = explode(',', $placeholders[3][$key]);
|
154 |
+
if( $this->array_is_numeric($image_size) && count($image_size) > 1 ){
|
155 |
+
if( get_option('dbem_disable_timthumb') && $this->get_image_id() ){
|
156 |
+
//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
|
157 |
+
$this->ms_global_switch();
|
158 |
+
$replace = wp_get_attachment_image($this->get_image_id(), $image_size);
|
159 |
+
$this->ms_global_switch_back();
|
160 |
+
}else{
|
161 |
+
$replace = "<img src='".em_get_thumbnail_url($this->get_image_url(), $image_size[0], $image_size[1])."' alt='".esc_attr($this->name)."' width='{$image_size[0]}' height='{$image_size[1]}'/>";
|
162 |
+
}
|
163 |
+
}else{
|
164 |
+
$replace = "<img src='".esc_url($this->get_image_url())."' alt='".esc_attr($this->name)."'/>";
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
break;
|
170 |
+
case '#_CATEGORYCOLOR':
|
171 |
+
$replace = $this->get_color();
|
172 |
+
break;
|
173 |
+
case '#_CATEGORYLINK':
|
174 |
+
case '#_CATEGORYURL':
|
175 |
+
$link = $this->get_url();
|
176 |
+
$replace = ($result == '#_CATEGORYURL') ? $link : '<a href="'.$link.'">'.esc_html($this->name).'</a>';
|
177 |
+
break;
|
178 |
+
case '#_CATEGORYSLUG':
|
179 |
+
$replace = $this->slug;
|
180 |
+
break;
|
181 |
+
case '#_CATEGORYEVENTSPAST': //depreciated, erroneous documentation, left for compatability
|
182 |
+
case '#_CATEGORYEVENTSNEXT': //depreciated, erroneous documentation, left for compatability
|
183 |
+
case '#_CATEGORYEVENTSALL': //depreciated, erroneous documentation, left for compatability
|
184 |
+
case '#_CATEGORYPASTEVENTS':
|
185 |
+
case '#_CATEGORYNEXTEVENTS':
|
186 |
+
case '#_CATEGORYALLEVENTS':
|
187 |
+
//convert depreciated placeholders for compatability
|
188 |
+
$result = ($result == '#_CATEGORYEVENTSPAST') ? '#_CATEGORYPASTEVENTS':$result;
|
189 |
+
$result = ($result == '#_CATEGORYEVENTSNEXT') ? '#_CATEGORYNEXTEVENTS':$result;
|
190 |
+
$result = ($result == '#_CATEGORYEVENTSALL') ? '#_CATEGORYALLEVENTS':$result;
|
191 |
+
//forget it ever happened? :/
|
192 |
+
if ($result == '#_CATEGORYPASTEVENTS'){ $scope = 'past'; }
|
193 |
+
elseif ( $result == '#_CATEGORYNEXTEVENTS' ){ $scope = 'future'; }
|
194 |
+
else{ $scope = 'all'; }
|
195 |
+
$events_count = EM_Events::count( array('category'=>$this->term_id, 'scope'=>$scope) );
|
196 |
+
if ( $events_count > 0 ){
|
197 |
+
$args = array('category'=>$this->term_id, 'scope'=>$scope, 'pagination'=>1);
|
198 |
+
$args['format_header'] = get_option('dbem_category_event_list_item_header_format');
|
199 |
+
$args['format_footer'] = get_option('dbem_category_event_list_item_footer_format');
|
200 |
+
$args['format'] = get_option('dbem_category_event_list_item_format');
|
201 |
+
$args['limit'] = get_option('dbem_category_event_list_limit');
|
202 |
+
$args['page'] = (!empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) )? $_REQUEST['pno'] : 1;
|
203 |
+
$replace = EM_Events::output($args);
|
204 |
+
} else {
|
205 |
+
$replace = get_option('dbem_category_no_events_message','</ul>');
|
206 |
+
}
|
207 |
+
break;
|
208 |
+
default:
|
209 |
+
$replace = $full_result;
|
210 |
+
break;
|
211 |
+
}
|
212 |
+
$replace = apply_filters('em_category_output_placeholder', $replace, $this, $full_result, $target); //USE WITH CAUTION! THIS MIGHT GET RENAMED
|
213 |
+
$category_string = str_replace($full_result, $replace , $category_string );
|
214 |
+
}
|
215 |
+
$name_filter = ($target == "html") ? 'dbem_general':'dbem_general_rss'; //TODO remove dbem_ filters
|
216 |
+
$category_string = str_replace('#_CATEGORY', apply_filters($name_filter, $this->name) , $category_string ); //Depreciated
|
217 |
+
return apply_filters('em_category_output', $category_string, $this, $format, $target);
|
218 |
+
}
|
219 |
+
|
220 |
+
function can_manage( $capability_owner = 'edit_categories', $capability_admin = false ){
|
221 |
+
global $em_capabilities_array;
|
222 |
+
//Figure out if this is multisite and require an extra bit of validation
|
223 |
+
$multisite_check = true;
|
224 |
+
$can_manage = current_user_can($capability_owner);
|
225 |
+
//if multisite and supoer admin, just return true
|
226 |
+
if( is_multisite() && is_super_admin() ){ return true; }
|
227 |
+
if( EM_MS_GLOBAL && !is_main_site() ){
|
228 |
+
//User can't admin this bit, as they're on a sub-blog
|
229 |
+
$can_manage = false;
|
230 |
+
if(array_key_exists($capability_owner, $em_capabilities_array) ){
|
231 |
+
$this->add_error( $em_capabilities_array[$capability_owner]);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
return $can_manage;
|
235 |
+
}
|
236 |
+
}
|
237 |
Â
?>
|
classes/em-event-post-admin.php
ADDED
@@ -0,0 +1,377 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Events Edit Page
|
4 |
+
*/
|
5 |
+
class EM_Event_Post_Admin{
|
6 |
+
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_action('save_post',array('EM_Event_Post_Admin','save_post'),10,1);
|
17 |
+
add_action('before_delete_post',array('EM_Event_Post_Admin','before_delete_post'),10,1);
|
18 |
+
add_action('trashed_post',array('EM_Event_Post_Admin','trashed_post'),10,1);
|
19 |
+
add_action('untrash_post',array('EM_Event_Post_Admin','untrash_post'),10,1);
|
20 |
+
add_action('untrashed_post',array('EM_Event_Post_Admin','untrashed_post'),10,1);
|
21 |
+
//Notices
|
22 |
+
add_action('post_updated_messages',array('EM_Event_Post_Admin','admin_notices_filter'),1,1);
|
23 |
+
}
|
24 |
+
|
25 |
+
function admin_head(){
|
26 |
+
global $post, $EM_Event;
|
27 |
+
if( !empty($post) && $post->post_type == EM_POST_TYPE_EVENT ){
|
28 |
+
$EM_Event = em_get_event($post->ID, 'post_id');
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
function admin_notices(){
|
33 |
+
//When editing
|
34 |
+
global $post, $EM_Event, $pagenow;
|
35 |
+
if( $pagenow == 'post.php' && ($post->post_type == EM_POST_TYPE_EVENT || $post->post_type == 'event-recurring') ){
|
36 |
+
if ( $EM_Event->is_recurring() ) {
|
37 |
+
$warning = "<p><strong>".__( 'WARNING: This is a recurring event.', 'dbem' )."</strong></p>";
|
38 |
+
$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' );
|
39 |
+
?><div class="updated"><?php echo $warning; ?></div><?php
|
40 |
+
} elseif ( $EM_Event->is_recurrence() ) {
|
41 |
+
$warning = "<p><strong>".__('WARNING: This is a recurrence in a set of recurring events.', 'dbem')."</strong></p>";
|
42 |
+
$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>";
|
43 |
+
$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>";
|
44 |
+
?><div class="updated"><?php echo $warning; ?></div><?php
|
45 |
+
}
|
46 |
+
if( !empty($EM_Event->group_id) && function_exists('groups_get_group') ){
|
47 |
+
$group = groups_get_group(array('group_id'=>$EM_Event->group_id));
|
48 |
+
$warning = sprintf(__('WARNING: This is a event belonging to the group "%s". Other group admins can also modify this event.', 'dbem'), $group->name);
|
49 |
+
?><div class="updated"><p><?php echo $warning; ?></p></div><?php
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
function admin_notices_filter($messages){
|
55 |
+
//When editing
|
56 |
+
global $post, $EM_Notices;
|
57 |
+
if( $post->post_type == EM_POST_TYPE_EVENT || $post->post_type == 'event-recurring' ){
|
58 |
+
if ( $EM_Notices->count_errors() > 0 ) {
|
59 |
+
unset($_GET['message']);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
return $messages;
|
63 |
+
}
|
64 |
+
|
65 |
+
function save_post($post_id){
|
66 |
+
global $wpdb, $EM_Event, $EM_Location, $EM_Notices;
|
67 |
+
$post_type = get_post_type($post_id);
|
68 |
+
$is_post_type = $post_type == EM_POST_TYPE_EVENT || $post_type == 'event-recurring';
|
69 |
+
$saving_status = !in_array(get_post_status($post_id), array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
70 |
+
if(!defined('UNTRASHING_'.$post_id) && $is_post_type && $saving_status ){
|
71 |
+
if( !empty($_REQUEST['_emnonce']) && wp_verify_nonce($_REQUEST['_emnonce'], 'edit_event') ){
|
72 |
+
//this is only run if we know form data was submitted, hence the nonce
|
73 |
+
$EM_Event = em_get_event($post_id, 'post_id');
|
74 |
+
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?)
|
75 |
+
//Handle Errors by making post draft
|
76 |
+
$get_meta = $EM_Event->get_post_meta();
|
77 |
+
$validate_meta = $EM_Event->validate_meta();
|
78 |
+
$save_meta = $EM_Event->save_meta();
|
79 |
+
$EM_Event->get_categories()->save(); //save categories in case of default category
|
80 |
+
if( !$get_meta || !$validate_meta || !$save_meta ){
|
81 |
+
//failed somewhere, set to draft, don't publish
|
82 |
+
$EM_Event->set_status(null, true);
|
83 |
+
if( $EM_Event->is_recurring() ){
|
84 |
+
$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
|
85 |
+
}else{
|
86 |
+
$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
|
87 |
+
}
|
88 |
+
$EM_Notices->add_error($EM_Event->get_errors(), true); //Always seems to redirect, so we make it static
|
89 |
+
apply_filters('em_event_save', false, $EM_Event);
|
90 |
+
}else{
|
91 |
+
//if this is just published, we need to email the user about the publication, or send to pending mode again for review
|
92 |
+
if( (!$EM_Event->is_recurring() && !current_user_can('publish_events')) || ($EM_Event->is_recurring() && !current_user_can('publish_recurring_events')) ){
|
93 |
+
if( $EM_Event->is_published() ){ $EM_Event->set_status(0, true); } //no publishing and editing... security threat
|
94 |
+
}
|
95 |
+
apply_filters('em_event_save', true, $EM_Event);
|
96 |
+
}
|
97 |
+
}else{
|
98 |
+
//we're updating only the quick-edit style information, which is only post info saved into the index
|
99 |
+
$EM_Event = em_get_event($post_id, 'post_id'); //grab event, via post info
|
100 |
+
if( $EM_Event->validate() ){
|
101 |
+
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?)
|
102 |
+
//first things first, we must make sure we have an index, if not, reset it to a new one:
|
103 |
+
$event_truly_exists = $wpdb->get_var('SELECT event_id FROM '.EM_EVENTS_TABLE." WHERE event_id={$EM_Event->event_id}") == $EM_Event->event_id;
|
104 |
+
if(empty($EM_Event->event_id) || !$event_truly_exists){ $EM_Event->save_meta(); }
|
105 |
+
//we can save the status now
|
106 |
+
$event_status = $EM_Event->get_status(true);
|
107 |
+
//if this is just published, we need to email the user about the publication, or send to pending mode again for review
|
108 |
+
if( (!$EM_Event->is_recurring() && !current_user_can('publish_events')) || ($EM_Event->is_recurring() && !current_user_can('publish_recurring_events')) ){
|
109 |
+
if( $EM_Event->is_published() ){ $EM_Event->set_status(0, true); } //no publishing and editing... security threat
|
110 |
+
}
|
111 |
+
//now update the db
|
112 |
+
$wpdb->query("UPDATE ".EM_EVENTS_TABLE." SET event_name='{$EM_Event->event_name}', event_slug='{$EM_Event->event_slug}', event_status={$event_status}, event_private={$EM_Event->event_private} WHERE event_id='{$EM_Event->event_id}'");
|
113 |
+
if( $EM_Event->is_recurring() && $EM_Event->is_published()){
|
114 |
+
//recurrences are (re)saved only if event is published
|
115 |
+
$EM_Event->save_events();
|
116 |
+
}
|
117 |
+
apply_filters('em_event_save', true, $EM_Event);
|
118 |
+
}else{
|
119 |
+
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?)
|
120 |
+
//Event doesn't validate, so set status to null
|
121 |
+
$EM_Event->set_status(null, true);
|
122 |
+
apply_filters('em_event_save', false, $EM_Event);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
self::maybe_publish_location($EM_Event);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* 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.
|
131 |
+
* @param EM_Event $EM_Event
|
132 |
+
*/
|
133 |
+
function maybe_publish_location($EM_Event){
|
134 |
+
//do a dirty update for location too if it's not published
|
135 |
+
if( $EM_Event->is_published() && !empty($EM_Event->location_id) ){
|
136 |
+
$EM_Location = $EM_Event->get_location();
|
137 |
+
if( $EM_Location->location_status !== 1 ){
|
138 |
+
//let's also publish the location
|
139 |
+
$EM_Location->set_status(1, true);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
function before_delete_post($post_id){
|
145 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
146 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
147 |
+
$EM_Event->delete_meta();
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
function trashed_post($post_id){
|
152 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
153 |
+
global $EM_Notices;
|
154 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
155 |
+
$EM_Event->set_status(null);
|
156 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
function untrash_post($post_id){
|
161 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
162 |
+
//set a constant so we know this event doesn't need 'saving'
|
163 |
+
if(!defined('UNTRASHING_'.$post_id)) define('UNTRASHING_'.$post_id, true);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
function untrashed_post($post_id){
|
168 |
+
if(get_post_type($post_id) == EM_POST_TYPE_EVENT){
|
169 |
+
global $EM_Notices;
|
170 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
171 |
+
$EM_Event->set_status(1);
|
172 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
function meta_boxes(){
|
177 |
+
global $EM_Event;
|
178 |
+
if( !empty($EM_Event->event_owner_anonymous) ){
|
179 |
+
add_meta_box('em-event-anonymous', __('Anonymous Submitter Info','dbem'), array('EM_Event_Post_Admin','meta_box_anonymous'),EM_POST_TYPE_EVENT, 'side','high');
|
180 |
+
}
|
181 |
+
add_meta_box('em-event-when', __('When','dbem'), array('EM_Event_Post_Admin','meta_box_date'),EM_POST_TYPE_EVENT, 'side','high');
|
182 |
+
if(get_option('dbem_locations_enabled', true)){
|
183 |
+
add_meta_box('em-event-where', __('Where','dbem'), array('EM_Event_Post_Admin','meta_box_location'),EM_POST_TYPE_EVENT, 'normal','high');
|
184 |
+
}
|
185 |
+
if( defined('WP_DEBUG') && WP_DEBUG ){
|
186 |
+
add_meta_box('em-event-meta', 'Event Meta (debugging only)', array('EM_Event_Post_Admin','meta_box_metadump'),EM_POST_TYPE_EVENT, 'normal','high');
|
187 |
+
}
|
188 |
+
if(get_option('dbem_rsvp_enabled', true)){
|
189 |
+
add_meta_box('em-event-bookings', __('Bookings/Registration','dbem'), array('EM_Event_Post_Admin','meta_box_bookings'),EM_POST_TYPE_EVENT, 'normal','high');
|
190 |
+
if( !empty($EM_Event->event_id) && $EM_Event->event_rsvp ){
|
191 |
+
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');
|
192 |
+
}
|
193 |
+
}
|
194 |
+
if( get_option('dbem_attributes_enabled', true) ){
|
195 |
+
add_meta_box('em-event-attributes', __('Attributes','dbem'), array('EM_Event_Post_Admin','meta_box_attributes'),EM_POST_TYPE_EVENT, 'normal','default');
|
196 |
+
}
|
197 |
+
if( EM_MS_GLOBAL && !is_main_site() && get_option('dbem_categories_enabled') ){
|
198 |
+
add_meta_box('em-event-categories', __('Site Categories','dbem'), array('EM_Event_Post_Admin','meta_box_ms_categories'),EM_POST_TYPE_EVENT, 'side','low');
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
function meta_box_metadump(){
|
203 |
+
global $post,$EM_Event;
|
204 |
+
echo "<pre>"; print_r($EM_Event); echo "</pre>";
|
205 |
+
}
|
206 |
+
|
207 |
+
function meta_box_anonymous(){
|
208 |
+
global $EM_Event;
|
209 |
+
?>
|
210 |
+
<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>
|
211 |
+
<p><strong><?php _e('Name','dbem'); ?> :</strong> <?php echo $EM_Event->event_owner_name; ?></p>
|
212 |
+
<p><strong><?php _e('Name','dbem'); ?> :</strong> <?php echo $EM_Event->event_owner_email; ?></p>
|
213 |
+
<?php
|
214 |
+
}
|
215 |
+
|
216 |
+
function meta_box_date(){
|
217 |
+
//create meta box check of date nonce
|
218 |
+
?><input type="hidden" name="_emnonce" value="<?php echo wp_create_nonce('edit_event'); ?>" /><?php
|
219 |
+
em_locate_template('forms/event/when.php', true);
|
220 |
+
}
|
221 |
+
|
222 |
+
function meta_box_bookings_stats(){
|
223 |
+
em_locate_template('forms/event/booking-stats.php',true);
|
224 |
+
}
|
225 |
+
|
226 |
+
function meta_box_bookings(){
|
227 |
+
em_locate_template('forms/event/bookings.php', true);
|
228 |
+
add_action('admin_footer',array('EM_Event_Post_Admin','meta_box_bookings_overlay'));
|
229 |
+
}
|
230 |
+
|
231 |
+
function meta_box_bookings_overlay(){
|
232 |
+
em_locate_template('forms/tickets-form.php', true); //put here as it can't be in the add event form
|
233 |
+
}
|
234 |
+
|
235 |
+
function meta_box_attributes(){
|
236 |
+
em_locate_template('forms/event/attributes.php',true);
|
237 |
+
}
|
238 |
+
|
239 |
+
function meta_box_location(){
|
240 |
+
em_locate_template('forms/event/location.php',true);
|
241 |
+
}
|
242 |
+
|
243 |
+
function meta_box_ms_categories(){
|
244 |
+
global $EM_Event;
|
245 |
+
$categories = EM_Categories::get(array('orderby'=>'category_name','hide_empty'=>false));
|
246 |
+
?>
|
247 |
+
<?php if( count($categories) > 0 ): ?>
|
248 |
+
<p>
|
249 |
+
<?php foreach( $categories as $EM_Category ):?>
|
250 |
+
<label><input type="checkbox" name="event_categories[]" value="<?php echo $EM_Category->id; ?>" <?php if($EM_Event->get_categories()->has($EM_Category->id)) echo 'checked="checked"'; ?> /> <?php echo $EM_Category->name ?></label><br />
|
251 |
+
<?php endforeach; ?>
|
252 |
+
</p>
|
253 |
+
<?php else: ?>
|
254 |
+
<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>
|
255 |
+
<?php endif; ?>
|
256 |
+
<!-- END Categories -->
|
257 |
+
<?php
|
258 |
+
}
|
259 |
+
}
|
260 |
+
add_action('admin_init',array('EM_Event_Post_Admin','init'));
|
261 |
+
|
262 |
+
/*
|
263 |
+
* Recurring Events
|
264 |
+
*/
|
265 |
+
class EM_Event_Recurring_Post_Admin{
|
266 |
+
function init(){
|
267 |
+
global $pagenow;
|
268 |
+
if($pagenow == 'post.php' || $pagenow == 'post-new.php' ){ //only needed if editing post
|
269 |
+
add_action('admin_head', array('EM_Event_Recurring_Post_Admin','admin_head'));
|
270 |
+
//Meta Boxes
|
271 |
+
add_action('add_meta_boxes', array('EM_Event_Recurring_Post_Admin','meta_boxes'));
|
272 |
+
//Notices
|
273 |
+
add_action('admin_notices',array('EM_Event_Post_Admin','admin_notices')); //shared with posts
|
274 |
+
}
|
275 |
+
//Save/Edit actions
|
276 |
+
add_action('before_delete_post',array('EM_Event_Recurring_Post_Admin','before_delete_post'),10,1);
|
277 |
+
add_action('trashed_post',array('EM_Event_Recurring_Post_Admin','trashed_post'),10,1);
|
278 |
+
add_action('untrash_post',array('EM_Event_Recurring_Post_Admin','untrash_post'),10,1);
|
279 |
+
add_action('untrashed_post',array('EM_Event_Recurring_Post_Admin','untrashed_post'),10,1);
|
280 |
+
//Notices
|
281 |
+
add_action('post_updated_messages',array('EM_Event_Post_Admin','admin_notices_filter'),1,1); //shared with posts
|
282 |
+
}
|
283 |
+
|
284 |
+
function admin_head(){
|
285 |
+
global $post, $EM_Event;
|
286 |
+
if( !empty($post) && $post->post_type == 'event-recurring' ){
|
287 |
+
$EM_Event = em_get_event($post->ID, 'post_id');
|
288 |
+
//quick hacks to make event admin table make more sense for events
|
289 |
+
?>
|
290 |
+
<script type="text/javascript">
|
291 |
+
jQuery(document).ready( function($){
|
292 |
+
if(!EM.recurrences_menu){
|
293 |
+
$('#menu-posts-'+EM.event_post_type+', #menu-posts-'+EM.event_post_type+' > a').addClass('wp-has-current-submenu');
|
294 |
+
}
|
295 |
+
});
|
296 |
+
</script>
|
297 |
+
<?php
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
function before_delete_post($post_id){
|
302 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
303 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
304 |
+
//now delete recurrences
|
305 |
+
$events_array = EM_Events::get( array('recurrence'=>$EM_Event->event_id, 'scope'=>'all', 'status'=>'all' ) );
|
306 |
+
foreach($events_array as $event){
|
307 |
+
/* @var $event EM_Event */
|
308 |
+
if($EM_Event->event_id == $event->recurrence_id && !empty($event->recurrence_id) ){ //double check the event is a recurrence of this event
|
309 |
+
wp_delete_post($event->post_id, true);
|
310 |
+
}
|
311 |
+
}
|
312 |
+
$EM_Event->post_type = EM_POST_TYPE_EVENT; //trick it into thinking it's one event.
|
313 |
+
$EM_Event->delete_meta();
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
function trashed_post($post_id){
|
318 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
319 |
+
global $EM_Notices, $wpdb;
|
320 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
321 |
+
$EM_Event->set_status(null);
|
322 |
+
//now trash recurrences
|
323 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$EM_Event->event_id, 'scope'=>'all', 'status'=>'all' ) );
|
324 |
+
foreach($events_array as $event){
|
325 |
+
/* @var $event EM_Event */
|
326 |
+
if($EM_Event->event_id == $event->recurrence_id ){ //double check the event is a recurrence of this event
|
327 |
+
wp_trash_post($event->post_id);
|
328 |
+
}
|
329 |
+
}
|
330 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
function untrash_post($post_id){
|
335 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
336 |
+
global $wpdb;
|
337 |
+
//set a constant so we know this event doesn't need 'saving'
|
338 |
+
if(!defined('UNTRASHING_'.$post_id)) define('UNTRASHING_'.$post_id, true);
|
339 |
+
$EM_Event = em_get_event($post_id,'post_id');
|
340 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$EM_Event->event_id, 'scope'=>'all', 'status'=>'all' ) );
|
341 |
+
foreach($events_array as $event){
|
342 |
+
/* @var $event EM_Event */
|
343 |
+
if($EM_Event->event_id == $event->recurrence_id){
|
344 |
+
wp_untrash_post($event->post_id);
|
345 |
+
}
|
346 |
+
}
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
function untrashed_post($post_id){
|
351 |
+
if(get_post_type($post_id) == 'event-recurring'){
|
352 |
+
global $EM_Notices,$EM_Event;
|
353 |
+
$EM_Event->set_status(1);
|
354 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
function meta_boxes(){
|
359 |
+
add_meta_box('em-event-recurring', __('Recurrences','dbem'), array('EM_Event_Recurring_Post_Admin','meta_box_recurrence'),'event-recurring', 'normal','high');
|
360 |
+
//add_meta_box('em-event-meta', 'Event Meta (debugging only)', array('EM_Event_Post_Admin','meta_box_metadump'),'event-recurring', 'normal','high');
|
361 |
+
add_meta_box('em-event-where', __('Where','dbem'), array('EM_Event_Post_Admin','meta_box_location'),'event-recurring', 'normal','high');
|
362 |
+
if(get_option('dbem_rsvp_enabled')){
|
363 |
+
add_meta_box('em-event-bookings', __('Bookings/Registration','dbem'), array('EM_Event_Post_Admin','meta_box_bookings'),'event-recurring', 'normal','high');
|
364 |
+
}
|
365 |
+
if( get_option('dbem_attributes_enabled') ){
|
366 |
+
add_meta_box('em-event-attributes', __('Attributes','dbem'), array('EM_Event_Post_Admin','meta_box_attributes'),'event-recurring', 'normal','default');
|
367 |
+
}
|
368 |
+
if( EM_MS_GLOBAL && !is_main_site() && get_option('dbem_categories_enabled') ){
|
369 |
+
add_meta_box('em-event-categories', __('Site Categories','dbem'), array('EM_Event_Post_Admin','meta_box_ms_categories'),'event-recurring', 'side','low');
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
function meta_box_recurrence(){
|
374 |
+
em_locate_template('forms/event/recurring-when.php', true);
|
375 |
+
}
|
376 |
+
}
|
377 |
+
add_action('admin_init',array('EM_Event_Recurring_Post_Admin','init'));
|
classes/em-event-post.php
ADDED
@@ -0,0 +1,289 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_page') ){
|
17 |
+
add_filter('single_template',array('EM_Event_Post','single_template'));
|
18 |
+
}
|
19 |
+
//Override post template tags
|
20 |
+
add_filter('the_date',array('EM_Event_Post','the_date'));
|
21 |
+
add_filter('get_the_date',array('EM_Event_Post','the_date'),10,2);
|
22 |
+
add_filter('the_category',array('EM_Event_Post','the_category'),10,3);
|
23 |
+
}
|
24 |
+
add_action('parse_query', array('EM_Event_Post','parse_query'));
|
25 |
+
add_action('publish_future_post',array('EM_Event_Post','publish_future_post'),10,1);
|
26 |
+
}
|
27 |
+
|
28 |
+
function publish_future_post($post_id){
|
29 |
+
global $wpdb, $EM_Event, $EM_Location, $EM_Notices;
|
30 |
+
$post_type = get_post_type($post_id);
|
31 |
+
$is_post_type = $post_type == EM_POST_TYPE_EVENT || $post_type == 'event-recurring';
|
32 |
+
$saving_status = !in_array(get_post_status($post_id), array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
33 |
+
if(!defined('UNTRASHING_'.$post_id) && $is_post_type && $saving_status ){
|
34 |
+
$EM_Event = em_get_event($post_id, 'post_id');
|
35 |
+
$EM_Event->set_status(1);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Overrides the default post format of an event and can display an event as a page, which uses the page.php template.
|
41 |
+
* @param string $template
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
function single_template($template){
|
45 |
+
global $post;
|
46 |
+
if( !locate_template('single-'.EM_POST_TYPE_EVENT.'.php') && $post->post_type == EM_POST_TYPE_EVENT ){
|
47 |
+
$template = locate_template(array('page.php','index.php'),false);
|
48 |
+
}
|
49 |
+
return $template;
|
50 |
+
}
|
51 |
+
|
52 |
+
function the_excerpt_rss( $content ){
|
53 |
+
global $post, $EM_Event;
|
54 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
55 |
+
if( get_option('dbem_cp_events_formats') ){
|
56 |
+
$EM_Event = em_get_event($post);
|
57 |
+
$content = $EM_Event->output( get_option ( 'dbem_rss_description_format' ), "rss");
|
58 |
+
$content = ent2ncr(convert_chars($content)); //Some RSS filtering
|
59 |
+
}
|
60 |
+
}
|
61 |
+
return $content;
|
62 |
+
}
|
63 |
+
|
64 |
+
function the_content( $content ){
|
65 |
+
global $post, $EM_Event;
|
66 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
67 |
+
if( is_archive() || is_search() ){
|
68 |
+
if(get_option('dbem_cp_events_archive_formats')){
|
69 |
+
$EM_Event = em_get_event($post);
|
70 |
+
$content = $EM_Event->output(get_option('dbem_event_list_item_format'));
|
71 |
+
}
|
72 |
+
}else{
|
73 |
+
if( get_option('dbem_cp_events_formats') && !post_password_required() ){
|
74 |
+
$EM_Event = em_get_event($post);
|
75 |
+
ob_start();
|
76 |
+
em_locate_template('templates/event-single.php',true);
|
77 |
+
$content = ob_get_clean();
|
78 |
+
}else{
|
79 |
+
$EM_Event = em_get_event($post);
|
80 |
+
if( $EM_Event->event_rsvp ){
|
81 |
+
$content .= $EM_Event->output('<h2>Bookings</h2>#_BOOKINGFORM');
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return $content;
|
87 |
+
}
|
88 |
+
|
89 |
+
function the_date( $the_date, $d = '' ){
|
90 |
+
global $post;
|
91 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
92 |
+
$EM_Event = em_get_event($post);
|
93 |
+
if ( '' == $d ){
|
94 |
+
$the_date = date(get_option('date_format'), $EM_Event->start);
|
95 |
+
}else{
|
96 |
+
$the_date = date($d, $EM_Event->start);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
return $the_date;
|
100 |
+
}
|
101 |
+
|
102 |
+
function the_category( $thelist, $separator = '', $parents='' ){
|
103 |
+
global $post, $wp_rewrite;
|
104 |
+
if( $post->post_type == EM_POST_TYPE_EVENT ){
|
105 |
+
$EM_Event = em_get_event($post);
|
106 |
+
$categories = $EM_Event->get_categories();
|
107 |
+
if( empty($categories) ) return '';
|
108 |
+
|
109 |
+
/* Copied from get_the_category_list function, with a few minor edits to make urls work, and removing parent stuff (for now) */
|
110 |
+
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
|
111 |
+
|
112 |
+
$thelist = '';
|
113 |
+
if ( '' == $separator ) {
|
114 |
+
$thelist .= '<ul class="post-categories">';
|
115 |
+
foreach ( $categories as $category ) {
|
116 |
+
$thelist .= "\n\t<li>";
|
117 |
+
switch ( strtolower( $parents ) ) {
|
118 |
+
case 'multiple':
|
119 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
|
120 |
+
break;
|
121 |
+
case 'single':
|
122 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>';
|
123 |
+
$thelist .= $category->name.'</a></li>';
|
124 |
+
break;
|
125 |
+
case '':
|
126 |
+
default:
|
127 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
|
128 |
+
}
|
129 |
+
}
|
130 |
+
$thelist .= '</ul>';
|
131 |
+
} else {
|
132 |
+
$i = 0;
|
133 |
+
foreach ( $categories as $category ) {
|
134 |
+
if ( 0 < $i )
|
135 |
+
$thelist .= $separator;
|
136 |
+
switch ( strtolower( $parents ) ) {
|
137 |
+
case 'multiple':
|
138 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
|
139 |
+
break;
|
140 |
+
case 'single':
|
141 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>';
|
142 |
+
$thelist .= "$category->name</a>";
|
143 |
+
break;
|
144 |
+
case '':
|
145 |
+
default:
|
146 |
+
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
|
147 |
+
}
|
148 |
+
++$i;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
/* End copying */
|
152 |
+
}
|
153 |
+
return $thelist;
|
154 |
+
}
|
155 |
+
|
156 |
+
function parse_query(){
|
157 |
+
global $wp_query;
|
158 |
+
//Search Query Filtering
|
159 |
+
if( !is_admin() ){
|
160 |
+
if( !empty($wp_query->query_vars['s']) && !get_option('dbem_cp_events_search_results') ){
|
161 |
+
$wp_query->query_vars['post_type'] = array_diff( get_post_types(array('exclude_from_search' => false)), array(EM_POST_TYPE_EVENT));
|
162 |
+
}
|
163 |
+
}else{
|
164 |
+
if( !empty($wp_query->query_vars[EM_TAXONOMY_CATEGORY]) && is_numeric($wp_query->query_vars[EM_TAXONOMY_CATEGORY]) ){
|
165 |
+
//sorts out filtering admin-side as it searches by id
|
166 |
+
$term = get_term_by('id', $wp_query->query_vars[EM_TAXONOMY_CATEGORY], EM_TAXONOMY_CATEGORY);
|
167 |
+
$wp_query->query_vars[EM_TAXONOMY_CATEGORY] = ( $term !== false && !is_wp_error($term) )? $term->name:0;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
//Scoping
|
171 |
+
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'))) ) {
|
172 |
+
//Let's deal with the scope - default is future
|
173 |
+
if( is_admin() ){
|
174 |
+
$scope = $wp_query->query_vars['scope'] = (!empty($_REQUEST['scope'])) ? $_REQUEST['scope']:'future';
|
175 |
+
//TODO limit what a user can see admin side for events/locations/recurring events
|
176 |
+
}else{
|
177 |
+
if( !empty($wp_query->query_vars['calendar_day']) ) $wp_query->query_vars['scope'] = $wp_query->query_vars['calendar_day'];
|
178 |
+
if( empty($wp_query->query_vars['scope']) ){
|
179 |
+
if( is_archive() ){
|
180 |
+
$scope = $wp_query->query_vars['scope'] = get_option('dbem_events_page_scope');
|
181 |
+
}else{
|
182 |
+
$scope = $wp_query->query_vars['scope'] = 'all'; //otherwise we'll get 404s for past events
|
183 |
+
}
|
184 |
+
}else{
|
185 |
+
$scope = $wp_query->query_vars['scope'];
|
186 |
+
}
|
187 |
+
}
|
188 |
+
$query = array();
|
189 |
+
$time = current_time('timestamp');
|
190 |
+
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
191 |
+
$today = strtotime($scope);
|
192 |
+
$tomorrow = $today + 60*60*24-1;
|
193 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
194 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($today,$tomorrow), 'compare' => 'BETWEEN' );
|
195 |
+
}else{
|
196 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<=' );
|
197 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
198 |
+
}
|
199 |
+
}elseif ($scope == "future"){
|
200 |
+
$today = strtotime(date('Y-m-d', $time));
|
201 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
202 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '>=' );
|
203 |
+
}else{
|
204 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
205 |
+
}
|
206 |
+
}elseif ($scope == "past"){
|
207 |
+
$today = strtotime(date('Y-m-d', $time));
|
208 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
209 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '<' );
|
210 |
+
}else{
|
211 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '<' );
|
212 |
+
}
|
213 |
+
}elseif ($scope == "today"){
|
214 |
+
$today = strtotime(date('Y-m-d', $time));
|
215 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
216 |
+
//date must be only today
|
217 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '=');
|
218 |
+
}else{
|
219 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '<=' );
|
220 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
221 |
+
}
|
222 |
+
}elseif ($scope == "tomorrow"){
|
223 |
+
$tomorrow = strtotime(date('Y-m-d',$time+60*60*24));
|
224 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
225 |
+
//date must be only tomorrow
|
226 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '=');
|
227 |
+
}else{
|
228 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<=' );
|
229 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $tomorrow, 'compare' => '>=' );
|
230 |
+
}
|
231 |
+
}elseif ($scope == "month"){
|
232 |
+
$start_month = strtotime(date('Y-m-d',$time));
|
233 |
+
$end_month = strtotime(date('Y-m-t',$time));
|
234 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
235 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
236 |
+
}else{
|
237 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
238 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
239 |
+
}
|
240 |
+
}elseif ($scope == "next-month"){
|
241 |
+
$start_month_timestamp = strtotime('+1 month', $time); //get the end of this month + 1 day
|
242 |
+
$start_month = strtotime(date('Y-m-1',$start_month_timestamp));
|
243 |
+
$end_month = strtotime(date('Y-m-t',$start_month_timestamp));
|
244 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
245 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
246 |
+
}else{
|
247 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
248 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
249 |
+
}
|
250 |
+
}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.
|
251 |
+
$months_to_add = $matches[1];
|
252 |
+
$start_month = strtotime(date('Y-m-d',$time));
|
253 |
+
$end_month = strtotime(date('Y-m-t',strtotime("+$months_to_add month", $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' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
256 |
+
}else{
|
257 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
258 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
259 |
+
}
|
260 |
+
}
|
261 |
+
if( !empty($query) && is_array($query) ){
|
262 |
+
$wp_query->query_vars['meta_query'] = $query;
|
263 |
+
}
|
264 |
+
if( is_admin() ){
|
265 |
+
//admin areas don't need special ordering, so make it simple
|
266 |
+
$wp_query->query_vars['orderby'] = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby']:'meta_value_num';
|
267 |
+
$wp_query->query_vars['meta_key'] = '_start_ts';
|
268 |
+
$wp_query->query_vars['order'] = (!empty($_REQUEST['order'])) ? $_REQUEST['order']:'ASC';
|
269 |
+
}else{
|
270 |
+
if( get_option('dbem_events_default_archive_orderby') == 'title'){
|
271 |
+
$wp_query->query_vars['orderby'] = 'title';
|
272 |
+
$wp_query->query_vars['order'] = get_option('dbem_events_default_archive_order','ASC');
|
273 |
+
}else{
|
274 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
275 |
+
$wp_query->query_vars['meta_key'] = '_start_ts';
|
276 |
+
}
|
277 |
+
$wp_query->query_vars['order'] = get_option('dbem_events_default_archive_order','ASC');
|
278 |
+
}
|
279 |
+
}elseif( !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == EM_POST_TYPE_EVENT ){
|
280 |
+
$wp_query->query_vars['scope'] = 'all';
|
281 |
+
if( $wp_query->query_vars['post_status'] == 'pending' ){
|
282 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
283 |
+
$wp_query->query_vars['order'] = 'ASC';
|
284 |
+
$wp_query->query_vars['meta_key'] = '_start_ts';
|
285 |
+
}
|
286 |
+
}
|
287 |
+
}
|
288 |
+
}
|
289 |
+
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' => 'event-categories',
|
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 $_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,2199 @@
|
|
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 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
var $
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
var $
|
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 |
-
var $
|
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 |
-
|
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 |
-
return apply_filters('
|
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 |
-
}else{
|
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 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
$
|
745 |
-
|
746 |
-
foreach($
|
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 |
-
|
905 |
-
|
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 |
-
* Returns
|
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 $EM_Event;
|
14 |
+
}elseif( !is_object($id) ){
|
15 |
+
if( $search_by == 'event_id' && $EM_Event->event_id == $id ){
|
16 |
+
return $EM_Event;
|
17 |
+
}elseif( $search_by == 'post_id' && $EM_Event->post_id == $id ){
|
18 |
+
return $EM_Event;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
if( is_object($id) && get_class($id) == 'EM_Event' ){
|
23 |
+
return $id;
|
24 |
+
}else{
|
25 |
+
return 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_spaces;
|
56 |
+
var $location_id;
|
57 |
+
var $recurrence_id;
|
58 |
+
var $event_status;
|
59 |
+
var $event_date_created;
|
60 |
+
var $event_date_modified;
|
61 |
+
var $blog_id;
|
62 |
+
var $group_id;
|
63 |
+
/**
|
64 |
+
* Populated with the non-hidden event post custom fields (i.e. not starting with _)
|
65 |
+
* @var array
|
66 |
+
*/
|
67 |
+
var $event_attributes = array();
|
68 |
+
/* Recurring Specific Values */
|
69 |
+
var $recurrence;
|
70 |
+
var $recurrence_interval;
|
71 |
+
var $recurrence_freq;
|
72 |
+
var $recurrence_byday;
|
73 |
+
var $recurrence_days = 0;
|
74 |
+
var $recurrence_byweekno;
|
75 |
+
/* anonymous submission information */
|
76 |
+
var $event_owner_anonymous;
|
77 |
+
var $event_owner_name;
|
78 |
+
var $event_owner_email;
|
79 |
+
/**
|
80 |
+
* 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.
|
81 |
+
* @var array
|
82 |
+
*/
|
83 |
+
var $fields = array(
|
84 |
+
'event_id' => array( 'name'=>'id', 'type'=>'%d' ),
|
85 |
+
'post_id' => array( 'name'=>'post_id', 'type'=>'%d' ),
|
86 |
+
'event_slug' => array( 'name'=>'slug', 'type'=>'%s', 'null'=>true ),
|
87 |
+
'event_owner' => array( 'name'=>'owner', 'type'=>'%d', 'null'=>true ),
|
88 |
+
'event_name' => array( 'name'=>'name', 'type'=>'%s', 'null'=>true ),
|
89 |
+
'event_start_time' => array( 'name'=>'start_time', 'type'=>'%s', 'null'=>true ),
|
90 |
+
'event_end_time' => array( 'name'=>'end_time', 'type'=>'%s', 'null'=>true ),
|
91 |
+
'event_all_day' => array( 'name'=>'all_day', 'type'=>'%d', 'null'=>true ),
|
92 |
+
'event_start_date' => array( 'name'=>'start_date', 'type'=>'%s', 'null'=>true ),
|
93 |
+
'event_end_date' => array( 'name'=>'end_date', 'type'=>'%s', 'null'=>true ),
|
94 |
+
'post_content' => array( 'name'=>'notes', 'type'=>'%s', 'null'=>true ),
|
95 |
+
'event_rsvp' => array( 'name'=>'rsvp', 'type'=>'%d', 'null'=>true ), //has a default, so can be null/excluded
|
96 |
+
'event_rsvp_date' => array( 'name'=>'rsvp_date', 'type'=>'%s', 'null'=>true ),
|
97 |
+
'event_rsvp_time' => array( 'name'=>'rsvp_time', 'type'=>'%s', 'null'=>true ),
|
98 |
+
'event_spaces' => array( 'name'=>'spaces', 'type'=>'%d', 'null'=>true),
|
99 |
+
'location_id' => array( 'name'=>'location_id', 'type'=>'%d', 'null'=>true ),
|
100 |
+
'recurrence_id' => array( 'name'=>'recurrence_id', 'type'=>'%d', 'null'=>true ),
|
101 |
+
'event_status' => array( 'name'=>'status', 'type'=>'%d', 'null'=>true ),
|
102 |
+
'event_private' => array( 'name'=>'status', 'type'=>'%d', 'null'=>true ),
|
103 |
+
'event_date_created' => array( 'name'=>'date_created', 'type'=>'%s', 'null'=>true ),
|
104 |
+
'event_date_modified' => array( 'name'=>'date_modified', 'type'=>'%s', 'null'=>true ),
|
105 |
+
'event_attributes' => array( 'name'=>'attributes', 'type'=>'%s', 'null'=>true ),
|
106 |
+
'blog_id' => array( 'name'=>'blog_id', 'type'=>'%d', 'null'=>true ),
|
107 |
+
'group_id' => array( 'name'=>'group_id', 'type'=>'%d', 'null'=>true ),
|
108 |
+
'recurrence' => array( 'name'=>'recurrence', 'type'=>'%d', 'null'=>true ), //every x day(s)/week(s)/month(s)
|
109 |
+
'recurrence_interval' => array( 'name'=>'interval', 'type'=>'%d', 'null'=>true ), //every x day(s)/week(s)/month(s)
|
110 |
+
'recurrence_freq' => array( 'name'=>'freq', 'type'=>'%s', 'null'=>true ), //daily,weekly,monthly?
|
111 |
+
'recurrence_days' => array( 'name'=>'days', 'type'=>'%d', 'null'=>true ), //daily,weekly,monthly?
|
112 |
+
'recurrence_byday' => array( 'name'=>'byday', 'type'=>'%s', 'null'=>true ), //if weekly or monthly, what days of the week?
|
113 |
+
'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d', 'null'=>true ), //if monthly which week (-1 is last)
|
114 |
+
);
|
115 |
+
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
|
116 |
+
var $recurrence_fields = array('recurrence_interval', 'recurrence_freq', 'recurrence_days', 'recurrence_byday', 'recurrence_byweekno');
|
117 |
+
|
118 |
+
var $image_url = '';
|
119 |
+
/**
|
120 |
+
* Timestamp of start date/time
|
121 |
+
* @var int
|
122 |
+
*/
|
123 |
+
var $start;
|
124 |
+
/**
|
125 |
+
* Timestamp of end date/time
|
126 |
+
* @var int
|
127 |
+
*/
|
128 |
+
var $end;
|
129 |
+
/**
|
130 |
+
* Timestamp for booking cut-off date/time
|
131 |
+
* @var int
|
132 |
+
*/
|
133 |
+
var $rsvp_end;
|
134 |
+
/**
|
135 |
+
* Created on timestamp, taken from DB, converted to TS
|
136 |
+
* @var int
|
137 |
+
*/
|
138 |
+
var $created;
|
139 |
+
/**
|
140 |
+
* Created on timestamp, taken from DB, converted to TS
|
141 |
+
* @var int
|
142 |
+
*/
|
143 |
+
var $modified;
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @var EM_Location
|
147 |
+
*/
|
148 |
+
var $location;
|
149 |
+
/**
|
150 |
+
* @var EM_Bookings
|
151 |
+
*/
|
152 |
+
var $bookings;
|
153 |
+
/**
|
154 |
+
* The contact person for this event
|
155 |
+
* @var WP_User
|
156 |
+
*/
|
157 |
+
var $contact;
|
158 |
+
/**
|
159 |
+
* The category object
|
160 |
+
* @var EM_Category
|
161 |
+
*/
|
162 |
+
var $category;
|
163 |
+
/**
|
164 |
+
* If there are any errors, they will be added here.
|
165 |
+
* @var array
|
166 |
+
*/
|
167 |
+
var $errors = array();
|
168 |
+
/**
|
169 |
+
* If something was successful, a feedback message might be supplied here.
|
170 |
+
* @var string
|
171 |
+
*/
|
172 |
+
var $feedback_message;
|
173 |
+
/**
|
174 |
+
* Any warnings about an event (e.g. bad data, recurrence, etc.)
|
175 |
+
* @var string
|
176 |
+
*/
|
177 |
+
var $warnings;
|
178 |
+
/**
|
179 |
+
* Array of dbem_event field names required to create an event
|
180 |
+
* @var array
|
181 |
+
*/
|
182 |
+
var $required_fields = array('event_name', 'event_start_date');
|
183 |
+
var $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
|
184 |
+
/**
|
185 |
+
* previous status of event when instantiated
|
186 |
+
* @access protected
|
187 |
+
* @var mixed
|
188 |
+
*/
|
189 |
+
var $previous_status = 0;
|
190 |
+
|
191 |
+
/* Post Variables - copied out of post object for easy IDE reference */
|
192 |
+
var $ID;
|
193 |
+
var $post_author;
|
194 |
+
var $post_date;
|
195 |
+
var $post_date_gmt;
|
196 |
+
var $post_title;
|
197 |
+
var $post_excerpt;
|
198 |
+
var $post_status;
|
199 |
+
var $comment_status;
|
200 |
+
var $ping_status;
|
201 |
+
var $post_password;
|
202 |
+
var $post_name;
|
203 |
+
var $to_ping;
|
204 |
+
var $pinged;
|
205 |
+
var $post_modified;
|
206 |
+
var $post_modified_gmt;
|
207 |
+
var $post_content_filtered;
|
208 |
+
var $post_parent;
|
209 |
+
var $guid;
|
210 |
+
var $menu_order;
|
211 |
+
var $post_type;
|
212 |
+
var $post_mime_type;
|
213 |
+
var $comment_count;
|
214 |
+
var $ancestors;
|
215 |
+
var $filter;
|
216 |
+
|
217 |
+
/**
|
218 |
+
* 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.
|
219 |
+
* @param mixed $event_data
|
220 |
+
* @param mixed $search_by default is post_id, otherwise it can be by event_id as well.
|
221 |
+
* @return null
|
222 |
+
*/
|
223 |
+
function __construct($id = false, $search_by = 'event_id') {
|
224 |
+
global $wpdb;
|
225 |
+
if( is_array($id) ){
|
226 |
+
//deal with the old array style, but we can't supply arrays anymore
|
227 |
+
$id = (!empty($id['event_id'])) ? $id['event_id'] : $id['post_id'];
|
228 |
+
$search_by = (!empty($id['event_id'])) ? 'event_id':'post_id';
|
229 |
+
}
|
230 |
+
$is_post = !empty($id->ID) && ($id->post_type == EM_POST_TYPE_EVENT || $id->post_type == 'event-recurring');
|
231 |
+
if( is_numeric($id) || $is_post ){ //only load info if $id is a number
|
232 |
+
if($search_by == 'event_id' && !$is_post ){
|
233 |
+
//search by event_id, get post_id and blog_id (if in ms mode) and load the post
|
234 |
+
$results = $wpdb->get_row($wpdb->prepare("SELECT post_id, blog_id FROM ".EM_EVENTS_TABLE." WHERE event_id=%d",$id), ARRAY_A);
|
235 |
+
if( is_multisite() && is_numeric($results['blog_id']) ){
|
236 |
+
$event_post = get_blog_post($results['blog_id'], $results['post_id']);
|
237 |
+
$search_by = $results['blog_id'];
|
238 |
+
}else{
|
239 |
+
$event_post = get_post($results['post_id']);
|
240 |
+
}
|
241 |
+
}else{
|
242 |
+
if(!$is_post){
|
243 |
+
if( is_numeric($search_by) && is_multisite() ){
|
244 |
+
//we've been given a blog_id, so we're searching for a post id
|
245 |
+
$event_post = get_blog_post($search_by, $id);
|
246 |
+
}else{
|
247 |
+
//search for the post id only
|
248 |
+
$event_post = get_post($id);
|
249 |
+
}
|
250 |
+
}else{
|
251 |
+
$event_post = $id;
|
252 |
+
}
|
253 |
+
}
|
254 |
+
$this->load_postdata($event_post, $search_by);
|
255 |
+
}
|
256 |
+
$this->recurrence = $this->is_recurring() ? 1:0;
|
257 |
+
//if(defined('trashtest')){ print_r($this); die("got here");}
|
258 |
+
//Do it here so things appear in the po file.
|
259 |
+
$this->status_array = array(
|
260 |
+
0 => __('Pending','dbem'),
|
261 |
+
1 => __('Approved','dbem')
|
262 |
+
);
|
263 |
+
do_action('em_event', $this, $id, $search_by);
|
264 |
+
}
|
265 |
+
|
266 |
+
function load_postdata($event_post, $search_by = false){
|
267 |
+
if( is_object($event_post) ){
|
268 |
+
//load post data - regardless
|
269 |
+
$this->post_id = $event_post->ID;
|
270 |
+
$this->event_name = $event_post->post_title;
|
271 |
+
$this->event_owner = $event_post->post_author;
|
272 |
+
$this->post_content = $event_post->post_content;
|
273 |
+
$this->event_slug = $event_post->post_name;
|
274 |
+
$this->event_modified = $event_post->post_modified;
|
275 |
+
foreach( $event_post as $key => $value ){ //merge post object into this object
|
276 |
+
$this->$key = $value;
|
277 |
+
}
|
278 |
+
$this->previous_status = $this->event_status; //so we know about updates
|
279 |
+
$this->recurrence = $this->is_recurring() ? 1:0;
|
280 |
+
//load meta data and other related information
|
281 |
+
if( $event_post->post_status != 'auto-draft' ){
|
282 |
+
$event_meta = $this->get_event_meta($search_by);
|
283 |
+
//Get custom fields and post meta
|
284 |
+
foreach($event_meta as $event_meta_key => $event_meta_val){
|
285 |
+
$field_name = substr($event_meta_key, 1);
|
286 |
+
if($event_meta_key[0] != '_'){
|
287 |
+
$this->event_attributes[$event_meta_key] = ( count($event_meta_val) > 1 ) ? $event_meta_val:$event_meta_val[0];
|
288 |
+
}elseif( !in_array($field_name, $this->post_fields) ){
|
289 |
+
if( array_key_exists($field_name, $this->fields) ){
|
290 |
+
$this->$field_name = $event_meta_val[0];
|
291 |
+
}elseif( in_array($field_name, array('event_owner_name','event_owner_anonymous','event_owner_email')) ){
|
292 |
+
$this->$field_name = $event_meta_val[0];
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
//Start/End times should be available as timestamp
|
297 |
+
$this->start = strtotime($this->event_start_date." ".$this->event_start_time);
|
298 |
+
$this->end = strtotime($this->event_end_date." ".$this->event_end_time);
|
299 |
+
if( !empty($this->event_rsvp_date ) ){
|
300 |
+
$this->rsvp_end = strtotime($this->event_rsvp_date." ".$this->event_rsvp_time);
|
301 |
+
}
|
302 |
+
//quick compatability fix in case _event_id isn't loaded or somehow got erased in post meta
|
303 |
+
if( empty($this->event_id) && !$this->is_recurring() ){
|
304 |
+
global $wpdb;
|
305 |
+
$event_array = $wpdb->get_row('SELECT * FROM '.EM_EVENTS_TABLE. ' WHERE post_id='.$event_post->ID, ARRAY_A);
|
306 |
+
if( !empty($event_array['event_id']) ){
|
307 |
+
foreach($event_array as $key => $value){
|
308 |
+
if( !empty($value) && empty($this->$key) ){
|
309 |
+
update_post_meta($event_post->ID, '_'.$key, $value);
|
310 |
+
$this->$key = $value;
|
311 |
+
}
|
312 |
+
}
|
313 |
+
}
|
314 |
+
}
|
315 |
+
}
|
316 |
+
$this->get_status();
|
317 |
+
$this->compat_keys();
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
function get_event_meta($blog_id = false){
|
322 |
+
if( is_numeric($blog_id) && $blog_id > 0 && is_multisite() ){
|
323 |
+
// if in multisite mode, switch blogs quickly to get the right post meta.
|
324 |
+
switch_to_blog($blog_id);
|
325 |
+
$event_meta = get_post_meta($this->post_id);
|
326 |
+
restore_current_blog();
|
327 |
+
$this->blog_id = $blog_id;
|
328 |
+
}else{
|
329 |
+
$event_meta = get_post_meta($this->post_id);
|
330 |
+
}
|
331 |
+
return $event_meta;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Retrieve event information via POST (only used in situations where posts aren't submitted via WP)
|
336 |
+
* @return boolean
|
337 |
+
*/
|
338 |
+
function get_post($validate = true){
|
339 |
+
global $allowedposttags;
|
340 |
+
//we need to get the post/event name and content.... that's it.
|
341 |
+
$this->post_content = !empty($_POST['content']) ? wp_kses( stripslashes($_POST['content']), $allowedposttags):'';
|
342 |
+
$this->event_name = !empty($_POST['event_name']) ? wp_kses_data( stripslashes($_POST['event_name']) ):'';
|
343 |
+
$this->post_type = ($this->is_recurring() || !empty($_POST['recurring'])) ? 'event-recurring':EM_POST_TYPE_EVENT;
|
344 |
+
//don't forget categories!
|
345 |
+
$this->get_categories()->get_post();
|
346 |
+
//anonymous submissions and guest basic info
|
347 |
+
if( !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->event_id) ){
|
348 |
+
$this->event_owner_anonymous = 1;
|
349 |
+
$this->event_owner_name = !empty($_POST['event_owner_name']) ? stripslashes($_POST['event_owner_name']):'';
|
350 |
+
$this->event_owner_email = !empty($_POST['event_owner_email']) ? $_POST['event_owner_email']:'';
|
351 |
+
}
|
352 |
+
//get the rest and validate (optional)
|
353 |
+
$this->get_post_meta(false);
|
354 |
+
$result = $validate ? $this->validate():true; //validate both post and meta, otherwise return true
|
355 |
+
return apply_filters('em_event_get_post', $result, $this);
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Retrieve event post meta information via POST, which should be always be called when saving the event custom post via WP.
|
360 |
+
* @param boolean $validate whether or not to run validation, default is true
|
361 |
+
* @return boolean
|
362 |
+
*/
|
363 |
+
function get_post_meta($validate = true){
|
364 |
+
//Grab POST data
|
365 |
+
$this->event_start_date = ( !empty($_POST['event_start_date']) ) ? $_POST['event_start_date'] : '';
|
366 |
+
$this->event_end_date = ( !empty($_POST['event_end_date']) ) ? $_POST['event_end_date'] : $this->event_start_date;
|
367 |
+
//check if this is recurring or not
|
368 |
+
if( !empty($_POST['recurring']) ){
|
369 |
+
$this->recurrence = 1;
|
370 |
+
$this->post_type = 'event-recurring';
|
371 |
+
}
|
372 |
+
//Get Location info
|
373 |
+
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')) ){
|
374 |
+
$this->location_id = 0;
|
375 |
+
}elseif( !empty($_POST['location_id']) && is_numeric($_POST['location_id']) ){
|
376 |
+
$this->location_id = $_POST['location_id'];
|
377 |
+
}else{
|
378 |
+
//we're adding a new location, so create an empty location and populate
|
379 |
+
$this->location_id = null;
|
380 |
+
$this->get_location()->get_post(false);
|
381 |
+
$this->get_location()->post_content = ''; //reset post content, as it'll grab the event description otherwise
|
382 |
+
}
|
383 |
+
//Sort out time
|
384 |
+
$this->event_all_day = ( !empty($_POST['event_all_day']) ) ? 1 : 0;
|
385 |
+
if( !$this->event_all_day ){
|
386 |
+
$match = array();
|
387 |
+
foreach( array('event_start_time','event_end_time', 'event_rsvp_time') as $timeName ){
|
388 |
+
if( !empty($_POST[$timeName]) && preg_match ( '/^([01]\d|2[0-3]):([0-5]\d) ?(AM|PM)?$/', $_POST[$timeName], $match ) ){
|
389 |
+
if( !empty($match[3]) && $match[3] == 'PM' && $match[1] != 12 ){
|
390 |
+
$match[1] = 12+$match[1];
|
391 |
+
}elseif( !empty($match[3]) && $match[3] == 'AM' && $match[1] == 12 ){
|
392 |
+
$match[1] = '00';
|
393 |
+
}
|
394 |
+
$this->$timeName = $match[1].":".$match[2].":00";
|
395 |
+
}else{
|
396 |
+
$this->$timeName = ($timeName == 'event_start_time') ? "00:00:00":$this->event_start_time;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
}else{
|
400 |
+
$this->event_start_time = $this->event_end_time = '00:00:00';
|
401 |
+
}
|
402 |
+
//Start/End times should be available as timestamp
|
403 |
+
$this->start = strtotime($this->event_start_date." ".$this->event_start_time);
|
404 |
+
$this->end = strtotime($this->event_end_date." ".$this->event_end_time);
|
405 |
+
//Bookings
|
406 |
+
if( !empty($_POST['event_rsvp']) && $_POST['event_rsvp'] ){
|
407 |
+
$this->get_bookings()->get_tickets()->get_post();
|
408 |
+
$this->event_rsvp = 1;
|
409 |
+
//RSVP cuttoff TIME is set up above where start/end times are as well
|
410 |
+
if( !$this->is_recurring() ){
|
411 |
+
$this->event_rsvp_date = ( isset($_POST['event_rsvp_date']) ) ? $_POST['event_rsvp_date'] : $this->event_start_date;
|
412 |
+
if( empty($this->event_rsvp_date) ){ $this->event_rsvp_time = '00:00:00'; }
|
413 |
+
}
|
414 |
+
$this->event_spaces = ( isset($_POST['event_spaces']) ) ? absint($_POST['event_spaces']):0;
|
415 |
+
}else{
|
416 |
+
$this->event_rsvp = 0;
|
417 |
+
$this->event_rsvp_time = '00:00:00';
|
418 |
+
}
|
419 |
+
//Sort out event attributes - note that custom post meta now also gets inserted here automatically (and is overwritten by these attributes)
|
420 |
+
if(get_option('dbem_attributes_enabled')){
|
421 |
+
global $allowedtags;
|
422 |
+
if( !is_array($this->event_attributes) ){ $this->event_attributes = array(); }
|
423 |
+
$event_available_attributes = em_get_attributes();
|
424 |
+
if( !empty($_POST['em_attributes']) && is_array($_POST['em_attributes']) ){
|
425 |
+
foreach($_POST['em_attributes'] as $att_key => $att_value ){
|
426 |
+
if( (in_array($att_key, $event_available_attributes['names']) || array_key_exists($att_key, $this->event_attributes) ) ){
|
427 |
+
$this->event_attributes[$att_key] = '';
|
428 |
+
$att_vals = count($event_available_attributes['values'][$att_key]);
|
429 |
+
if( !empty($att_value) ){
|
430 |
+
if( $att_vals <= 1 || ($att_vals > 1 && in_array($att_value, $event_available_attributes['values'][$att_key])) ){
|
431 |
+
$this->event_attributes[$att_key] = stripslashes($att_value);
|
432 |
+
}
|
433 |
+
}
|
434 |
+
if( empty($att_value) && $att_vals > 1){
|
435 |
+
$this->event_attributes[$att_key] = stripslashes(wp_kses($event_available_attributes['values'][$att_key][0], $allowedtags));
|
436 |
+
}
|
437 |
+
}
|
438 |
+
}
|
439 |
+
}
|
440 |
+
}
|
441 |
+
//Set Blog ID
|
442 |
+
if( is_multisite() ){
|
443 |
+
$this->blog_id = get_current_blog_id();
|
444 |
+
}
|
445 |
+
//group id
|
446 |
+
$this->group_id = (!empty($_POST['group_id']) && is_numeric($_POST['group_id'])) ? $_POST['group_id']:0;
|
447 |
+
//Recurrence data
|
448 |
+
if( $this->is_recurring() ){
|
449 |
+
$this->recurrence = 1; //just in case
|
450 |
+
$this->recurrence_freq = ( !empty($_POST['recurrence_freq']) && in_array($_POST['recurrence_freq'], array('daily','weekly','monthly','yearly')) ) ? $_POST['recurrence_freq']:'daily';
|
451 |
+
if( !empty($_POST['recurrence_bydays']) && $this->recurrence_freq == 'weekly' && self::array_is_numeric($_POST['recurrence_bydays']) ){
|
452 |
+
$this->recurrence_byday = implode( ",", $_POST['recurrence_bydays'] );
|
453 |
+
}elseif( !empty($_POST['recurrence_byday']) && $this->recurrence_freq == 'monthly' ){
|
454 |
+
$this->recurrence_byday = $_POST['recurrence_byday'];
|
455 |
+
}
|
456 |
+
$this->recurrence_interval = ( !empty($_POST['recurrence_interval']) && is_numeric($_POST['recurrence_interval']) ) ? $_POST['recurrence_interval']:1;
|
457 |
+
$this->recurrence_byweekno = ( !empty($_POST['recurrence_byweekno']) ) ? $_POST['recurrence_byweekno']:'';
|
458 |
+
$this->recurrence_days = ( !empty($_POST['recurrence_days']) && is_numeric($_POST['recurrence_days']) ) ? (int) $_POST['recurrence_days']:0;
|
459 |
+
}
|
460 |
+
//categories in MS GLobal
|
461 |
+
if(EM_MS_GLOBAL && !is_main_site()){
|
462 |
+
$this->get_categories()->get_post(); //it'll know what to do
|
463 |
+
}
|
464 |
+
//validate (optional) and return result
|
465 |
+
$this->compat_keys(); //compatability
|
466 |
+
return apply_filters('em_event_get_post', count($this->errors) == 0, $this);
|
467 |
+
}
|
468 |
+
|
469 |
+
function validate(){
|
470 |
+
$validate_post = true;
|
471 |
+
if( empty($this->event_name) ){
|
472 |
+
$validate_post = false;
|
473 |
+
$this->add_error( sprintf(__("%s is required.", "dbem"), __('Event name','dbem')) );
|
474 |
+
}
|
475 |
+
//anonymous submissions and guest basic info
|
476 |
+
if( !empty($this->event_owner_anonymous) ){
|
477 |
+
if( !is_email($this->event_owner_email) ){
|
478 |
+
$this->add_error( sprintf(__("%s is required.", "dbem"), __('A valid email','dbem')) );
|
479 |
+
}
|
480 |
+
if( empty($this->event_owner_name) ){
|
481 |
+
$this->add_error( sprintf(__("%s is required.", "dbem"), __('Your name','dbem')) );
|
482 |
+
}
|
483 |
+
}
|
484 |
+
$validate_tickets = $this->get_bookings()->get_tickets()->validate();
|
485 |
+
$validate_image = $this->image_validate();
|
486 |
+
$validate_meta = $this->validate_meta();
|
487 |
+
return apply_filters('em_event_validate', $validate_post && $validate_image && $validate_meta && $validate_tickets, $this );
|
488 |
+
}
|
489 |
+
function validate_meta(){
|
490 |
+
$missing_fields = Array ();
|
491 |
+
foreach ( array('event_start_date') as $field ) {
|
492 |
+
if ( $this->$field == "") {
|
493 |
+
$missing_fields[$field] = $field;
|
494 |
+
}
|
495 |
+
}
|
496 |
+
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) ){
|
497 |
+
if( strtotime($this->event_start_date . $this->event_start_time) > strtotime($this->event_end_date . $this->event_end_time) ){
|
498 |
+
$this->add_error(__('Events cannot start after they end.','dbem'));
|
499 |
+
}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) ){
|
500 |
+
$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.'));
|
501 |
+
}
|
502 |
+
}else{
|
503 |
+
if( !empty($missing_fields['event_start_date']) ) { unset($missing_fields['event_start_date']); }
|
504 |
+
if( !empty($missing_fields['event_end_date']) ) { unset($missing_fields['event_end_date']); }
|
505 |
+
$this->add_error(__('Dates must have correct formatting. Please use the date picker provided.','dbem'));
|
506 |
+
}
|
507 |
+
if( $this->event_rsvp ){
|
508 |
+
if( !$this->get_bookings()->get_tickets()->validate() ){
|
509 |
+
$this->add_error($this->get_bookings()->get_tickets()->get_errors());
|
510 |
+
}
|
511 |
+
if( !empty($this->event_rsvp_date) && !preg_match('/\d{4}-\d{2}-\d{2}/', $this->event_rsvp_date) ){
|
512 |
+
$this->add_error(__('Dates must have correct formatting. Please use the date picker provided.','dbem'));
|
513 |
+
}
|
514 |
+
}
|
515 |
+
if( get_option('dbem_locations_enabled') && empty($this->location_id) ){ //location ids don't need validating as we're not saving a location
|
516 |
+
if( get_option('dbem_require_location',true) || $this->location_id !== 0 ){
|
517 |
+
if( !$this->get_location()->validate() ){
|
518 |
+
$this->add_error($this->get_location()->get_errors());
|
519 |
+
}
|
520 |
+
}
|
521 |
+
}
|
522 |
+
if ( count($missing_fields) > 0){
|
523 |
+
// TODO Create friendly equivelant names for missing fields notice in validation
|
524 |
+
$this->add_error( __( 'Missing fields: ', 'dbem') . implode ( ", ", $missing_fields ) . ". " );
|
525 |
+
}
|
526 |
+
if ( $this->is_recurring() && ($this->event_end_date == "" || $this->event_end_date == $this->event_start_date) ){
|
527 |
+
$this->add_error( __( 'Since the event is repeated, you must specify an event end date greater than the start date.', 'dbem' ));
|
528 |
+
}
|
529 |
+
return apply_filters('em_event_validate_meta', count($this->errors) == 0, $this );
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* 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.
|
534 |
+
* Will automatically detect whether it's a new or existing event.
|
535 |
+
* @return boolean
|
536 |
+
*/
|
537 |
+
function save(){
|
538 |
+
global $wpdb, $current_user, $blog_id;
|
539 |
+
if( !$this->can_manage('edit_events', 'edit_others_events') && !( get_option('dbem_events_anonymous_submissions') && empty($this->event_id)) ){
|
540 |
+
//unless events can be submitted by an anonymous user (and this is a new event), user must have permissions.
|
541 |
+
return apply_filters('em_event_save', false, $this);
|
542 |
+
}
|
543 |
+
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
|
544 |
+
do_action('em_event_save_pre', $this);
|
545 |
+
$post_array = array();
|
546 |
+
//Deal with updates to an event
|
547 |
+
if( !empty($this->post_id) ){
|
548 |
+
//get the full array of post data so we don't overwrite anything.
|
549 |
+
if( !empty($this->blog_id) && is_multisite() ){
|
550 |
+
$post_array = (array) get_blog_post($this->blog_id, $this->post_id);
|
551 |
+
}else{
|
552 |
+
$post_array = (array) get_post($this->post_id);
|
553 |
+
}
|
554 |
+
}
|
555 |
+
//Overwrite new post info
|
556 |
+
$post_array['post_type'] = ($this->recurrence && get_option('dbem_recurrence_enabled')) ? 'event-recurring':EM_POST_TYPE_EVENT;
|
557 |
+
$post_array['post_title'] = $this->event_name;
|
558 |
+
$post_array['post_content'] = $this->post_content;
|
559 |
+
//decide on post status
|
560 |
+
if( count($this->errors) == 0 ){
|
561 |
+
$post_array['post_status'] = ( $this->can_manage('publish_events','publish_events') ) ? 'publish':'pending';
|
562 |
+
}else{
|
563 |
+
$post_array['post_status'] = 'draft';
|
564 |
+
}
|
565 |
+
//anonymous submission only
|
566 |
+
if( !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->event_id) ){
|
567 |
+
$post_array['post_author'] = get_option('dbem_events_anonymous_user');
|
568 |
+
if( !is_numeric($post_array['post_author']) ) $post_array['post_author'] = 0;
|
569 |
+
}
|
570 |
+
//Save post and continue with meta
|
571 |
+
$post_id = wp_insert_post($post_array);
|
572 |
+
$post_save = false;
|
573 |
+
$meta_save = false;
|
574 |
+
if( !is_wp_error($post_id) && !empty($post_id) ){
|
575 |
+
$post_save = true;
|
576 |
+
//refresh this event with wp post info we'll put into the db
|
577 |
+
$post_data = get_post($post_id);
|
578 |
+
$this->post_id = $post_id;
|
579 |
+
$this->event_slug = $post_data->post_name;
|
580 |
+
$this->event_owner = $post_data->post_author;
|
581 |
+
$this->post_status = $post_data->post_status;
|
582 |
+
$this->get_status();
|
583 |
+
//Categories? note that categories will soft-fail, so no errors
|
584 |
+
$this->get_categories()->event_id = $this->event_id;
|
585 |
+
$this->categories->post_id = $this->post_id;
|
586 |
+
$this->categories->save();
|
587 |
+
//anonymous submissions should save this information
|
588 |
+
if( !empty($this->event_owner_anonymous) ){
|
589 |
+
update_post_meta($this->post_id, '_event_owner_anonymous', 1);
|
590 |
+
update_post_meta($this->post_id, '_event_owner_name', $this->event_owner_name);
|
591 |
+
update_post_meta($this->post_id, '_event_owner_email', $this->event_owner_email);
|
592 |
+
}
|
593 |
+
//save the image
|
594 |
+
$this->image_upload();
|
595 |
+
//now save the meta
|
596 |
+
$meta_save = $this->save_meta();
|
597 |
+
$image_save = (count($this->errors) == 0); //whilst it might not be an image save that fails, we can know something went wrong
|
598 |
+
}
|
599 |
+
$result = $meta_save && $post_save && $image_save;
|
600 |
+
$previous_status = $this->previous_status;
|
601 |
+
if($result) $this->load_postdata($post_data, $blog_id); //reload post info
|
602 |
+
$this->previous_status = $previous_status;
|
603 |
+
//do a dirty update for location too if it's not published
|
604 |
+
if( $this->is_published() && !empty($this->location_id) ){
|
605 |
+
$EM_Location = $this->get_location();
|
606 |
+
if( $EM_Location->location_status !== 1 ){
|
607 |
+
//let's also publish the location
|
608 |
+
$EM_Location->set_status(1, true);
|
609 |
+
}
|
610 |
+
}
|
611 |
+
return apply_filters('em_event_save', $result, $this);
|
612 |
+
}
|
613 |
+
|
614 |
+
function save_meta(){
|
615 |
+
global $wpdb;
|
616 |
+
if( ( get_option('dbem_events_anonymous_submissions') && empty($this->event_id)) || $this->can_manage('edit_events', 'edit_others_events') ){
|
617 |
+
do_action('em_event_save_meta_pre', $this);
|
618 |
+
//first save location
|
619 |
+
if( empty($this->location_id) && !($this->location_id === 0 && !get_option('dbem_require_location',true)) ){
|
620 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){ $this->ms_global_switch(); }
|
621 |
+
if( !$this->get_location()->save() ){ //soft fail
|
622 |
+
global $EM_Notices;
|
623 |
+
if( !empty($this->get_location()->location_id) ){
|
624 |
+
$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);
|
625 |
+
}else{
|
626 |
+
$this->get_location()->set_status(null);
|
627 |
+
$EM_Notices->add_error( __('There were some errors saving your location.'), true);
|
628 |
+
}
|
629 |
+
}
|
630 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){ $this->ms_global_switch_back(); }
|
631 |
+
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
|
632 |
+
$this->location_id = $this->location->location_id;
|
633 |
+
}
|
634 |
+
}
|
635 |
+
//Update Post Meta
|
636 |
+
foreach($this->fields as $key => $field_info){
|
637 |
+
if( !in_array($key, $this->post_fields) && $key != 'event_attributes' ){
|
638 |
+
update_post_meta($this->post_id, '_'.$key, $this->$key);
|
639 |
+
}elseif($key == 'event_attributes'){
|
640 |
+
//attributes get saved as individual keys
|
641 |
+
foreach($this->event_attributes as $event_attribute_key => $event_attribute){
|
642 |
+
if( !empty($event_attribute) ){
|
643 |
+
update_post_meta($this->post_id, $event_attribute_key, $event_attribute);
|
644 |
+
}else{
|
645 |
+
delete_post_meta($this->post_id, $event_attribute_key);
|
646 |
+
}
|
647 |
+
}
|
648 |
+
}
|
649 |
+
}
|
650 |
+
//update timestampes
|
651 |
+
update_post_meta($this->post_id, '_start_ts', str_pad($this->start, 10, 0, STR_PAD_LEFT));
|
652 |
+
update_post_meta($this->post_id, '_end_ts', str_pad($this->end, 10, 0, STR_PAD_LEFT));
|
653 |
+
//sort out event status
|
654 |
+
$result = count($this->errors) == 0;
|
655 |
+
$this->get_status();
|
656 |
+
$this->event_status = ($result) ? $this->event_status:null; //set status at this point, it's either the current status, or if validation fails, null
|
657 |
+
//Save to em_event table
|
658 |
+
$event_array = $this->to_array(true);
|
659 |
+
unset($event_array['event_id']);
|
660 |
+
if( $this->post_status == 'private' ) $event_array['event_private'] = 1;
|
661 |
+
$event_array['event_attributes'] = serialize($this->event_attributes); //might as well
|
662 |
+
if( !empty($this->event_id) ){
|
663 |
+
$blog_condition = '';
|
664 |
+
if( EM_MS_GLOBAL ){
|
665 |
+
$blog_condition = " AND blog_id='".get_current_blog_id()."' ";
|
666 |
+
}
|
667 |
+
$event_truly_exists = $wpdb->get_var('SELECT post_id FROM '.EM_EVENTS_TABLE." WHERE event_id={$this->event_id}".$blog_condition) == $this->post_id;
|
668 |
+
}else{
|
669 |
+
$event_truly_exists = false;
|
670 |
+
}
|
671 |
+
if( empty($this->event_id) || !$event_truly_exists ){
|
672 |
+
$this->previous_status = 0; //for sure this was previously status 0
|
673 |
+
$this->event_date_created = current_time('mysql');
|
674 |
+
if ( !$wpdb->insert(EM_EVENTS_TABLE, $event_array) ){
|
675 |
+
$this->add_error( sprintf(__('Something went wrong saving your %s to the index table. Please inform a site administrator about this.','dbem'),__('event','dbem')));
|
676 |
+
}else{
|
677 |
+
//success, so link the event with the post via an event id meta value for easy retrieval
|
678 |
+
$this->event_id = $wpdb->insert_id;
|
679 |
+
update_post_meta($this->post_id, '_event_id', $this->event_id);
|
680 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Event','dbem'));
|
681 |
+
$just_added_event = true; //make an easy hook
|
682 |
+
do_action('em_event_save_new', $this);
|
683 |
+
}
|
684 |
+
}else{
|
685 |
+
$this->previous_status = $this->get_previous_status();
|
686 |
+
$this->event_date_modified = $event_array['event_date_modified'] = current_time('mysql');
|
687 |
+
if ( $wpdb->update(EM_EVENTS_TABLE, $event_array, array('event_id'=>$this->event_id) ) === false ){
|
688 |
+
$this->add_error( sprintf(__('Something went wrong updating your %s to the index table. Please inform a site administrator about this.','dbem'),__('event','dbem')));
|
689 |
+
}else{
|
690 |
+
//Also set the status here if status != previous status
|
691 |
+
if( $this->previous_status != $this->get_status()){
|
692 |
+
$status_value = $this->get_status(true);
|
693 |
+
$wpdb->query('UPDATE '.EM_EVENTS_TABLE." SET event_status=$status_value WHERE event_id=".$this->event_id);
|
694 |
+
}
|
695 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Event','dbem'));
|
696 |
+
}
|
697 |
+
}
|
698 |
+
//Add/Delete Tickets
|
699 |
+
if($this->event_rsvp == 0){
|
700 |
+
$this->get_bookings()->delete();
|
701 |
+
}else{
|
702 |
+
if( !$this->get_bookings()->get_tickets()->save() ){
|
703 |
+
$this->add_error( $this->get_bookings()->get_tickets()->get_errors() );
|
704 |
+
}
|
705 |
+
}
|
706 |
+
$result = count($this->errors) == 0;
|
707 |
+
//If we're saving event categories in MS Global mode, we'll add them here, saving by term id (cat ids are gone now)
|
708 |
+
if( EM_MS_GLOBAL && !is_main_site() ){
|
709 |
+
$this->get_categories()->save(); //it'll know what to do
|
710 |
+
}elseif( EM_MS_GLOBAL ){
|
711 |
+
$this->get_categories()->save_index(); //just save to index, we assume cats are saved in $this->save();
|
712 |
+
}
|
713 |
+
//build recurrences if needed
|
714 |
+
if( $this->is_recurring() && $result && $this->is_published() ){ //only save events if recurring event validates and is published
|
715 |
+
if( !$this->save_events() ){ //only save if post is 'published'
|
716 |
+
$this->add_error(__ ( 'Something went wrong with the recurrence update...', 'dbem' ). __ ( 'There was a problem saving the recurring events.', 'dbem' ));
|
717 |
+
}
|
718 |
+
}
|
719 |
+
if( !empty($just_added_event) ){
|
720 |
+
do_action('em_event_added', $this);
|
721 |
+
}
|
722 |
+
}
|
723 |
+
$this->compat_keys();
|
724 |
+
return apply_filters('em_event_save_meta', count($this->errors) == 0, $this);
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Duplicates this event and returns the duplicated event. Will return false if there is a problem with duplication.
|
729 |
+
* @return EM_Event
|
730 |
+
*/
|
731 |
+
function duplicate(){
|
732 |
+
global $wpdb, $EZSQL_ERROR;
|
733 |
+
//First, duplicate.
|
734 |
+
if( $this->can_manage('edit_events','edit_others_events') ){
|
735 |
+
$EM_Event = clone $this;
|
736 |
+
$EM_Event->get_categories(); //before we remove event/post ids
|
737 |
+
$EM_Event->get_bookings()->get_tickets(); //in case this wasn't loaded and before we reset ids
|
738 |
+
$EM_Event->event_id = null;
|
739 |
+
$EM_Event->post_id = null;
|
740 |
+
$EM_Event->ID = null;
|
741 |
+
$EM_Event->post_name = '';
|
742 |
+
$EM_Event->location_id = (empty($EM_Event->location_id) && !get_option('dbem_require_location')) ? 0:$EM_Event->location_id;
|
743 |
+
$EM_Event->get_bookings()->event_id = null;
|
744 |
+
$EM_Event->get_bookings()->get_tickets()->event_id = null;
|
745 |
+
//if bookings reset ticket ids and duplicate tickets
|
746 |
+
foreach($EM_Event->get_bookings()->get_tickets()->tickets as $EM_Ticket){
|
747 |
+
$EM_Ticket->ticket_id = null;
|
748 |
+
$EM_Ticket->event_id = null;
|
749 |
+
}
|
750 |
+
do_action('em_event_duplicate_pre', $EM_Event);
|
751 |
+
if( $EM_Event->save() ){
|
752 |
+
$EM_Event->feedback_message = sprintf(__("%s successfully duplicated.", 'dbem'), __('Event','dbem'));
|
753 |
+
//other non-EM post meta inc. featured image
|
754 |
+
$event_meta = $this->get_event_meta($this->blog_id);
|
755 |
+
$event_meta_inserts = array();
|
756 |
+
//Get custom fields and post meta - adapted from $this->load_post_meta()
|
757 |
+
foreach($event_meta as $event_meta_key => $event_meta_vals){
|
758 |
+
if($event_meta_key[0] == '_'){
|
759 |
+
$field_name = substr($event_meta_key, 1);
|
760 |
+
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')) ){
|
761 |
+
foreach($event_meta_vals as $event_meta_val){
|
762 |
+
$event_meta_inserts[] = "({$EM_Event->post_id}, '{$event_meta_key}', '{$event_meta_val}')";
|
763 |
+
}
|
764 |
+
}
|
765 |
+
}
|
766 |
+
}
|
767 |
+
//save in one SQL statement
|
768 |
+
if( !empty($event_meta_inserts) ){
|
769 |
+
$wpdb->query('INSERT INTO '.$wpdb->postmeta." (post_id, meta_key, meta_value) VALUES ".implode(', ', $event_meta_inserts));
|
770 |
+
}
|
771 |
+
return apply_filters('em_event_duplicate', $EM_Event, $this);
|
772 |
+
}
|
773 |
+
}
|
774 |
+
//TODO add error notifications for duplication failures.
|
775 |
+
return apply_filters('em_event_duplicate', false, $this);;
|
776 |
+
}
|
777 |
+
|
778 |
+
/**
|
779 |
+
* Delete whole event, including bookings, tickets, etc.
|
780 |
+
* @return boolean
|
781 |
+
*/
|
782 |
+
function delete($force_delete = false){ //atm wp seems to force cp deletions anyway
|
783 |
+
global $wpdb;
|
784 |
+
if( $this->can_manage('delete_events', 'delete_others_events') ){
|
785 |
+
if( !is_admin() ){
|
786 |
+
include_once('em-event-post-admin.php');
|
787 |
+
if( !defined('EM_EVENT_DELETE_INCLUDE') ){
|
788 |
+
EM_Event_Post_Admin::init();
|
789 |
+
EM_Event_Recurring_Post_Admin::init();
|
790 |
+
define('EM_EVENT_DELETE_INCLUDE',true);
|
791 |
+
}
|
792 |
+
}
|
793 |
+
do_action('em_event_delete_pre', $this);
|
794 |
+
if( $force_delete ){
|
795 |
+
$result = wp_delete_post($this->post_id,$force_delete);
|
796 |
+
}else{
|
797 |
+
$result = wp_trash_post($this->post_id);
|
798 |
+
}
|
799 |
+
}else{
|
800 |
+
$result = false;
|
801 |
+
}
|
802 |
+
//print_r($result); echo "|"; print_r($result_meta); die('DELETING');
|
803 |
+
return apply_filters('em_event_delete', $result !== false, $this);
|
804 |
+
}
|
805 |
+
|
806 |
+
function delete_meta(){
|
807 |
+
global $wpdb;
|
808 |
+
$result = false;
|
809 |
+
if( $this->can_manage('delete_events', 'delete_others_events') ){
|
810 |
+
do_action('em_event_delete_meta_event_pre', $this);
|
811 |
+
$result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". EM_EVENTS_TABLE ." WHERE event_id=%d", $this->event_id) );
|
812 |
+
if( $result !== false ){
|
813 |
+
$this->delete_bookings();
|
814 |
+
$this->delete_tickets();
|
815 |
+
//Delete the recurrences then this recurrence event
|
816 |
+
if( $this->is_recurring() ){
|
817 |
+
$result = $this->delete_events(); //was true at this point, so false if fails
|
818 |
+
}
|
819 |
+
//Delete categories from meta if in MS global mode
|
820 |
+
if( EM_MS_GLOBAL ){
|
821 |
+
$wpdb->query('DELETE FROM '.EM_META_TABLE.' WHERE object_id='.$this->event_id." AND meta_key='event-category'");
|
822 |
+
}
|
823 |
+
}
|
824 |
+
}
|
825 |
+
return apply_filters('em_event_delete_meta', $result !== false, $this);
|
826 |
+
}
|
827 |
+
|
828 |
+
/**
|
829 |
+
* Shortcut function for $this->get_bookings()->delete(), because using the EM_Bookings requires loading previous bookings, which isn't neceesary.
|
830 |
+
*/
|
831 |
+
function delete_bookings(){
|
832 |
+
global $wpdb;
|
833 |
+
do_action('em_event_delete_bookings_pre', $this);
|
834 |
+
$result = false;
|
835 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
836 |
+
$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) );
|
837 |
+
$result = $wpdb->query( $wpdb->prepare("DELETE FROM ".EM_BOOKINGS_TABLE." WHERE event_id=%d", $this->event_id) );
|
838 |
+
}
|
839 |
+
return apply_filters('em_event_delete_bookings', $result !== false && $result_bt !== false, $this);
|
840 |
+
}
|
841 |
+
|
842 |
+
/**
|
843 |
+
* Shortcut function for $this->get_bookings()->delete(), because using the EM_Bookings requires loading previous bookings, which isn't neceesary.
|
844 |
+
*/
|
845 |
+
function delete_tickets(){
|
846 |
+
global $wpdb;
|
847 |
+
do_action('em_event_delete_tickets_pre', $this);
|
848 |
+
$result = false;
|
849 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
850 |
+
$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) );
|
851 |
+
$result = $wpdb->query( $wpdb->prepare("DELETE FROM ".EM_TICKETS_TABLE." WHERE event_id=%d", $this->event_id) );
|
852 |
+
}
|
853 |
+
return apply_filters('em_event_delete_tickets', $result, $this);
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Change the status of the event. This will save to the Database too.
|
858 |
+
* @param int $status
|
859 |
+
* @param boolean $set_post_status
|
860 |
+
* @return string
|
861 |
+
*/
|
862 |
+
function set_status($status, $set_post_status = false){
|
863 |
+
global $wpdb;
|
864 |
+
if($status === null){
|
865 |
+
$set_status='NULL';
|
866 |
+
if($set_post_status){
|
867 |
+
//if the post is trash, don't untrash it!
|
868 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $this->post_id ) );
|
869 |
+
$this->post_status = 'draft';
|
870 |
+
}
|
871 |
+
}else{
|
872 |
+
$set_status = $status ? 1:0;
|
873 |
+
if($set_post_status){
|
874 |
+
if($this->post_status == 'pending'){
|
875 |
+
$this->post_name = sanitize_title($this->post_title);
|
876 |
+
}
|
877 |
+
$this->post_status = $set_status ? 'publish':'pending';
|
878 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => $this->post_status, 'post_name' => $this->post_name ), array( 'ID' => $this->post_id ) );
|
879 |
+
}
|
880 |
+
}
|
881 |
+
$this->previous_status = $this->get_previous_status();
|
882 |
+
$result = $wpdb->query("UPDATE ".EM_EVENTS_TABLE." SET event_status=$set_status, event_slug='{$this->post_name}' WHERE event_id=".$this->event_id);
|
883 |
+
$this->get_status(); //reload status
|
884 |
+
return apply_filters('em_event_set_status', $result !== false, $status, $this);
|
885 |
+
}
|
886 |
+
|
887 |
+
function is_published(){
|
888 |
+
return apply_filters('em_event_is_published', ($this->post_status == 'publish' || $this->post_status == 'private'), $this);
|
889 |
+
}
|
890 |
+
|
891 |
+
function get_status($db = false){
|
892 |
+
switch( $this->post_status ){
|
893 |
+
case 'private':
|
894 |
+
$this->event_private = 1;
|
895 |
+
$this->event_status = $status = 1;
|
896 |
+
break;
|
897 |
+
case 'publish':
|
898 |
+
$this->event_private = 0;
|
899 |
+
$this->event_status = $status = 1;
|
900 |
+
break;
|
901 |
+
case 'pending':
|
902 |
+
$this->event_private = 0;
|
903 |
+
$this->event_status = $status = 0;
|
904 |
+
break;
|
905 |
+
default: //draft or unknown
|
906 |
+
$this->event_private = 0;
|
907 |
+
$status = $db ? 'NULL':null;
|
908 |
+
$this->event_status = null;
|
909 |
+
break;
|
910 |
+
}
|
911 |
+
return $status;
|
912 |
+
}
|
913 |
+
|
914 |
+
function get_previous_status(){
|
915 |
+
global $wpdb;
|
916 |
+
return $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
|
917 |
+
}
|
918 |
+
|
919 |
+
/**
|
920 |
+
* Returns an EM_Categories object of the EM_Event instance.
|
921 |
+
* @return EM_Categories
|
922 |
+
*/
|
923 |
+
function get_categories() {
|
924 |
+
if( empty($this->categories) ){
|
925 |
+
$this->categories = new EM_Categories($this);
|
926 |
+
}elseif(empty($this->categories->event_id)){
|
927 |
+
$this->categories->event_id = $this->event_id;
|
928 |
+
$this->categories->post_id = $this->post_id;
|
929 |
+
}
|
930 |
+
return apply_filters('em_event_get_categories', $this->categories, $this);
|
931 |
+
}
|
932 |
+
|
933 |
+
/**
|
934 |
+
* Returns the location object this event belongs to.
|
935 |
+
* @return EM_Location
|
936 |
+
*/
|
937 |
+
function get_location() {
|
938 |
+
global $EM_Location;
|
939 |
+
if( is_object($EM_Location) && $EM_Location->location_id == $this->location_id ){
|
940 |
+
$this->location = $EM_Location;
|
941 |
+
}else{
|
942 |
+
if( !is_object($this->location) || $this->location->location_id != $this->location_id ){
|
943 |
+
$this->location = em_get_location($this->location_id);
|
944 |
+
}
|
945 |
+
}
|
946 |
+
return $this->location;
|
947 |
+
}
|
948 |
+
|
949 |
+
/**
|
950 |
+
* Returns the location object this event belongs to.
|
951 |
+
* @return EM_Person
|
952 |
+
*/
|
953 |
+
function get_contact(){
|
954 |
+
if( !is_object($this->contact) ){
|
955 |
+
$this->contact = new EM_Person($this->event_owner);
|
956 |
+
//if this is anonymous submission, change contact email and name
|
957 |
+
if( $this->event_owner_anonymous ){
|
958 |
+
$this->contact->user_email = $this->event_owner_email;
|
959 |
+
$name = explode(' ',$this->event_owner_name);
|
960 |
+
$first_name = array_shift($name);
|
961 |
+
$last_name = (count($name) > 0) ? implode(' ',$name):'';
|
962 |
+
$this->contact->user_firstname = $this->contact->first_name = $first_name;
|
963 |
+
$this->contact->user_lastname = $this->contact->last_name = $last_name;
|
964 |
+
}
|
965 |
+
}
|
966 |
+
return $this->contact;
|
967 |
+
}
|
968 |
+
|
969 |
+
/**
|
970 |
+
* 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.
|
971 |
+
* @param boolean $force_reload
|
972 |
+
* @return EM_Bookings
|
973 |
+
*/
|
974 |
+
function get_bookings( $force_reload = false ){
|
975 |
+
if( get_option('dbem_rsvp_enabled') ){
|
976 |
+
if( (!$this->bookings || $force_reload) ){
|
977 |
+
$this->bookings = new EM_Bookings($this);
|
978 |
+
}
|
979 |
+
$this->bookings->event_id = $this->event_id; //always refresh event_id
|
980 |
+
}else{
|
981 |
+
return new EM_Bookings();
|
982 |
+
}
|
983 |
+
return apply_filters('em_event_get_bookings', $this->bookings, $this);
|
984 |
+
}
|
985 |
+
|
986 |
+
/**
|
987 |
+
* Get the tickets related to this event.
|
988 |
+
* @param boolean $force_reload
|
989 |
+
* @return EM_Tickets
|
990 |
+
*/
|
991 |
+
function get_tickets( $force_reload = false ){
|
992 |
+
return $this->get_bookings($force_reload)->get_tickets();
|
993 |
+
}
|
994 |
+
|
995 |
+
/**
|
996 |
+
* Gets number of spaces in this event, dependent on ticket spaces or hard limit, whichever is smaller.
|
997 |
+
* @param boolean $force_refresh
|
998 |
+
* @return int
|
999 |
+
*/
|
1000 |
+
function get_spaces($force_refresh=false){
|
1001 |
+
return $this->get_bookings()->get_spaces($force_refresh);
|
1002 |
+
}
|
1003 |
+
|
1004 |
+
/*
|
1005 |
+
* Extends the default EM_Object function by switching blogs as needed if in MS Global mode
|
1006 |
+
* @param string $size
|
1007 |
+
* @return string
|
1008 |
+
* @see EM_Object::get_image_url()
|
1009 |
+
*/
|
1010 |
+
function get_image_url($size = 'full'){
|
1011 |
+
if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){
|
1012 |
+
switch_to_blog($this->blog_id);
|
1013 |
+
$switch_back = true;
|
1014 |
+
}
|
1015 |
+
$return = parent::get_image_url($size);
|
1016 |
+
if( !empty($switch_back) ){ restore_current_blog(); }
|
1017 |
+
return $return;
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
function get_edit_reschedule_url(){
|
1021 |
+
if( $this->is_recurrence() ){
|
1022 |
+
$EM_Event = em_get_event($this->recurrence_id);
|
1023 |
+
return $EM_Event->get_edit_url();
|
1024 |
+
}
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
function get_edit_url(){
|
1028 |
+
if( $this->can_manage('edit_events','edit_others_events') ){
|
1029 |
+
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() ){
|
1030 |
+
if( get_blog_option($this->blog_id, 'dbem_edit_events_page') ){
|
1031 |
+
$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);
|
1032 |
+
}
|
1033 |
+
if( empty($link))
|
1034 |
+
$link = get_admin_url($this->blog_id, "post.php?post={$this->post_id}&action=edit");
|
1035 |
+
}else{
|
1036 |
+
if( get_option('dbem_edit_events_page') && !is_admin() ){
|
1037 |
+
$link = em_add_get_params(get_permalink(get_option('dbem_edit_events_page')), array('action'=>'edit','event_id'=>$this->event_id), false);
|
1038 |
+
}
|
1039 |
+
if( empty($link))
|
1040 |
+
$link = admin_url()."post.php?post={$this->post_id}&action=edit";
|
1041 |
+
}
|
1042 |
+
return apply_filters('em_event_get_edit_url', $link, $this);
|
1043 |
+
}
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
function get_bookings_url(){
|
1047 |
+
if( get_option('dbem_edit_bookings_page') && (!is_admin() || !empty($_REQUEST['is_public'])) ){
|
1048 |
+
$my_bookings_page = get_permalink(get_option('dbem_edit_bookings_page'));
|
1049 |
+
$bookings_link = em_add_get_params($my_bookings_page, array('event_id'=>$this->event_id), false);
|
1050 |
+
}else{
|
1051 |
+
if( $this->blog_id != get_current_blog_id() ){
|
1052 |
+
$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);
|
1053 |
+
}else{
|
1054 |
+
$bookings_link = EM_ADMIN_URL. "&page=events-manager-bookings&event_id=".$this->event_id;
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
+
return apply_filters('em_event_get_bookings_url', $bookings_link, $this);
|
1058 |
+
}
|
1059 |
+
|
1060 |
+
function get_permalink(){
|
1061 |
+
if( EM_MS_GLOBAL ){
|
1062 |
+
if( get_site_option('dbem_ms_global_events_links') && !empty($this->blog_id) && $this->blog_id != get_current_blog_id() ){
|
1063 |
+
//linking directly to the blog
|
1064 |
+
$event_link = get_blog_permalink( $this->blog_id, $this->post_id);
|
1065 |
+
}elseif( !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id() ){
|
1066 |
+
if( get_option('dbem_events_page') ){
|
1067 |
+
$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);
|
1068 |
+
}else{
|
1069 |
+
$event_link = trailingslashit(home_url()).EM_POST_TYPE_EVENT_SLUG.'/'.get_site_option('dbem_ms_events_slug',EM_EVENT_SLUG).'/'.$this->event_slug.'-'.$this->event_id;
|
1070 |
+
}
|
1071 |
+
}
|
1072 |
+
}
|
1073 |
+
if( empty($event_link) ){
|
1074 |
+
$event_link = get_post_permalink($this->post_id);
|
1075 |
+
}
|
1076 |
+
return apply_filters('em_event_get_permalink', $event_link, $this);
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
function get_ical_url(){
|
1080 |
+
global $wp_rewrite;
|
1081 |
+
if( !empty($wp_rewrite) && $wp_rewrite->using_permalinks() ){
|
1082 |
+
return trailingslashit($this->get_permalink()).'ical/';
|
1083 |
+
}else{
|
1084 |
+
return em_add_get_params($this->get_permalink(), array('ical'=>1));
|
1085 |
+
}
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
function is_free(){
|
1089 |
+
$free = true;
|
1090 |
+
foreach($this->get_tickets() as $EM_Ticket){
|
1091 |
+
if( $EM_Ticket->get_price() > 0 ){
|
1092 |
+
$free = false;
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
return apply_filters('em_event_is_free',$free,$this);
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
/**
|
1099 |
+
* Will output a single event format of this event.
|
1100 |
+
* Equivalent of calling EM_Event::output( get_option ( 'dbem_single_event_format' ) )
|
1101 |
+
* @param string $target
|
1102 |
+
* @return string
|
1103 |
+
*/
|
1104 |
+
function output_single($target='html'){
|
1105 |
+
$format = get_option ( 'dbem_single_event_format' );
|
1106 |
+
return apply_filters('em_event_output_single', $this->output($format, $target), $this, $target);
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
/**
|
1110 |
+
* Will output a event in the format passed in $format by replacing placeholders within the format.
|
1111 |
+
* @param string $format
|
1112 |
+
* @param string $target
|
1113 |
+
* @return string
|
1114 |
+
*/
|
1115 |
+
function output($format, $target="html") {
|
1116 |
+
$event_string = $format;
|
1117 |
+
//Time place holder that doesn't show if empty.
|
1118 |
+
//TODO add filter here too
|
1119 |
+
preg_match_all('/#@?_\{[^}]+\}/', $format, $results);
|
1120 |
+
foreach($results[0] as $result) {
|
1121 |
+
if(substr($result, 0, 3 ) == "#@_"){
|
1122 |
+
$date = 'end_date';
|
1123 |
+
$offset = 4;
|
1124 |
+
}else{
|
1125 |
+
$date = 'start_date';
|
1126 |
+
$offset = 3;
|
1127 |
+
}
|
1128 |
+
if( $date == 'end_date' && $this->event_end_date == $this->event_start_date ){
|
1129 |
+
$replace = __( apply_filters('em_event_output_placeholder', '', $this, $result, $target) );
|
1130 |
+
}else{
|
1131 |
+
$replace = __( apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, (strlen($result)-($offset+1)) ), $this->$date), $this, $result, $target) );
|
1132 |
+
}
|
1133 |
+
$event_string = str_replace($result,$replace,$event_string );
|
1134 |
+
}
|
1135 |
+
//This is for the custom attributes
|
1136 |
+
preg_match_all('/#_ATT\{([^}]+)\}(\{([^}]+)\})?/', $format, $results);
|
1137 |
+
$attributes = em_get_attributes();
|
1138 |
+
foreach($results[0] as $resultKey => $result) {
|
1139 |
+
//Strip string of placeholder and just leave the reference
|
1140 |
+
$attRef = substr( substr($result, 0, strpos($result, '}')), 6 );
|
1141 |
+
$attString = '';
|
1142 |
+
if( is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes) ){
|
1143 |
+
$attString = $this->event_attributes[$attRef];
|
1144 |
+
}elseif( !empty($results[3][$resultKey]) ){
|
1145 |
+
//Check to see if we have a second set of braces;
|
1146 |
+
$attString = $results[3][$resultKey];
|
1147 |
+
}elseif( !empty($attributes['values'][$attRef][0]) ){
|
1148 |
+
$attString = $attributes['values'][$attRef][0];
|
1149 |
+
}
|
1150 |
+
$attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
|
1151 |
+
$event_string = str_replace($result, $attString ,$event_string );
|
1152 |
+
}
|
1153 |
+
//First let's do some conditional placeholder removals
|
1154 |
+
for ($i = 0 ; $i < get_option('dbem_conditional_recursions',1); $i++){ //you can add nested recursions by modifying this setting in your wp_options table
|
1155 |
+
preg_match_all('/\{([a-zA-Z0-9_]+)\}(.+?)\{\/\1\}/s', $event_string, $conditionals);
|
1156 |
+
if( count($conditionals[0]) > 0 ){
|
1157 |
+
//Check if the language we want exists, if not we take the first language there
|
1158 |
+
foreach($conditionals[1] as $key => $condition){
|
1159 |
+
$show_condition = false;
|
1160 |
+
if ($condition == 'has_bookings') {
|
1161 |
+
//check if there's a booking, if not, remove this section of code.
|
1162 |
+
$show_condition = ($this->event_rsvp && get_option('dbem_rsvp_enabled'));
|
1163 |
+
}elseif ($condition == 'no_bookings') {
|
1164 |
+
//check if there's a booking, if not, remove this section of code.
|
1165 |
+
$show_condition = (!$this->event_rsvp && get_option('dbem_rsvp_enabled'));
|
1166 |
+
}elseif ($condition == 'no_location'){
|
1167 |
+
//does this event have a valid location?
|
1168 |
+
$show_condition = ( empty($this->location_id) || !$this->get_location()->location_status );
|
1169 |
+
}elseif ($condition == 'has_location'){
|
1170 |
+
//does this event have a valid location?
|
1171 |
+
$show_condition = ( !empty($this->location_id) && $this->get_location()->location_status );
|
1172 |
+
}elseif ($condition == 'has_image'){
|
1173 |
+
//does this event have an image?
|
1174 |
+
$show_condition = ( $this->get_image_url() != '' );
|
1175 |
+
}elseif ($condition == 'no_image'){
|
1176 |
+
//does this event have an image?
|
1177 |
+
$show_condition = ( $this->get_image_url() == '' );
|
1178 |
+
}elseif ($condition == 'has_time'){
|
1179 |
+
//are the booking times different and not an all-day event
|
1180 |
+
$show_condition = ( $this->event_start_time != $this->event_end_time && !$this->event_all_day );
|
1181 |
+
}elseif ($condition == 'no_time'){
|
1182 |
+
//are the booking times exactly the same and it's not an all-day event.
|
1183 |
+
$show_condition = ( $this->event_start_time == $this->event_end_time && !$this->event_all_day );
|
1184 |
+
}elseif ($condition == 'all_day'){
|
1185 |
+
//is it an all day event
|
1186 |
+
$show_condition = !empty($this->event_all_day);
|
1187 |
+
}elseif ($condition == 'logged_in'){
|
1188 |
+
//user is logged in
|
1189 |
+
$show_condition = is_user_logged_in();
|
1190 |
+
}elseif ($condition == 'not_logged_in'){
|
1191 |
+
//not logged in
|
1192 |
+
$show_condition = !is_user_logged_in();
|
1193 |
+
}elseif ($condition == 'has_spaces'){
|
1194 |
+
//is it an all day event
|
1195 |
+
$show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
|
1196 |
+
}elseif ($condition == 'fully_booked'){
|
1197 |
+
//is it an all day event
|
1198 |
+
$show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
|
1199 |
+
}elseif ($condition == 'is_long'){
|
1200 |
+
//is it an all day event
|
1201 |
+
$show_condition = $this->event_start_date != $this->event_end_date;
|
1202 |
+
}elseif ($condition == 'not_long'){
|
1203 |
+
//is it an all day event
|
1204 |
+
$show_condition = $this->event_start_date == $this->event_end_date;
|
1205 |
+
}elseif ($condition == 'is_past'){
|
1206 |
+
//if event is past
|
1207 |
+
$show_condition = $this->start <= current_time('timestamp');
|
1208 |
+
}elseif ($condition == 'is_future'){
|
1209 |
+
//if event is upcoming
|
1210 |
+
$show_condition = $this->start > current_time('timestamp');
|
1211 |
+
}elseif ($condition == 'is_recurrence'){
|
1212 |
+
//if event is a recurrence
|
1213 |
+
$show_condition = $this->is_recurrence();
|
1214 |
+
}elseif ($condition == 'not_recurrence'){
|
1215 |
+
//if event is not a recurrence
|
1216 |
+
$show_condition = !$this->is_recurrence();
|
1217 |
+
}elseif ($condition == 'is_private'){
|
1218 |
+
//if event is a recurrence
|
1219 |
+
$show_condition = $this->event_private == 1;
|
1220 |
+
}elseif ($condition == 'not_private'){
|
1221 |
+
//if event is not a recurrence
|
1222 |
+
$show_condition = $this->event_private == 0;
|
1223 |
+
}elseif ( preg_match('/^has_category_([a-zA-Z0-9_\-]+)$/', $condition, $category_match)){
|
1224 |
+
//event is in this category
|
1225 |
+
$show_condition = has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
|
1226 |
+
}elseif ( preg_match('/^no_category_([a-zA-Z0-9_\-]+)$/', $condition, $category_match)){
|
1227 |
+
//event is NOT in this category
|
1228 |
+
$show_condition = !has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
|
1229 |
+
}elseif ( preg_match('/^has_tag_([a-zA-Z0-9_\-]+)$/', $condition, $tag_match)){
|
1230 |
+
//event has this tag
|
1231 |
+
$show_condition = has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
|
1232 |
+
}elseif ( preg_match('/^no_tag_([a-zA-Z0-9_\-]+)$/', $condition, $tag_match)){
|
1233 |
+
//event doesn't have this tag
|
1234 |
+
$show_condition = !has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
|
1235 |
+
}
|
1236 |
+
//other potential ones - has_attribute_... no_attribute_... has_categories_...
|
1237 |
+
$show_condition = apply_filters('em_event_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
|
1238 |
+
if($show_condition){
|
1239 |
+
//calculate lengths to delete placeholders
|
1240 |
+
$placeholder_length = strlen($condition)+2;
|
1241 |
+
$replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key])-($placeholder_length *2 +1));
|
1242 |
+
}else{
|
1243 |
+
$replacement = '';
|
1244 |
+
}
|
1245 |
+
$event_string = str_replace($conditionals[0][$key], apply_filters('em_event_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $event_string);
|
1246 |
+
}
|
1247 |
+
}
|
1248 |
+
}
|
1249 |
+
//Now let's check out the placeholders.
|
1250 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9_,]+)})?/", $format, $placeholders);
|
1251 |
+
$replaces = array();
|
1252 |
+
foreach($placeholders[1] as $key => $result) {
|
1253 |
+
$match = true;
|
1254 |
+
$replace = '';
|
1255 |
+
$full_result = $placeholders[0][$key];
|
1256 |
+
switch( $result ){
|
1257 |
+
//Event Details
|
1258 |
+
case '#_EVENTID':
|
1259 |
+
$replace = $this->event_id;
|
1260 |
+
break;
|
1261 |
+
case '#_EVENTPOSTID':
|
1262 |
+
$replace = $this->post_id;
|
1263 |
+
break;
|
1264 |
+
case '#_NAME': //depreciated
|
1265 |
+
case '#_EVENTNAME':
|
1266 |
+
$replace = $this->event_name;
|
1267 |
+
break;
|
1268 |
+
case '#_NOTES': //depreciated
|
1269 |
+
case '#_EXCERPT': //depreciated
|
1270 |
+
case '#_EVENTNOTES':
|
1271 |
+
case '#_EVENTEXCERPT':
|
1272 |
+
$replace = $this->post_content;
|
1273 |
+
if($result == "#_EXCERPT" || $result == "#_EVENTEXCERPT"){
|
1274 |
+
if( !empty($this->post_excerpt) ){
|
1275 |
+
$replace = $this->post_excerpt;
|
1276 |
+
}else{
|
1277 |
+
$matches = explode('<!--more', $this->post_content);
|
1278 |
+
$replace = $matches[0];
|
1279 |
+
}
|
1280 |
+
}
|
1281 |
+
break;
|
1282 |
+
case '#_EVENTIMAGEURL':
|
1283 |
+
case '#_EVENTIMAGE':
|
1284 |
+
if($this->get_image_url() != ''){
|
1285 |
+
if($result == '#_EVENTIMAGEURL'){
|
1286 |
+
$replace = esc_url($this->image_url);
|
1287 |
+
}else{
|
1288 |
+
if( empty($placeholders[3][$key]) ){
|
1289 |
+
$replace = "<img src='".esc_url($this->image_url)."' alt='".esc_attr($this->event_name)."'/>";
|
1290 |
+
}else{
|
1291 |
+
$image_size = explode(',', $placeholders[3][$key]);
|
1292 |
+
$image_src = $this->image_url;
|
1293 |
+
if( $this->array_is_numeric($image_size) && count($image_size) > 1 ){
|
1294 |
+
//get a thumbnail
|
1295 |
+
if( get_option('dbem_disable_timthumb') ){
|
1296 |
+
if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){
|
1297 |
+
switch_to_blog($this->blog_id);
|
1298 |
+
$switch_back = true;
|
1299 |
+
}
|
1300 |
+
$replace = get_the_post_thumbnail($this->ID, $image_size);
|
1301 |
+
if( !empty($switch_back) ){ restore_current_blog(); }
|
1302 |
+
}else{
|
1303 |
+
if ( is_multisite() ) { //get the direct url as timthumb doesn't support redirect urls
|
1304 |
+
global $blog_id;
|
1305 |
+
$imageParts = explode('/blogs.dir/', $image_src);
|
1306 |
+
if (isset($imageParts[1])) {
|
1307 |
+
$image_src = network_site_url('/wp-content/blogs.dir/'. $imageParts[1]);
|
1308 |
+
}
|
1309 |
+
}
|
1310 |
+
$replace = "<img src='".esc_url(em_get_thumbnail_url($image_src, $image_size[0], $image_size[1]))."' alt='".esc_attr($this->event_name)."' width='{$image_size[0]}' height='{$image_size[1]}'/>";
|
1311 |
+
}
|
1312 |
+
}else{
|
1313 |
+
$replace = "<img src='".esc_url($image_src)."' alt='".esc_attr($this->event_name)."'/>";
|
1314 |
+
}
|
1315 |
+
}
|
1316 |
+
}
|
1317 |
+
}
|
1318 |
+
break;
|
1319 |
+
//Times & Dates
|
1320 |
+
case '#_24HSTARTTIME':
|
1321 |
+
case '#_24HENDTIME':
|
1322 |
+
$time = ($result == '#_24HSTARTTIME') ? $this->event_start_time:$this->event_end_time;
|
1323 |
+
$replace = substr($time, 0,5);
|
1324 |
+
break;
|
1325 |
+
case '#_12HSTARTTIME':
|
1326 |
+
case '#_12HENDTIME':
|
1327 |
+
$time = ($result == '#_12HSTARTTIME') ? $this->event_start_time:$this->event_end_time;
|
1328 |
+
$replace = date('g:i A', strtotime($time));
|
1329 |
+
break;
|
1330 |
+
case '#_EVENTTIMES':
|
1331 |
+
//get format of time to show
|
1332 |
+
if( !$this->event_all_day ){
|
1333 |
+
$time_format = ( get_option('dbem_time_format') ) ? get_option('dbem_time_format'):get_option('time_format');
|
1334 |
+
if($this->event_start_time != $this->event_end_time ){
|
1335 |
+
$replace = date_i18n($time_format, $this->start). get_option('dbem_times_seperator') . date_i18n($time_format, $this->end);
|
1336 |
+
}else{
|
1337 |
+
$replace = date_i18n($time_format, $this->start);
|
1338 |
+
}
|
1339 |
+
}else{
|
1340 |
+
$replace = get_option('dbem_event_all_day_message');
|
1341 |
+
}
|
1342 |
+
break;
|
1343 |
+
case '#_EVENTDATES':
|
1344 |
+
//get format of time to show
|
1345 |
+
$date_format = ( get_option('dbem_date_format') ) ? get_option('dbem_date_format'):get_option('date_format');
|
1346 |
+
if( $this->event_start_date != $this->event_end_date){
|
1347 |
+
$replace = date_i18n($date_format, $this->start). get_option('dbem_dates_seperator') . date_i18n($date_format, $this->end);
|
1348 |
+
}else{
|
1349 |
+
$replace = date_i18n($date_format, $this->start);
|
1350 |
+
}
|
1351 |
+
break;
|
1352 |
+
//Links
|
1353 |
+
case '#_EVENTPAGEURL': //Depreciated
|
1354 |
+
case '#_LINKEDNAME': //Depreciated
|
1355 |
+
case '#_EVENTURL': //Just the URL
|
1356 |
+
case '#_EVENTLINK': //HTML Link
|
1357 |
+
$event_link = esc_url($this->get_permalink());
|
1358 |
+
if($result == '#_LINKEDNAME' || $result == '#_EVENTLINK'){
|
1359 |
+
$replace = '<a href="'.$event_link.'" title="'.esc_attr($this->event_name).'">'.esc_attr($this->event_name).'</a>';
|
1360 |
+
}else{
|
1361 |
+
$replace = $event_link;
|
1362 |
+
}
|
1363 |
+
break;
|
1364 |
+
case '#_EDITEVENTURL':
|
1365 |
+
case '#_EDITEVENTLINK':
|
1366 |
+
if( $this->can_manage('edit_events','edit_others_events') ){
|
1367 |
+
$link = esc_url($this->get_edit_url());
|
1368 |
+
if( $result == '#_EDITEVENTLINK'){
|
1369 |
+
$replace = '<a href="'.$link.'">'.esc_html(sprintf(__('Edit Event','dbem'))).'</a>';
|
1370 |
+
}else{
|
1371 |
+
$replace = $link;
|
1372 |
+
}
|
1373 |
+
}
|
1374 |
+
break;
|
1375 |
+
//Bookings
|
1376 |
+
case '#_ADDBOOKINGFORM': //Depreciated
|
1377 |
+
case '#_REMOVEBOOKINGFORM': //Depreciated
|
1378 |
+
case '#_BOOKINGFORM':
|
1379 |
+
if( get_option('dbem_rsvp_enabled')){
|
1380 |
+
ob_start();
|
1381 |
+
$template = em_locate_template('placeholders/bookingform.php', true, array('EM_Event'=>$this));
|
1382 |
+
if( !defined('EM_BOOKING_JS_LOADED') ){
|
1383 |
+
//this kicks off the Javascript required by booking forms. This is fired once for all booking forms on a page load and appears at the bottom of the page
|
1384 |
+
//your theme must call the wp_footer() function for this to work (as required by many other plugins too)
|
1385 |
+
function em_booking_js_footer(){
|
1386 |
+
?>
|
1387 |
+
<script type="text/javascript">
|
1388 |
+
jQuery(document).ready( function($){
|
1389 |
+
<?php
|
1390 |
+
//we call the segmented JS files and include them here
|
1391 |
+
include(WP_PLUGIN_DIR.'/events-manager/includes/js/bookingsform.js');
|
1392 |
+
do_action('em_gateway_js');
|
1393 |
+
?>
|
1394 |
+
});
|
1395 |
+
</script>
|
1396 |
+
<?php
|
1397 |
+
}
|
1398 |
+
add_action('wp_footer','em_booking_js_footer');
|
1399 |
+
add_action('admin_footer','em_booking_js_footer');
|
1400 |
+
define('EM_BOOKING_JS_LOADED',true);
|
1401 |
+
}
|
1402 |
+
$replace = ob_get_clean();
|
1403 |
+
}
|
1404 |
+
break;
|
1405 |
+
case '#_BOOKINGBUTTON':
|
1406 |
+
if( get_option('dbem_rsvp_enabled') && $this->event_rsvp ){
|
1407 |
+
ob_start();
|
1408 |
+
$template = em_locate_template('placeholders/bookingbutton.php', true, array('EM_Event'=>$this));
|
1409 |
+
$replace = ob_get_clean();
|
1410 |
+
}
|
1411 |
+
break;
|
1412 |
+
case '#_EVENTPRICERANGEALL':
|
1413 |
+
$show_all_ticket_prices = true; //continues below
|
1414 |
+
case '#_EVENTPRICERANGE':
|
1415 |
+
//get the range of prices
|
1416 |
+
$min = false;
|
1417 |
+
$max = 0;
|
1418 |
+
if( $this->get_bookings()->is_open() || $show_all_ticket_prices ){
|
1419 |
+
foreach( $this->get_tickets()->tickets as $EM_Ticket ){
|
1420 |
+
/* @var $EM_Ticket EM_Ticket */
|
1421 |
+
if( $EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable') || !empty($show_all_ticket_prices) ){
|
1422 |
+
if($EM_Ticket->get_price() > $max ){
|
1423 |
+
$max = $EM_Ticket->get_price();
|
1424 |
+
}
|
1425 |
+
if($EM_Ticket->get_price() < $min || $min === false){
|
1426 |
+
$min = $EM_Ticket->get_price();
|
1427 |
+
}
|
1428 |
+
}
|
1429 |
+
}
|
1430 |
+
}
|
1431 |
+
if( $min === false ) $min = 0;
|
1432 |
+
if( $min != $max ){
|
1433 |
+
$replace = em_get_currency_formatted($min).' - '.em_get_currency_formatted($max);
|
1434 |
+
}else{
|
1435 |
+
$replace = em_get_currency_formatted($min);
|
1436 |
+
}
|
1437 |
+
break;
|
1438 |
+
case '#_EVENTPRICEMIN':
|
1439 |
+
//get the range of prices
|
1440 |
+
$min = false;
|
1441 |
+
foreach( $this->get_tickets()->tickets as $EM_Ticket ){
|
1442 |
+
/* @var $EM_Ticket EM_Ticket */
|
1443 |
+
if( $EM_Ticket->is_available()|| get_option('dbem_bookings_tickets_show_unavailable') ){
|
1444 |
+
if( $EM_Ticket->get_price() < $min || $min === false){
|
1445 |
+
$min = $EM_Ticket->get_price();
|
1446 |
+
}
|
1447 |
+
}
|
1448 |
+
}
|
1449 |
+
if( $min === false ) $min = 0;
|
1450 |
+
$replace = em_get_currency_formatted($min);
|
1451 |
+
break;
|
1452 |
+
case '#_EVENTPRICEMAX':
|
1453 |
+
//get the range of prices
|
1454 |
+
$max = 0;
|
1455 |
+
foreach( $this->get_tickets()->tickets as $EM_Ticket ){
|
1456 |
+
/* @var $EM_Ticket EM_Ticket */
|
1457 |
+
if( $EM_Ticket->is_available()|| get_option('dbem_bookings_tickets_show_unavailable') ){
|
1458 |
+
if( $EM_Ticket->get_price() > $max ){
|
1459 |
+
$max = $EM_Ticket->get_price();
|
1460 |
+
}
|
1461 |
+
}
|
1462 |
+
}
|
1463 |
+
$replace = em_get_currency_formatted($max);
|
1464 |
+
break;
|
1465 |
+
case '#_AVAILABLESEATS': //Depreciated
|
1466 |
+
case '#_AVAILABLESPACES':
|
1467 |
+
if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
|
1468 |
+
$replace = $this->get_bookings()->get_available_spaces();
|
1469 |
+
} else {
|
1470 |
+
$replace = "0";
|
1471 |
+
}
|
1472 |
+
break;
|
1473 |
+
case '#_BOOKEDSEATS': //Depreciated
|
1474 |
+
case '#_BOOKEDSPACES':
|
1475 |
+
//This placeholder is actually a little misleading, as it'll consider reserved (i.e. pending) bookings as 'booked'
|
1476 |
+
if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
|
1477 |
+
$replace = $this->get_bookings()->get_booked_spaces();
|
1478 |
+
if( get_option('dbem_bookings_approval_reserved') ){
|
1479 |
+
$replace += $this->get_bookings()->get_pending_spaces();
|
1480 |
+
}
|
1481 |
+
} else {
|
1482 |
+
$replace = "0";
|
1483 |
+
}
|
1484 |
+
break;
|
1485 |
+
case '#_PENDINGSPACES':
|
1486 |
+
if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
|
1487 |
+
$replace = $this->get_bookings()->get_pending_spaces();
|
1488 |
+
} else {
|
1489 |
+
$replace = "0";
|
1490 |
+
}
|
1491 |
+
break;
|
1492 |
+
case '#_SEATS': //Depreciated
|
1493 |
+
case '#_SPACES':
|
1494 |
+
$replace = $this->get_spaces();
|
1495 |
+
break;
|
1496 |
+
case '#_BOOKINGSURL':
|
1497 |
+
case '#_BOOKINGSLINK':
|
1498 |
+
if( $this->can_manage('manage_bookings','manage_others_bookings') ){
|
1499 |
+
$bookings_link = esc_url($this->get_bookings_url());
|
1500 |
+
if($result == '#_BOOKINGSLINK'){
|
1501 |
+
$replace = '<a href="'.$bookings_link.'" title="'.esc_attr($this->event_name).'">'.esc_html($this->event_name).'</a>';
|
1502 |
+
}else{
|
1503 |
+
$replace = $bookings_link;
|
1504 |
+
}
|
1505 |
+
}
|
1506 |
+
break;
|
1507 |
+
//Contact Person
|
1508 |
+
case '#_CONTACTNAME':
|
1509 |
+
case '#_CONTACTPERSON': //Depreciated (your call, I think name is better)
|
1510 |
+
$replace = $this->get_contact()->display_name;
|
1511 |
+
break;
|
1512 |
+
case '#_CONTACTUSERNAME':
|
1513 |
+
$replace = $this->get_contact()->user_login;
|
1514 |
+
break;
|
1515 |
+
case '#_CONTACTEMAIL':
|
1516 |
+
case '#_CONTACTMAIL': //Depreciated
|
1517 |
+
$replace = $this->get_contact()->user_email;
|
1518 |
+
break;
|
1519 |
+
case '#_CONTACTID':
|
1520 |
+
$replace = $this->get_contact()->ID;
|
1521 |
+
break;
|
1522 |
+
case '#_CONTACTPHONE':
|
1523 |
+
$replace = ( $this->get_contact()->phone != '') ? $this->get_contact()->phone : __('N/A', 'dbem');
|
1524 |
+
break;
|
1525 |
+
case '#_CONTACTAVATAR':
|
1526 |
+
$replace = get_avatar( $this->get_contact()->ID, $size = '50' );
|
1527 |
+
break;
|
1528 |
+
case '#_CONTACTPROFILELINK':
|
1529 |
+
case '#_CONTACTPROFILEURL':
|
1530 |
+
if( function_exists('bp_core_get_user_domain') ){
|
1531 |
+
$replace = bp_core_get_user_domain($this->get_contact()->ID);
|
1532 |
+
if( $result == '#_CONTACTPROFILELINK' ){
|
1533 |
+
$replace = '<a href="'.esc_url($replace).'">'.__('Profile', 'dbem').'</a>';
|
1534 |
+
}
|
1535 |
+
}
|
1536 |
+
break;
|
1537 |
+
case '#_CONTACTMETA':
|
1538 |
+
if( !empty($placeholders[3][$key]) ){
|
1539 |
+
$replace = get_user_meta($this->event_owner, $placeholders[3][$key], true);
|
1540 |
+
}
|
1541 |
+
break;
|
1542 |
+
case '#_ATTENDEES':
|
1543 |
+
ob_start();
|
1544 |
+
$template = em_locate_template('placeholders/attendees.php', true, array('EM_Event'=>$this));
|
1545 |
+
$replace = ob_get_clean();
|
1546 |
+
break;
|
1547 |
+
case '#_ATTENDEESLIST':
|
1548 |
+
ob_start();
|
1549 |
+
$template = em_locate_template('placeholders/attendeeslist.php', true, array('EM_Event'=>$this));
|
1550 |
+
$replace = ob_get_clean();
|
1551 |
+
break;
|
1552 |
+
case '#_ATTENDEESPENDINGLIST':
|
1553 |
+
ob_start();
|
1554 |
+
$template = em_locate_template('placeholders/attendeespendinglist.php', true, array('EM_Event'=>$this));
|
1555 |
+
$replace = ob_get_clean();
|
1556 |
+
break;
|
1557 |
+
//Categories and Tags
|
1558 |
+
case '#_EVENTCATEGORIESIMAGES':
|
1559 |
+
ob_start();
|
1560 |
+
$template = em_locate_template('placeholders/eventcategoriesimages.php', true, array('EM_Event'=>$this));
|
1561 |
+
$replace = ob_get_clean();
|
1562 |
+
break;
|
1563 |
+
case '#_EVENTTAGS':
|
1564 |
+
ob_start();
|
1565 |
+
$template = em_locate_template('placeholders/eventtags.php', true, array('EM_Event'=>$this));
|
1566 |
+
$replace = ob_get_clean();
|
1567 |
+
break;
|
1568 |
+
case '#_CATEGORIES': //depreciated
|
1569 |
+
case '#_EVENTCATEGORIES':
|
1570 |
+
ob_start();
|
1571 |
+
$template = em_locate_template('placeholders/categories.php', true, array('EM_Event'=>$this));
|
1572 |
+
$replace = ob_get_clean();
|
1573 |
+
break;
|
1574 |
+
//Ical Stuff
|
1575 |
+
case '#_EVENTICALURL':
|
1576 |
+
case '#_EVENTICALLINK':
|
1577 |
+
$replace = $this->get_ical_url();
|
1578 |
+
if( $result == '#_EVENTICALLINK' ){
|
1579 |
+
$replace = '<a href="'.esc_url($replace).'">iCal</a>';
|
1580 |
+
}
|
1581 |
+
break;
|
1582 |
+
case '#_EVENTGCALURL':
|
1583 |
+
case '#_EVENTGCALLINK':
|
1584 |
+
//get dates
|
1585 |
+
if($this->event_all_day && $this->event_start_date == $this->event_end_date){
|
1586 |
+
$dateStart = date('Ymd',$this->start - (60*60*get_option('gmt_offset')));
|
1587 |
+
$dateEnd = date('Ymd',$this->start + 60*60*24 - (60*60*get_option('gmt_offset')));
|
1588 |
+
}else{
|
1589 |
+
$dateStart = date('Ymd\THis\Z',$this->start - (60*60*get_option('gmt_offset')));
|
1590 |
+
$dateEnd = date('Ymd\THis\Z',$this->end - (60*60*get_option('gmt_offset')));
|
1591 |
+
}
|
1592 |
+
//build url
|
1593 |
+
$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';
|
1594 |
+
$gcal_url = str_replace('event_name', urlencode($this->event_name), $gcal_url);
|
1595 |
+
$gcal_url = str_replace('start_date', urlencode($dateStart), $gcal_url);
|
1596 |
+
$gcal_url = str_replace('end_date', urlencode($dateEnd), $gcal_url);
|
1597 |
+
$gcal_url = str_replace('location_name', urlencode($this->output('#_LOCATION')), $gcal_url);
|
1598 |
+
$gcal_url = str_replace('blog_name', urlencode(get_bloginfo()), $gcal_url);
|
1599 |
+
$gcal_url = str_replace('event_url', urlencode($this->get_permalink()), $gcal_url);
|
1600 |
+
//calculate URL length so we know how much we can work with to make a description.
|
1601 |
+
if( !empty($this->post_excerpt) ){
|
1602 |
+
$gcal_url_description = $this->post_excerpt;
|
1603 |
+
}else{
|
1604 |
+
$matches = explode('<!--more', $this->post_content);
|
1605 |
+
$gcal_url_description = wp_kses_data($matches[0]);
|
1606 |
+
}
|
1607 |
+
$gcal_url_length = strlen($gcal_url) - 9;
|
1608 |
+
if( strlen($gcal_url_description) + $gcal_url_length > 1350 ){
|
1609 |
+
$gcal_url_description = substr($gcal_url_description, 0, 1380 - $gcal_url_length - 3 ).'...';
|
1610 |
+
}
|
1611 |
+
$gcal_url = str_replace('post_content', urlencode($gcal_url_description), $gcal_url);
|
1612 |
+
//get the final url
|
1613 |
+
$replace = $gcal_url;
|
1614 |
+
if( $result == '#_EVENTGCALLINK' ){
|
1615 |
+
$img_url = 'www.google.com/calendar/images/ext/gc_button2.gif';
|
1616 |
+
$img_url = is_ssl() ? 'https://'.$img_url:'http://'.$img_url;
|
1617 |
+
$replace = '<a href="'.esc_url($replace).'" target="_blank"><img src="'.esc_url($img_url).'" alt="0" border="0"></a>';
|
1618 |
+
}
|
1619 |
+
break;
|
1620 |
+
default:
|
1621 |
+
$replace = $full_result;
|
1622 |
+
break;
|
1623 |
+
}
|
1624 |
+
$replaces[$full_result] = apply_filters('em_event_output_placeholder', $replace, $this, $full_result, $target);
|
1625 |
+
}
|
1626 |
+
//sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
|
1627 |
+
krsort($replaces);
|
1628 |
+
foreach($replaces as $full_result => $replacement){
|
1629 |
+
if( !in_array($full_result, array('#_NOTES','#_EVENTNOTES')) ){
|
1630 |
+
$event_string = str_replace($full_result, $replacement , $event_string );
|
1631 |
+
}else{
|
1632 |
+
$desc_replace[$full_result] = $replacement;
|
1633 |
+
}
|
1634 |
+
}
|
1635 |
+
//Time placeholders
|
1636 |
+
foreach($placeholders[1] as $result) {
|
1637 |
+
// matches all PHP START date and time placeholders
|
1638 |
+
if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
|
1639 |
+
$replace = date_i18n(ltrim($result, "#"), $this->start);
|
1640 |
+
$replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
|
1641 |
+
$event_string = str_replace($result, $replace, $event_string );
|
1642 |
+
}
|
1643 |
+
// matches all PHP END time placeholders for endtime
|
1644 |
+
if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
|
1645 |
+
$replace = date_i18n(ltrim($result, "#@"), $this->end);
|
1646 |
+
$replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
|
1647 |
+
$event_string = str_replace($result, $replace, $event_string );
|
1648 |
+
}
|
1649 |
+
}
|
1650 |
+
//Now do dependent objects
|
1651 |
+
if( !empty($this->location_id) && $this->get_location()->location_status ){
|
1652 |
+
$event_string = $this->get_location()->output($event_string, $target);
|
1653 |
+
}else{
|
1654 |
+
$EM_Location = new EM_Location();
|
1655 |
+
$event_string = $EM_Location->output($event_string, $target);
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
//for backwards compat and easy use, take over the individual category placeholders with the frirst cat in th elist.
|
1659 |
+
$EM_Categories = $this->get_categories();
|
1660 |
+
if( count($EM_Categories->categories) > 0 ){
|
1661 |
+
$EM_Category = $EM_Categories->get_first();
|
1662 |
+
}
|
1663 |
+
|
1664 |
+
if( empty($EM_Category) ) $EM_Category = new EM_Category();
|
1665 |
+
$event_string = $EM_Category->output($event_string, $target);
|
1666 |
+
|
1667 |
+
//Finally, do the event notes, so that previous placeholders don't get replaced within the content, which may use shortcodes
|
1668 |
+
if( !empty($desc_replace) ){
|
1669 |
+
foreach($desc_replace as $full_result => $replacement){
|
1670 |
+
$event_string = str_replace($full_result, $replacement , $event_string );
|
1671 |
+
}
|
1672 |
+
}
|
1673 |
+
|
1674 |
+
return apply_filters('em_event_output', $event_string, $this, $format, $target);
|
1675 |
+
}
|
1676 |
+
|
1677 |
+
/**********************************************************
|
1678 |
+
* RECURRENCE METHODS
|
1679 |
+
***********************************************************/
|
1680 |
+
|
1681 |
+
/**
|
1682 |
+
* Returns true if this is a recurring event.
|
1683 |
+
* @return boolean
|
1684 |
+
*/
|
1685 |
+
function is_recurring(){
|
1686 |
+
return $this->post_type == 'event-recurring' && get_option('dbem_recurrence_enabled');
|
1687 |
+
}
|
1688 |
+
/**
|
1689 |
+
* Will return true if this individual event is part of a set of events that recur
|
1690 |
+
* @return boolean
|
1691 |
+
*/
|
1692 |
+
function is_recurrence(){
|
1693 |
+
return ( $this->event_id > 0 && $this->recurrence_id > 0 && get_option('dbem_recurrence_enabled') );
|
1694 |
+
}
|
1695 |
+
/**
|
1696 |
+
* Returns if this is an individual event and is not a recurrence
|
1697 |
+
* @return boolean
|
1698 |
+
*/
|
1699 |
+
function is_individual(){
|
1700 |
+
return ( !$this->is_recurring() && !$this->is_recurrence() );
|
1701 |
+
}
|
1702 |
+
|
1703 |
+
/**
|
1704 |
+
* Gets the event recurrence template, which is an EM_Event_Recurrence object (based off an event-recurring post)
|
1705 |
+
* @return EM_Event_Recurrence
|
1706 |
+
*/
|
1707 |
+
function get_event_recurrence(){
|
1708 |
+
if(!$this->is_recurring()){
|
1709 |
+
return new EM_Event($this->recurrence_id); //remember, recurrence_id is a post!
|
1710 |
+
}else{
|
1711 |
+
return $this;
|
1712 |
+
}
|
1713 |
+
}
|
1714 |
+
|
1715 |
+
function get_detach_url(){
|
1716 |
+
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);
|
1717 |
+
}
|
1718 |
+
|
1719 |
+
function get_attach_url($recurrence_id){
|
1720 |
+
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);
|
1721 |
+
}
|
1722 |
+
|
1723 |
+
/**
|
1724 |
+
* Returns if this is an individual event and is not recurring or a recurrence
|
1725 |
+
* @return boolean
|
1726 |
+
*/
|
1727 |
+
function detach(){
|
1728 |
+
global $wpdb;
|
1729 |
+
if( $this->is_recurrence() && !$this->is_recurring() && $this->can_manage('edit_recurring_events','edit_others_recurring_events') ){
|
1730 |
+
//remove recurrence id from post meta and index table
|
1731 |
+
$url = $this->get_attach_url($this->recurrence_id);
|
1732 |
+
$wpdb->update(EM_EVENTS_TABLE, array('recurrence_id'=>0), array('event_id' => $this->event_id));
|
1733 |
+
update_post_meta($this->post_id, '_recurrence_id', 0);
|
1734 |
+
$this->feedback_message = __('Event detached.','dbem') . ' <a href="'.$url.'">'.__('Undo','dbem').'</a>';
|
1735 |
+
$this->recurrence_id = 0;
|
1736 |
+
return true;
|
1737 |
+
}
|
1738 |
+
$this->add_error(__('Event could not be detached.','dbem'));
|
1739 |
+
return false;
|
1740 |
+
}
|
1741 |
+
|
1742 |
+
/**
|
1743 |
+
* Returns if this is an individual event and is not recurring or a recurrence
|
1744 |
+
* @return boolean
|
1745 |
+
*/
|
1746 |
+
function attach($recurrence_id){
|
1747 |
+
global $wpdb;
|
1748 |
+
if( !$this->is_recurrence() && !$this->is_recurring() && is_numeric($recurrence_id) && $this->can_manage('edit_recurring_events','edit_others_recurring_events') ){
|
1749 |
+
//add recurrence id to post meta and index table
|
1750 |
+
$wpdb->update(EM_EVENTS_TABLE, array('recurrence_id'=>$recurrence_id), array('event_id' => $this->event_id));
|
1751 |
+
update_post_meta($this->post_id, '_recurrence_id', $recurrence_id);
|
1752 |
+
$this->feedback_message = __('Event re-attached to recurrence.','dbem');
|
1753 |
+
return true;
|
1754 |
+
}
|
1755 |
+
$this->add_error(__('Event could not be attached.','dbem'));
|
1756 |
+
return false;
|
1757 |
+
}
|
1758 |
+
|
1759 |
+
/**
|
1760 |
+
* Saves events and replaces old ones. Returns true if sucecssful or false if not.
|
1761 |
+
* @return boolean
|
1762 |
+
*/
|
1763 |
+
function save_events() {
|
1764 |
+
global $wpdb;
|
1765 |
+
if( $this->can_manage('edit_events','edit_others_events') && $this->is_published() ){
|
1766 |
+
do_action('em_event_save_events_pre', $this); //actions/filters only run if event is recurring
|
1767 |
+
//Make template event index, post, and meta (and we just change event dates)
|
1768 |
+
$event = $this->to_array(true); //event template - for index
|
1769 |
+
$event['event_attributes'] = serialize($event['event_attributes']);
|
1770 |
+
$post_fields = $wpdb->get_row('SELECT * FROM '.$wpdb->posts.' WHERE ID='.$this->post_id, ARRAY_A); //post to copy
|
1771 |
+
$post_name = $post_fields['post_name']; //save post slug since we'll be using this
|
1772 |
+
$post_fields['post_type'] = 'event'; //make sure we'll save events, not recurrence templates
|
1773 |
+
$meta_fields_map = $wpdb->get_results('SELECT meta_key,meta_value FROM '.$wpdb->postmeta.' WHERE post_id='.$this->post_id, ARRAY_A);
|
1774 |
+
$meta_fields = array();
|
1775 |
+
//convert meta_fields into a cleaner array
|
1776 |
+
foreach($meta_fields_map as $meta_data){
|
1777 |
+
$meta_fields[$meta_data['meta_key']] = $meta_data['meta_value'];
|
1778 |
+
}
|
1779 |
+
//remove id and we have a event template to feed to wpdb insert
|
1780 |
+
unset($event['event_id']);
|
1781 |
+
unset($post_fields['ID']);
|
1782 |
+
//remove recurrence meta info we won't need in events
|
1783 |
+
foreach( array_keys($this->recurrence_fields) as $recurrence_field){
|
1784 |
+
unset($event[$recurrence_field]);
|
1785 |
+
unset($meta_fields['_'.$recurrence_field]);
|
1786 |
+
}
|
1787 |
+
$event['event_date_created'] = current_time('mysql'); //since the recurrences are recreated
|
1788 |
+
unset($event['event_date_modified']);
|
1789 |
+
//Set the recurrence ID
|
1790 |
+
$event['recurrence_id'] = $meta_fields['_recurrence_id'] = $this->event_id;
|
1791 |
+
$event['recurrence'] = $meta_fields['_recurrence'] = 0;
|
1792 |
+
//Let's start saving!
|
1793 |
+
$this->delete_events(); //Delete old events beforehand, this will change soon
|
1794 |
+
$event_saves = array();
|
1795 |
+
$event_ids = array();
|
1796 |
+
$post_ids = array();
|
1797 |
+
$matching_days = $this->get_recurrence_days(); //Get days where events recur
|
1798 |
+
if( count($matching_days) > 0 ){
|
1799 |
+
//first save event post data
|
1800 |
+
$recurring_date_format = apply_filters('em_event_save_events_format', 'Y-m-d');
|
1801 |
+
foreach( $matching_days as $day ) {
|
1802 |
+
//rewrite post fields if needed
|
1803 |
+
$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);
|
1804 |
+
//adjust certain meta information
|
1805 |
+
$event['event_start_date'] = $meta_fields['_event_start_date'] = date("Y-m-d", $day);
|
1806 |
+
$meta_fields['_start_ts'] = strtotime($event['event_start_date'].' '.$event['event_start_time']);
|
1807 |
+
$event['event_rsvp_date'] = $meta_fields['_event_rsvp_date'] = $event['event_start_date'];
|
1808 |
+
$event['event_rsvp_time'] = $meta_fields['_event_rsvp_time'] = $event['event_start_time'];
|
1809 |
+
if($this->recurrence_days > 0){
|
1810 |
+
$event['event_end_date'] = $meta_fields['_event_end_date'] = date("Y-m-d", $meta_fields['_start_ts'] + ($this->recurrence_days * 60*60*24));
|
1811 |
+
}else{
|
1812 |
+
$event['event_end_date'] = $meta_fields['_event_end_date'] = $event['event_start_date'];
|
1813 |
+
}
|
1814 |
+
$meta_fields['_end_ts'] = strtotime($event['event_end_date'].' '.$event['event_end_time']);
|
1815 |
+
//create the event
|
1816 |
+
if( $wpdb->insert($wpdb->posts, $post_fields ) ){
|
1817 |
+
$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
|
1818 |
+
// Set GUID and event slug as per wp_insert_post
|
1819 |
+
$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_id ) ), array('ID'=>$post_id) );
|
1820 |
+
//insert into events index table
|
1821 |
+
$event_saves[] = $wpdb->insert(EM_EVENTS_TABLE, $event);
|
1822 |
+
$event_ids[] = $event_id = $wpdb->insert_id;
|
1823 |
+
//create the meta inserts for each event
|
1824 |
+
$meta_fields['_event_id'] = $event_id;
|
1825 |
+
foreach($meta_fields as $meta_key => $meta_val){
|
1826 |
+
$meta_inserts[] = $wpdb->prepare("(%d, '%s', '%s')", array($post_id, $meta_key, $meta_val));
|
1827 |
+
}
|
1828 |
+
}else{
|
1829 |
+
$event_saves[] = false;
|
1830 |
+
}
|
1831 |
+
//if( EM_DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
|
1832 |
+
}
|
1833 |
+
//insert the metas in one go, faster than one by one
|
1834 |
+
if( count($meta_inserts) > 0 ){
|
1835 |
+
$result = $wpdb->query("INSERT INTO ".$wpdb->postmeta." (post_id,meta_key,meta_value) VALUES ".implode(',',$meta_inserts));
|
1836 |
+
if($result === false){
|
1837 |
+
$this->add_error('There was a problem adding custom fields to your recurring events.','dbem');
|
1838 |
+
}
|
1839 |
+
}
|
1840 |
+
//copy the event tags and categories
|
1841 |
+
$categories = $this->get_categories()->categories;
|
1842 |
+
foreach( $categories as $category){
|
1843 |
+
if( !empty($category->slug) ) $cat_slugs[] = $category->slug; //save of category will soft-fail if slug is empty
|
1844 |
+
}
|
1845 |
+
$cat_slugs_count = count($categories);
|
1846 |
+
$tags = get_the_terms( $this->post_id, EM_TAXONOMY_TAG);
|
1847 |
+
$tax_slugs = array();
|
1848 |
+
if( is_array($tags) ){
|
1849 |
+
foreach($tags as $tag){
|
1850 |
+
if( !empty($tag->slug) ) $tax_slugs[] = $tag->slug; //save of category will soft-fail if slug is empty
|
1851 |
+
}
|
1852 |
+
}
|
1853 |
+
$tax_slugs_count = count($categories);
|
1854 |
+
foreach($post_ids as $post_id){
|
1855 |
+
if( $cat_slugs_count > 0 && !EM_MS_GLOBAL ){
|
1856 |
+
wp_set_object_terms($post_id, $cat_slugs, EM_TAXONOMY_CATEGORY);
|
1857 |
+
}
|
1858 |
+
if( $tax_slugs_count > 0 ){
|
1859 |
+
wp_set_object_terms($post_id, $tax_slugs, EM_TAXONOMY_TAG);
|
1860 |
+
}
|
1861 |
+
}
|
1862 |
+
//featured images
|
1863 |
+
if( !empty($this->attributes['thumbnail_id']) ){
|
1864 |
+
$image_inserts = array();
|
1865 |
+
foreach($post_ids as $post_ids){
|
1866 |
+
$image_inserts[] = "({$this->post_id}, '_thumbnail_id', {$this->attributes['thumbnail_id']})";
|
1867 |
+
}
|
1868 |
+
if( count($image_inserts) > 0 ){
|
1869 |
+
$wpdb->query('INSERT INTO '.$wpdb->postmeta.' (post_id, meta_key, meta_value) VALUES '.implode(', ', $image_inserts));
|
1870 |
+
}
|
1871 |
+
}
|
1872 |
+
//MS Global Categories
|
1873 |
+
if( $cat_slugs_count > 0 && EM_MS_GLOBAL ){
|
1874 |
+
foreach($categories as $EM_Category){
|
1875 |
+
foreach($event_ids as $event_id){
|
1876 |
+
$wpdb->insert(EM_META_TABLE, array('meta_value'=>$EM_Category->term_id,'object_id'=>$event_id,'meta_key'=>'event-category'));
|
1877 |
+
}
|
1878 |
+
}
|
1879 |
+
}
|
1880 |
+
//now, save booking info for each event
|
1881 |
+
if( $this->event_rsvp ){
|
1882 |
+
$meta_inserts = array();
|
1883 |
+
foreach($this->get_tickets() as $EM_Ticket){
|
1884 |
+
/* @var $EM_Ticket EM_Ticket */
|
1885 |
+
//get array, modify event id and insert
|
1886 |
+
$ticket = $EM_Ticket->to_array();
|
1887 |
+
unset($ticket['ticket_id']);
|
1888 |
+
//clean up ticket values
|
1889 |
+
foreach($ticket as $k => $v){
|
1890 |
+
if( empty($v) && $k != 'ticket_name' ){
|
1891 |
+
$ticket[$k] = 'NULL';
|
1892 |
+
}else{
|
1893 |
+
$data_type = !empty($EM_Ticket->fields[$k]['type']) ? $EM_Ticket->fields[$k]['type']:'%s';
|
1894 |
+
$ticket[$k] = $wpdb->prepare($data_type,$v);
|
1895 |
+
}
|
1896 |
+
}
|
1897 |
+
foreach($event_ids as $event_id){
|
1898 |
+
$ticket['event_id'] = $event_id;
|
1899 |
+
$meta_inserts[] = "(".implode(",",$ticket).")";
|
1900 |
+
}
|
1901 |
+
}
|
1902 |
+
$keys = "(".implode(",",array_keys($ticket)).")";
|
1903 |
+
$values = implode(',',$meta_inserts);
|
1904 |
+
$sql = "INSERT INTO ".EM_TICKETS_TABLE." $keys VALUES $values";
|
1905 |
+
$result = $wpdb->query($sql);
|
1906 |
+
}
|
1907 |
+
}else{
|
1908 |
+
$this->add_error('You have not defined a date range long enough to create a recurrence.','dbem');
|
1909 |
+
$result = false;
|
1910 |
+
}
|
1911 |
+
return apply_filters('em_event_save_events', !in_array(false, $event_saves) && $result !== false, $this, $event_ids, $post_ids);
|
1912 |
+
}
|
1913 |
+
return apply_filters('em_event_save_events', false, $this, $event_ids, $post_ids);
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
/**
|
1917 |
+
* Removes all reoccurring events.
|
1918 |
+
* @param $recurrence_id
|
1919 |
+
* @return null
|
1920 |
+
*/
|
1921 |
+
function delete_events(){
|
1922 |
+
global $wpdb;
|
1923 |
+
do_action('em_event_delete_events_pre', $this);
|
1924 |
+
//So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer
|
1925 |
+
$result = false;
|
1926 |
+
if( $this->can_manage('delete_events', 'delete_others_events') ){
|
1927 |
+
//delete events from em_events table
|
1928 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$this->event_id, 'scope'=>'all', 'status'=>false ) );
|
1929 |
+
foreach($events_array as $EM_Event){
|
1930 |
+
/* @var $EM_Event EM_Event */
|
1931 |
+
if($EM_Event->recurrence_id == $this->event_id){
|
1932 |
+
$EM_Event->delete(true);
|
1933 |
+
}
|
1934 |
+
}
|
1935 |
+
}
|
1936 |
+
return apply_filters('delete_events', $result, $this, $events_array);
|
1937 |
+
}
|
1938 |
+
|
1939 |
+
/**
|
1940 |
+
* Returns the days that match the recurrance array passed (unix timestamps)
|
1941 |
+
* @param array $recurrence
|
1942 |
+
* @return array
|
1943 |
+
*/
|
1944 |
+
function get_recurrence_days(){
|
1945 |
+
$start_date = strtotime($this->event_start_date);
|
1946 |
+
$end_date = strtotime($this->event_end_date);
|
1947 |
+
|
1948 |
+
$weekdays = explode(",", $this->recurrence_byday); //what days of the week (or if monthly, one value at index 0)
|
1949 |
+
|
1950 |
+
$matching_days = array();
|
1951 |
+
$aDay = 86400; // a day in seconds
|
1952 |
+
$aWeek = $aDay * 7;
|
1953 |
+
|
1954 |
+
//TODO can this be optimized?
|
1955 |
+
switch ( $this->recurrence_freq ){
|
1956 |
+
case 'daily':
|
1957 |
+
//If daily, it's simple. Get start date, add interval timestamps to that and create matching day for each interval until end date.
|
1958 |
+
$current_date = $start_date;
|
1959 |
+
while( $current_date <= $end_date ){
|
1960 |
+
$matching_days[] = $current_date;
|
1961 |
+
$current_date = $current_date + ($aDay * $this->recurrence_interval);
|
1962 |
+
}
|
1963 |
+
break;
|
1964 |
+
case 'weekly':
|
1965 |
+
//sort out week one, get starting days and then days that match time span of event (i.e. remove past events in week 1)
|
1966 |
+
$start_of_week = get_option('start_of_week'); //Start of week depends on WordPress
|
1967 |
+
//first, get the start of this week as timestamp
|
1968 |
+
$event_start_day = date('w', $start_date);
|
1969 |
+
//then get the timestamps of weekdays during this first week, regardless if within event range
|
1970 |
+
$start_weekday_dates = array(); //Days in week 1 where there would events, regardless of event date range
|
1971 |
+
for($i = 0; $i < 7; $i++){
|
1972 |
+
$weekday_date = $start_date+($aDay*$i); //the date of the weekday we're currently checking
|
1973 |
+
$weekday_day = date('w',$weekday_date); //the day of the week we're checking, taking into account wp start of week setting
|
1974 |
+
|
1975 |
+
if( in_array( $weekday_day, $weekdays) ){
|
1976 |
+
$start_weekday_dates[] = $weekday_date; //it's in our starting week day, so add it
|
1977 |
+
}
|
1978 |
+
}
|
1979 |
+
//for each day of eventful days in week 1, add 7 days * weekly intervals
|
1980 |
+
foreach ($start_weekday_dates as $weekday_date){
|
1981 |
+
//Loop weeks by interval until we reach or surpass end date
|
1982 |
+
while($weekday_date <= $end_date){
|
1983 |
+
if( $weekday_date >= $start_date && $weekday_date <= $end_date ){
|
1984 |
+
$matching_days[] = $weekday_date;
|
1985 |
+
}
|
1986 |
+
$weekday_date = $weekday_date + ($aWeek * $this->recurrence_interval);
|
1987 |
+
}
|
1988 |
+
}//done!
|
1989 |
+
break;
|
1990 |
+
case 'monthly':
|
1991 |
+
//loop months starting this month by intervals
|
1992 |
+
$current_arr = getdate($start_date);
|
1993 |
+
$end_arr = getdate($end_date);
|
1994 |
+
$end_month_date = strtotime( date('Y-m-t', $end_date) ); //End date on last day of month
|
1995 |
+
$current_date = strtotime( date('Y-m-1', $start_date) ); //Start date on first day of month
|
1996 |
+
while( $current_date <= $end_month_date ){
|
1997 |
+
$last_day_of_month = date('t', $current_date);
|
1998 |
+
//Now find which day we're talking about
|
1999 |
+
$current_week_day = date('w',$current_date);
|
2000 |
+
$matching_month_days = array();
|
2001 |
+
//Loop through days of this years month and save matching days to temp array
|
2002 |
+
for($day = 1; $day <= $last_day_of_month; $day++){
|
2003 |
+
if((int) $current_week_day == $this->recurrence_byday){
|
2004 |
+
$matching_month_days[] = $day;
|
2005 |
+
}
|
2006 |
+
$current_week_day = ($current_week_day < 6) ? $current_week_day+1 : 0;
|
2007 |
+
}
|
2008 |
+
//Now grab from the array the x day of the month
|
2009 |
+
$matching_day = ($this->recurrence_byweekno > 0) ? $matching_month_days[$this->recurrence_byweekno-1] : array_pop($matching_month_days);
|
2010 |
+
$matching_date = strtotime(date('Y-m',$current_date).'-'.$matching_day);
|
2011 |
+
if($matching_date >= $start_date && $matching_date <= $end_date){
|
2012 |
+
$matching_days[] = $matching_date;
|
2013 |
+
}
|
2014 |
+
//add the number of days in this month to make start of next month
|
2015 |
+
$current_arr['mon'] += $this->recurrence_interval;
|
2016 |
+
if($current_arr['mon'] > 12){
|
2017 |
+
//FIXME this won't work if interval is more than 12
|
2018 |
+
$current_arr['mon'] = $current_arr['mon'] - 12;
|
2019 |
+
$current_arr['year']++;
|
2020 |
+
}
|
2021 |
+
$current_date = strtotime("{$current_arr['year']}-{$current_arr['mon']}-1");
|
2022 |
+
}
|
2023 |
+
break;
|
2024 |
+
case 'yearly':
|
2025 |
+
//If yearly, it's simple. Get start date, add interval timestamps to that and create matching day for each interval until end date.
|
2026 |
+
$month = date('m', $this->start);
|
2027 |
+
$day = date('d',$this->start);
|
2028 |
+
$year = date('Y',$this->start);
|
2029 |
+
$end_year = date('Y',$this->end);
|
2030 |
+
if( @mktime(0,0,0,$day,$month,$end_year) < $this->end ) $end_year--;
|
2031 |
+
while( $year <= $end_year ){
|
2032 |
+
$matching_days[] = mktime(0,0,0,$month,$day,$year);
|
2033 |
+
$year++;
|
2034 |
+
}
|
2035 |
+
break;
|
2036 |
+
}
|
2037 |
+
sort($matching_days);
|
2038 |
+
return apply_filters('em_events_get_recurrence_days', $matching_days, $this);
|
2039 |
+
}
|
2040 |
+
|
2041 |
+
/**
|
2042 |
+
* If event is recurring, set recurrences to same status as template
|
2043 |
+
* @param $status
|
2044 |
+
*/
|
2045 |
+
function set_status_events($status){
|
2046 |
+
//give sub events same status
|
2047 |
+
$events_array = EM_Events::get( array('recurrence_id'=>$this->post_id, 'scope'=>'all', 'status'=>false ) );
|
2048 |
+
foreach($events_array as $EM_Event){
|
2049 |
+
/* @var $EM_Event EM_Event */
|
2050 |
+
if($EM_Event->recurrence_id == $this->event_id){
|
2051 |
+
$EM_Event->set_status($status);
|
2052 |
+
}
|
2053 |
+
}
|
2054 |
+
}
|
2055 |
+
|
2056 |
+
/**
|
2057 |
+
* Returns a string representation of this recurrence. Will return false if not a recurrence
|
2058 |
+
* @return string
|
2059 |
+
*/
|
2060 |
+
function get_recurrence_description() {
|
2061 |
+
$EM_Event_Recurring = $this->get_event_recurrence();
|
2062 |
+
$recurrence = $this->to_array();
|
2063 |
+
$weekdays_name = array(__('Sunday', 'dbem'),__('Monday', 'dbem'),__('Tuesday', 'dbem'),__('Wednesday', 'dbem'),__('Thursday', 'dbem'),__('Friday', 'dbem'),__('Saturday', 'dbem'));
|
2064 |
+
$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'));
|
2065 |
+
$output = sprintf (__('From %1$s to %2$s', 'dbem'), $EM_Event_Recurring->event_start_date, $EM_Event_Recurring->event_end_date).", ";
|
2066 |
+
if ($EM_Event_Recurring->recurrence_freq == 'daily') {
|
2067 |
+
$freq_desc =__('everyday', 'dbem');
|
2068 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2069 |
+
$freq_desc = sprintf (__("every %s days", 'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2070 |
+
}
|
2071 |
+
}elseif ($EM_Event_Recurring->recurrence_freq == 'weekly') {
|
2072 |
+
$weekday_array = explode(",", $EM_Event_Recurring->recurrence_byday);
|
2073 |
+
$natural_days = array();
|
2074 |
+
foreach($weekday_array as $day){
|
2075 |
+
array_push($natural_days, $weekdays_name[$day]);
|
2076 |
+
}
|
2077 |
+
$output .= implode(", ", $natural_days);
|
2078 |
+
$freq_desc = " " . __("every week", 'dbem');
|
2079 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2080 |
+
$freq_desc = " ".sprintf (__("every %s weeks", 'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2081 |
+
}
|
2082 |
+
|
2083 |
+
}elseif ($EM_Event_Recurring->recurrence_freq == 'monthly') {
|
2084 |
+
$weekday_array = explode(",", $EM_Event_Recurring->recurrence_byday);
|
2085 |
+
$natural_days = array();
|
2086 |
+
foreach($weekday_array as $day){
|
2087 |
+
array_push($natural_days, $weekdays_name[$day]);
|
2088 |
+
}
|
2089 |
+
$freq_desc = sprintf (($monthweek_name[$EM_Event_Recurring->recurrence_byweekno]), implode(" and ", $natural_days));
|
2090 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2091 |
+
$freq_desc .= ", ".sprintf (__("every %s months",'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2092 |
+
}
|
2093 |
+
}elseif ($EM_Event_Recurring->recurrence_freq == 'yearly') {
|
2094 |
+
$freq_desc .= __("every year", 'dbem');
|
2095 |
+
if ($EM_Event_Recurring->recurrence_interval > 1 ) {
|
2096 |
+
$freq_desc .= sprintf (__("every %s years",'dbem'), $EM_Event_Recurring->recurrence_interval);
|
2097 |
+
}
|
2098 |
+
}else{
|
2099 |
+
$freq_desc = "[ERROR: corrupted database record]";
|
2100 |
+
}
|
2101 |
+
$output .= $freq_desc;
|
2102 |
+
return $output;
|
2103 |
+
}
|
2104 |
+
|
2105 |
+
/**********************************************************
|
2106 |
+
* UTILITIES
|
2107 |
+
***********************************************************/
|
2108 |
+
|
2109 |
+
/**
|
2110 |
+
* Can the user manage this?
|
2111 |
+
*/
|
2112 |
+
function can_manage( $owner_capability = false, $admin_capability = false, $user_to_check = false ){
|
2113 |
+
if( $this->event_id == '' && !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') ){
|
2114 |
+
$user_to_check = get_option('dbem_events_anonymous_user');
|
2115 |
+
}
|
2116 |
+
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);
|
2117 |
+
}
|
2118 |
+
}
|
2119 |
+
|
2120 |
+
//TODO placeholder targets filtering could be streamlined better
|
2121 |
+
/**
|
2122 |
+
* This is a temporary filter function which mimicks the old filters in the old 2.x placeholders function
|
2123 |
+
* @param string $result
|
2124 |
+
* @param EM_Event $event
|
2125 |
+
* @param string $placeholder
|
2126 |
+
* @param string $target
|
2127 |
+
* @return mixed
|
2128 |
+
*/
|
2129 |
+
function em_event_output_placeholder($result,$event,$full_result,$target='html'){
|
2130 |
+
if( $target == 'raw' ) return $result;
|
2131 |
+
if( in_array($placeholder, array("#_EXCERPT",'#_EVENTEXCERPT', "#_LOCATIONEXCERPT")) && $target == 'html' ){
|
2132 |
+
$result = apply_filters('dbem_notes_excerpt', $result);
|
2133 |
+
}elseif( $placeholder == '#_CONTACTEMAIL' && $target == 'html' ){
|
2134 |
+
$result = em_ascii_encode($event->get_contact()->user_email);
|
2135 |
+
}elseif( in_array($placeholder, array('#_EVENTNOTES','#_NOTES','#_DESCRIPTION','#_LOCATIONNOTES','#_CATEGORYNOTES','#_CATEGORYDESCRIPTION')) ){
|
2136 |
+
if($target == 'rss'){
|
2137 |
+
$result = apply_filters('dbem_notes_rss', $result);
|
2138 |
+
$result = apply_filters('the_content_rss', $result);
|
2139 |
+
}elseif($target == 'map'){
|
2140 |
+
$result = apply_filters('dbem_notes_map', $result);
|
2141 |
+
}elseif($target == 'ical'){
|
2142 |
+
$result = apply_filters('dbem_notes_ical', $result);
|
2143 |
+
}elseif ($target == "email"){
|
2144 |
+
$result = apply_filters('dbem_notes_email', $result);
|
2145 |
+
}else{ //html
|
2146 |
+
$result = apply_filters('dbem_notes', $result);
|
2147 |
+
}
|
2148 |
+
}elseif( in_array($placeholder, array("#_NAME",'#_LOCATION','#_TOWN','#_ADDRESS','#_LOCATIONNAME',"#_EVENTNAME","#_LOCATIONNAME")) ){
|
2149 |
+
if ($target == "rss"){
|
2150 |
+
$result = apply_filters('dbem_general_rss', $result);
|
2151 |
+
}elseif ($target == "ical"){
|
2152 |
+
$result = apply_filters('dbem_general_ical', $result);
|
2153 |
+
}elseif ($target == "email"){
|
2154 |
+
$result = apply_filters('dbem_general_email', $result);
|
2155 |
+
}else{ //html
|
2156 |
+
$result = apply_filters('dbem_general', $result);
|
2157 |
+
}
|
2158 |
+
}
|
2159 |
+
return $result;
|
2160 |
+
}
|
2161 |
+
add_filter('em_category_output_placeholder','em_event_output_placeholder',1,4);
|
2162 |
+
add_filter('em_event_output_placeholder','em_event_output_placeholder',1,4);
|
2163 |
+
add_filter('em_location_output_placeholder','em_event_output_placeholder',1,4);
|
2164 |
+
// FILTERS
|
2165 |
+
// filters for general events field (corresponding to those of "the _title")
|
2166 |
+
add_filter('dbem_general', 'wptexturize');
|
2167 |
+
add_filter('dbem_general', 'convert_chars');
|
2168 |
+
add_filter('dbem_general', 'trim');
|
2169 |
+
// filters for the notes field in html (corresponding to those of "the _content")
|
2170 |
+
add_filter('dbem_notes', 'wptexturize');
|
2171 |
+
add_filter('dbem_notes', 'convert_smilies');
|
2172 |
+
add_filter('dbem_notes', 'convert_chars');
|
2173 |
+
add_filter('dbem_notes', 'wpautop');
|
2174 |
+
add_filter('dbem_notes', 'prepend_attachment');
|
2175 |
+
// RSS content filter
|
2176 |
+
add_filter('dbem_notes_rss', 'convert_chars', 8);
|
2177 |
+
add_filter('dbem_general_rss', 'esc_html', 8);
|
2178 |
+
// Notes map filters
|
2179 |
+
add_filter('dbem_notes_map', 'convert_chars', 8);
|
2180 |
+
add_filter('dbem_notes_map', 'js_escape');
|
2181 |
+
|
2182 |
+
/**
|
2183 |
+
* 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.
|
2184 |
+
* @param array $attr
|
2185 |
+
*/
|
2186 |
+
function em_event_gallery_override( $attr = array() ){
|
2187 |
+
global $post;
|
2188 |
+
if( $post->post_type == EM_POST_TYPE_EVENT && empty($attr['id']) ){
|
2189 |
+
//no id specified, so check if it's recurring and override id with recurrence template post id
|
2190 |
+
$EM_Event = em_get_event($post->ID, 'post_id');
|
2191 |
+
if( $EM_Event->is_recurrence() ){
|
2192 |
+
$attr['id'] = $EM_Event->get_event_recurrence()->post_id;
|
2193 |
+
}
|
2194 |
+
}
|
2195 |
+
return gallery_shortcode($attr);
|
2196 |
+
}
|
2197 |
+
remove_shortcode('gallery');
|
2198 |
+
add_shortcode('gallery', 'em_event_gallery_override');
|
2199 |
Â
?>
|
classes/em-events.php
CHANGED
@@ -1,254 +1,397 @@
|
|
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 |
-
|
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 |
-
$events = $
|
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 |
Â
?>
|
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 implements Iterator {
|
8 |
+
/**
|
9 |
+
* Array of EM_Event objects
|
10 |
+
* @var array EM_Event
|
11 |
+
*/
|
12 |
+
var $events = array();
|
13 |
+
|
14 |
+
function EM_Events( $args = array() ){
|
15 |
+
if( is_array($args) ){
|
16 |
+
if( is_object(current($args)) && get_class(current($args)) == 'EM_Event' ){
|
17 |
+
$this->events = $args;
|
18 |
+
}else{
|
19 |
+
$this->events = EM_Events::get($args);
|
20 |
+
}
|
21 |
+
}else{
|
22 |
+
$this->events = EM_Events::get();
|
23 |
+
}
|
24 |
+
do_action('em_events',$this);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Returns an array of EM_Events that match the given specs in the argument, or returns a list of future evetnts in future
|
29 |
+
* (see EM_Events::get_default_search() ) for explanation of possible search array values. You can also supply a numeric array
|
30 |
+
* containing the ids of the events you'd like to obtain
|
31 |
+
*
|
32 |
+
* @param array $args
|
33 |
+
* @return EM_Event array()
|
34 |
+
*/
|
35 |
+
function get( $args = array(), $count=false ) {
|
36 |
+
global $wpdb;
|
37 |
+
$events_table = EM_EVENTS_TABLE;
|
38 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
39 |
+
|
40 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
41 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
42 |
+
//We can just get all the events here and return them
|
43 |
+
$sql = "
|
44 |
+
SELECT * FROM $events_table
|
45 |
+
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
46 |
+
WHERE event_id=".implode(" OR event_id=", $args)."
|
47 |
+
";
|
48 |
+
$results = $wpdb->get_results(apply_filters('em_events_get_sql',$sql),ARRAY_A);
|
49 |
+
$events = array();
|
50 |
+
foreach($results as $result){
|
51 |
+
$events[$result['event_id']] = new EM_Event($result);
|
52 |
+
}
|
53 |
+
return $events; //We return all the events matched as an EM_Event array.
|
54 |
+
}
|
55 |
+
|
56 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
57 |
+
$args = self::get_default_search($args);
|
58 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
59 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
60 |
+
|
61 |
+
//Get the default conditions
|
62 |
+
$conditions = self::build_sql_conditions($args);
|
63 |
+
//Put it all together
|
64 |
+
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
65 |
+
|
66 |
+
//Get ordering instructions
|
67 |
+
$EM_Event = new EM_Event();
|
68 |
+
$EM_Location = new EM_Location();
|
69 |
+
$orderby = self::build_sql_orderby($args, array_keys(array_merge($EM_Event->fields, $EM_Location->fields)), get_option('dbem_events_default_order'));
|
70 |
+
//Now, build orderby sql
|
71 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
|
72 |
+
|
73 |
+
//Create the SQL statement and execute
|
74 |
+
|
75 |
+
if( EM_MS_GLOBAL ){
|
76 |
+
$selectors = ( $count ) ? 'COUNT(*)':$events_table.'.post_id, '.$events_table.'.blog_id';
|
77 |
+
}else{
|
78 |
+
$selectors = ( $count ) ? 'COUNT(*)':$events_table.'.post_id';
|
79 |
+
}
|
80 |
+
|
81 |
+
$sql = "
|
82 |
+
SELECT $selectors FROM $events_table
|
83 |
+
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
84 |
+
$where
|
85 |
+
$orderby_sql
|
86 |
+
$limit $offset
|
87 |
+
";
|
88 |
+
|
89 |
+
//If we're only counting results, return the number of results
|
90 |
+
if( $count ){
|
91 |
+
return apply_filters('em_events_get_count', $wpdb->get_var($sql), $args);
|
92 |
+
}
|
93 |
+
$results = $wpdb->get_results( apply_filters('em_events_get_sql',$sql, $args), ARRAY_A);
|
94 |
+
|
95 |
+
//If we want results directly in an array, why not have a shortcut here?
|
96 |
+
if( $args['array'] == true ){
|
97 |
+
return apply_filters('em_events_get_array',$results, $args);
|
98 |
+
}
|
99 |
+
|
100 |
+
//Make returned results EM_Event objects
|
101 |
+
$results = (is_array($results)) ? $results:array();
|
102 |
+
$events = array();
|
103 |
+
|
104 |
+
if( EM_MS_GLOBAL ){
|
105 |
+
foreach ( $results as $event ){
|
106 |
+
$events[] = em_get_event($event['post_id'], $event['blog_id']);
|
107 |
+
}
|
108 |
+
}else{
|
109 |
+
foreach ( $results as $event ){
|
110 |
+
$events[] = em_get_event($event['post_id'], 'post_id');
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
return apply_filters('em_events_get', $events, $args);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Returns the number of events on a given date
|
119 |
+
* @param $date
|
120 |
+
* @return int
|
121 |
+
*/
|
122 |
+
function count_date($date){
|
123 |
+
global $wpdb;
|
124 |
+
$table_name = EM_EVENTS_TABLE;
|
125 |
+
$sql = "SELECT COUNT(*) FROM $table_name WHERE (event_start_date like '$date') OR (event_start_date <= '$date' AND event_end_date >= '$date');";
|
126 |
+
return apply_filters('em_events_count_date', $wpdb->get_var($sql));
|
127 |
+
}
|
128 |
+
|
129 |
+
function count( $args = array() ){
|
130 |
+
return apply_filters('em_events_count', self::get($args, true), $args);
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Will delete given an array of event_ids or EM_Event objects
|
135 |
+
* @param unknown_type $id_array
|
136 |
+
*/
|
137 |
+
function delete( $array ){
|
138 |
+
global $wpdb;
|
139 |
+
//Detect array type and generate SQL for event IDs
|
140 |
+
$results = array();
|
141 |
+
if( !empty($array) && @get_class(current($array)) != 'EM_Event' ){
|
142 |
+
$events = self::get($array);
|
143 |
+
}else{
|
144 |
+
$events = $array;
|
145 |
+
}
|
146 |
+
$event_ids = array();
|
147 |
+
foreach ($events as $EM_Event){
|
148 |
+
$event_ids[] = $EM_Event->event_id;
|
149 |
+
$results[] = $EM_Event->delete();
|
150 |
+
}
|
151 |
+
//TODO add better error feedback on events delete fails
|
152 |
+
return apply_filters('em_events_delete', in_array(false, $results), $event_ids);
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/**
|
157 |
+
* 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.
|
158 |
+
* Note that you can pass a 'pagination' boolean attribute to enable pagination, default is enabled (true).
|
159 |
+
* @param array $args
|
160 |
+
* @param array $secondary_args
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
function output( $args ){
|
164 |
+
global $EM_Event;
|
165 |
+
$EM_Event_old = $EM_Event; //When looping, we can replace EM_Event global with the current event in the loop
|
166 |
+
//Can be either an array for the get search or an array of EM_Event objects
|
167 |
+
$func_args = func_get_args();
|
168 |
+
$page = 1; //default
|
169 |
+
if( !array_key_exists('page',$args) && !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ){
|
170 |
+
$page = $args['page'] = $_REQUEST['pno'];
|
171 |
+
}
|
172 |
+
if( is_object(current($args)) && get_class((current($args))) == 'EM_Event' ){
|
173 |
+
$func_args = func_get_args();
|
174 |
+
$events = $func_args[0];
|
175 |
+
$args = (!empty($func_args[1]) && is_array($func_args[1])) ? $func_args[1] : array();
|
176 |
+
$args = apply_filters('em_events_output_args', self::get_default_search($args), $events);
|
177 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
178 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
179 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:$page;
|
180 |
+
$events_count = count($events);
|
181 |
+
}else{
|
182 |
+
//Firstly, let's check for a limit/offset here, because if there is we need to remove it and manually do this
|
183 |
+
$args = apply_filters('em_events_output_args', self::get_default_search($args) );
|
184 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
185 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
186 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:$page;
|
187 |
+
$args_count = $args;
|
188 |
+
$args_count['limit'] = false;
|
189 |
+
$args_count['offset'] = false;
|
190 |
+
$args_count['page'] = false;
|
191 |
+
$events_count = self::count($args_count);
|
192 |
+
$events = self::get( $args );
|
193 |
+
}
|
194 |
+
//What format shall we output this to, or use default
|
195 |
+
$format = ( empty($args['format']) ) ? get_option( 'dbem_event_list_item_format' ) : $args['format'] ;
|
196 |
+
|
197 |
+
$output = "";
|
198 |
+
$events = apply_filters('em_events_output_events', $events);
|
199 |
+
if ( $events_count > 0 ) {
|
200 |
+
foreach ( $events as $EM_Event ) {
|
201 |
+
$output .= $EM_Event->output($format);
|
202 |
+
}
|
203 |
+
//Add headers and footers to output
|
204 |
+
if( $format == get_option ( 'dbem_event_list_item_format' ) ){
|
205 |
+
$format_header = ( get_option( 'dbem_event_list_item_format_header') == '' ) ? '':get_option ( 'dbem_event_list_item_format_header' );
|
206 |
+
$format_footer = ( get_option ( 'dbem_event_list_item_format_footer' ) == '' ) ? '':get_option ( 'dbem_event_list_item_format_footer' );
|
207 |
+
}else{
|
208 |
+
$format_header = ( !empty($args['format_header']) ) ? $args['format_header']:'';
|
209 |
+
$format_footer = ( !empty($args['format_footer']) ) ? $args['format_footer']:'';
|
210 |
+
}
|
211 |
+
$output = $format_header . $output . $format_footer;
|
212 |
+
//Pagination (if needed/requested)
|
213 |
+
if( !empty($args['pagination']) && !empty($limit) && $events_count > $limit ){
|
214 |
+
//Show the pagination links (unless there's less than $limit events)
|
215 |
+
$page_link_template = preg_replace('/(&|\?)pno=\d+/i','',$_SERVER['REQUEST_URI']);
|
216 |
+
$page_link_template = em_add_get_params($page_link_template, array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing;
|
217 |
+
$output .= apply_filters('em_events_output_pagination', em_paginate( $page_link_template, $events_count, $limit, $page), $page_link_template, $events_count, $limit, $page);
|
218 |
+
}
|
219 |
+
} else {
|
220 |
+
$output = get_option ( 'dbem_no_events_message' );
|
221 |
+
}
|
222 |
+
|
223 |
+
//TODO check if reference is ok when restoring object, due to changes in php5 v 4
|
224 |
+
$EM_Event = $EM_Event_old;
|
225 |
+
$output = apply_filters('em_events_output', $output, $events, $args);
|
226 |
+
return $output;
|
227 |
+
}
|
228 |
+
|
229 |
+
function can_manage($event_ids){
|
230 |
+
global $wpdb;
|
231 |
+
if( current_user_can('edit_others_events') ){
|
232 |
+
return apply_filters('em_events_can_manage', true, $event_ids);
|
233 |
+
}
|
234 |
+
if( EM_Object::array_is_numeric($event_ids) ){
|
235 |
+
$condition = implode(" OR event_id=", $event_ids);
|
236 |
+
//we try to find any of these events that don't belong to this user
|
237 |
+
$results = $wpdb->get_var("SELECT COUNT(*) FROM ". EM_EVENTS_TABLE ." WHERE event_owner != '". get_current_user_id() ."' event_id=$condition;");
|
238 |
+
return apply_filters('em_events_can_manage', ($results == 0), $event_ids);
|
239 |
+
}
|
240 |
+
return apply_filters('em_events_can_manage', false, $event_ids);
|
241 |
+
}
|
242 |
+
|
243 |
+
function get_post_search($args = array(), $filter = false){
|
244 |
+
if( !empty($_REQUEST['em_search']) && empty($args['search']) ) $_REQUEST['search'] = $_REQUEST['em_search'];
|
245 |
+
if( !empty($_REQUEST['category']) && $_REQUEST['category'] == -1 ) $_REQUEST['category'] = $args['category'] = 0;
|
246 |
+
$accepted_searches = apply_filters('em_accepted_searches', array('scope','search','category','country','state','region','town'), $args);
|
247 |
+
foreach($_REQUEST as $post_key => $post_value){
|
248 |
+
if( in_array($post_key, $accepted_searches) && !empty($post_value) ){
|
249 |
+
if(is_array($post_value)){
|
250 |
+
$post_value = implode(',',$post_value);
|
251 |
+
}
|
252 |
+
if($post_value != ',' ){
|
253 |
+
$args[$post_key] = $post_value;
|
254 |
+
}elseif( $post_value == ',' && $post_key == 'scope' ){
|
255 |
+
$args['scope'] = get_option('dbem_events_page_scope');
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
259 |
+
if( $filter ){
|
260 |
+
foreach($args as $arg_key => $arg_value){
|
261 |
+
if( !in_array($arg_key, $accepted_searches) ){
|
262 |
+
unset($args[$arg_key]);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
return apply_filters('em_events_get_post_search', $args);
|
267 |
+
}
|
268 |
+
|
269 |
+
/* Overrides EM_Object method to apply a filter to result
|
270 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
|
271 |
+
*/
|
272 |
+
function build_sql_conditions( $args = array() ){
|
273 |
+
$conditions = parent::build_sql_conditions($args);
|
274 |
+
if( !empty($args['search']) ){
|
275 |
+
$like_search = array('event_name',EM_EVENTS_TABLE.'.post_content','location_name','location_address','location_town','location_postcode','location_state','location_country');
|
276 |
+
$conditions['search'] = "(".implode(" LIKE '%{$args['search']}%' OR ", $like_search). " LIKE '%{$args['search']}%')";
|
277 |
+
}
|
278 |
+
if( array_key_exists('status',$args) && is_numeric($args['status']) ){
|
279 |
+
$null = ($args['status'] == 0) ? ' OR `event_status` = 0':'';
|
280 |
+
$conditions['status'] = "(`event_status`={$args['status']}{$null} )";
|
281 |
+
}elseif( empty($args['status']) || $args['status'] != 'all'){
|
282 |
+
$conditions['status'] = "(`event_status` IS NOT NULL )"; //by default, we don't ever show deleted items
|
283 |
+
}
|
284 |
+
//private events
|
285 |
+
if( empty($args['private']) ){
|
286 |
+
$conditions['private'] = "(`event_private`=0)";
|
287 |
+
}elseif( !empty($args['private_only']) ){
|
288 |
+
$conditions['private_only'] = "(`event_private`=1)";
|
289 |
+
}
|
290 |
+
if( EM_MS_GLOBAL && !empty($args['blog']) ){
|
291 |
+
if( is_numeric($args['blog']) ){
|
292 |
+
if( is_main_site($args['blog']) ){
|
293 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']} OR ".EM_EVENTS_TABLE.".blog_id IS NULL)";
|
294 |
+
}else{
|
295 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id={$args['blog']})";
|
296 |
+
}
|
297 |
+
}else{
|
298 |
+
if( !is_array($args['blog']) && preg_match('/^([\-0-9],?)+$/', $args['blog']) ){
|
299 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id IN ({$args['blog']}) )";
|
300 |
+
}elseif( is_array($args['blog']) && $this->array_is_numeric($args['blog']) ){
|
301 |
+
$conditions['blog'] = "(".EM_EVENTS_TABLE.".blog_id IN (".implode(',',$args['blog']).") )";
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
if( $args['bookings'] === 'user' && is_user_logged_in()){
|
306 |
+
//get bookings of user
|
307 |
+
$EM_Person = new EM_Person(get_current_user_id());
|
308 |
+
$booking_ids = $EM_Person->get_bookings(true);
|
309 |
+
if( count($booking_ids) > 0 ){
|
310 |
+
$conditions['bookings'] = "(event_id IN (SELECT event_id FROM ".EM_BOOKINGS_TABLE." WHERE booking_id IN (".implode(',',$booking_ids).")))";
|
311 |
+
}else{
|
312 |
+
$conditions['bookings'] = "(event_id = 0)";
|
313 |
+
}
|
314 |
+
}
|
315 |
+
//post search
|
316 |
+
if( !empty($args['post_id'])){
|
317 |
+
if( is_array($args['post_id']) ){
|
318 |
+
$conditions['post_id'] = "(".EM_EVENTS_TABLE.".post_id IN (".implode(',',$args['post_id'])."))";
|
319 |
+
}else{
|
320 |
+
$conditions['post_id'] = "(".EM_EVENTS_TABLE.".post_id={$args['post_id']})";
|
321 |
+
}
|
322 |
+
}
|
323 |
+
return apply_filters( 'em_events_build_sql_conditions', $conditions, $args );
|
324 |
+
}
|
325 |
+
|
326 |
+
/* Overrides EM_Object method to apply a filter to result
|
327 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
|
328 |
+
*/
|
329 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
330 |
+
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 );
|
331 |
+
}
|
332 |
+
|
333 |
+
/*
|
334 |
+
* Adds custom Events search defaults
|
335 |
+
* @param array $array
|
336 |
+
* @return array
|
337 |
+
* @uses EM_Object#get_default_search()
|
338 |
+
*/
|
339 |
+
function get_default_search( $array = array() ){
|
340 |
+
$defaults = array(
|
341 |
+
'orderby' => get_option('dbem_events_default_orderby'),
|
342 |
+
'order' => get_option('dbem_events_default_order'),
|
343 |
+
'bookings' => false, //if set to true, only events with bookings enabled are returned
|
344 |
+
'status' => 1, //approved events only
|
345 |
+
'format_header' => '', //events can have custom html above the list
|
346 |
+
'format_footer' => '', //events can have custom html below the list
|
347 |
+
'town' => false,
|
348 |
+
'state' => false,
|
349 |
+
'country' => false,
|
350 |
+
'region' => false,
|
351 |
+
'blog' => get_current_blog_id(),
|
352 |
+
'private' => current_user_can('read_private_events'),
|
353 |
+
'private_only' => false,
|
354 |
+
'post_id' => false
|
355 |
+
);
|
356 |
+
if( EM_MS_GLOBAL && !is_admin() ){
|
357 |
+
if( empty($array['blog']) && is_main_site() && get_site_option('dbem_ms_global_events') ){
|
358 |
+
$array['blog'] = false;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
if( is_admin() ){
|
362 |
+
//figure out default owning permissions
|
363 |
+
$defaults['owner'] = !current_user_can('edit_others_events') ? get_current_user_id() : false;
|
364 |
+
if( !array_key_exists('status', $array) && current_user_can('edit_others_events') ){
|
365 |
+
$defaults['status'] = false; //by default, admins see pending and live events
|
366 |
+
}
|
367 |
+
}
|
368 |
+
return apply_filters('em_events_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
|
369 |
+
}
|
370 |
+
|
371 |
+
//TODO Implement object and interators for handling groups of events.
|
372 |
+
public function rewind(){
|
373 |
+
reset($this->events);
|
374 |
+
}
|
375 |
+
|
376 |
+
public function current(){
|
377 |
+
$var = current($this->events);
|
378 |
+
return $var;
|
379 |
+
}
|
380 |
+
|
381 |
+
public function key(){
|
382 |
+
$var = key($this->events);
|
383 |
+
return $var;
|
384 |
+
}
|
385 |
+
|
386 |
+
public function next(){
|
387 |
+
$var = next($this->events);
|
388 |
+
return $var;
|
389 |
+
}
|
390 |
+
|
391 |
+
public function valid(){
|
392 |
+
$key = key($this->events);
|
393 |
+
$var = ($key !== NULL && $key !== FALSE);
|
394 |
+
return $var;
|
395 |
+
}
|
396 |
+
}
|
397 |
Â
?>
|
classes/em-location-post-admin.php
ADDED
@@ -0,0 +1,134 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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_action('save_post',array('EM_Location_Post_Admin','save_post'));
|
12 |
+
add_action('before_delete_post',array('EM_Location_Post_Admin','before_delete_post'),10,1);
|
13 |
+
add_action('trashed_post',array('EM_Location_Post_Admin','trashed_post'),10,1);
|
14 |
+
add_action('untrash_post',array('EM_Location_Post_Admin','untrash_post'),10,1);
|
15 |
+
add_action('untrashed_post',array('EM_Location_Post_Admin','untrashed_post'),10,1);
|
16 |
+
//Notices
|
17 |
+
add_action('admin_notices',array('EM_Location_Post_Admin','admin_notices'));
|
18 |
+
add_action('post_updated_messages',array('EM_Location_Post_Admin','admin_notices_filter'),1,1);
|
19 |
+
}
|
20 |
+
|
21 |
+
function admin_head(){
|
22 |
+
global $post, $EM_Location;
|
23 |
+
if( !empty($post) && $post->post_type == EM_POST_TYPE_LOCATION ){
|
24 |
+
$EM_Location = em_get_location($post);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
function admin_notices(){
|
29 |
+
//When editing
|
30 |
+
global $post, $EM_Notices;
|
31 |
+
if( !empty($post) && $post->post_type == EM_POST_TYPE_LOCATION){
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
function admin_notices_filter($messages){
|
36 |
+
//When editing
|
37 |
+
global $post, $EM_Notices;
|
38 |
+
if( $post->post_type == EM_POST_TYPE_LOCATION ){
|
39 |
+
if ( $EM_Notices->count_errors() > 0 ) {
|
40 |
+
unset($_GET['message']);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
return $messages;
|
44 |
+
}
|
45 |
+
|
46 |
+
function save_post($post_id){
|
47 |
+
global $wpdb, $EM_Location, $EM_Notices;
|
48 |
+
$saving_status = !in_array(get_post_status($post_id), array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
|
49 |
+
$is_post_type = get_post_type($post_id) == EM_POST_TYPE_LOCATION;
|
50 |
+
if(!defined('UNTRASHING_'.$post_id) && $is_post_type && $saving_status){
|
51 |
+
if( !empty($_REQUEST['_emnonce']) && wp_verify_nonce($_REQUEST['_emnonce'], 'edit_location')){
|
52 |
+
$EM_Location = em_get_location($post_id, 'post_id');
|
53 |
+
do_action('em_location_save_pre', $EM_Location);
|
54 |
+
$get_meta = $EM_Location->get_post_meta();
|
55 |
+
$save_meta = $EM_Location->save_meta();
|
56 |
+
//Handle Errors by making post draft
|
57 |
+
if( !$get_meta || !$save_meta ){
|
58 |
+
$EM_Location->set_status(null, true);
|
59 |
+
$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
|
60 |
+
$EM_Notices->add_error($EM_Location->get_errors(), true); //Always seems to redirect, so we make it static
|
61 |
+
apply_filters('em_location_save', false , $EM_Location);
|
62 |
+
}else{
|
63 |
+
apply_filters('em_location_save', true , $EM_Location);
|
64 |
+
}
|
65 |
+
}else{
|
66 |
+
//do a quick and dirty update
|
67 |
+
$EM_Location = new EM_Location($post_id, 'post_id');
|
68 |
+
do_action('em_location_save_pre', $EM_Location);
|
69 |
+
//check for existence of index
|
70 |
+
$loc_truly_exists = $wpdb->get_var('SELECT location_id FROM '.EM_LOCATIONS_TABLE." WHERE location_id={$EM_Location->location_id}") == $EM_Location->location_id;
|
71 |
+
if(empty($EM_Location->location_id) || !$loc_truly_exists){ $EM_Location->save_meta(); }
|
72 |
+
//continue
|
73 |
+
$location_status = ($EM_Location->is_published()) ? 1:0;
|
74 |
+
$wpdb->query("UPDATE ".EM_LOCATIONS_TABLE." SET location_name='{$EM_Location->location_name}', location_slug='{$EM_Location->location_slug}', location_private='{$EM_Location->location_private}',location_status={$location_status} WHERE location_id='{$EM_Location->location_id}'");
|
75 |
+
apply_filters('em_location_save', true , $EM_Location);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
function before_delete_post($post_id){
|
81 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
82 |
+
$EM_Location = em_get_location($post_id,'post_id');
|
83 |
+
$EM_Location->delete_meta();
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
function trashed_post($post_id){
|
88 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
89 |
+
global $EM_Notices;
|
90 |
+
$EM_Location = em_get_location($post_id,'post_id');
|
91 |
+
$EM_Location->set_status(null);
|
92 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
function untrash_post($post_id){
|
97 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
98 |
+
//set a constant so we know this event doesn't need 'saving'
|
99 |
+
if(!defined('UNTRASHING_'.$post_id)) define('UNTRASHING_'.$post_id, true);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
function untrashed_post($post_id){
|
104 |
+
if(get_post_type($post_id) == EM_POST_TYPE_LOCATION){
|
105 |
+
global $EM_Notices;
|
106 |
+
$EM_Location = em_get_location($post_id,'post_id');
|
107 |
+
$EM_Location->set_status(1);
|
108 |
+
$EM_Notices->remove_all(); //no validation/notices needed
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
function meta_boxes(){
|
113 |
+
add_meta_box('em-location-where', __('Where','dbem'), array('EM_Location_Post_Admin','meta_box_where'),EM_POST_TYPE_LOCATION, 'normal','high');
|
114 |
+
//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');
|
115 |
+
if( get_option('dbem_location_attributes_enabled') ){
|
116 |
+
add_meta_box('em-location-attributes', __('Attributes','dbem'), array('EM_Location_Post_Admin','meta_box_attributes'),EM_POST_TYPE_LOCATION, 'normal','default');
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
function meta_box_metadump(){
|
121 |
+
global $post,$EM_Location;
|
122 |
+
echo "<pre>"; print_r(get_post_custom($post->ID)); echo "</pre>";
|
123 |
+
echo "<pre>"; print_r($EM_Location); echo "</pre>";
|
124 |
+
}
|
125 |
+
function meta_box_where(){
|
126 |
+
?><input type="hidden" name="_emnonce" value="<?php echo wp_create_nonce('edit_location'); ?>" /><?php
|
127 |
+
em_locate_template('forms/location/where.php',true);
|
128 |
+
}
|
129 |
+
|
130 |
+
function meta_box_attributes(){
|
131 |
+
em_locate_template('forms/location/attributes.php',true);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
add_action('admin_init',array('EM_Location_Post_Admin','init'));
|
classes/em-location-post.php
ADDED
@@ -0,0 +1,69 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 template?
|
9 |
+
if( get_option('dbem_cp_locations_template_page') ){
|
10 |
+
add_filter('single_template',array('EM_Location_Post','single_template'));
|
11 |
+
}
|
12 |
+
}
|
13 |
+
add_action('parse_query', array('EM_Location_Post','parse_query'));
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Overrides the default post format of a location and can display a location as a page, which uses the page.php template.
|
18 |
+
* @param string $template
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
function single_template($template){
|
22 |
+
global $post;
|
23 |
+
if( !locate_template('single-'.EM_POST_TYPE_LOCATION.'.php') && $post->post_type == EM_POST_TYPE_LOCATION ){
|
24 |
+
$template = locate_template(array('page.php','index.php'),false);
|
25 |
+
}
|
26 |
+
return $template;
|
27 |
+
}
|
28 |
+
|
29 |
+
function the_content( $content ){
|
30 |
+
global $post, $EM_Location;
|
31 |
+
if( $post->post_type == EM_POST_TYPE_LOCATION ){
|
32 |
+
if( is_archive() || is_search() ){
|
33 |
+
if( get_option('dbem_cp_locations_archive_formats') ){
|
34 |
+
$EM_Location = em_get_location($post);
|
35 |
+
$content = $EM_Location->output(get_option('dbem_location_list_item_format'));
|
36 |
+
}
|
37 |
+
}else{
|
38 |
+
if( get_option('dbem_cp_locations_formats') && !post_password_required() ){
|
39 |
+
$EM_Location = em_get_location($post);
|
40 |
+
ob_start();
|
41 |
+
em_locate_template('templates/location-single.php',true);
|
42 |
+
$content = ob_get_clean();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
return $content;
|
47 |
+
}
|
48 |
+
|
49 |
+
function parse_query(){
|
50 |
+
global $wp_query;
|
51 |
+
if( !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == EM_POST_TYPE_LOCATION ){
|
52 |
+
if( is_admin() ){
|
53 |
+
$wp_query->query_vars['orderby'] = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby']:'title';
|
54 |
+
$wp_query->query_vars['order'] = (!empty($_REQUEST['order'])) ? $_REQUEST['order']:'ASC';
|
55 |
+
}else{
|
56 |
+
if( empty($wp_query->query_vars['location']) ) {
|
57 |
+
if( get_option('dbem_locations_default_archive_orderby') == 'title'){
|
58 |
+
$wp_query->query_vars['orderby'] = 'title';
|
59 |
+
}else{
|
60 |
+
$wp_query->query_vars['orderby'] = 'meta_value_num';
|
61 |
+
$wp_query->query_vars['meta_key'] = get_option('dbem_locations_default_archive_orderby','_location_country');
|
62 |
+
}
|
63 |
+
$wp_query->query_vars['order'] = get_option('dbem_locations_default_archive_orderby','ASC');
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
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,803 @@
|
|
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 |
-
$this
|
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 |
-
if($
|
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 $id;
|
11 |
+
}else{
|
12 |
+
return 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 = 0;
|
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 |
+
if( is_multisite() && is_numeric($results['blog_id']) ){
|
116 |
+
$location_post = get_blog_post($results['blog_id'], $results['post_id']);
|
117 |
+
$search_by = $results['blog_id'];
|
118 |
+
}else{
|
119 |
+
$location_post = get_post($results['post_id']);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}else{
|
123 |
+
if(!$is_post){
|
124 |
+
if( is_numeric($search_by) && is_multisite() ){
|
125 |
+
//we've been given a blog_id, so we're searching for a post id
|
126 |
+
$location_post = get_blog_post($search_by, $id);
|
127 |
+
}else{
|
128 |
+
//search for the post id only
|
129 |
+
$location_post = get_post($id);
|
130 |
+
}
|
131 |
+
}else{
|
132 |
+
$location_post = $id;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
$this->load_postdata($location_post, $search_by);
|
136 |
+
}
|
137 |
+
$this->compat_keys();
|
138 |
+
do_action('em_location', $this, $id, $search_by);
|
139 |
+
}
|
140 |
+
|
141 |
+
function load_postdata($location_post, $search_by = false){
|
142 |
+
if( is_object($location_post) ){
|
143 |
+
if( $location_post->post_status != 'auto-draft' ){
|
144 |
+
if( is_numeric($search_by) && is_multisite() ){
|
145 |
+
// if in multisite mode, switch blogs quickly to get the right post meta.
|
146 |
+
switch_to_blog($search_by);
|
147 |
+
$location_meta = get_post_custom($location_post->ID);
|
148 |
+
restore_current_blog();
|
149 |
+
$this->blog_id = $search_by;
|
150 |
+
}else{
|
151 |
+
$location_meta = get_post_custom($location_post->ID);
|
152 |
+
}
|
153 |
+
//Get custom fields
|
154 |
+
foreach($location_meta as $location_meta_key => $location_meta_val){
|
155 |
+
$found = false;
|
156 |
+
foreach($this->fields as $field_name => $field_info){
|
157 |
+
if( $location_meta_key == '_'.$field_name){
|
158 |
+
$this->$field_name = $location_meta_val[0];
|
159 |
+
$found = true;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
if(!$found && $location_meta_key[0] != '_'){
|
163 |
+
$this->location_attributes[$location_meta_key] = ( count($location_meta_val) > 1 ) ? $location_meta_val:$location_meta_val[0];
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
//load post data - regardless
|
168 |
+
$this->post_id = $location_post->ID;
|
169 |
+
$this->location_name = $location_post->post_title;
|
170 |
+
$this->location_slug = $location_post->post_name;
|
171 |
+
$this->location_owner = $location_post->post_author;
|
172 |
+
$this->post_content = $location_post->post_content;
|
173 |
+
foreach( $location_post as $key => $value ){ //merge the post data into location object
|
174 |
+
$this->$key = $value;
|
175 |
+
}
|
176 |
+
$this->previous_status = $this->location_status; //so we know about updates
|
177 |
+
$this->get_status();
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Retrieve event information via POST (used in situations where posts aren't submitted via WP)
|
183 |
+
* @param boolean $validate whether or not to run validation, default is true
|
184 |
+
* @return boolean
|
185 |
+
*/
|
186 |
+
function get_post($validate = true){
|
187 |
+
global $allowedtags;
|
188 |
+
do_action('em_location_get_post_pre', $this);
|
189 |
+
$this->location_name = ( !empty($_POST['location_name']) ) ? wp_kses_data( stripslashes($_POST['location_name'])):'';
|
190 |
+
$this->post_content = ( !empty($_POST['content']) ) ? wp_kses( stripslashes($_POST['content']), $allowedtags):'';
|
191 |
+
$this->get_post_meta(false);
|
192 |
+
$result = $validate ? $this->validate():true; //validate both post and meta, otherwise return true
|
193 |
+
$this->compat_keys();
|
194 |
+
return apply_filters('em_location_get_post', $result, $this);
|
195 |
+
}
|
196 |
+
/**
|
197 |
+
* Retrieve event post meta information via POST, which should be always be called when saving the event custom post via WP.
|
198 |
+
* @param boolean $validate whether or not to run validation, default is true
|
199 |
+
* @return mixed
|
200 |
+
*/
|
201 |
+
function get_post_meta($validate = true){
|
202 |
+
//We are getting the values via POST or GET
|
203 |
+
do_action('em_location_get_post_meta_pre', $this);
|
204 |
+
$this->location_address = ( !empty($_POST['location_address']) ) ? wp_kses(stripslashes($_POST['location_address']), array()):'';
|
205 |
+
$this->location_town = ( !empty($_POST['location_town']) ) ? wp_kses(stripslashes($_POST['location_town']), array()):'';
|
206 |
+
$this->location_state = ( !empty($_POST['location_state']) ) ? wp_kses(stripslashes($_POST['location_state']), array()):'';
|
207 |
+
$this->location_postcode = ( !empty($_POST['location_postcode']) ) ? wp_kses(stripslashes($_POST['location_postcode']), array()):'';
|
208 |
+
$this->location_region = ( !empty($_POST['location_region']) ) ? wp_kses(stripslashes($_POST['location_region']), array()):'';
|
209 |
+
$this->location_country = ( !empty($_POST['location_country']) ) ? wp_kses(stripslashes($_POST['location_country']), array()):'';
|
210 |
+
$this->location_latitude = ( !empty($_POST['location_latitude']) && is_numeric($_POST['location_latitude']) ) ? $_POST['location_latitude']:'';
|
211 |
+
$this->location_longitude = ( !empty($_POST['location_longitude']) && is_numeric($_POST['location_longitude']) ) ? $_POST['location_longitude']:'';
|
212 |
+
//Set Blog ID
|
213 |
+
if( is_multisite() && empty($this->blog_id) ){
|
214 |
+
$this->blog_id = get_current_blog_id();
|
215 |
+
}
|
216 |
+
//Sort out event attributes - note that custom post meta now also gets inserted here automatically (and is overwritten by these attributes)
|
217 |
+
if(get_option('dbem_location_attributes_enabled')){
|
218 |
+
global $allowedtags;
|
219 |
+
if( !is_array($this->location_attributes) ){ $this->location_attributes = array(); }
|
220 |
+
$location_available_attributes = em_get_attributes(true); //lattributes only
|
221 |
+
if( !empty($_POST['em_attributes']) && is_array($_POST['em_attributes']) ){
|
222 |
+
foreach($_POST['em_attributes'] as $att_key => $att_value ){
|
223 |
+
if( (in_array($att_key, $location_available_attributes['names']) || array_key_exists($att_key, $this->location_attributes) ) ){
|
224 |
+
$att_vals = count($location_available_attributes['values'][$att_key]);
|
225 |
+
if( $att_vals == 0 || ($att_vals > 0 && in_array($att_value, $location_available_attributes['values'][$att_key])) ){
|
226 |
+
$this->location_attributes[$att_key] = stripslashes($att_value);
|
227 |
+
}elseif($att_vals > 0){
|
228 |
+
$this->location_attributes[$att_key] = stripslashes(wp_kses($location_available_attributes['values'][$att_key][0], $allowedtags));
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
}
|
233 |
+
}
|
234 |
+
$result = $validate ? $this->validate_meta():true; //post returns null
|
235 |
+
$this->compat_keys();
|
236 |
+
return apply_filters('em_location_get_post_meta',$result,$this);
|
237 |
+
}
|
238 |
+
|
239 |
+
function validate(){
|
240 |
+
$validate_post = true;
|
241 |
+
if( empty($this->location_name) ){
|
242 |
+
$validate_post = false;
|
243 |
+
$this->add_error( __('Location name','dbem').__(" is required.", "dbem") );
|
244 |
+
}
|
245 |
+
$validate_image = $this->image_validate();
|
246 |
+
$validate_meta = $this->validate_meta();
|
247 |
+
return apply_filters('em_location_validate', $validate_post && $validate_image && $validate_meta, $this );
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Validates the location. Should be run during any form submission or saving operation.
|
252 |
+
* @return boolean
|
253 |
+
*/
|
254 |
+
function validate_meta(){
|
255 |
+
//check required fields
|
256 |
+
foreach ( $this->required_fields as $field => $description) {
|
257 |
+
if( $field == 'location_country' && !array_key_exists($this->location_country, em_get_countries()) ){
|
258 |
+
//country specific checking
|
259 |
+
$this->add_error( $this->required_fields['location_country'].__(" is required.", "dbem") );
|
260 |
+
}elseif ( $this->$field == "" ) {
|
261 |
+
$this->add_error( $description.__(" is required.", "dbem") );
|
262 |
+
}
|
263 |
+
}
|
264 |
+
return apply_filters('em_location_validate_meta', ( count($this->errors) == 0 ), $this);
|
265 |
+
}
|
266 |
+
|
267 |
+
function save(){
|
268 |
+
global $wpdb, $current_user, $blog_id;
|
269 |
+
//TODO shuffle filters into right place
|
270 |
+
if( !$this->can_manage('edit_locations', 'edit_others_locations') && !( get_option('dbem_events_anonymous_submissions') && empty($this->location_id)) ){
|
271 |
+
return apply_filters('em_location_save', false, $this);
|
272 |
+
}
|
273 |
+
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
|
274 |
+
do_action('em_location_save_pre', $this);
|
275 |
+
$post_array = array();
|
276 |
+
//Deal with updates to a location
|
277 |
+
if( !empty($this->post_id) ){
|
278 |
+
//get the full array of post data so we don't overwrite anything.
|
279 |
+
if( !empty($this->blog_id) && is_multisite() ){
|
280 |
+
$post_array = (array) get_blog_post($this->blog_id, $this->post_id);
|
281 |
+
}else{
|
282 |
+
$post_array = (array) get_post($this->post_id);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
//Overwrite new post info
|
286 |
+
$post_array['post_type'] = EM_POST_TYPE_LOCATION;
|
287 |
+
$post_array['post_title'] = $this->location_name;
|
288 |
+
$post_array['post_content'] = $this->post_content;
|
289 |
+
//decide on post status
|
290 |
+
if( count($this->errors) == 0 ){
|
291 |
+
if( EM_MS_GLOBAL && !is_main_site() && get_site_option('dbem_ms_mainblog_locations') ){
|
292 |
+
//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
|
293 |
+
restore_current_blog();
|
294 |
+
$switch_back = true;
|
295 |
+
}
|
296 |
+
$post_array['post_status'] = $this->can_manage('publish_locations') ? 'publish':'pending';
|
297 |
+
if(!empty($switch_back) && get_site_option('dbem_ms_mainblog_locations') ) EM_Object::ms_global_switch(); //switch 'back' to main blog
|
298 |
+
}else{
|
299 |
+
$post_array['post_status'] = 'draft';
|
300 |
+
}
|
301 |
+
//Anonymous submission
|
302 |
+
if( !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->location_id) ){
|
303 |
+
$post_array['post_author'] = get_option('dbem_events_anonymous_user');
|
304 |
+
if( !is_numeric($post_array['post_author']) ) $post_array['post_author'] = 0;
|
305 |
+
}
|
306 |
+
//Save post and continue with meta
|
307 |
+
$post_id = wp_insert_post($post_array);
|
308 |
+
$post_save = false;
|
309 |
+
$meta_save = false;
|
310 |
+
if( !is_wp_error($post_id) && !empty($post_id) ){
|
311 |
+
$post_save = true;
|
312 |
+
//refresh this event with wp post
|
313 |
+
$post_data = get_post($post_id);
|
314 |
+
$this->post_id = $post_id;
|
315 |
+
$this->location_slug = $post_data->post_name;
|
316 |
+
$this->location_owner = $post_data->post_author;
|
317 |
+
$this->post_status = $post_data->post_status;
|
318 |
+
$this->get_status();
|
319 |
+
//now save the meta
|
320 |
+
$meta_save = $this->save_meta();
|
321 |
+
//save the image
|
322 |
+
$this->image_upload();
|
323 |
+
$image_save = (count($this->errors) == 0);
|
324 |
+
}elseif(is_wp_error($post_id)){
|
325 |
+
//location not saved, add an error
|
326 |
+
$this->add_error($post_id->get_error_message());
|
327 |
+
}
|
328 |
+
return apply_filters('em_location_save', $post_save && $meta_save && $image_save, $this);
|
329 |
+
}
|
330 |
+
|
331 |
+
function save_meta(){
|
332 |
+
//echo "<pre>"; print_r($this); echo "</pre>"; die();
|
333 |
+
global $wpdb, $current_user;
|
334 |
+
if( $this->can_manage('edit_locations','edit_others_locations') || ( get_option('dbem_events_anonymous_submissions') && empty($this->location_id)) ){
|
335 |
+
do_action('em_location_save_meta_pre', $this);
|
336 |
+
$data = $this->to_array();
|
337 |
+
//Update Post Meta
|
338 |
+
foreach( array_keys($this->fields) as $key ){
|
339 |
+
if( !in_array($key, $this->post_fields) ){
|
340 |
+
update_post_meta($this->post_id, '_'.$key, $this->$key);
|
341 |
+
}
|
342 |
+
}
|
343 |
+
//Update Post Attributes
|
344 |
+
foreach($this->location_attributes as $location_attribute_key => $location_attribute){
|
345 |
+
update_post_meta($this->post_id, $location_attribute_key, $location_attribute);
|
346 |
+
}
|
347 |
+
$this->get_status();
|
348 |
+
$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
|
349 |
+
//Save to em_locations table
|
350 |
+
$location_array = $this->to_array(true);
|
351 |
+
if( $this->post_status == 'private' ) $location_array['location_private'] = 1;
|
352 |
+
unset($location_array['location_id']);
|
353 |
+
if( !empty($this->location_id) ){
|
354 |
+
$loc_truly_exists = $wpdb->get_var('SELECT post_id FROM '.EM_LOCATIONS_TABLE." WHERE location_id={$this->location_id}") == $this->post_id;
|
355 |
+
}else{
|
356 |
+
$loc_truly_exists = false;
|
357 |
+
}
|
358 |
+
if( empty($this->location_id) || !$loc_truly_exists ){
|
359 |
+
$this->previous_status = 0; //for sure this was previously status 0
|
360 |
+
if ( !$wpdb->insert(EM_LOCATIONS_TABLE, $location_array) ){
|
361 |
+
$this->add_error( sprintf(__('Something went wrong saving your %s to the index table. Please inform a site administrator about this.','dbem'),__('location','dbem')));
|
362 |
+
}else{
|
363 |
+
//success, so link the event with the post via an event id meta value for easy retrieval
|
364 |
+
$this->location_id = $wpdb->insert_id;
|
365 |
+
update_post_meta($this->post_id, '_location_id', $this->location_id);
|
366 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Location','dbem'));
|
367 |
+
}
|
368 |
+
}else{
|
369 |
+
$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
|
370 |
+
if ( $wpdb->update(EM_LOCATIONS_TABLE, $location_array, array('location_id'=>$this->location_id)) === false ){
|
371 |
+
$this->add_error( sprintf(__('Something went wrong updating your %s to the index table. Please inform a site administrator about this.','dbem'),__('location','dbem')));
|
372 |
+
}else{
|
373 |
+
$this->feedback_message = sprintf(__('Successfully saved %s','dbem'),__('Location','dbem'));
|
374 |
+
}
|
375 |
+
}
|
376 |
+
}else{
|
377 |
+
$this->add_error( sprintf(__('You do not have permission to create/edit %s.','dbem'), __('locations','dbem')) );
|
378 |
+
}
|
379 |
+
$this->compat_keys();
|
380 |
+
return apply_filters('em_location_save_meta', count($this->errors) == 0, $this);
|
381 |
+
}
|
382 |
+
|
383 |
+
function delete($force_delete = true){ //atm wp seems to force cp deletions anyway
|
384 |
+
global $wpdb;
|
385 |
+
$result = false;
|
386 |
+
if( $this->can_manage('delete_locations','delete_others_locations') ){
|
387 |
+
do_action('em_location_delete_pre', $this);
|
388 |
+
$result = wp_delete_post($this->post_id,$force_delete); //the post class will take care of the meta
|
389 |
+
if( $force_delete ){
|
390 |
+
$result_meta = $this->delete_meta();
|
391 |
+
}
|
392 |
+
}
|
393 |
+
return apply_filters('em_location_delete', $result !== false && $result_meta, $this);
|
394 |
+
}
|
395 |
+
|
396 |
+
function delete_meta(){
|
397 |
+
global $wpdb;
|
398 |
+
$result = false;
|
399 |
+
if( $this->can_manage('delete_locations','delete_others_locations') ){
|
400 |
+
do_action('em_location_delete_meta_pre', $this);
|
401 |
+
$result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". EM_LOCATIONS_TABLE ." WHERE location_id=%d", $this->location_id) );
|
402 |
+
}
|
403 |
+
return apply_filters('em_location_delete_meta', $result !== false, $this);
|
404 |
+
}
|
405 |
+
|
406 |
+
function is_published(){
|
407 |
+
return apply_filters('em_location_is_published', ($this->post_status == 'publish' || $this->post_status == 'private'), $this);
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Change the status of the location. This will save to the Database too.
|
412 |
+
* @param int $status
|
413 |
+
* @param boolean $set_post_status
|
414 |
+
* @return string
|
415 |
+
*/
|
416 |
+
function set_status($status, $set_post_status = false){
|
417 |
+
global $wpdb;
|
418 |
+
if($status === null){
|
419 |
+
$set_status='NULL';
|
420 |
+
if($set_post_status){
|
421 |
+
//if the post is trash, don't untrash it!
|
422 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $this->post_id ) );
|
423 |
+
$this->post_status = 'draft';
|
424 |
+
}
|
425 |
+
}else{
|
426 |
+
$set_status = $status ? 1:0;
|
427 |
+
if($set_post_status){
|
428 |
+
if($this->post_status == 'pending'){
|
429 |
+
$this->post_name = sanitize_title($this->post_title);
|
430 |
+
}
|
431 |
+
$this->post_status = $set_status ? 'publish':'pending';
|
432 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => $this->post_status, 'post_name' => $this->post_name ), array( 'ID' => $this->post_id ) );
|
433 |
+
}
|
434 |
+
}
|
435 |
+
$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
|
436 |
+
$result = $wpdb->query("UPDATE ".EM_LOCATIONS_TABLE." SET location_status=$set_status, location_slug='{$this->post_name}' WHERE location_id={$this->location_id}");
|
437 |
+
$this->get_status();
|
438 |
+
return apply_filters('em_location_set_status', $result !== false, $status, $this);
|
439 |
+
}
|
440 |
+
|
441 |
+
function get_status($db = false){
|
442 |
+
switch( $this->post_status ){
|
443 |
+
case 'private':
|
444 |
+
$this->location_private = 1;
|
445 |
+
$this->location_status = $status = 1;
|
446 |
+
break;
|
447 |
+
case 'publish':
|
448 |
+
$this->location_private = 0;
|
449 |
+
$this->location_status = $status = 1;
|
450 |
+
break;
|
451 |
+
case 'pending':
|
452 |
+
$this->location_private = 0;
|
453 |
+
$this->location_status = $status = 0;
|
454 |
+
break;
|
455 |
+
default: //draft or unknown
|
456 |
+
$this->location_private = 0;
|
457 |
+
$status = $db ? 'NULL':null;
|
458 |
+
$this->location_status = null;
|
459 |
+
break;
|
460 |
+
}
|
461 |
+
return $status;
|
462 |
+
}
|
463 |
+
|
464 |
+
function load_similar($criteria){
|
465 |
+
global $wpdb;
|
466 |
+
if( !empty($criteria['location_name']) && !empty($criteria['location_name']) && !empty($criteria['location_name']) ){
|
467 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
468 |
+
$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']) );
|
469 |
+
//$wpdb->show_errors(true);
|
470 |
+
$location = $wpdb->get_row($prepared_sql, ARRAY_A);
|
471 |
+
if( is_array($location) ){
|
472 |
+
$this->to_object($location);
|
473 |
+
}
|
474 |
+
return apply_filters('em_location_load_similar', $location, $this);
|
475 |
+
}
|
476 |
+
return apply_filters('em_location_load_similar', false, $this);
|
477 |
+
}
|
478 |
+
|
479 |
+
function has_events(){
|
480 |
+
global $wpdb;
|
481 |
+
$events_table = EM_EVENTS_TABLE;
|
482 |
+
$sql = "SELECT count(event_id) as events_no FROM $events_table WHERE location_id = {$this->location_id}";
|
483 |
+
$affected_events = $wpdb->get_row($sql);
|
484 |
+
return apply_filters('em_location_has_events', (count($affected_events) > 0), $this);
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Can the user manage this location?
|
489 |
+
*/
|
490 |
+
function can_manage( $owner_capability = false, $admin_capability = false, $user_to_check = false ){
|
491 |
+
if( $this->location_id == '' && !is_user_logged_in() && get_option('dbem_events_anonymous_submissions') ){
|
492 |
+
$user_to_check = get_option('dbem_events_anonymous_user');
|
493 |
+
}
|
494 |
+
return apply_filters('em_location_can_manage', parent::can_manage($owner_capability, $admin_capability, $user_to_check), $this, $owner_capability, $admin_capability, $user_to_check);
|
495 |
+
}
|
496 |
+
|
497 |
+
function get_permalink(){
|
498 |
+
if( EM_MS_GLOBAL ){
|
499 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){
|
500 |
+
$link = get_blog_permalink( get_current_site()->blog_id, $this->post_id);
|
501 |
+
}else{
|
502 |
+
if( get_site_option('dbem_ms_global_locations_links') && !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id() ){
|
503 |
+
//linking directly to the blog, we should be on the main blog here
|
504 |
+
$link = get_blog_permalink( $this->blog_id, $this->post_id);
|
505 |
+
}elseif( !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id() ){
|
506 |
+
if( get_option('dbem_locations_page') ){
|
507 |
+
$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);
|
508 |
+
}else{
|
509 |
+
$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;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
if( empty($link) ){
|
515 |
+
$link = get_post_permalink($this->post_id);
|
516 |
+
}
|
517 |
+
return apply_filters('em_location_get_permalink', $link, $this); ;
|
518 |
+
}
|
519 |
+
|
520 |
+
function get_edit_url(){
|
521 |
+
if( $this->can_manage('edit_locations','edit_others_locations') ){
|
522 |
+
if( EM_MS_GLOBAL ){
|
523 |
+
global $current_site, $current_blog;
|
524 |
+
if( get_site_option('dbem_ms_mainblog_locations') ){
|
525 |
+
//location stored as post on main blog, but can be edited either in sub-blog admin area or if not on main blog
|
526 |
+
if( get_blog_option($this->blog_id, 'dbem_edit_locations_page') && !is_admin() ){
|
527 |
+
$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);
|
528 |
+
}
|
529 |
+
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
|
530 |
+
$link = em_add_get_params(get_blog_permalink(get_option('dbem_edit_locations_page')), array('action'=>'edit','location_id'=>$this->location_id), false);
|
531 |
+
}
|
532 |
+
if( empty($link) && !is_main_site() ){
|
533 |
+
$link = get_admin_url($current_blog->blog_id, "edit.php?post_type=event&page=locations&action=edit&location_id={$this->location_id}");
|
534 |
+
}elseif( empty($link) && is_main_site() ){
|
535 |
+
$link = get_admin_url($current_site->blog_id, "post.php?post={$this->post_id}&action=edit");
|
536 |
+
}
|
537 |
+
}else{
|
538 |
+
//location stored as post on blog where location was created
|
539 |
+
if( get_blog_option($this->blog_id, 'dbem_edit_locations_page') && !is_admin() ){
|
540 |
+
$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);
|
541 |
+
}
|
542 |
+
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
|
543 |
+
$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);
|
544 |
+
}
|
545 |
+
if( empty($link)){
|
546 |
+
$link = get_admin_url($this->blog_id, "post.php?post={$this->post_id}&action=edit");
|
547 |
+
}
|
548 |
+
}
|
549 |
+
}else{
|
550 |
+
if( get_option('dbem_edit_locations_page') && !is_admin() ){
|
551 |
+
$link = em_add_get_params(get_permalink(get_option('dbem_edit_locations_page')), array('action'=>'edit','location_id'=>$this->location_id), false);
|
552 |
+
}
|
553 |
+
if( empty($link))
|
554 |
+
$link = admin_url()."post.php?post={$this->post_id}&action=edit";
|
555 |
+
}
|
556 |
+
return apply_filters('em_location_get_edit_url', $link, $this);
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
+
function output_single($target = 'html'){
|
561 |
+
$format = get_option ( 'dbem_single_location_format' );
|
562 |
+
return apply_filters('em_location_output_single', $this->output($format, $target), $this, $target);
|
563 |
+
}
|
564 |
+
|
565 |
+
function output($format, $target="html") {
|
566 |
+
$location_string = $format;
|
567 |
+
//First let's do some conditional placeholder removals
|
568 |
+
for ($i = 0 ; $i < get_option('dbem_conditional_recursions',1); $i++){ //you can add nested recursions by modifying this setting in your wp_options table
|
569 |
+
preg_match_all('/\{([a-zA-Z0-9_]+)\}(.+?)\{\/\1\}/s', $location_string, $conditionals);
|
570 |
+
if( count($conditionals[0]) > 0 ){
|
571 |
+
//Check if the language we want exists, if not we take the first language there
|
572 |
+
foreach($conditionals[1] as $key => $condition){
|
573 |
+
$show_condition = false;
|
574 |
+
if ($condition == 'has_loc_image'){
|
575 |
+
//does this event have an image?
|
576 |
+
$show_condition = ( $this->get_image_url() != '' );
|
577 |
+
}elseif ($condition == 'no_loc_image'){
|
578 |
+
//does this event have an image?
|
579 |
+
$show_condition = ( $this->get_image_url() == '' );
|
580 |
+
}
|
581 |
+
$show_condition = apply_filters('em_location_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
|
582 |
+
if($show_condition){
|
583 |
+
//calculate lengths to delete placeholders
|
584 |
+
$placeholder_length = strlen($condition)+2;
|
585 |
+
$replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key])-($placeholder_length *2 +1));
|
586 |
+
}else{
|
587 |
+
$replacement = '';
|
588 |
+
}
|
589 |
+
$location_string = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $location_string);
|
590 |
+
}
|
591 |
+
}
|
592 |
+
}
|
593 |
+
//This is for the custom attributes
|
594 |
+
preg_match_all('/#_LATT\{([^}]+)\}(\{([^}]+)\})?/', $format, $results);
|
595 |
+
foreach($results[0] as $resultKey => $result) {
|
596 |
+
//Strip string of placeholder and just leave the reference
|
597 |
+
$attRef = substr( substr($result, 0, strpos($result, '}')), 7 );
|
598 |
+
$attString = '';
|
599 |
+
if( is_array($this->location_attributes) && array_key_exists($attRef, $this->location_attributes) && !empty($this->location_attributes[$attRef]) ){
|
600 |
+
$attString = $this->location_attributes[$attRef];
|
601 |
+
}elseif( !empty($results[3][$resultKey]) ){
|
602 |
+
//Check to see if we have a second set of braces;
|
603 |
+
$attString = $results[3][$resultKey];
|
604 |
+
}
|
605 |
+
$attString = apply_filters('em_location_output_placeholder', $attString, $this, $result, $target);
|
606 |
+
$location_string = str_replace($result, $attString ,$location_string );
|
607 |
+
}
|
608 |
+
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
|
609 |
+
$replaces = array();
|
610 |
+
foreach($placeholders[1] as $key => $result) {
|
611 |
+
$replace = '';
|
612 |
+
$full_result = $placeholders[0][$key];
|
613 |
+
switch( $result ){
|
614 |
+
case '#_LOCATIONID':
|
615 |
+
$replace = $this->location_id;
|
616 |
+
break;
|
617 |
+
case '#_LOCATIONPOSTID':
|
618 |
+
$replace = $this->post_id;
|
619 |
+
break;
|
620 |
+
case '#_NAME': //Depricated
|
621 |
+
case '#_LOCATION': //Depricated
|
622 |
+
case '#_LOCATIONNAME':
|
623 |
+
$replace = $this->location_name;
|
624 |
+
break;
|
625 |
+
case '#_ADDRESS': //Depricated
|
626 |
+
case '#_LOCATIONADDRESS':
|
627 |
+
$replace = $this->location_address;
|
628 |
+
break;
|
629 |
+
case '#_TOWN': //Depricated
|
630 |
+
case '#_LOCATIONTOWN':
|
631 |
+
$replace = $this->location_town;
|
632 |
+
break;
|
633 |
+
case '#_LOCATIONSTATE':
|
634 |
+
$replace = $this->location_state;
|
635 |
+
break;
|
636 |
+
case '#_LOCATIONPOSTCODE':
|
637 |
+
$replace = $this->location_postcode;
|
638 |
+
break;
|
639 |
+
case '#_LOCATIONREGION':
|
640 |
+
$replace = $this->location_region;
|
641 |
+
break;
|
642 |
+
case '#_LOCATIONCOUNTRY':
|
643 |
+
$replace = $this->get_country();
|
644 |
+
break;
|
645 |
+
case '#_LOCATIONFULLLINE':
|
646 |
+
$replace = $this->location_address;
|
647 |
+
$replace .= empty($this->location_town) ? '':', '.$this->location_town;
|
648 |
+
$replace .= empty($this->location_state) ? '':', '.$this->location_state;
|
649 |
+
$replace .= empty($this->location_postcode) ? '':', '.$this->location_postcode;
|
650 |
+
$replace .= empty($this->location_region) ? '':', '.$this->location_region;
|
651 |
+
break;
|
652 |
+
case '#_LOCATIONFULLBR':
|
653 |
+
$replace = $this->location_address;
|
654 |
+
$replace .= empty($this->location_town) ? '':'<br />'.$this->location_town;
|
655 |
+
$replace .= empty($this->location_state) ? '':'<br />'.$this->location_state;
|
656 |
+
$replace .= empty($this->location_postcode) ? '':'<br />'.$this->location_postcode;
|
657 |
+
$replace .= empty($this->location_region) ? '':'<br />'.$this->location_region;
|
658 |
+
break;
|
659 |
+
case '#_MAP': //Depricated
|
660 |
+
case '#_LOCATIONMAP':
|
661 |
+
ob_start();
|
662 |
+
$template = em_locate_template('placeholders/locationmap.php', true, array('EM_Location'=>$this));
|
663 |
+
$replace = ob_get_clean();
|
664 |
+
break;
|
665 |
+
case '#_LOCATIONLONGITUDE':
|
666 |
+
$replace = $this->location_longitude;
|
667 |
+
break;
|
668 |
+
case '#_LOCATIONLATITUDE':
|
669 |
+
$replace = $this->location_latitude;
|
670 |
+
break;
|
671 |
+
case '#_DESCRIPTION': //Depricated
|
672 |
+
case '#_EXCERPT': //Depricated
|
673 |
+
case '#_LOCATIONNOTES':
|
674 |
+
case '#_LOCATIONEXCERPT':
|
675 |
+
$replace = $this->post_content;
|
676 |
+
if($result == "#_EXCERPT" || $result == "#_LOCATIONEXCERPT"){
|
677 |
+
if( !empty($this->post_excerpt) ){
|
678 |
+
$replace = $this->post_excerpt;
|
679 |
+
}else{
|
680 |
+
$matches = explode('<!--more', $this->post_content);
|
681 |
+
$replace = $matches[0];
|
682 |
+
}
|
683 |
+
}
|
684 |
+
break;
|
685 |
+
case '#_LOCATIONIMAGEURL':
|
686 |
+
case '#_LOCATIONIMAGE':
|
687 |
+
if($this->get_image_url() != ''){
|
688 |
+
$image_url = esc_url($this->get_image_url());
|
689 |
+
if($result == '#_LOCATIONIMAGEURL'){
|
690 |
+
$replace = $this->get_image_url();
|
691 |
+
}else{
|
692 |
+
if( empty($placeholders[3][$key]) ){
|
693 |
+
$replace = "<img src='".$image_url."' alt='".esc_attr($this->location_name)."'/>";
|
694 |
+
}else{
|
695 |
+
$image_size = explode(',', $placeholders[3][$key]);
|
696 |
+
if( $this->array_is_numeric($image_size) && count($image_size) > 1 ){
|
697 |
+
if( get_option('dbem_disable_timthumb') ){
|
698 |
+
if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){
|
699 |
+
switch_to_blog($this->blog_id);
|
700 |
+
$switch_back = true;
|
701 |
+
}
|
702 |
+
$replace = get_the_post_thumbnail($this->ID, $image_size);
|
703 |
+
if( !empty($switch_back) ){ restore_current_blog(); }
|
704 |
+
}else{
|
705 |
+
global $blog_id;
|
706 |
+
if ( is_multisite() && $blog_id > 0) {
|
707 |
+
$imageParts = explode('/blogs.dir/', $image_url);
|
708 |
+
if (isset($imageParts[1])) {
|
709 |
+
$image_url = network_site_url('/wp-content/blogs.dir/'. $blog_id. '/' . $imageParts[1]);
|
710 |
+
}
|
711 |
+
}
|
712 |
+
$replace = "<img src='".esc_url(em_get_thumbnail_url($image_url, $image_size[0], $image_size[1]))."' alt='".esc_attr($this->location_name)."' width='{$image_size[0]}' height='{$image_size[1]}'/>";
|
713 |
+
}
|
714 |
+
}else{
|
715 |
+
$replace = "<img src='".$image_url."' alt='".esc_attr($this->location_name)."'/>";
|
716 |
+
}
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
720 |
+
break;
|
721 |
+
case '#_LOCATIONURL':
|
722 |
+
case '#_LOCATIONLINK':
|
723 |
+
case '#_LOCATIONPAGEURL': //Depricated
|
724 |
+
$link = esc_url($this->get_permalink());
|
725 |
+
$replace = ($result == '#_LOCATIONURL' || $result == '#_LOCATIONPAGEURL') ? $link : '<a href="'.$link.'" title="'.esc_attr($this->location_name).'">'.esc_html($this->location_name).'</a>';
|
726 |
+
break;
|
727 |
+
case '#_LOCATIONEDITURL':
|
728 |
+
case '#_LOCATIONEDITLINK':
|
729 |
+
if( $this->can_manage('edit_locations','edit_others_locations') ){
|
730 |
+
$link = esc_url($this->get_edit_url());
|
731 |
+
$replace = ($result == '#_LOCATIONEDITURL') ? $link : '<a href="'.$link.'" title="'.esc_attr($this->location_name).'">'.esc_html(sprintf(__('Edit Location','dbem'))).'</a>';
|
732 |
+
}
|
733 |
+
break;
|
734 |
+
case '#_PASTEVENTS': //Depricated
|
735 |
+
case '#_LOCATIONPASTEVENTS':
|
736 |
+
case '#_NEXTEVENTS': //Depricated
|
737 |
+
case '#_LOCATIONNEXTEVENTS':
|
738 |
+
case '#_ALLEVENTS': //Depricated
|
739 |
+
case '#_LOCATIONALLEVENTS':
|
740 |
+
//TODO: add limit to lists of events
|
741 |
+
//convert depreciated placeholders for compatability
|
742 |
+
$result = ($result == '#_PASTEVENTS') ? '#_LOCATIONPASTEVENTS':$result;
|
743 |
+
$result = ($result == '#_NEXTEVENTS') ? '#_LOCATIONNEXTEVENTS':$result;
|
744 |
+
$result = ($result == '#_ALLEVENTS') ? '#_LOCATIONALLEVENTS':$result;
|
745 |
+
//forget it ever happened? :/
|
746 |
+
if ( $result == '#_LOCATIONPASTEVENTS'){ $scope = 'past'; }
|
747 |
+
elseif ( $result == '#_LOCATIONNEXTEVENTS' ){ $scope = 'future'; }
|
748 |
+
else{ $scope = 'all'; }
|
749 |
+
$events_count = EM_Events::count( array('location'=>$this->location_id, 'scope'=>$scope) );
|
750 |
+
if ( $events_count > 0 ){
|
751 |
+
$args = array('location'=>$this->location_id, 'scope'=>$scope, 'pagination'=>1);
|
752 |
+
$args['format_header'] = get_option('dbem_location_event_list_item_header_format');
|
753 |
+
$args['format_footer'] = get_option('dbem_location_event_list_item_footer_format');
|
754 |
+
$args['format'] = get_option('dbem_location_event_list_item_format');
|
755 |
+
$args['limit'] = get_option('dbem_location_event_list_limit');
|
756 |
+
$args['page'] = (!empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) )? $_REQUEST['pno'] : 1;
|
757 |
+
$replace = EM_Events::output($args);
|
758 |
+
} else {
|
759 |
+
$replace = get_option('dbem_location_no_events_message');
|
760 |
+
}
|
761 |
+
break;
|
762 |
+
case '#_LOCATIONNEXTEVENT':
|
763 |
+
$events = EM_Events::get( array('location'=>$this->location_id, 'scope'=>'future', 'limit'=>1, 'orderby'=>'event_start_date,event_start_time') );
|
764 |
+
$replace = get_option('dbem_location_no_events_message');
|
765 |
+
foreach($events as $EM_Event){
|
766 |
+
$replace = $EM_Event->output('#_EVENTLINK');
|
767 |
+
}
|
768 |
+
break;
|
769 |
+
default:
|
770 |
+
$replace = $full_result;
|
771 |
+
break;
|
772 |
+
}
|
773 |
+
$replaces[$full_result] = apply_filters('em_location_output_placeholder', $replace, $this, $full_result, $target);
|
774 |
+
}
|
775 |
+
//sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
|
776 |
+
krsort($replaces);
|
777 |
+
foreach($replaces as $full_result => $replacement){
|
778 |
+
if( !in_array($full_result, array('#_DESCRIPTION','#_LOCATIONNOTES')) ){
|
779 |
+
$location_string = str_replace($full_result, $replacement , $location_string );
|
780 |
+
}else{
|
781 |
+
$desc_replace[$full_result] = $replacement;
|
782 |
+
}
|
783 |
+
}
|
784 |
+
|
785 |
+
//Finally, do the location notes, so that previous placeholders don't get replaced within the content, which may use shortcodes
|
786 |
+
if( !empty($desc_replace) ){
|
787 |
+
foreach($desc_replace as $full_result => $replacement){
|
788 |
+
$location_string = str_replace($full_result, $replacement , $location_string );
|
789 |
+
}
|
790 |
+
}
|
791 |
+
|
792 |
+
return apply_filters('em_location_output', $location_string, $this, $format, $target);
|
793 |
+
}
|
794 |
+
|
795 |
+
function get_country(){
|
796 |
+
$countries = em_get_countries();
|
797 |
+
if( !empty($countries[$this->location_country]) ){
|
798 |
+
return apply_filters('em_location_get_country', $countries[$this->location_country], $this);
|
799 |
+
}
|
800 |
+
return apply_filters('em_location_get_country', false, $this);
|
801 |
+
|
802 |
+
}
|
803 |
Â
}
|
classes/em-locations.php
CHANGED
@@ -1,213 +1,310 @@
|
|
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 |
-
|
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 |
-
if(
|
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 |
Â
?>
|
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 implements Iterator {
|
8 |
+
/**
|
9 |
+
* Array of EM_Location objects
|
10 |
+
* @var array EM_Location
|
11 |
+
*/
|
12 |
+
var $locations = array();
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Returns an array of EM_Location objects
|
16 |
+
* @param boolean $eventful
|
17 |
+
* @param boolean $return_objects
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
function get( $args = array(), $count=false ){
|
21 |
+
global $wpdb;
|
22 |
+
$events_table = EM_EVENTS_TABLE;
|
23 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
24 |
+
$locations = array();
|
25 |
+
|
26 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
27 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
28 |
+
//We can just get all the events here and return them
|
29 |
+
$sql = "SELECT * FROM $locations_table WHERE location_id=".implode(" OR location_id=", $args);
|
30 |
+
$results = $wpdb->get_results($sql,ARRAY_A);
|
31 |
+
$events = array();
|
32 |
+
foreach($results as $result){
|
33 |
+
$locations[$result['location_id']] = new EM_Location($result);
|
34 |
+
}
|
35 |
+
return apply_filters('em_locations_get', $locations, $args); //We return all the events matched as an EM_Event array.
|
36 |
+
}elseif( is_numeric($args) ){
|
37 |
+
//return an event in the usual array format
|
38 |
+
return apply_filters('em_locations_get', array(new EM_Location($args)), $args);
|
39 |
+
}elseif( is_array($args) && is_object(current($args)) && get_class((current($args))) == 'EM_Location' ){
|
40 |
+
return apply_filters('em_locations_get', $args, $args);
|
41 |
+
}
|
42 |
+
|
43 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
44 |
+
$args = self::get_default_search($args);
|
45 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
46 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
47 |
+
|
48 |
+
//Get the default conditions
|
49 |
+
$conditions = self::build_sql_conditions($args);
|
50 |
+
|
51 |
+
//Put it all together
|
52 |
+
$EM_Location = new EM_Location(0); //Empty class for strict message avoidance
|
53 |
+
$fields = $locations_table .".". implode(", {$locations_table}.", array_keys($EM_Location->fields));
|
54 |
+
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
55 |
+
|
56 |
+
//Get ordering instructions
|
57 |
+
$EM_Event = new EM_Event(); //blank event for below
|
58 |
+
$accepted_fields = $EM_Location->get_fields(true);
|
59 |
+
$accepted_fields = array_merge($EM_Event->get_fields(true),$accepted_fields);
|
60 |
+
$orderby = self::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order'));
|
61 |
+
//Now, build orderby sql
|
62 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
|
63 |
+
|
64 |
+
$fields = ( $count ) ? $locations_table.'.location_id':$locations_table.'.post_id';
|
65 |
+
if( EM_MS_GLOBAL ){
|
66 |
+
$selectors = ( $count ) ? 'COUNT('.$locations_table.'.location_id)':$locations_table.'.post_id, '.$locations_table.'.blog_id';
|
67 |
+
}else{
|
68 |
+
$selectors = ( $count ) ? 'COUNT('.$locations_table.'.location_id)':$locations_table.'.post_id';
|
69 |
+
}
|
70 |
+
//Create the SQL statement and execute
|
71 |
+
$sql = "
|
72 |
+
SELECT $selectors FROM $locations_table
|
73 |
+
LEFT JOIN $events_table ON {$locations_table}.location_id={$events_table}.location_id
|
74 |
+
$where
|
75 |
+
GROUP BY {$locations_table}.location_id
|
76 |
+
$orderby_sql
|
77 |
+
$limit $offset
|
78 |
+
";
|
79 |
+
|
80 |
+
//If we're only counting results, return the number of results
|
81 |
+
if( $count ){
|
82 |
+
return apply_filters('em_locations_get_array', count($wpdb->get_col($sql)), $args);
|
83 |
+
}
|
84 |
+
$results = $wpdb->get_results($sql, ARRAY_A);
|
85 |
+
|
86 |
+
//If we want results directly in an array, why not have a shortcut here?
|
87 |
+
if( $args['array'] == true ){
|
88 |
+
return apply_filters('em_locations_get_array', $results, $args);
|
89 |
+
}
|
90 |
+
|
91 |
+
if( EM_MS_GLOBAL ){
|
92 |
+
foreach ( $results as $location ){
|
93 |
+
if( empty($location['blog_id']) ) $location['blog_id'] = get_current_site()->blog_id;
|
94 |
+
$locations[] = em_get_location($location['post_id'], $location['blog_id']);
|
95 |
+
}
|
96 |
+
}else{
|
97 |
+
foreach ( $results as $location ){
|
98 |
+
$locations[] = em_get_location($location['post_id'], 'post_id');
|
99 |
+
}
|
100 |
+
}
|
101 |
+
return apply_filters('em_locations_get', $locations, $args);
|
102 |
+
}
|
103 |
+
|
104 |
+
function count( $args = array() ){
|
105 |
+
return apply_filters('em_locations_count', self::get($args, true), $args);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Output a set of matched of events
|
110 |
+
* @param array $args
|
111 |
+
* @return string
|
112 |
+
*/
|
113 |
+
function output( $args ){
|
114 |
+
global $EM_Location;
|
115 |
+
$EM_Location_old = $EM_Location; //When looping, we can replace EM_Location global with the current event in the loop
|
116 |
+
//Can be either an array for the get search or an array of EM_Location objects
|
117 |
+
if( is_object(current($args)) && get_class((current($args))) == 'EM_Location' ){
|
118 |
+
$func_args = func_get_args();
|
119 |
+
$locations = $func_args[0];
|
120 |
+
$args = (!empty($func_args[1])) ? $func_args[1] : array();
|
121 |
+
$args = apply_filters('em_locations_output_args', self::get_default_search($args), $locations);
|
122 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
123 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
124 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
125 |
+
$locations_count = count($locations);
|
126 |
+
}else{
|
127 |
+
$args = apply_filters('em_locations_output_args', self::get_default_search($args) );
|
128 |
+
$limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
|
129 |
+
$offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:0;
|
130 |
+
$page = ( !empty($args['page']) && is_numeric($args['page']) ) ? $args['page']:1;
|
131 |
+
$args_count = $args;
|
132 |
+
$args_count['limit'] = 0;
|
133 |
+
$args_count['offset'] = 0;
|
134 |
+
$args_count['page'] = 1;
|
135 |
+
$locations_count = self::count($args_count);
|
136 |
+
$locations = self::get( $args );
|
137 |
+
}
|
138 |
+
//What format shall we output this to, or use default
|
139 |
+
$format = ( $args['format'] == '' ) ? get_option( 'dbem_location_list_item_format' ) : $args['format'] ;
|
140 |
+
|
141 |
+
$output = "";
|
142 |
+
$locations = apply_filters('em_locations_output_locations', $locations);
|
143 |
+
if ( count($locations) > 0 ) {
|
144 |
+
foreach ( $locations as $EM_Location ) {
|
145 |
+
$output .= $EM_Location->output($format);
|
146 |
+
}
|
147 |
+
//Add headers and footers to output
|
148 |
+
if( $format == get_option ( 'dbem_location_list_item_format' ) ){
|
149 |
+
$single_event_format_header = get_option ( 'dbem_location_list_item_format_header' );
|
150 |
+
$single_event_format_footer = get_option ( 'dbem_location_list_item_format_footer' );
|
151 |
+
$output = $single_event_format_header . $output . $single_event_format_footer;
|
152 |
+
}
|
153 |
+
//Pagination (if needed/requested)
|
154 |
+
if( !empty($args['pagination']) && !empty($limit) && $locations_count >= $limit ){
|
155 |
+
//Show the pagination links (unless there's less than 10 events
|
156 |
+
$page_link_template = preg_replace('/(&|\?)pno=\d+/i','',$_SERVER['REQUEST_URI']);
|
157 |
+
$page_link_template = em_add_get_params($page_link_template, array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing
|
158 |
+
$output .= apply_filters('em_events_output_pagination', em_paginate( $page_link_template, $locations_count, $limit, $page), $page_link_template, $locations_count, $limit, $page);
|
159 |
+
}
|
160 |
+
} else {
|
161 |
+
$output = get_option ( 'dbem_no_locations_message' );
|
162 |
+
}
|
163 |
+
//FIXME check if reference is ok when restoring object, due to changes in php5 v 4
|
164 |
+
$EM_Location_old= $EM_Location;
|
165 |
+
return apply_filters('em_locations_output', $output, $locations, $args);
|
166 |
+
}
|
167 |
+
|
168 |
+
function delete( $args = array() ){
|
169 |
+
if( !is_object(current($args)) && get_class((current($args))) != 'EM_Location' ){
|
170 |
+
$locations = self::get($args);
|
171 |
+
}else{
|
172 |
+
$locations = $args;
|
173 |
+
}
|
174 |
+
$results = array();
|
175 |
+
foreach ( $locations as $EM_Location ){
|
176 |
+
$results[] = $EM_Location->delete();
|
177 |
+
}
|
178 |
+
return apply_filters('em_locations_delete', in_array(false, $results), $locations);
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Builds an array of SQL query conditions based on regularly used arguments
|
183 |
+
* @param array $args
|
184 |
+
* @return array
|
185 |
+
*/
|
186 |
+
function build_sql_conditions( $args = array(), $count=false ){
|
187 |
+
global $wpdb;
|
188 |
+
$events_table = EM_EVENTS_TABLE;
|
189 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
190 |
+
|
191 |
+
$conditions = parent::build_sql_conditions($args);
|
192 |
+
//eventful locations
|
193 |
+
if( true == $args['eventful'] ){
|
194 |
+
$conditions['eventful'] = "{$events_table}.event_id IS NOT NULL";
|
195 |
+
}elseif( true == $args['eventless'] ){
|
196 |
+
$conditions['eventless'] = "{$events_table}.event_id IS NULL";
|
197 |
+
}
|
198 |
+
//owner lookup
|
199 |
+
if( !empty($args['owner']) && is_numeric($args['owner'])){
|
200 |
+
$conditions['owner'] = "location_owner=".$args['owner'];
|
201 |
+
}elseif( !empty($args['owner']) && $args['owner'] == 'me' && is_user_logged_in() ){
|
202 |
+
$conditions['owner'] = 'location_owner='.get_current_user_id();
|
203 |
+
}
|
204 |
+
//blog id in events table
|
205 |
+
if( EM_MS_GLOBAL && !empty($args['blog']) ){
|
206 |
+
if( is_numeric($args['blog']) ){
|
207 |
+
if( is_main_site($args['blog']) ){
|
208 |
+
$conditions['blog'] = "(".$locations_table.".blog_id={$args['blog']} OR ".$locations_table.".blog_id IS NULL)";
|
209 |
+
}else{
|
210 |
+
$conditions['blog'] = "(".$locations_table.".blog_id={$args['blog']})";
|
211 |
+
}
|
212 |
+
}else{
|
213 |
+
if( !is_array($args['blog']) && preg_match('/^([\-0-9],?)+$/', $args['blog']) ){
|
214 |
+
$conditions['blog'] = "(".$locations_table.".blog_id IN ({$args['blog']}) )";
|
215 |
+
}elseif( is_array($args['blog']) && $this->array_is_numeric($args['blog']) ){
|
216 |
+
$conditions['blog'] = "(".$locations_table.".blog_id IN (".implode(',',$args['blog']).") )";
|
217 |
+
}
|
218 |
+
}
|
219 |
+
}
|
220 |
+
//status
|
221 |
+
if( array_key_exists('status',$args) && is_numeric($args['status']) ){
|
222 |
+
$null = ($args['status'] == 0) ? ' OR `location_status` = 0':'';
|
223 |
+
$conditions['status'] = "(`location_status`={$args['status']}{$null} )";
|
224 |
+
}else{
|
225 |
+
$conditions['status'] = "(`location_status` IS NOT NULL)";
|
226 |
+
}
|
227 |
+
//private locations
|
228 |
+
if( empty($args['private']) ){
|
229 |
+
$conditions['private'] = "(`location_private`=0)";
|
230 |
+
}elseif( !empty($args['private_only']) ){
|
231 |
+
$conditions['private_only'] = "(`location_private`=1)";
|
232 |
+
}
|
233 |
+
//post search
|
234 |
+
if( !empty($args['post_id'])){
|
235 |
+
if( is_array($args['post_id']) ){
|
236 |
+
$conditions['post_id'] = "($locations_table.post_id IN (".implode(',',$args['post_id'])."))";
|
237 |
+
}else{
|
238 |
+
$conditions['post_id'] = "($locations_table.post_id={$args['post_id']})";
|
239 |
+
}
|
240 |
+
}
|
241 |
+
return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
|
242 |
+
}
|
243 |
+
|
244 |
+
/* Overrides EM_Object method to apply a filter to result
|
245 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
|
246 |
+
*/
|
247 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
248 |
+
return apply_filters( 'em_locations_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order')), $args, $accepted_fields, $default_order );
|
249 |
+
}
|
250 |
+
|
251 |
+
/*
|
252 |
+
* Generate a search arguments array from defalut and user-defined.
|
253 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object::get_default_search()
|
254 |
+
*/
|
255 |
+
function get_default_search($array = array()){
|
256 |
+
$defaults = array(
|
257 |
+
'eventful' => false, //Locations that have an event (scope will also play a part here
|
258 |
+
'eventless' => false, //Locations WITHOUT events, eventful takes precedence
|
259 |
+
'orderby' => 'location_name',
|
260 |
+
'town' => false,
|
261 |
+
'state' => false,
|
262 |
+
'country' => false,
|
263 |
+
'region' => false,
|
264 |
+
'status' => 1, //approved locations only
|
265 |
+
'scope' => 'all', //we probably want to search all locations by default, not like events
|
266 |
+
'blog' => get_current_blog_id(),
|
267 |
+
'private' => current_user_can('read_private_locations'),
|
268 |
+
'private_only' => false,
|
269 |
+
'post_id' => false
|
270 |
+
);
|
271 |
+
if( EM_MS_GLOBAL && get_site_option('dbem_ms_mainblog_locations') ){
|
272 |
+
if( empty($array['blog']) && !is_main_site() ){
|
273 |
+
$array['blog'] = get_current_site()->blog_id;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
$array['eventful'] = ( !empty($array['eventful']) && $array['eventful'] == true );
|
277 |
+
$array['eventless'] = ( !empty($array['eventless']) && $array['eventless'] == true );
|
278 |
+
if( is_admin() ){
|
279 |
+
$defaults['owner'] = !current_user_can('read_others_locations') ? get_current_user_id():false;
|
280 |
+
}
|
281 |
+
return apply_filters('em_locations_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults);
|
282 |
+
}
|
283 |
+
|
284 |
+
//Iteratior methods
|
285 |
+
public function rewind(){
|
286 |
+
reset($this->locations);
|
287 |
+
}
|
288 |
+
|
289 |
+
public function current(){
|
290 |
+
$var = current($this->locations);
|
291 |
+
return $var;
|
292 |
+
}
|
293 |
+
|
294 |
+
public function key(){
|
295 |
+
$var = key($this->locations);
|
296 |
+
return $var;
|
297 |
+
}
|
298 |
+
|
299 |
+
public function next(){
|
300 |
+
$var = next($this->locations);
|
301 |
+
return $var;
|
302 |
+
}
|
303 |
+
|
304 |
+
public function valid(){
|
305 |
+
$key = key($this->locations);
|
306 |
+
$var = ($key !== NULL && $key !== FALSE);
|
307 |
+
return $var;
|
308 |
+
}
|
309 |
+
}
|
310 |
Â
?>
|
classes/em-mailer.php
CHANGED
@@ -1,80 +1,134 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* phpmailer support
|
4 |
-
*
|
5 |
-
*/
|
6 |
-
class EM_Mailer {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* if any errors crop up, here they are
|
10 |
-
* @var array
|
11 |
-
*/
|
12 |
-
var $errors = array();
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @param $subject
|
16 |
-
* @param $body
|
17 |
-
* @param $receiver
|
18 |
-
*/
|
19 |
-
function send($subject="no title",$body="No message specified", $receiver='') {
|
20 |
-
//TODO add an EM_Error global object, for this sort of error reporting. (@marcus like StatusNotice)
|
21 |
-
global $smtpsettings, $phpmailer, $cformsSettings;
|
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 |
Â
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* phpmailer support
|
4 |
+
*
|
5 |
+
*/
|
6 |
+
class EM_Mailer {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* if any errors crop up, here they are
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
var $errors = array();
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param $subject
|
16 |
+
* @param $body
|
17 |
+
* @param $receiver
|
18 |
+
*/
|
19 |
+
function send($subject="no title",$body="No message specified", $receiver='', $attachments = array() ) {
|
20 |
+
//TODO add an EM_Error global object, for this sort of error reporting. (@marcus like StatusNotice)
|
21 |
+
global $smtpsettings, $phpmailer, $cformsSettings;
|
22 |
+
if( is_array($receiver) ){
|
23 |
+
$receiver_emails = array();
|
24 |
+
foreach($receiver as $receiver_email){
|
25 |
+
$receiver_emails[] = is_email($receiver_email);
|
26 |
+
}
|
27 |
+
$emails_ok = !in_array(false, $receiver_emails);
|
28 |
+
}else{
|
29 |
+
$emails_ok = is_email($receiver);
|
30 |
+
}
|
31 |
+
if( get_option('dbem_smtp_html') && get_option('dbem_smtp_html_br') ){
|
32 |
+
$body = nl2br($body);
|
33 |
+
}
|
34 |
+
if ( $emails_ok && get_option('dbem_rsvp_mail_send_method') == 'wp_mail' ){
|
35 |
+
$from = get_option('dbem_mail_sender_address');
|
36 |
+
$headers = get_option('dbem_mail_sender_name') ? 'From: '.get_option('dbem_mail_sender_name').' <'.$from.'>':'From: '.$from;
|
37 |
+
if( get_option('dbem_smtp_html') ){ //create filter to change content type to html in wp_mail
|
38 |
+
add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
|
39 |
+
}
|
40 |
+
$send = wp_mail($receiver, $subject, $body, $headers);
|
41 |
+
if(!$send){
|
42 |
+
global $phpmailer;
|
43 |
+
$this->errors[] = $phpmailer->ErrorInfo;
|
44 |
+
}
|
45 |
+
return $send;
|
46 |
+
}elseif ( $emails_ok && get_option('dbem_rsvp_mail_send_method') == 'mail' ){
|
47 |
+
if(is_array($receiver)){
|
48 |
+
$receiver = implode(', ', $receiver);
|
49 |
+
}
|
50 |
+
$headers = '';
|
51 |
+
if( get_option('dbem_smtp_html') ){
|
52 |
+
$headers = 'MIME-Version: 1.0' . "\r\n";
|
53 |
+
$headers .= 'Content-type: text/html; charset="UTF-8"' . "\r\n";
|
54 |
+
}else{
|
55 |
+
$headers = 'Content-Type: text/plain; charset="UTF-8"' . "\r\n";
|
56 |
+
}
|
57 |
+
$from = get_option('dbem_mail_sender_address');
|
58 |
+
$headers .= get_option('dbem_mail_sender_name') ? 'From: '.get_option('dbem_mail_sender_name').' <'.$from.'>':'From: '.$from;
|
59 |
+
$send = mail($receiver, $subject, $body, $headers);
|
60 |
+
if(!$send){
|
61 |
+
$this->errors = __('Could not send email.', 'dbem');
|
62 |
+
}
|
63 |
+
return $send;
|
64 |
+
}elseif( $emails_ok ){
|
65 |
+
$this->load_phpmailer();
|
66 |
+
$mail = new EM_PHPMailer();
|
67 |
+
//$mail->SMTPDebug = true;
|
68 |
+
if( get_option('dbem_smtp_html') ){
|
69 |
+
$mail->isHTML();
|
70 |
+
}
|
71 |
+
$mail->ClearAllRecipients();
|
72 |
+
$mail->ClearAddresses();
|
73 |
+
$mail->ClearAttachments();
|
74 |
+
$mail->CharSet = 'utf-8';
|
75 |
+
$mail->SetLanguage('en', dirname(__FILE__).'/');
|
76 |
+
$mail->PluginDir = dirname(__FILE__).'/phpmailer/';
|
77 |
+
$mail->Host = get_option('dbem_smtp_host');
|
78 |
+
$mail->port = get_option('dbem_rsvp_mail_port');
|
79 |
+
$mail->Username = get_option('dbem_smtp_username');
|
80 |
+
$mail->Password = get_option('dbem_smtp_password');
|
81 |
+
$mail->From = get_option('dbem_mail_sender_address');
|
82 |
+
$mail->FromName = get_option('dbem_mail_sender_name'); // This is the from name in the email, you can put anything you like here
|
83 |
+
$mail->Body = $body;
|
84 |
+
$mail->Subject = $subject;
|
85 |
+
//add attachments
|
86 |
+
foreach($attachments as $attachment){
|
87 |
+
$att = array('name'=> '', 'encoding' => 'base64', 'type' => 'application/octet-stream');
|
88 |
+
if( is_array($attachment) ){
|
89 |
+
$att = array_merge($att, $attachment);
|
90 |
+
}else{
|
91 |
+
$att['path'] = $attachment;
|
92 |
+
}
|
93 |
+
$mail->AddAttachment($att['path'], $att['name'], $att['encoding'], $att['type']);
|
94 |
+
}
|
95 |
+
|
96 |
+
do_action('em_mailer', $mail); //$mail will still be modified
|
97 |
+
if(is_array($receiver)){
|
98 |
+
foreach($receiver as $receiver_email){
|
99 |
+
$mail->AddAddress($receiver_email);
|
100 |
+
}
|
101 |
+
}else{
|
102 |
+
$mail->AddAddress($receiver);
|
103 |
+
}
|
104 |
+
|
105 |
+
//Protocols
|
106 |
+
if( get_option('dbem_rsvp_mail_send_method') == 'qmail' ){
|
107 |
+
$mail->IsQmail();
|
108 |
+
}else {
|
109 |
+
$mail->Mailer = get_option('dbem_rsvp_mail_send_method');
|
110 |
+
}
|
111 |
+
if(get_option('dbem_rsvp_mail_SMTPAuth') == '1'){
|
112 |
+
$mail->SMTPAuth = TRUE;
|
113 |
+
}
|
114 |
+
$send = $mail->Send();
|
115 |
+
if(!$send){
|
116 |
+
$this->errors[] = $mail->ErrorInfo;
|
117 |
+
}
|
118 |
+
do_action('em_mailer_sent', $mail, $send); //$mail can still be modified
|
119 |
+
return $send;
|
120 |
+
}else{
|
121 |
+
$this->errors = __('Please supply a valid email format.', 'dbem');
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* load phpmailer classes
|
128 |
+
*/
|
129 |
+
function load_phpmailer(){
|
130 |
+
require_once(dirname(__FILE__) . '/phpmailer/class.phpmailer.php');
|
131 |
+
require_once(dirname(__FILE__) . '/phpmailer/class.smtp.php');
|
132 |
+
}
|
133 |
+
}
|
134 |
Â
?>
|
classes/em-map.php
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Obtains the html required to display a google map for given location(s)
|
4 |
-
*
|
5 |
-
*/
|
6 |
-
class EM_Map extends EM_Object {
|
7 |
-
/**
|
8 |
-
* Shortcode for producing a google map with all the locations. Unfinished and undocumented.
|
9 |
-
* @param array $atts
|
10 |
-
* @return string
|
11 |
-
*/
|
12 |
-
function get_global($atts) {
|
13 |
-
//TODO Finish and document this feature, need to add balloons here
|
14 |
-
if (get_option('dbem_gmap_is_active') == '1') {
|
15 |
-
ob_start();
|
16 |
-
$atts['em_ajax'] = true;
|
17 |
-
$atts['query'] = 'GlobalMapData';
|
18 |
-
$rand = substr(md5(rand().rand()),0,5);
|
19 |
-
//build js array of arguments to send to event query
|
20 |
-
?>
|
21 |
-
<div class='em-locations-map' id='em-locations-map-<?php echo $rand; ?>' style='width:<?php echo $atts['width']; ?>px; height:<?php echo $atts['height']; ?>px'><em><?php _e('Loading Map....', 'dbem'); ?></em></div>
|
22 |
-
<div class='em-locations-map-coords' id='em-locations-map-coords-<?php echo $rand; ?>' style="display:none; visibility:hidden;"><?php echo EM_Object::json_encode($atts); ?></div>
|
23 |
-
<?php
|
24 |
-
return apply_filters('em_map_get_global', ob_get_clean());
|
25 |
-
}else{
|
26 |
-
return '';
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Returns th HTML and JS required to produce a google map in for this location.
|
33 |
-
* @param EM_Location $location
|
34 |
-
* @return string
|
35 |
-
*/
|
36 |
-
function get_single($args) {
|
37 |
-
//TODO do some validation here of defaults
|
38 |
-
//FIXME change baloon to balloon for consistent spelling
|
39 |
-
$location = $args['location'];
|
40 |
-
if ( get_option('dbem_gmap_is_active') && ( is_object($location) && $location->latitude != 0 && $location->longitude != 0 ) ) {
|
41 |
-
$width = (isset($args['width'])) ? $args['width']:'400';
|
42 |
-
$height = (isset($args['height'])) ? $args['height']:'300';
|
43 |
-
ob_start();
|
44 |
-
$rand = substr(md5(rand().rand()),0,5);
|
45 |
-
?>
|
46 |
-
<div class='em-location-map' id='em-location-map-<?php echo $rand ?>' style='background: #CDCDCD; width: <?php echo $width ?>px; height: <?php echo $height ?>px'><?php _e('Loading Map....', 'dbem'); ?></div>
|
47 |
-
<div class='em-location-map-info' id='em-location-map-info-<?php echo $rand ?>' style="display:none; visibility:hidden;"><div class="em-map-balloon" style="font-size:12px;"><div class="em-map-balloon-content" ><?php echo $location->output(get_option('dbem_location_baloon_format')); ?></div></div></div>
|
48 |
-
<div class='em-location-map-coords' id='em-location-map-coords-<?php echo $rand ?>' style="display:none; visibility:hidden;">
|
49 |
-
<span class="lat"><?php echo $location->latitude; ?></span>
|
50 |
-
<span class="lng"><?php echo $location->longitude; ?></span>
|
51 |
-
</div>
|
52 |
-
<?php
|
53 |
-
return ob_get_clean();
|
54 |
-
}elseif( is_object($location) && $location->latitude == 0 && $location->longitude == 0 ){
|
55 |
-
return '<i>'. __('Map Unavailable', 'dbem') .'</i>';
|
56 |
-
}else{
|
57 |
-
return '';
|
58 |
-
}
|
59 |
-
}
|
60 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
classes/em-notices.php
ADDED
@@ -0,0 +1,238 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @author marcus
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class EM_Notices implements Iterator {
|
8 |
+
var $notices = array('errors'=>array(), 'infos'=>array(), 'alerts'=>array(), 'confirms'=>array());
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
//Grab from cookie, if it exists
|
12 |
+
if( !empty($_COOKIE['em_notices']) ) {
|
13 |
+
$notices = base64_decode($_COOKIE['em_notices']);
|
14 |
+
if( is_serialized( $notices ) ){
|
15 |
+
$this->notices = unserialize($notices);
|
16 |
+
setcookie('em_notices', '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); //unset the cookie
|
17 |
+
}
|
18 |
+
}
|
19 |
+
add_filter('wp_redirect', array(&$this,'destruct'), 1,1);
|
20 |
+
}
|
21 |
+
|
22 |
+
function destruct($redirect = false){
|
23 |
+
//Flush notices that weren't made to stay cross-requests, we can do this if initialized immediately.
|
24 |
+
foreach($this->notices as $notice_type => $notices){
|
25 |
+
foreach ($notices as $key => $notice){
|
26 |
+
if( empty($notice['static']) ){
|
27 |
+
unset($this->notices[$notice_type][$key]);
|
28 |
+
}else{
|
29 |
+
unset($this->notices[$notice_type][$key]['static']); //so it gets removed next request
|
30 |
+
$has_static = true;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
if(count($this->notices['errors']) > 0 || count($this->notices['alerts']) > 0 || count($this->notices['infos']) > 0 || count($this->notices['confirms']) > 0){
|
35 |
+
setcookie('em_notices', base64_encode(serialize($this->notices)), time() + 30, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); //sets cookie for 30 seconds, which may be too much
|
36 |
+
}
|
37 |
+
return $redirect;
|
38 |
+
}
|
39 |
+
|
40 |
+
function __toString(){
|
41 |
+
$string = false;
|
42 |
+
if(count($this->notices['errors']) > 0){
|
43 |
+
$string .= "<div class='em-warning em-warning-errors error'>{$this->get_errors()}</div>";
|
44 |
+
}
|
45 |
+
if(count($this->notices['alerts']) > 0){
|
46 |
+
$string .= "<div class='em-warning em-warning-alerts updated'>{$this->get_alerts()}</div>";
|
47 |
+
}
|
48 |
+
if(count($this->notices['infos']) > 0){
|
49 |
+
$string .= "<div class='em-warning em-warning-infos updated'>{$this->get_infos()}</div>";
|
50 |
+
}
|
51 |
+
if(count($this->notices['confirms']) > 0){
|
52 |
+
$string .= "<div class='em-warning em-warning-confirms updated'>{$this->get_confirms()}</div>";
|
53 |
+
}
|
54 |
+
return ($string !== false) ? "<div class='statusnotice'>".$string."</div>" : '';
|
55 |
+
}
|
56 |
+
|
57 |
+
/* General */
|
58 |
+
function add($string, $type, $static = false){
|
59 |
+
if( is_array($string) ){
|
60 |
+
$result = true;
|
61 |
+
foreach($string as $key => $string_item){
|
62 |
+
if( !is_array($string_item) ){
|
63 |
+
if( $this->add($string_item, $type, $static) === false ){ $result = false; }
|
64 |
+
}else{
|
65 |
+
if( $this->add_item($string_item, $type, $static) === false ){ $result = false; }
|
66 |
+
}
|
67 |
+
}
|
68 |
+
return $result;
|
69 |
+
}
|
70 |
+
if($string != ''){
|
71 |
+
return $this->add_item($string, $type, $static);
|
72 |
+
}else{
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
function add_item($string, $type, $static = false){
|
78 |
+
if( isset($this->notices[$type]) ){
|
79 |
+
$notice_key = 0;
|
80 |
+
foreach( $this->notices[$type] as $notice_key => $notice ){
|
81 |
+
if($string == $notice['string']){
|
82 |
+
return $notice_key;
|
83 |
+
}elseif( is_array($string) && !empty($notice['title']) && $this->get_array_title($string) == $notice['title'] ){
|
84 |
+
return $notice_key;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
$i = $notice_key+1;
|
88 |
+
if( is_array($string) ){
|
89 |
+
$this->notices[$type][$i]['title'] = $this->get_array_title($string);
|
90 |
+
$this->notices[$type][$i]['string'] = array_shift($string);
|
91 |
+
}else{
|
92 |
+
$this->notices[$type][$i]['string'] = $string;
|
93 |
+
}
|
94 |
+
if( $static ){
|
95 |
+
$this->notices[$type][$i]['static'] = true;
|
96 |
+
}
|
97 |
+
return $i;
|
98 |
+
}else{
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Returns title of an array, assumes a assoc array with one item containing title => messages
|
105 |
+
* @param unknown_type $array
|
106 |
+
* @return unknown
|
107 |
+
*/
|
108 |
+
function get_array_title($array){
|
109 |
+
foreach($array as $title => $msgs)
|
110 |
+
return $title;
|
111 |
+
}
|
112 |
+
|
113 |
+
function remove($key, $type){
|
114 |
+
if( isset($this->notices[$type]) ){
|
115 |
+
unset($this->notices[$type][$key]);
|
116 |
+
return true;
|
117 |
+
}else{
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
function remove_all(){
|
123 |
+
$this->notices = array('errors'=>array(), 'infos'=>array(), 'alerts'=>array(), 'confirms'=>array());
|
124 |
+
}
|
125 |
+
|
126 |
+
function get($type){
|
127 |
+
if( isset($this->notices[$type]) ){
|
128 |
+
$string = '';
|
129 |
+
foreach ($this->notices[$type] as $message){
|
130 |
+
if( !is_array($message['string']) ){
|
131 |
+
$string .= "<p>{$message['string']}</p>";
|
132 |
+
}else{
|
133 |
+
$string .= "<p><strong>".$message['title']."</strong><ul>";
|
134 |
+
foreach($message['string'] as $msg){
|
135 |
+
if( trim($msg) != '' ){
|
136 |
+
$string .= "<li>$msg</li>";
|
137 |
+
}
|
138 |
+
}
|
139 |
+
$string .= "</ul></p>";
|
140 |
+
}
|
141 |
+
}
|
142 |
+
return $string;
|
143 |
+
}
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
|
147 |
+
function count($type){
|
148 |
+
if( isset($this->notices[$type]) ){
|
149 |
+
return count($this->notices[$type]);
|
150 |
+
}
|
151 |
+
return 0;
|
152 |
+
}
|
153 |
+
|
154 |
+
/* Errors */
|
155 |
+
function add_error($string, $static=false){
|
156 |
+
return $this->add($string, 'errors', $static);
|
157 |
+
}
|
158 |
+
function remove_error($key){
|
159 |
+
return $this->remove($key, 'errors');
|
160 |
+
}
|
161 |
+
function get_errors(){
|
162 |
+
return $this->get('errors');
|
163 |
+
}
|
164 |
+
function count_errors(){
|
165 |
+
return $this->count('errors');
|
166 |
+
}
|
167 |
+
|
168 |
+
/* Alerts */
|
169 |
+
function add_alert($string, $static=false){
|
170 |
+
return $this->add($string, 'alerts', $static);
|
171 |
+
}
|
172 |
+
function remove_alert($key){
|
173 |
+
return $this->remove($key, 'alerts');
|
174 |
+
}
|
175 |
+
function get_alerts(){
|
176 |
+
return $this->get('alerts');
|
177 |
+
}
|
178 |
+
function count_alerts(){
|
179 |
+
return $this->count('alerts');
|
180 |
+
}
|
181 |
+
|
182 |
+
/* Info */
|
183 |
+
function add_info($string, $static=false){
|
184 |
+
return $this->add($string, 'infos', $static);
|
185 |
+
}
|
186 |
+
function remove_info($key){
|
187 |
+
return $this->remove($key, 'infos');
|
188 |
+
}
|
189 |
+
function get_infos(){
|
190 |
+
return $this->get('infos');
|
191 |
+
}
|
192 |
+
function count_infos(){
|
193 |
+
return $this->count('infos');
|
194 |
+
}
|
195 |
+
|
196 |
+
/* Confirms */
|
197 |
+
function add_confirm($string, $static=false){
|
198 |
+
return $this->add($string, 'confirms', $static);
|
199 |
+
}
|
200 |
+
function remove_confirm($key){
|
201 |
+
return $this->remove($key, 'confirms');
|
202 |
+
}
|
203 |
+
function get_confirms(){
|
204 |
+
return $this->get('confirms');
|
205 |
+
}
|
206 |
+
function count_confirms(){
|
207 |
+
return $this->count('confirms');
|
208 |
+
}
|
209 |
+
|
210 |
+
//Iterator Implementation
|
211 |
+
function rewind(){
|
212 |
+
reset($this->bookings);
|
213 |
+
}
|
214 |
+
function current(){
|
215 |
+
$var = current($this->bookings);
|
216 |
+
return $var;
|
217 |
+
}
|
218 |
+
function key(){
|
219 |
+
$var = key($this->bookings);
|
220 |
+
return $var;
|
221 |
+
}
|
222 |
+
function next(){
|
223 |
+
$var = next($this->bookings);
|
224 |
+
return $var;
|
225 |
+
}
|
226 |
+
function valid(){
|
227 |
+
$key = key($this->bookings);
|
228 |
+
$var = ($key !== NULL && $key !== FALSE);
|
229 |
+
return $var;
|
230 |
+
}
|
231 |
+
|
232 |
+
}
|
233 |
+
function em_notices_init(){
|
234 |
+
global $EM_Notices;
|
235 |
+
$EM_Notices = new EM_Notices();
|
236 |
+
}
|
237 |
+
add_action('plugins_loaded', 'em_notices_init');
|
238 |
+
?>
|
classes/em-object.php
CHANGED
@@ -1,486 +1,1244 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Base class which others extend on. Contains functions shared across all EM objects.
|
4 |
-
*
|
5 |
-
*/
|
6 |
-
class EM_Object {
|
7 |
-
|
8 |
-
var $
|
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 |
-
if(
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
//
|
56 |
-
if( array_key_exists('
|
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 |
-
if(
|
91 |
-
$defaults['
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
$defaults['
|
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 |
-
$owner = $
|
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 |
-
$conditions['
|
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 |
-
if(
|
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 |
-
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Base class which others extend on. Contains functions shared across all EM objects.
|
4 |
+
*
|
5 |
+
*/
|
6 |
+
class EM_Object {
|
7 |
+
var $fields = array();
|
8 |
+
var $required_fields = array();
|
9 |
+
var $feedback_message = "";
|
10 |
+
var $errors = array();
|
11 |
+
var $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Takes the array and provides a clean array of search parameters, along with details
|
15 |
+
* @param array $defaults
|
16 |
+
* @param array $array
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
function get_default_search($defaults=array(), $array = array()){
|
20 |
+
global $wpdb;
|
21 |
+
//TODO accept all objects as search options as well as ids (e.g. location vs. location_id, person vs. person_id)
|
22 |
+
//Create minimal defaults array, merge it with supplied defaults array
|
23 |
+
$super_defaults = array(
|
24 |
+
'limit' => false,
|
25 |
+
'scope' => 'future',
|
26 |
+
'order' => 'ASC', //hard-coded at end of this function
|
27 |
+
'orderby' => false,
|
28 |
+
'format' => '',
|
29 |
+
'category' => 0,
|
30 |
+
'tag' => 0,
|
31 |
+
'location' => 0,
|
32 |
+
'event' => 0,
|
33 |
+
'offset'=>0,
|
34 |
+
'page'=>1,//basically, if greater than 0, calculates offset at end
|
35 |
+
'recurrence'=>0,
|
36 |
+
'recurrences'=>null,
|
37 |
+
'recurring'=>false,
|
38 |
+
'month'=>'',
|
39 |
+
'year'=>'',
|
40 |
+
'pagination'=>false,
|
41 |
+
'array'=>false,
|
42 |
+
'owner'=>false,
|
43 |
+
'rsvp'=>false, //depreciated for bookings
|
44 |
+
'bookings'=>false,
|
45 |
+
'search'=>false
|
46 |
+
);
|
47 |
+
//Return default if nothing passed
|
48 |
+
if( empty($defaults) && empty($array) ){
|
49 |
+
return $super_defaults;
|
50 |
+
}
|
51 |
+
//TODO decide on search defaults shared across all objects and then validate here
|
52 |
+
$defaults = array_merge($super_defaults, $defaults);
|
53 |
+
|
54 |
+
if(is_array($array)){
|
55 |
+
//We are still dealing with recurrence_id, location_id, category_id in some place, so we do a quick replace here just in case
|
56 |
+
if( array_key_exists('recurrence_id', $array) && !array_key_exists('recurrence', $array) ) { $array['recurrence'] = $array['recurrence_id']; }
|
57 |
+
if( array_key_exists('location_id', $array) && !array_key_exists('location', $array) ) { $array['location'] = $array['location_id']; }
|
58 |
+
if( array_key_exists('category_id', $array) && !array_key_exists('category', $array) ) { $array['category'] = $array['category_id']; }
|
59 |
+
|
60 |
+
//Clean all id lists
|
61 |
+
$array = self::clean_id_atts($array, array('location', 'event', 'category', 'post_id'));
|
62 |
+
if( !empty($array['tag']) && strstr(',', $array['tag']) !== false ){
|
63 |
+
$array['tag'] = explode(',',$array['tag']);
|
64 |
+
}
|
65 |
+
|
66 |
+
//OrderBy - can be a comma-seperated array of field names to order by (field names of object, not db)
|
67 |
+
if( array_key_exists('orderby', $array)){
|
68 |
+
if( !is_array($array['orderby']) && preg_match('/,/', $array['orderby']) ) {
|
69 |
+
$array['orderby'] = explode(',', $array['orderby']);
|
70 |
+
}
|
71 |
+
}
|
72 |
+
//TODO validate search query array
|
73 |
+
//Clean the supplied array, so we only have allowed keys
|
74 |
+
foreach( array_keys($array) as $key){
|
75 |
+
if( !array_key_exists($key, $defaults) ) unset($array[$key]);
|
76 |
+
}
|
77 |
+
//return clean array
|
78 |
+
$defaults = array_merge ( $defaults, $array ); //No point using WP's cleaning function, we're doing it already.
|
79 |
+
}
|
80 |
+
|
81 |
+
//Do some spring cleaning for known values
|
82 |
+
//Month & Year - may be array or single number
|
83 |
+
$month_regex = '/^[0-9]{1,2}$/';
|
84 |
+
$year_regex = '/^[0-9]{4}$/';
|
85 |
+
if( is_array($defaults['month']) ){
|
86 |
+
$defaults['month'] = ( preg_match($month_regex, $defaults['month'][0]) && preg_match($month_regex, $defaults['month'][1]) ) ? $defaults['month']:'';
|
87 |
+
}else{
|
88 |
+
$defaults['month'] = preg_match($month_regex, $defaults['month']) ? $defaults['month']:'';
|
89 |
+
}
|
90 |
+
if( is_array($defaults['year']) ){
|
91 |
+
$defaults['year'] = ( preg_match($year_regex, $defaults['year'][0]) && preg_match($year_regex, $defaults['year'][1]) ) ? $defaults['year']:'';
|
92 |
+
}else{
|
93 |
+
$defaults['year'] = preg_match($year_regex, $defaults['year']) ? $defaults['year']:'';
|
94 |
+
}
|
95 |
+
//Deal with scope and date searches
|
96 |
+
if ( !is_array($defaults['scope']) && preg_match ( "/^([0-9]{4}-[0-9]{2}-[0-9]{2})?,([0-9]{4}-[0-9]{2}-[0-9]{2})?$/", $defaults['scope'] ) ) {
|
97 |
+
//This is to become an array, so let's split it up
|
98 |
+
$defaults['scope'] = explode(',', $defaults['scope']);
|
99 |
+
}
|
100 |
+
if( is_array($defaults['scope']) ){
|
101 |
+
//looking for a date range here, so we'll verify the dates validate, if not get the default.
|
102 |
+
if ( !preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $defaults['scope'][0]) ){
|
103 |
+
$defaults['scope'][0] = '';
|
104 |
+
}
|
105 |
+
if( !preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $defaults['scope'][1]) ) {
|
106 |
+
$defaults['scope'][1] = '';
|
107 |
+
}
|
108 |
+
if( empty($defaults['scope'][0]) && empty($defaults['scope'][1]) ){
|
109 |
+
$defaults['scope'] = $super_defaults['scope'];
|
110 |
+
}
|
111 |
+
}
|
112 |
+
//Order - it's either ASC or DESC, so let's just validate
|
113 |
+
if( !is_array($defaults['order']) && preg_match('/,/', $defaults['order']) ) {
|
114 |
+
$defaults['order'] = explode(',', $defaults['order']);
|
115 |
+
}elseif( !in_array($defaults['order'], array('ASC','DESC')) ){
|
116 |
+
$defaults['order'] = $super_defaults['order'];
|
117 |
+
}
|
118 |
+
//ORDER BY, split if an array
|
119 |
+
if( !is_array($defaults['orderby']) && preg_match('/,/', $defaults['orderby']) ) {
|
120 |
+
$defaults['orderby'] = explode(',', $defaults['orderby']);
|
121 |
+
}
|
122 |
+
//TODO should we clean format of malicious code over here and run everything thorugh this?
|
123 |
+
$defaults['array'] = ($defaults['array'] == true);
|
124 |
+
$defaults['pagination'] = ($defaults['pagination'] == true);
|
125 |
+
$defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
|
126 |
+
$defaults['offset'] = (is_numeric($defaults['offset'])) ? $defaults['offset']:$super_defaults['offset'];
|
127 |
+
$defaults['recurring'] = ($defaults['recurring'] == true);
|
128 |
+
$defaults['owner'] = (is_numeric($defaults['owner']) || $defaults['owner'] == 'me') ? $defaults['owner']:$super_defaults['owner'];
|
129 |
+
$defaults['search'] = ($defaults['search']) ? trim($wpdb->escape(like_escape($defaults['search']))):false;
|
130 |
+
//Calculate offset if event page is set
|
131 |
+
if($defaults['page'] > 1){
|
132 |
+
$defaults['offset'] = $defaults['limit'] * ($defaults['page']-1);
|
133 |
+
}else{
|
134 |
+
$defaults['page'] = ($defaults['limit'] > 0 ) ? floor($defaults['offset']/$defaults['limit']) + 1 : 1;
|
135 |
+
}
|
136 |
+
return apply_filters('em_object_get_default_search', $defaults, $array, $super_defaults);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Builds an array of SQL query conditions based on regularly used arguments
|
141 |
+
* @param array $args
|
142 |
+
* @return array
|
143 |
+
*/
|
144 |
+
function build_sql_conditions( $args = array() ){
|
145 |
+
global $wpdb;
|
146 |
+
$events_table = EM_EVENTS_TABLE;
|
147 |
+
$locations_table = EM_LOCATIONS_TABLE;
|
148 |
+
|
149 |
+
$args = apply_filters('em_object_build_sql_conditions_args',$args);
|
150 |
+
|
151 |
+
//Format the arguments passed on
|
152 |
+
$scope = $args['scope'];//undefined variable warnings in ZDE, could just delete this (but dont pls!)
|
153 |
+
$recurring = $args['recurring'];
|
154 |
+
$recurrence = $args['recurrence'];
|
155 |
+
$recurrences = $args['recurrences'];
|
156 |
+
$category = $args['category'];
|
157 |
+
$tag = $args['tag'];
|
158 |
+
$location = $args['location'];
|
159 |
+
$bookings = $args['rsvp'];
|
160 |
+
$bookings = !empty($args['bookings']) ? $args['bookings']:$bookings;
|
161 |
+
$owner = $args['owner'];
|
162 |
+
$event = $args['event'];
|
163 |
+
$month = $args['month'];
|
164 |
+
$year = $args['year'];
|
165 |
+
$today = date('Y-m-d', current_time('timestamp'));
|
166 |
+
//Create the WHERE statement
|
167 |
+
|
168 |
+
//Recurrences
|
169 |
+
$conditions = array();
|
170 |
+
if( $recurring ){
|
171 |
+
$conditions['recurring'] = "`recurrence`=1";
|
172 |
+
}elseif( $recurrence > 0 ){
|
173 |
+
$conditions['recurrence'] = "`recurrence_id`=$recurrence";
|
174 |
+
}else{
|
175 |
+
if( $recurrences !== null ){
|
176 |
+
$conditions['recurrences'] = $recurrences ? "(`recurrence_id` > 0 )":"(`recurrence_id` IS NULL OR `recurrence_id`=0 )";
|
177 |
+
}
|
178 |
+
$conditions['recurring'] = "(`recurrence`!=1 OR `recurrence` IS NULL)";
|
179 |
+
}
|
180 |
+
//Dates - first check 'month', and 'year', and adjust scope if needed
|
181 |
+
if( !($month=='' && $year=='') ){
|
182 |
+
//Sort out month range, if supplied an array of array(month,month), it'll check between these two months
|
183 |
+
if( self::array_is_numeric($month) ){
|
184 |
+
$date_month_start = $month[0];
|
185 |
+
$date_month_end = $month[1];
|
186 |
+
}else{
|
187 |
+
if( !empty($month) ){
|
188 |
+
$date_month_start = $date_month_end = $month;
|
189 |
+
}else{
|
190 |
+
$date_month_start = 1;
|
191 |
+
$date_month_end = 12;
|
192 |
+
}
|
193 |
+
}
|
194 |
+
//Sort out year range, if supplied an array of array(year,year), it'll check between these two years
|
195 |
+
if( self::array_is_numeric($year) ){
|
196 |
+
$date_year_start = $year[0];
|
197 |
+
$date_year_end = $year[1];
|
198 |
+
}else{
|
199 |
+
$date_year_start = $date_year_end = $year;
|
200 |
+
}
|
201 |
+
$date_start = $date_year_start."-".$date_month_start."-01";
|
202 |
+
$date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
|
203 |
+
$scope = array($date_start,$date_end); //just modify the scope here
|
204 |
+
}
|
205 |
+
//No date requested, so let's look at scope
|
206 |
+
if ( is_array($scope) ) {
|
207 |
+
//This is an array, let's split it up
|
208 |
+
$date_start = $scope[0];
|
209 |
+
$date_end = $scope[1];
|
210 |
+
if( !empty($date_start) && empty($date_end) ){
|
211 |
+
//do a from till infinity
|
212 |
+
$conditions['scope'] = " event_start_date >= CAST('$date_start' AS DATE)";
|
213 |
+
}elseif( empty($date_start) && !empty($date_end) ){
|
214 |
+
//do past till $date_end
|
215 |
+
if( get_option('dbem_events_current_are_past') ){
|
216 |
+
$conditions['scope'] = " event_start_date <= CAST('$date_end' AS DATE)";
|
217 |
+
}else{
|
218 |
+
$conditions['scope'] = " event_end_date <= CAST('$date_end' AS DATE)";
|
219 |
+
}
|
220 |
+
}else{
|
221 |
+
//date range
|
222 |
+
if( get_option('dbem_events_current_are_past') ){
|
223 |
+
$conditions['scope'] = "( event_start_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE) )";
|
224 |
+
}else{
|
225 |
+
$conditions['scope'] = "( event_start_date <= CAST('$date_end' AS DATE) AND event_end_date >= CAST('$date_start' AS DATE) )";
|
226 |
+
}
|
227 |
+
//$conditions['scope'] = " ( ( event_start_date <= CAST('$date_end' AS DATE) AND event_end_date >= CAST('$date_start' AS DATE) ) OR (event_start_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)) OR (event_end_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)) )";
|
228 |
+
}
|
229 |
+
} elseif ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
230 |
+
//Scope can also be a specific date. However, if 'day', 'month', or 'year' are set, that will take precedence
|
231 |
+
if( get_option('dbem_events_current_are_past') ){
|
232 |
+
$conditions['scope'] = "event_start_date = CAST('$scope' AS DATE)";
|
233 |
+
}else{
|
234 |
+
$conditions['scope'] = " ( event_start_date = CAST('$scope' AS DATE) OR ( event_start_date <= CAST('$scope' AS DATE) AND event_end_date >= CAST('$scope' AS DATE) ) )";
|
235 |
+
}
|
236 |
+
} else {
|
237 |
+
if ($scope == "past"){
|
238 |
+
if( get_option('dbem_events_current_are_past') ){
|
239 |
+
$conditions['scope'] = " event_start_date < '$today'";
|
240 |
+
}else{
|
241 |
+
$conditions['scope'] = " event_end_date < '$today'";
|
242 |
+
}
|
243 |
+
}elseif ($scope == "today"){
|
244 |
+
$conditions['scope'] = " (event_start_date = CAST('$today' AS DATE))";
|
245 |
+
if( !get_option('dbem_events_current_are_past') ){
|
246 |
+
$conditions['scope'] .= " OR (event_start_date <= CAST('$today' AS DATE) AND event_end_date >= CAST('$today' AS DATE))";
|
247 |
+
}
|
248 |
+
}elseif ($scope == "tomorrow"){
|
249 |
+
$tomorrow = date('Y-m-d',current_time('timestamp')+60*60*24);
|
250 |
+
$conditions['scope'] = "(event_start_date = CAST('$tomorrow' AS DATE))";
|
251 |
+
if( !get_option('dbem_events_current_are_past') ){
|
252 |
+
$conditions['scope'] .= " OR (event_start_date <= CAST('$tomorrow' AS DATE) AND event_end_date >= CAST('$tomorrow' AS DATE))";
|
253 |
+
}
|
254 |
+
}elseif ($scope == "month"){
|
255 |
+
$start_month = date('Y-m-d',current_time('timestamp'));
|
256 |
+
$end_month = date('Y-m-t',current_time('timestamp'));
|
257 |
+
$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_month' AS DATE) AND CAST('$end_month' AS DATE))";
|
258 |
+
if( !get_option('dbem_events_current_are_past') ){
|
259 |
+
$conditions['scope'] .= " OR (event_start_date < CAST('$start_month' AS DATE) AND event_end_date >= CAST('$start_month' AS DATE))";
|
260 |
+
}
|
261 |
+
}elseif ($scope == "next-month"){
|
262 |
+
$start_month_timestamp = strtotime('+1 month', current_time('timestamp')); //get the end of this month + 1 day
|
263 |
+
$start_month = date('Y-m-1',$start_month_timestamp);
|
264 |
+
$end_month = date('Y-m-t',$start_month_timestamp);
|
265 |
+
$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_month' AS DATE) AND CAST('$end_month' AS DATE))";
|
266 |
+
if( !get_option('dbem_events_current_are_past') ){
|
267 |
+
$conditions['scope'] .= " OR (event_start_date < CAST('$start_month' AS DATE) AND event_end_date >= CAST('$start_month' AS DATE))";
|
268 |
+
}
|
269 |
+
}elseif( preg_match('/([0-9]+)\-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.
|
270 |
+
$months_to_add = $matches[1];
|
271 |
+
$start_month = date('Y-m-d',current_time('timestamp'));
|
272 |
+
$end_month = date('Y-m-t',strtotime("+$months_to_add month", current_time('timestamp')));
|
273 |
+
$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_month' AS DATE) AND CAST('$end_month' AS DATE))";
|
274 |
+
if( !get_option('dbem_events_current_are_past') ){
|
275 |
+
$conditions['scope'] .= " OR (event_start_date < CAST('$start_month' AS DATE) AND event_end_date >= CAST('$start_month' AS DATE))";
|
276 |
+
}
|
277 |
+
}elseif ($scope == "future"){
|
278 |
+
$conditions['scope'] = " event_start_date >= CAST('$today' AS DATE)";
|
279 |
+
if( !get_option('dbem_events_current_are_past') ){
|
280 |
+
$conditions['scope'] .= " OR (event_end_date >= CAST('$today' AS DATE) AND event_end_date != '0000-00-00' AND event_end_date IS NOT NULL)";
|
281 |
+
}
|
282 |
+
}
|
283 |
+
if( !empty($conditions['scope']) ){
|
284 |
+
$conditions['scope'] = '('.$conditions['scope'].')';
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
//Filter by Location - can be object, array, or id
|
289 |
+
if ( is_numeric($location) && $location > 0 ) { //Location ID takes precedence
|
290 |
+
$conditions['location'] = " {$locations_table}.location_id = $location";
|
291 |
+
}elseif ( self::array_is_numeric($location) ){
|
292 |
+
$conditions['location'] = "( {$locations_table}.location_id = " . implode(" OR {$locations_table}.location_id = ", $location) .' )';
|
293 |
+
}elseif ( is_object($location) && get_class($location)=='EM_Location' ){ //Now we deal with objects
|
294 |
+
$conditions['location'] = " {$locations_table}.location_id = $location->location_id";
|
295 |
+
}elseif ( is_array($location) && @get_class(current($location)=='EM_Location') ){ //we can accept array of ids or EM_Location objects
|
296 |
+
foreach($location as $EM_Location){
|
297 |
+
$location_ids[] = $EM_Location->location_id;
|
298 |
+
}
|
299 |
+
$conditions['location'] = "( {$locations_table}.location_id=". implode(" {$locations_table}.location_id=", $location_ids) ." )";
|
300 |
+
}
|
301 |
+
|
302 |
+
//Filter by Event - can be object, array, or id
|
303 |
+
if ( is_numeric($event) && $event > 0 ) { //event ID takes precedence
|
304 |
+
$conditions['event'] = " {$events_table}.event_id = $event";
|
305 |
+
}elseif ( self::array_is_numeric($event) ){ //array of ids
|
306 |
+
$conditions['event'] = "( {$events_table}.event_id = " . implode(" OR {$events_table}.event_id = ", $event) .' )';
|
307 |
+
}elseif ( is_object($event) && get_class($event)=='EM_Event' ){ //Now we deal with objects
|
308 |
+
$conditions['event'] = " {$events_table}.event_id = $event->event_id";
|
309 |
+
}elseif ( is_array($event) && @get_class(current($event)=='EM_Event') ){ //we can accept array of ids or EM_event objects
|
310 |
+
foreach($event as $EM_Event){
|
311 |
+
$event_ids[] = $EM_Event->event_id;
|
312 |
+
}
|
313 |
+
$conditions['event'] = "( {$events_table}.event_id=". implode(" {$events_table}.event_id=", $event_ids) ." )";
|
314 |
+
}
|
315 |
+
//Location specific filters
|
316 |
+
//country lookup
|
317 |
+
if( !empty($args['country']) ){
|
318 |
+
$countries = em_get_countries();
|
319 |
+
//we can accept country codes or names
|
320 |
+
if( in_array($args['country'], $countries) ){
|
321 |
+
//we have a country name,
|
322 |
+
$conditions['country'] = "location_country='".array_search($args['country'], $countries)."'";
|
323 |
+
}elseif( array_key_exists($args['country'], $countries) ){
|
324 |
+
//we have a country code
|
325 |
+
$conditions['country'] = "location_country='".$args['country']."'";
|
326 |
+
}
|
327 |
+
}
|
328 |
+
//state lookup
|
329 |
+
if( !empty($args['state']) ){
|
330 |
+
$conditions['state'] = $wpdb->prepare('location_state=%s', $args['state']);
|
331 |
+
}
|
332 |
+
//state lookup
|
333 |
+
if( !empty($args['town']) ){
|
334 |
+
$conditions['town'] = $wpdb->prepare('location_town=%s', $args['town']);
|
335 |
+
}
|
336 |
+
//region lookup
|
337 |
+
if( !empty($args['region']) ){
|
338 |
+
$conditions['region'] = $wpdb->prepare('location_region=%s', $args['region']);
|
339 |
+
}
|
340 |
+
//Add conditions for category selection
|
341 |
+
//Filter by category, can be id or comma seperated ids
|
342 |
+
$not = '';
|
343 |
+
if ( !empty($category) && is_numeric($category) ){
|
344 |
+
$not = ( $category < 0 ) ? "NOT":'';
|
345 |
+
//get the term id directly
|
346 |
+
$term = new EM_Category(absint($category));
|
347 |
+
if( !empty($term->term_id) ){
|
348 |
+
if( EM_MS_GLOBAL ){
|
349 |
+
$conditions['category'] = " ".EM_EVENTS_TABLE.".event_id $not IN ( SELECT object_id FROM ".EM_META_TABLE." WHERE meta_value={$term->term_id} AND meta_key='event-category' ) ";
|
350 |
+
}else{
|
351 |
+
$conditions['category'] = " ".EM_EVENTS_TABLE.".post_id $not IN ( SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id={$term->term_taxonomy_id} ) ";
|
352 |
+
}
|
353 |
+
}elseif( $category > 0 ){
|
354 |
+
$conditions = array('category'=>'2=1'); //force a false
|
355 |
+
}
|
356 |
+
}elseif( self::array_is_numeric($category) ){
|
357 |
+
$term_ids = array();
|
358 |
+
$term_not_ids = array();
|
359 |
+
foreach($category as $category_id){
|
360 |
+
$term = new EM_Category(absint($category_id));
|
361 |
+
if( !empty($term->term_taxonomy_id) ){
|
362 |
+
if( $category_id > 0 ){
|
363 |
+
$term_ids[] = $term->term_taxonomy_id;
|
364 |
+
}else{
|
365 |
+
$term_not_ids[] = $term->term_taxonomy_id;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
}
|
369 |
+
if( count($term_ids) > 0 || count($term_not_ids) > 0 ){
|
370 |
+
if( EM_MS_GLOBAL ){
|
371 |
+
$cat_conds = array();
|
372 |
+
if( count($term_ids) > 0 ){
|
373 |
+
$cat_conds[] = EM_EVENTS_TABLE.".event_id IN ( SELECT object_id FROM ".EM_META_TABLE." WHERE meta_value IN (".implode(',',$term_ids).") AND meta_name='event-category' )";
|
374 |
+
}
|
375 |
+
if( count($term_not_ids) > 0 ){
|
376 |
+
$cat_conds[] = EM_EVENTS_TABLE.".event_id NOT IN ( SELECT object_id FROM ".EM_META_TABLE." WHERE meta_value IN (".implode(',',$term_not_ids).") AND meta_name='event-category' )";
|
377 |
+
}
|
378 |
+
$conditions['category'] = '('. implode(' || ', $cat_conds) .')';
|
379 |
+
}else{
|
380 |
+
$cat_conds = array();
|
381 |
+
if( count($term_ids) > 0 ){
|
382 |
+
$cat_conds[] = EM_EVENTS_TABLE.".post_id IN ( SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id IN (".implode(',',$term_ids).") )";
|
383 |
+
}
|
384 |
+
if( count($term_not_ids) > 0 ){
|
385 |
+
$cat_conds[] = EM_EVENTS_TABLE.".post_id NOT IN ( SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id IN (".implode(',',$term_not_ids).") )";
|
386 |
+
}
|
387 |
+
$conditions['category'] = '('. implode(' || ', $cat_conds) .')';
|
388 |
+
}
|
389 |
+
}else{
|
390 |
+
$conditions = array('tag'=>'2=1'); //force a false
|
391 |
+
}
|
392 |
+
}
|
393 |
+
//Add conditions for tags
|
394 |
+
//Filter by tag, can be id or comma seperated ids
|
395 |
+
if ( !empty($tag) && !is_array($tag) ){
|
396 |
+
//get the term id directly
|
397 |
+
$term = new EM_Tag($tag);
|
398 |
+
if( !empty($term->term_id) ){
|
399 |
+
$conditions['tag'] = " ".EM_EVENTS_TABLE.".post_id IN ( SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id={$term->term_taxonomy_id} ) ";
|
400 |
+
}else{
|
401 |
+
$conditions = array('tag'=>'2=1'); //force a false
|
402 |
+
}
|
403 |
+
}elseif( is_array($tag) ){
|
404 |
+
$term_ids = array();
|
405 |
+
foreach($tag as $tag_id){
|
406 |
+
$term = new EM_Tag($tag_id);
|
407 |
+
if( !empty($term->term_id) ){
|
408 |
+
$term_ids[] = $term->term_taxonomy_id;
|
409 |
+
}
|
410 |
+
}
|
411 |
+
if( count($term_ids) > 0 ){
|
412 |
+
$conditions['tag'] = " ".EM_EVENTS_TABLE.".post_id IN ( SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id IN (".implode(',',$term_ids).") ) ";
|
413 |
+
}else{
|
414 |
+
$conditions = array('tag'=>'2=1'); //force a false
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
//If we want rsvped items, we usually check the event
|
419 |
+
if( $bookings == 1 ){
|
420 |
+
$conditions['bookings'] = 'event_rsvp=1';
|
421 |
+
}
|
422 |
+
//Default ownership belongs to an event, child objects can just overwrite this if needed.
|
423 |
+
if( is_numeric($owner) ){
|
424 |
+
$conditions['owner'] = 'event_owner='.$owner;
|
425 |
+
}elseif( $owner == 'me' && is_user_logged_in() ){
|
426 |
+
$conditions['owner'] = 'event_owner='.get_current_user_id();
|
427 |
+
}
|
428 |
+
return apply_filters('em_object_build_sql_conditions', $conditions);
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* WORK IN PROGRESS
|
433 |
+
* Builds an array of SQL query conditions based on regularly used arguments
|
434 |
+
* @param array $args
|
435 |
+
* @return array
|
436 |
+
*/
|
437 |
+
function build_wpquery_conditions( $args = array(), $wp_query ){
|
438 |
+
global $wpdb;
|
439 |
+
|
440 |
+
$args = apply_filters('em_object_build_sql_conditions_args',$args);
|
441 |
+
|
442 |
+
//Format the arguments passed on
|
443 |
+
$scope = $args['scope'];//undefined variable warnings in ZDE, could just delete this (but dont pls!)
|
444 |
+
$recurring = $args['recurring'];
|
445 |
+
$recurrence = $args['recurrence'];
|
446 |
+
$category = $args['category'];
|
447 |
+
$tag = $args['tag'];
|
448 |
+
$location = $args['location'];
|
449 |
+
$bookings = $args['rsvp'];
|
450 |
+
$bookings = !empty($args['bookings']) ? $args['bookings']:$bookings;
|
451 |
+
$owner = $args['owner'];
|
452 |
+
$event = $args['event'];
|
453 |
+
$month = $args['month'];
|
454 |
+
$year = $args['year'];
|
455 |
+
$today = date('Y-m-d', current_time('timestamp'));
|
456 |
+
//Create the WHERE statement
|
457 |
+
|
458 |
+
//Recurrences
|
459 |
+
$query = array();
|
460 |
+
if( $recurrence > 0 ){
|
461 |
+
$query[] = array( 'key' => '_recurrence_id', 'value' => $recurrence, 'compare' => '=' );
|
462 |
+
}
|
463 |
+
//Dates - first check 'month', and 'year', and adjust scope if needed
|
464 |
+
if( !($month=='' && $year=='') ){
|
465 |
+
//Sort out month range, if supplied an array of array(month,month), it'll check between these two months
|
466 |
+
if( self::array_is_numeric($month) ){
|
467 |
+
$date_month_start = $month[0];
|
468 |
+
$date_month_end = $month[1];
|
469 |
+
}else{
|
470 |
+
if( !empty($month) ){
|
471 |
+
$date_month_start = $date_month_end = $month;
|
472 |
+
}else{
|
473 |
+
$date_month_start = 1;
|
474 |
+
$date_month_end = 12;
|
475 |
+
}
|
476 |
+
}
|
477 |
+
//Sort out year range, if supplied an array of array(year,year), it'll check between these two years
|
478 |
+
if( self::array_is_numeric($year) ){
|
479 |
+
$date_year_start = $year[0];
|
480 |
+
$date_year_end = $year[1];
|
481 |
+
}else{
|
482 |
+
$date_year_start = $date_year_end = $year;
|
483 |
+
}
|
484 |
+
$date_start = $date_year_start."-".$date_month_start."-01";
|
485 |
+
$date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
|
486 |
+
$scope = array($date_start,$date_end); //just modify the scope here
|
487 |
+
}
|
488 |
+
//No date requested, so let's look at scope
|
489 |
+
$time = current_time('timestamp');
|
490 |
+
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
491 |
+
$today = strtotime($scope);
|
492 |
+
$tomorrow = $today + 60*60*24-1;
|
493 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
494 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($today,$tomorrow), 'compare' => 'BETWEEN' );
|
495 |
+
}else{
|
496 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<=' );
|
497 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
498 |
+
}
|
499 |
+
}elseif ( is_array($scope) || preg_match( "/^[0-9]{4}-[0-9]{2}-[0-9]{2},[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
500 |
+
if( !is_array($scope) ) $scope = explode(',',$scope);
|
501 |
+
if( !empty($scope[0]) ){
|
502 |
+
$start = strtotime(date('Y-m-d',$scope[0]));
|
503 |
+
$end = !empty($scope[1]) ? strtotime(date('Y-m-t',$scope[1])):$start;
|
504 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
505 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start,$end), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
506 |
+
}else{
|
507 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end, 'compare' => '<=' );
|
508 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start, 'compare' => '>=' );
|
509 |
+
}
|
510 |
+
}
|
511 |
+
}elseif ($scope == "future"){
|
512 |
+
$today = strtotime(date('Y-m-d', $time));
|
513 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
514 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '>=' );
|
515 |
+
}else{
|
516 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
517 |
+
}
|
518 |
+
}elseif ($scope == "past"){
|
519 |
+
$today = strtotime(date('Y-m-d', $time));
|
520 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
521 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '<' );
|
522 |
+
}else{
|
523 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '<' );
|
524 |
+
}
|
525 |
+
}elseif ($scope == "today"){
|
526 |
+
$today = strtotime(date('Y-m-d', $time));
|
527 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
528 |
+
//date must be only today
|
529 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '=');
|
530 |
+
}else{
|
531 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '<=' );
|
532 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
|
533 |
+
}
|
534 |
+
}elseif ($scope == "tomorrow"){
|
535 |
+
$tomorrow = strtotime(date('Y-m-d',$time+60*60*24));
|
536 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
537 |
+
//date must be only tomorrow
|
538 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '=');
|
539 |
+
}else{
|
540 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<=' );
|
541 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $tomorrow, 'compare' => '>=' );
|
542 |
+
}
|
543 |
+
}elseif ($scope == "month"){
|
544 |
+
$start_month = strtotime(date('Y-m-d',$time));
|
545 |
+
$end_month = strtotime(date('Y-m-t',$time));
|
546 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
547 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
548 |
+
}else{
|
549 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
550 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
551 |
+
}
|
552 |
+
}elseif ($scope == "next-month"){
|
553 |
+
$start_month_timestamp = strtotime('+1 month', $time); //get the end of this month + 1 day
|
554 |
+
$start_month = strtotime(date('Y-m-1',$start_month_timestamp));
|
555 |
+
$end_month = strtotime(date('Y-m-t',$start_month_timestamp));
|
556 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
557 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
558 |
+
}else{
|
559 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
560 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
561 |
+
}
|
562 |
+
}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.
|
563 |
+
$months_to_add = $matches[1];
|
564 |
+
$start_month = strtotime(date('Y-m-d',$time));
|
565 |
+
$end_month = strtotime(date('Y-m-t',strtotime("+$months_to_add month", $time)));
|
566 |
+
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
|
567 |
+
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
|
568 |
+
}else{
|
569 |
+
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
|
570 |
+
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
|
571 |
+
}
|
572 |
+
}
|
573 |
+
|
574 |
+
//Filter by Location - can be object, array, or id
|
575 |
+
if ( is_numeric($location) && $location > 0 ) { //Location ID takes precedence
|
576 |
+
$query[] = array( 'key' => '_location_id', 'value' => $location, 'compare' => '=' );
|
577 |
+
}elseif ( self::array_is_numeric($location) ){
|
578 |
+
$query[] = array( 'key' => '_location_id', 'value' => $location, 'compare' => 'IN' );
|
579 |
+
}elseif ( is_object($location) && get_class($location)=='EM_Location' ){ //Now we deal with objects
|
580 |
+
$query[] = array( 'key' => '_location_id', 'value' => $location->location_id, 'compare' => '=' );
|
581 |
+
}elseif ( is_array($location) && @get_class(current($location)=='EM_Location') ){ //we can accept array of ids or EM_Location objects
|
582 |
+
foreach($location as $EM_Location){
|
583 |
+
$location_ids[] = $EM_Location->location_id;
|
584 |
+
}
|
585 |
+
$query[] = array( 'key' => '_location_id', 'value' => $location_ids, 'compare' => 'IN' );
|
586 |
+
}
|
587 |
+
|
588 |
+
//Filter by Event - can be object, array, or id
|
589 |
+
if ( is_numeric($event) && $event > 0 ) { //event ID takes precedence
|
590 |
+
$query[] = array( 'key' => '_event_id', 'value' => $event, 'compare' => '=' );
|
591 |
+
}elseif ( self::array_is_numeric($event) ){ //array of ids
|
592 |
+
$query[] = array( 'key' => '_event_id', 'value' => $event, 'compare' => 'IN' );
|
593 |
+
}elseif ( is_object($event) && get_class($event)=='EM_Event' ){ //Now we deal with objects
|
594 |
+
$query[] = array( 'key' => '_event_id', 'value' => $event->event_id, 'compare' => '=' );
|
595 |
+
}elseif ( is_array($event) && @get_class(current($event)=='EM_Event') ){ //we can accept array of ids or EM_event objects
|
596 |
+
foreach($event as $EM_Event){
|
597 |
+
$event_ids[] = $EM_Event->event_id;
|
598 |
+
}
|
599 |
+
$query[] = array( 'key' => '_event_id', 'value' => $event_ids, 'compare' => 'IN' );
|
600 |
+
}
|
601 |
+
//country lookup
|
602 |
+
if( !empty($args['country']) ){
|
603 |
+
$countries = em_get_countries();
|
604 |
+
//we can accept country codes or names
|
605 |
+
if( in_array($args['country'], $countries) ){
|
606 |
+
//we have a country name,
|
607 |
+
$country = $countries[$args['country']]."'";
|
608 |
+
}elseif( array_key_exists($args['country'], $countries) ){
|
609 |
+
//we have a country code
|
610 |
+
$country = $args['country'];
|
611 |
+
}
|
612 |
+
if(!empty($country)){
|
613 |
+
//get loc ids
|
614 |
+
$ids = $wpdb->get_col("SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key='_location_country' AND meta_value='$country'");
|
615 |
+
$query[] = array( 'key' => '_location_id', 'value' => $ids, 'compare' => 'IN' );
|
616 |
+
}
|
617 |
+
}
|
618 |
+
//state lookup
|
619 |
+
if( !empty($args['state']) ){
|
620 |
+
$ids = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key='_location_country' AND meta_value='%s'", $args['state']));
|
621 |
+
if( is_array($wp_query->query_vars['post__in']) ){
|
622 |
+
//remove values not in this array.
|
623 |
+
$wp_query->query_vars['post__in'] = array_intersect($wp_query->query_vars['post__in'], $ids);
|
624 |
+
}else{
|
625 |
+
$wp_query->query_vars['post__in'] = $ids;
|
626 |
+
}
|
627 |
+
}
|
628 |
+
//state lookup
|
629 |
+
if( !empty($args['town']) ){
|
630 |
+
$ids = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key='_location_town' AND meta_value='%s'", $args['town']));
|
631 |
+
if( is_array($wp_query->query_vars['post__in']) ){
|
632 |
+
//remove values not in this array.
|
633 |
+
$wp_query->query_vars['post__in'] = array_intersect($wp_query->query_vars['post__in'], $ids);
|
634 |
+
}else{
|
635 |
+
$wp_query->query_vars['post__in'] = $ids;
|
636 |
+
}
|
637 |
+
}
|
638 |
+
//region lookup
|
639 |
+
if( !empty($args['region']) ){
|
640 |
+
$ids = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key='_location_region' AND meta_value='%s'", $args['region']));
|
641 |
+
if( is_array($wp_query->query_vars['post__in']) ){
|
642 |
+
//remove values not in this array.
|
643 |
+
$wp_query->query_vars['post__in'] = array_intersect($wp_query->query_vars['post__in'], $ids);
|
644 |
+
}else{
|
645 |
+
$wp_query->query_vars['post__in'] = $ids;
|
646 |
+
}
|
647 |
+
}
|
648 |
+
//Add conditions for category selection
|
649 |
+
//Filter by category, can be id or comma seperated ids
|
650 |
+
//TODO create an exclude category option
|
651 |
+
if ( is_numeric($category) && $category > 0 ){
|
652 |
+
//get the term id directly
|
653 |
+
$term = new EM_Category($category);
|
654 |
+
if( !empty($term->term_id) ){
|
655 |
+
if( EM_MS_GLOBAL ){
|
656 |
+
$event_ids = $wpdb->get_col($wpdb->prepare("SELECT object_id FROM ".EM_META_TABLE." WHERE meta_value=%d AND meta_key='event-category'", $term->term_id));
|
657 |
+
$query[] = array( 'key' => '_event_id', 'value' => $event_ids, 'compare' => 'IN' );
|
658 |
+
}else{
|
659 |
+
if( !is_array($wp_query->query_vars['tax_query']) ) $wp_query->query_vars['tax_query'] = array();
|
660 |
+
$wp_query->query_vars['tax_query'] = array('taxonomy' => EM_TAXONOMY_CATEGORY, 'field'=>'id', 'terms'=>$term->term_id);
|
661 |
+
}
|
662 |
+
}
|
663 |
+
}elseif( self::array_is_numeric($category) ){
|
664 |
+
$term_ids = array();
|
665 |
+
foreach($category as $category_id){
|
666 |
+
$term = new EM_Category($category_id);
|
667 |
+
if( !empty($term->term_id) ){
|
668 |
+
$term_ids[] = $term->term_taxonomy_id;
|
669 |
+
}
|
670 |
+
}
|
671 |
+
if( count($term_ids) > 0 ){
|
672 |
+
if( EM_MS_GLOBAL ){
|
673 |
+
$event_ids = $wpdb->get_col("SELECT object_id FROM ".EM_META_TABLE." WHERE meta_value IN (".implode(',',$term_ids).") AND meta_name='event-category'");
|
674 |
+
$query[] = array( 'key' => '_event_id', 'value' => $event_ids, 'compare' => 'IN' );
|
675 |
+
}else{
|
676 |
+
if( !is_array($wp_query->query_vars['tax_query']) ) $wp_query->query_vars['tax_query'] = array();
|
677 |
+
$wp_query->query_vars['tax_query'] = array('taxonomy' => EM_TAXONOMY_CATEGORY, 'field'=>'id', 'terms'=>$term_ids);
|
678 |
+
}
|
679 |
+
}
|
680 |
+
}
|
681 |
+
//Add conditions for tags
|
682 |
+
//Filter by tag, can be id or comma seperated ids
|
683 |
+
if ( !empty($tag) && !is_array($tag) ){
|
684 |
+
//get the term id directly
|
685 |
+
$term = new EM_Tag($tag);
|
686 |
+
if( !empty($term->term_id) ){
|
687 |
+
if( !is_array($wp_query->query_vars['tax_query']) ) $wp_query->query_vars['tax_query'] = array();
|
688 |
+
$wp_query->query_vars['tax_query'] = array('taxonomy' => EM_TAXONOMY_TAXONOMY, 'field'=>'id', 'terms'=>$term->term_taxonomy_id);
|
689 |
+
}
|
690 |
+
}elseif( is_array($tag) ){
|
691 |
+
$term_ids = array();
|
692 |
+
foreach($tag as $tag_data){
|
693 |
+
$term = new EM_Tag($tag_data);
|
694 |
+
if( !empty($term->term_id) ){
|
695 |
+
$term_ids[] = $term->term_taxonomy_id;
|
696 |
+
}
|
697 |
+
}
|
698 |
+
if( count($term_ids) > 0 ){
|
699 |
+
if( !is_array($wp_query->query_vars['tax_query']) ) $wp_query->query_vars['tax_query'] = array();
|
700 |
+
$wp_query->query_vars['tax_query'] = array('taxonomy' => EM_TAXONOMY_TAXONOMY, 'field'=>'id', 'terms'=>$term_ids);
|
701 |
+
}
|
702 |
+
}
|
703 |
+
|
704 |
+
//If we want rsvped items, we usually check the event
|
705 |
+
if( $bookings == 1 ){
|
706 |
+
$query[] = array( 'key' => '_event_rsvp', 'value' => 1, 'compare' => '=' );
|
707 |
+
}
|
708 |
+
//Default ownership belongs to an event, child objects can just overwrite this if needed.
|
709 |
+
if( is_numeric($owner) ){
|
710 |
+
$wp_query->query_vars['author'] = $owner;
|
711 |
+
}elseif( $owner == 'me' && is_user_logged_in() ){
|
712 |
+
$wp_query->query_vars['author'] = get_current_user_id();
|
713 |
+
}
|
714 |
+
if( !empty($query) && is_array($query) ){
|
715 |
+
$wp_query->query_vars['meta_query'] = $query;
|
716 |
+
}
|
717 |
+
return apply_filters('em_object_build_wp_query_conditions', $wp_query);
|
718 |
+
}
|
719 |
+
|
720 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
721 |
+
//First, ORDER BY
|
722 |
+
$args = apply_filters('em_object_build_sql_orderby_args', $args);
|
723 |
+
$orderby = array();
|
724 |
+
if(is_array($args['orderby'])){
|
725 |
+
//Clean orderby array so we only have accepted values
|
726 |
+
foreach( $args['orderby'] as $key => $field ){
|
727 |
+
if( array_key_exists($field, $accepted_fields) ){
|
728 |
+
$orderby[] = $accepted_fields[$field];
|
729 |
+
}elseif( in_array($field,$accepted_fields) ){
|
730 |
+
$orderby[] = $field;
|
731 |
+
}else{
|
732 |
+
unset($args['orderby'][$key]);
|
733 |
+
}
|
734 |
+
}
|
735 |
+
}elseif( $args['orderby'] != '' && array_key_exists($args['orderby'], $accepted_fields) ){
|
736 |
+
$orderby[] = $accepted_fields[$args['orderby']];
|
737 |
+
}elseif( $args['orderby'] != '' && in_array($args['orderby'], $accepted_fields) ){
|
738 |
+
$orderby[] = $args['orderby'];
|
739 |
+
}
|
740 |
+
//ORDER
|
741 |
+
//If order is an array, we'll go through the orderby array and match the order values (in order of array) with orderby values
|
742 |
+
//If orders don't match up, or it's not ASC/DESC, the default events search in EM settings/options page will be used.
|
743 |
+
foreach($orderby as $i => $field){
|
744 |
+
$orderby[$i] .= ' ';
|
745 |
+
if(is_array($args['order'])){
|
746 |
+
if( in_array($args['order'][$i], array('ASC','DESC')) ){
|
747 |
+
$orderby[$i] .= $args['order'][$i];
|
748 |
+
}else{
|
749 |
+
$orderby[$i] .= $default_order;
|
750 |
+
}
|
751 |
+
}else{
|
752 |
+
$orderby[$i] .= ( in_array($args['order'], array('ASC','DESC')) ) ? $args['order'] : $default_order;
|
753 |
+
}
|
754 |
+
}
|
755 |
+
return apply_filters('em_object_build_sql_orderby', $orderby);
|
756 |
+
}
|
757 |
+
|
758 |
+
/**
|
759 |
+
* Used by "single" objects, e.g. bookings, events, locations to verify if they have the capability to edit this or someone else's object. Relies on the fact that the object has an owner property with id of user (or admin capability must pass).
|
760 |
+
* @param string $owner_capability If the object has an owner property and the user id matches that, this capability will be checked for.
|
761 |
+
* @param string $admin_capability If the user isn't the owner of the object, this capability will be checked for.
|
762 |
+
* @return boolean
|
763 |
+
*/
|
764 |
+
function can_manage( $owner_capability = false, $admin_capability = false, $user_to_check = false ){
|
765 |
+
global $em_capabilities_array;
|
766 |
+
if( $user_to_check ){
|
767 |
+
$user = new WP_User($user_to_check);
|
768 |
+
if( empty($user->ID) ) $user = false;
|
769 |
+
}
|
770 |
+
//if multisite and supoer admin, just return true
|
771 |
+
if( is_multisite() && is_super_admin() ){ return true; }
|
772 |
+
//do they own this?
|
773 |
+
$is_owner = ( (!empty($this->owner) && ($this->owner == get_current_user_id()) || empty($this->id) || (!empty($user) && $this->owner == $user->ID)) );
|
774 |
+
//now check capability
|
775 |
+
$can_manage = false;
|
776 |
+
if( $is_owner && (current_user_can($owner_capability) || (!empty($user) && $user->has_cap($owner_capability))) ){
|
777 |
+
//user owns the object and can therefore manage it
|
778 |
+
$can_manage = true;
|
779 |
+
}elseif( $owner_capability && array_key_exists($owner_capability, $em_capabilities_array) ){
|
780 |
+
//currently user is not able to manage as they aren't the owner
|
781 |
+
$error_msg = $em_capabilities_array[$owner_capability];
|
782 |
+
}
|
783 |
+
//admins have special rights
|
784 |
+
if( !$admin_capability ) $admin_capability = $owner_capability;
|
785 |
+
if( current_user_can($admin_capability) || (!empty($user) && $user->has_cap($admin_capability)) ){
|
786 |
+
$can_manage = true;
|
787 |
+
}elseif( $admin_capability && array_key_exists($admin_capability, $em_capabilities_array) ){
|
788 |
+
$error_msg = $em_capabilities_array[$admin_capability];
|
789 |
+
}
|
790 |
+
|
791 |
+
if( !$can_manage && !$is_owner && !empty($error_msg) ){
|
792 |
+
$this->add_error($error_msg);
|
793 |
+
}
|
794 |
+
return $can_manage;
|
795 |
+
}
|
796 |
+
|
797 |
+
|
798 |
+
function ms_global_switch(){
|
799 |
+
if( EM_MS_GLOBAL && !is_main_site() ){
|
800 |
+
//If in multisite global, then get the main blog categories
|
801 |
+
global $current_site;
|
802 |
+
switch_to_blog($current_site->blog_id);
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
+
function ms_global_switch_back(){
|
807 |
+
if( EM_MS_GLOBAL ){
|
808 |
+
restore_current_blog();
|
809 |
+
}
|
810 |
+
}
|
811 |
+
|
812 |
+
/**
|
813 |
+
* Save an array into this class.
|
814 |
+
* If you provide a record from the
|