Version Description
This fixes some recurrence issues along with most other bugs we've been made aware of.
=
Download this release
Release Info
Developer | netweblogic |
Plugin | Events Manager |
Version | 3.0.3 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.0.3
- admin/bookings.php +4 -4
- admin/event.php +5 -6
- admin/events.php +1 -1
- admin/locations.php +1 -2
- admin/options.php +4 -14
- admin/people.php +12 -12
- ajax.php +6 -19
- bookings.php +5 -6
- classes/bookings.php +1 -1
- classes/calendar.php +16 -8
- classes/event.php +126 -69
- classes/events.php +17 -91
- classes/location.php +20 -16
- classes/locations.php +126 -19
- classes/map.php +7 -5
- classes/object.php +117 -4
- events-manager.php +16 -13
- includes/js/em_admin.js +6 -2
- includes/js/em_calendar_ajax.js +1 -1
- includes/js/em_maps.js +38 -35
- includes/sample-placeholers/event-single.html +5 -2
- install.php +5 -4
- locations.php +4 -1
- readme.txt +34 -129
- rss.php +30 -41
- shortcode.php +24 -12
- template-tags-depreciated.php +1 -14
- widgets/events.php +8 -5
- widgets/locations.php +90 -0
admin/bookings.php
CHANGED
@@ -9,7 +9,7 @@ function dbem_admin_actions_bookings() {
|
|
9 |
global $wpdb;
|
10 |
|
11 |
//DELETE Bookings
|
12 |
-
if( $_POST['secondaryAction'] == 'delete_bookings' ){
|
13 |
if( EM_Object::array_is_numeric($_GET['bookings']) && count($_GET['bookings']) > 0 ){
|
14 |
$bookings = $_GET['bookings'];
|
15 |
$sql = "DELETE FROM ". $wpdb->prefix.BOOKINGS_TBNAME ." WHERE booking_id = ". implode(' OR booking_id = ', $bookings);
|
@@ -46,7 +46,7 @@ function dbem_bookings_table() {
|
|
46 |
</thead>
|
47 |
<tbody>
|
48 |
<?php
|
49 |
-
foreach ($EM_Event->
|
50 |
?>
|
51 |
<tr>
|
52 |
<td><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></td>
|
@@ -62,11 +62,11 @@ function dbem_bookings_table() {
|
|
62 |
<tfoot>
|
63 |
<tr>
|
64 |
<th scope='row' colspan='4'>Booked seats:</th>
|
65 |
-
<td class='booking-result' id='booked-seats'><?php echo $EM_Event->
|
66 |
</tr>
|
67 |
<tr>
|
68 |
<th scope='row' colspan='4'>Available seats:</th>
|
69 |
-
<td class='booking-result' id='available-seats'><?php echo $EM_Event->
|
70 |
</tr>
|
71 |
</tfoot>
|
72 |
</table>
|
9 |
global $wpdb;
|
10 |
|
11 |
//DELETE Bookings
|
12 |
+
if( isset($_POST['secondaryAction']) && $_POST['secondaryAction'] == 'delete_bookings' ){
|
13 |
if( EM_Object::array_is_numeric($_GET['bookings']) && count($_GET['bookings']) > 0 ){
|
14 |
$bookings = $_GET['bookings'];
|
15 |
$sql = "DELETE FROM ". $wpdb->prefix.BOOKINGS_TBNAME ." WHERE booking_id = ". implode(' OR booking_id = ', $bookings);
|
46 |
</thead>
|
47 |
<tbody>
|
48 |
<?php
|
49 |
+
foreach ($EM_Event->get_bookings()->bookings as $EM_Booking) {
|
50 |
?>
|
51 |
<tr>
|
52 |
<td><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></td>
|
62 |
<tfoot>
|
63 |
<tr>
|
64 |
<th scope='row' colspan='4'>Booked seats:</th>
|
65 |
+
<td class='booking-result' id='booked-seats'><?php echo $EM_Event->get_bookings()->get_booked_seats() ?></td>
|
66 |
</tr>
|
67 |
<tr>
|
68 |
<th scope='row' colspan='4'>Available seats:</th>
|
69 |
+
<td class='booking-result' id='available-seats'><?php echo $EM_Event->get_bookings()->get_booked_seats() ?></td>
|
70 |
</tr>
|
71 |
</tfoot>
|
72 |
</table>
|
admin/event.php
CHANGED
@@ -28,7 +28,7 @@ function dbem_event_form( $title ) {
|
|
28 |
if (preg_match ( "/en|sk|zh|us|uk/", $locale_code ))
|
29 |
$hours_locale_regexp = "h:iA";
|
30 |
|
31 |
-
$days_names = array (1 => __ ( 'Mon' ), 2 => __ ( 'Tue' ), 3 => __ ( 'Wed' ), 4 => __ ( 'Thu' ), 5 => __ ( 'Fri' ), 6 => __ ( 'Sat' ),
|
32 |
?>
|
33 |
<form id="eventForm" method="post" action="<?php echo $form_destination; ?>">
|
34 |
<div class="wrap">
|
@@ -176,11 +176,10 @@ function dbem_event_form( $title ) {
|
|
176 |
<!-- START RSVP Stats -->
|
177 |
<?php
|
178 |
if ($EM_Event->rsvp ) {
|
179 |
-
$EM_Event->get_bookings();
|
180 |
-
$
|
181 |
-
$booked_seats = $EM_Event->bookings->get_booked_seats();
|
182 |
|
183 |
-
if ( count($EM_Event->
|
184 |
?>
|
185 |
<div class='wrap'>
|
186 |
<h4><?php echo $booked_seats ?> <?php echo __('responses so far') ?></h4>
|
@@ -201,7 +200,7 @@ function dbem_event_form( $title ) {
|
|
201 |
</tfoot>
|
202 |
<tbody>
|
203 |
<?php
|
204 |
-
foreach ($EM_Event->
|
205 |
?>
|
206 |
<tr id='booking-<?php echo $EM_Booking->id ?>'>
|
207 |
<td>
|
28 |
if (preg_match ( "/en|sk|zh|us|uk/", $locale_code ))
|
29 |
$hours_locale_regexp = "h:iA";
|
30 |
|
31 |
+
$days_names = array (1 => __ ( 'Mon' ), 2 => __ ( 'Tue' ), 3 => __ ( 'Wed' ), 4 => __ ( 'Thu' ), 5 => __ ( 'Fri' ), 6 => __ ( 'Sat' ), 0 => __ ( 'Sun' ) );
|
32 |
?>
|
33 |
<form id="eventForm" method="post" action="<?php echo $form_destination; ?>">
|
34 |
<div class="wrap">
|
176 |
<!-- START RSVP Stats -->
|
177 |
<?php
|
178 |
if ($EM_Event->rsvp ) {
|
179 |
+
$available_seats = $EM_Event->get_bookings()->get_available_seats();
|
180 |
+
$booked_seats = $EM_Event->get_bookings()->get_booked_seats();
|
|
|
181 |
|
182 |
+
if ( count($EM_Event->get_bookings()->bookings) > 0 ) {
|
183 |
?>
|
184 |
<div class='wrap'>
|
185 |
<h4><?php echo $booked_seats ?> <?php echo __('responses so far') ?></h4>
|
200 |
</tfoot>
|
201 |
<tbody>
|
202 |
<?php
|
203 |
+
foreach ($EM_Event->get_bookings()->bookings as $EM_Booking) {
|
204 |
?>
|
205 |
<tr id='booking-<?php echo $EM_Booking->id ?>'>
|
206 |
<td>
|
admin/events.php
CHANGED
@@ -22,7 +22,7 @@ function dbem_events_subpanel() {
|
|
22 |
$event_table_name = $wpdb->prefix . EVENTS_TBNAME;
|
23 |
|
24 |
// DELETE action
|
25 |
-
if ($action == 'deleteEvents') {
|
26 |
EM_Events::delete( $selectedEvents );
|
27 |
dbem_events_table ( EM_Events::get( array('scope'=>$scope) ), "Future events" );
|
28 |
}
|
22 |
$event_table_name = $wpdb->prefix . EVENTS_TBNAME;
|
23 |
|
24 |
// DELETE action
|
25 |
+
if ( $action == 'deleteEvents' && EM_Object::array_is_numeric($selectedEvents) ) {
|
26 |
EM_Events::delete( $selectedEvents );
|
27 |
dbem_events_table ( EM_Events::get( array('scope'=>$scope) ), "Future events" );
|
28 |
}
|
admin/locations.php
CHANGED
@@ -34,7 +34,6 @@ function dbem_locations_page() {
|
|
34 |
if ( $validation_result ) {
|
35 |
$EM_Location->save();
|
36 |
$message = __('The location has been updated.', 'dbem');
|
37 |
-
$locations = EM_Locations::get();
|
38 |
dbem_admin_locations($message);
|
39 |
} else {
|
40 |
?>
|
@@ -120,7 +119,7 @@ function dbem_admin_locations($message='', $fill_fields = false) {
|
|
120 |
<td><input type='checkbox' class ='row-selector' value='<?php echo $location->id ?>' name='locations[]'/></td>
|
121 |
<td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=locations&action=edit&location_id=<?php echo $location->id ?>'><?php echo $location->name ?></a></td>
|
122 |
<td><?php echo $location->address ?></td>
|
123 |
-
<td><?php echo $location->
|
124 |
</tr>
|
125 |
<?php endforeach; ?>
|
126 |
</tbody>
|
34 |
if ( $validation_result ) {
|
35 |
$EM_Location->save();
|
36 |
$message = __('The location has been updated.', 'dbem');
|
|
|
37 |
dbem_admin_locations($message);
|
38 |
} else {
|
39 |
?>
|
119 |
<td><input type='checkbox' class ='row-selector' value='<?php echo $location->id ?>' name='locations[]'/></td>
|
120 |
<td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=locations&action=edit&location_id=<?php echo $location->id ?>'><?php echo $location->name ?></a></td>
|
121 |
<td><?php echo $location->address ?></td>
|
122 |
+
<td><?php echo $location->town ?></td>
|
123 |
</tr>
|
124 |
<?php endforeach; ?>
|
125 |
</tbody>
|
admin/options.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
// Function composing the options subpanel
|
3 |
function em_options_save(){
|
4 |
-
if( current_user_can('activate_plugins')
|
5 |
//Build the array of options here
|
6 |
foreach ($_POST as $postKey => $postValue){
|
7 |
if( substr($postKey, 0, 5) == 'dbem_' ){
|
@@ -17,17 +17,7 @@ function em_options_save(){
|
|
17 |
<?php
|
18 |
}
|
19 |
add_action ( 'admin_notices', 'em_options_saved_notice' );
|
20 |
-
}
|
21 |
-
if( current_user_can('activate_plugins') and $_GET['revert-to2'] == '1' ){
|
22 |
-
update_option('dbem_version',2);
|
23 |
-
function em_reverted_to2(){
|
24 |
-
?>
|
25 |
-
<div class="updated"><p><strong><?php _e('Succesfully reverted to 2. Now deactivate Events Manager and replace it with versione 2.2.'); ?></strong></p></div>
|
26 |
-
<?php
|
27 |
-
}
|
28 |
-
add_action ( 'admin_notices', 'em_reverted_to2' );
|
29 |
-
|
30 |
-
}
|
31 |
}
|
32 |
add_action('admin_head', 'em_options_save');
|
33 |
|
@@ -94,11 +84,11 @@ function dbem_options_subpanel() {
|
|
94 |
$em_disable_filter = true;
|
95 |
$get_pages = get_pages();
|
96 |
$events_page_options = array();
|
|
|
97 |
//TODO Add the hierarchy style ddm, like when choosing page parents
|
98 |
foreach($get_pages as $page){
|
99 |
$events_page_options[$page->ID] = $page->post_title;
|
100 |
-
}
|
101 |
-
$events_page_options[0] = __('No Events Page');
|
102 |
dbem_options_select ( __( 'Events page' ), 'dbem_events_page', $events_page_options, __( 'This option allows you to select which page to use as an events page','dbem' ) );
|
103 |
$em_disable_filter = false;
|
104 |
//Rest
|
1 |
<?php
|
2 |
// Function composing the options subpanel
|
3 |
function em_options_save(){
|
4 |
+
if( current_user_can('activate_plugins') && !empty($_POST['em-submitted']) ){
|
5 |
//Build the array of options here
|
6 |
foreach ($_POST as $postKey => $postValue){
|
7 |
if( substr($postKey, 0, 5) == 'dbem_' ){
|
17 |
<?php
|
18 |
}
|
19 |
add_action ( 'admin_notices', 'em_options_saved_notice' );
|
20 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
add_action('admin_head', 'em_options_save');
|
23 |
|
84 |
$em_disable_filter = true;
|
85 |
$get_pages = get_pages();
|
86 |
$events_page_options = array();
|
87 |
+
$events_page_options[0] = __('[No Events Page]');
|
88 |
//TODO Add the hierarchy style ddm, like when choosing page parents
|
89 |
foreach($get_pages as $page){
|
90 |
$events_page_options[$page->ID] = $page->post_title;
|
91 |
+
}
|
|
|
92 |
dbem_options_select ( __( 'Events page' ), 'dbem_events_page', $events_page_options, __( 'This option allows you to select which page to use as an events page','dbem' ) );
|
93 |
$em_disable_filter = false;
|
94 |
//Rest
|
admin/people.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
function
|
3 |
// Managing AJAX booking removal
|
4 |
if(isset($_GET['action']) && $_GET['action'] == 'remove_booking') {
|
5 |
if(isset($_POST['booking_id'])){
|
@@ -9,14 +9,14 @@ function dbem_people_page() {
|
|
9 |
}
|
10 |
?>
|
11 |
<div class='wrap'>
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
</div>
|
16 |
<?php
|
17 |
}
|
18 |
|
19 |
-
function
|
20 |
global $EM_Event;
|
21 |
if(isset($_GET['action']) && $_GET['action'] == 'printable' && is_object($EM_Event)){
|
22 |
?>
|
@@ -42,7 +42,7 @@ function dbem_printable_booking_report() {
|
|
42 |
<th scope='col'><?php _e('Seats', 'dbem')?></th>
|
43 |
<th scope='col'><?php _e('Comment', 'dbem')?></th>
|
44 |
</tr>
|
45 |
-
<?php foreach($EM_Event->
|
46 |
<tr>
|
47 |
|
48 |
<td><?php echo $EM_Booking->person->name ?></td>
|
@@ -55,12 +55,12 @@ function dbem_printable_booking_report() {
|
|
55 |
<tr id='booked-seats'>
|
56 |
<td colspan='3'> </td>
|
57 |
<td class='total-label'><?php _e('Booked', 'dbem')?>:</td>
|
58 |
-
<td class='seats-number'><?php echo $EM_Event->
|
59 |
</tr>
|
60 |
<tr id='available-seats'>
|
61 |
<td colspan='3'> </td>
|
62 |
<td class='total-label'><?php _e('Available', 'dbem')?>:</td>
|
63 |
-
<td class='seats-number'><?php echo $EM_Event->
|
64 |
</tr>
|
65 |
</table>
|
66 |
</div>
|
@@ -70,9 +70,9 @@ function dbem_printable_booking_report() {
|
|
70 |
die();
|
71 |
}
|
72 |
}
|
73 |
-
add_action('init', '
|
74 |
|
75 |
-
function
|
76 |
$EM_People = EM_People::get();
|
77 |
if (count($EM_People) < 1 ) {
|
78 |
_e("No people have responded to your events yet!", 'dbem');
|
@@ -114,10 +114,10 @@ function dbem_people_table() {
|
|
114 |
* @param $array
|
115 |
* @return array
|
116 |
*/
|
117 |
-
function
|
118 |
$array['dbem_phone'] = __('Phone','dbem') . ' <span class="description">('. __('Events Manager','dbem') .')</span>';
|
119 |
return $array;
|
120 |
}
|
121 |
-
add_filter( 'user_contactmethods' , '
|
122 |
|
123 |
?>
|
1 |
<?php
|
2 |
+
function em_people_page() {
|
3 |
// Managing AJAX booking removal
|
4 |
if(isset($_GET['action']) && $_GET['action'] == 'remove_booking') {
|
5 |
if(isset($_POST['booking_id'])){
|
9 |
}
|
10 |
?>
|
11 |
<div class='wrap'>
|
12 |
+
<div id="icon-users" class="icon32"><br/></div>
|
13 |
+
<h2>People</h2>
|
14 |
+
<?php em_people_table(); ?>
|
15 |
</div>
|
16 |
<?php
|
17 |
}
|
18 |
|
19 |
+
function em_printable_booking_report() {
|
20 |
global $EM_Event;
|
21 |
if(isset($_GET['action']) && $_GET['action'] == 'printable' && is_object($EM_Event)){
|
22 |
?>
|
42 |
<th scope='col'><?php _e('Seats', 'dbem')?></th>
|
43 |
<th scope='col'><?php _e('Comment', 'dbem')?></th>
|
44 |
</tr>
|
45 |
+
<?php foreach($EM_Event->get_bookings()->bookings as $EM_Booking) { ?>
|
46 |
<tr>
|
47 |
|
48 |
<td><?php echo $EM_Booking->person->name ?></td>
|
55 |
<tr id='booked-seats'>
|
56 |
<td colspan='3'> </td>
|
57 |
<td class='total-label'><?php _e('Booked', 'dbem')?>:</td>
|
58 |
+
<td class='seats-number'><?php echo $EM_Event->get_bookings()->get_booked_seats(); ?></td>
|
59 |
</tr>
|
60 |
<tr id='available-seats'>
|
61 |
<td colspan='3'> </td>
|
62 |
<td class='total-label'><?php _e('Available', 'dbem')?>:</td>
|
63 |
+
<td class='seats-number'><?php echo $EM_Event->get_bookings()->get_available_seats(); ?></td>
|
64 |
</tr>
|
65 |
</table>
|
66 |
</div>
|
70 |
die();
|
71 |
}
|
72 |
}
|
73 |
+
add_action('init', 'em_printable_booking_report');
|
74 |
|
75 |
+
function em_people_table() {
|
76 |
$EM_People = EM_People::get();
|
77 |
if (count($EM_People) < 1 ) {
|
78 |
_e("No people have responded to your events yet!", 'dbem');
|
114 |
* @param $array
|
115 |
* @return array
|
116 |
*/
|
117 |
+
function em_contact_methods($array){
|
118 |
$array['dbem_phone'] = __('Phone','dbem') . ' <span class="description">('. __('Events Manager','dbem') .')</span>';
|
119 |
return $array;
|
120 |
}
|
121 |
+
add_filter( 'user_contactmethods' , 'em_contact_methods' , 10 , 1 );
|
122 |
|
123 |
?>
|
ajax.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
//AJAX function
|
3 |
function em_ajax_actions() {
|
4 |
-
//Clean this up.... use a uniformed way of calling EM Ajax actions
|
5 |
if(isset($_REQUEST['dbem_ajax_action']) && $_REQUEST['dbem_ajax_action'] == 'booking_data') {
|
6 |
if(isset($_REQUEST['id'])){
|
7 |
$EM_Event = new EM_Event($_REQUEST['id']);
|
8 |
-
echo "[ {bookedSeats:".$EM_Event->
|
9 |
}
|
10 |
-
die();
|
11 |
}
|
12 |
if(isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
|
13 |
if(isset($_REQUEST['id'])){
|
@@ -18,8 +18,8 @@ function em_ajax_actions() {
|
|
18 |
}
|
19 |
die();
|
20 |
}
|
21 |
-
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
|
22 |
-
$locations = EM_Locations::get(
|
23 |
$json_locations = array();
|
24 |
foreach($locations as $location_key => $location) {
|
25 |
$json_locations[$location_key] = $location->to_array();
|
@@ -31,20 +31,7 @@ function em_ajax_actions() {
|
|
31 |
|
32 |
if(isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
|
33 |
//FIXME if long events enabled originally, this won't show up on ajax call
|
34 |
-
|
35 |
-
if( isset($_REQUEST['full']) && $_REQUEST['full'] == 1 ) {
|
36 |
-
$args['full'] = 1;
|
37 |
-
}
|
38 |
-
if( isset($_REQUEST['longevents']) && $_REQUEST['longevents'] ) {
|
39 |
-
$args['long_events'] = 1;
|
40 |
-
}
|
41 |
-
if( isset($_REQUEST['calmonth']) ) {
|
42 |
-
$args['month'] = $_REQUEST['calmonth'];
|
43 |
-
}
|
44 |
-
if( isset($_REQUEST['calyear']) ) {
|
45 |
-
$args['year'] = $_REQUEST['calyear'];
|
46 |
-
}
|
47 |
-
echo EM_Calendar::get($args);
|
48 |
die();
|
49 |
}
|
50 |
}
|
1 |
<?php
|
2 |
//AJAX function
|
3 |
function em_ajax_actions() {
|
4 |
+
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
|
5 |
if(isset($_REQUEST['dbem_ajax_action']) && $_REQUEST['dbem_ajax_action'] == 'booking_data') {
|
6 |
if(isset($_REQUEST['id'])){
|
7 |
$EM_Event = new EM_Event($_REQUEST['id']);
|
8 |
+
echo "[ {bookedSeats:".$EM_Event->get_bookings()->get_booked_seats().", availableSeats:".$EM_Event->get_bookings()->get_available_seats()."}]";
|
9 |
}
|
10 |
+
die();
|
11 |
}
|
12 |
if(isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
|
13 |
if(isset($_REQUEST['id'])){
|
18 |
}
|
19 |
die();
|
20 |
}
|
21 |
+
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
|
22 |
+
$locations = EM_Locations::get( $_REQUEST );
|
23 |
$json_locations = array();
|
24 |
foreach($locations as $location_key => $location) {
|
25 |
$json_locations[$location_key] = $location->to_array();
|
31 |
|
32 |
if(isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
|
33 |
//FIXME if long events enabled originally, this won't show up on ajax call
|
34 |
+
echo EM_Calendar::get($_REQUEST);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
die();
|
36 |
}
|
37 |
}
|
bookings.php
CHANGED
@@ -17,20 +17,19 @@ function em_actions_bookings() {
|
|
17 |
if( @get_class($EM_Event) == 'EM_Event' ){
|
18 |
//ADD/EDIT Booking
|
19 |
if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'add_booking') {
|
20 |
-
|
21 |
-
if( $EM_Event->
|
22 |
-
$dbem_form_messages_booking_add['success'] = $EM_Event->
|
23 |
}else{
|
24 |
-
$dbem_form_messages_booking_add['error'] = implode('<br />', $EM_Event->
|
25 |
}
|
26 |
}
|
27 |
//DELETE Booking
|
28 |
if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'delete_booking') {
|
29 |
-
$EM_Event->get_bookings();
|
30 |
$EM_Person = new EM_Person();
|
31 |
if( $EM_Person->get(array('person_name' => $_POST['person_name'], 'person_email' => $_POST['person_email'])) ){
|
32 |
$deleted = 0;
|
33 |
-
foreach($EM_Event->
|
34 |
if($EM_Booking->person->id == $EM_Person->id ){
|
35 |
$EM_Booking->delete();
|
36 |
$deleted++;
|
17 |
if( @get_class($EM_Event) == 'EM_Event' ){
|
18 |
//ADD/EDIT Booking
|
19 |
if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'add_booking') {
|
20 |
+
//$EM_Event->get_bookings();
|
21 |
+
if( $EM_Event->get_bookings()->add( new EM_Booking($_POST) ) ){
|
22 |
+
$dbem_form_messages_booking_add['success'] = $EM_Event->get_bookings()->feedback_message;
|
23 |
}else{
|
24 |
+
$dbem_form_messages_booking_add['error'] = implode('<br />', $EM_Event->get_bookings()->errors);
|
25 |
}
|
26 |
}
|
27 |
//DELETE Booking
|
28 |
if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'delete_booking') {
|
|
|
29 |
$EM_Person = new EM_Person();
|
30 |
if( $EM_Person->get(array('person_name' => $_POST['person_name'], 'person_email' => $_POST['person_email'])) ){
|
31 |
$deleted = 0;
|
32 |
+
foreach($EM_Event->get_bookings()->get_bookings() as $EM_Booking){
|
33 |
if($EM_Booking->person->id == $EM_Person->id ){
|
34 |
$EM_Booking->delete();
|
35 |
$deleted++;
|
classes/bookings.php
CHANGED
@@ -94,7 +94,7 @@ class EM_Bookings extends EM_Object{
|
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
-
* Delete
|
98 |
* @return boolean
|
99 |
*/
|
100 |
function delete(){
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
+
* Delete bookings on this id
|
98 |
* @return boolean
|
99 |
*/
|
100 |
function delete(){
|
classes/calendar.php
CHANGED
@@ -10,7 +10,7 @@ class EM_Calendar extends EM_Object {
|
|
10 |
$full = $args['full']; //For ZDE, don't delete pls
|
11 |
$month = $args['month'];
|
12 |
$year = $args['year'];
|
13 |
-
$long_events =
|
14 |
|
15 |
$week_starts_on_sunday = get_option('dbem_week_starts_sunday');
|
16 |
$start_of_week = get_option('start_of_week');
|
@@ -128,7 +128,7 @@ class EM_Calendar extends EM_Object {
|
|
128 |
$back_year = $year;
|
129 |
}
|
130 |
$full ? $link_extra_class = "full-link" : $link_extra_class = '';
|
131 |
-
$previous_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&
|
132 |
|
133 |
if($month == 12){
|
134 |
$next_month = 1;
|
@@ -137,7 +137,7 @@ class EM_Calendar extends EM_Object {
|
|
137 |
$next_month = $month + 1;
|
138 |
$next_year = $year;
|
139 |
}
|
140 |
-
$next_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&
|
141 |
$class = ($full) ? 'dbem-calendar-full' : 'dbem-calendar';
|
142 |
$calendar="<div class='$class'><div style='display:none' class='month_n'>$month</div><div class='year_n' style='display:none' >$year</div>";
|
143 |
|
@@ -212,8 +212,9 @@ class EM_Calendar extends EM_Object {
|
|
212 |
$year_pre=$year;
|
213 |
$year_post=$year;
|
214 |
}
|
215 |
-
|
216 |
-
$
|
|
|
217 |
|
218 |
$eventful_days= array();
|
219 |
if($events){
|
@@ -291,7 +292,7 @@ class EM_Calendar extends EM_Object {
|
|
291 |
}
|
292 |
}
|
293 |
}
|
294 |
-
return
|
295 |
}
|
296 |
|
297 |
/**
|
@@ -316,8 +317,15 @@ class EM_Calendar extends EM_Object {
|
|
316 |
}
|
317 |
|
318 |
function get_default_search($array=array()){
|
319 |
-
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
}
|
322 |
}
|
323 |
add_action('init', array('EM_Calendar', 'init'));
|
10 |
$full = $args['full']; //For ZDE, don't delete pls
|
11 |
$month = $args['month'];
|
12 |
$year = $args['year'];
|
13 |
+
$long_events = $args['long_events'];
|
14 |
|
15 |
$week_starts_on_sunday = get_option('dbem_week_starts_sunday');
|
16 |
$start_of_week = get_option('start_of_week');
|
128 |
$back_year = $year;
|
129 |
}
|
130 |
$full ? $link_extra_class = "full-link" : $link_extra_class = '';
|
131 |
+
$previous_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&month={$back_month}&year={$back_year}&long_events={$long_events}&full={$full}'><<</a>";
|
132 |
|
133 |
if($month == 12){
|
134 |
$next_month = 1;
|
137 |
$next_month = $month + 1;
|
138 |
$next_year = $year;
|
139 |
}
|
140 |
+
$next_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&month={$next_month}&year={$next_year}&long_events={$long_events}&full={$full}'>>></a>";
|
141 |
$class = ($full) ? 'dbem-calendar-full' : 'dbem-calendar';
|
142 |
$calendar="<div class='$class'><div style='display:none' class='month_n'>$month</div><div class='year_n' style='display:none' >$year</div>";
|
143 |
|
212 |
$year_pre=$year;
|
213 |
$year_post=$year;
|
214 |
}
|
215 |
+
$args['year'] = array($year_pre, $year_post);
|
216 |
+
$args['month'] = array($month_pre, $month_post);
|
217 |
+
$events = EM_Events::get($args);
|
218 |
|
219 |
$eventful_days= array();
|
220 |
if($events){
|
292 |
}
|
293 |
}
|
294 |
}
|
295 |
+
return '<div id="em-calendar-'.rand(100,200).'" class="em-calendar-wrapper">'.$calendar.'</div>';
|
296 |
}
|
297 |
|
298 |
/**
|
317 |
}
|
318 |
|
319 |
function get_default_search($array=array()){
|
320 |
+
//These defaults aren't for db queries, but flags for what to display in calendar output
|
321 |
+
$defaults = array(
|
322 |
+
'full' => 0, //Will display a full calendar with event names
|
323 |
+
'long_events' => 0, //Events that last longer than a day
|
324 |
+
);
|
325 |
+
$atts = parent::get_default_search($defaults, $array);
|
326 |
+
$atts['full'] = ($atts['full']==true) ? 1:0;
|
327 |
+
$atts['long_events'] = ($atts['long_events']==true) ? 1:0;
|
328 |
+
return $atts;
|
329 |
}
|
330 |
}
|
331 |
add_action('init', array('EM_Calendar', 'init'));
|
classes/event.php
CHANGED
@@ -33,10 +33,10 @@ class EM_Event extends EM_Object{
|
|
33 |
'event_category_id' => array( 'name'=>'category_id', 'type'=>'%d' ),
|
34 |
'event_attributes' => array( 'name'=>'attributes', 'type'=>'%s' ),
|
35 |
'recurrence' => array( 'name'=>'recurrence', 'type'=>'%d' ),
|
36 |
-
'recurrence_interval' => array( 'name'=>'interval', 'type'=>'%d' ),
|
37 |
-
'recurrence_freq' => array( 'name'=>'freq', 'type'=>'%s' ),
|
38 |
-
'recurrence_byday' => array( 'name'=>'byday', 'type'=>'%s' ),
|
39 |
-
'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d' )
|
40 |
);
|
41 |
|
42 |
/**
|
@@ -98,9 +98,11 @@ class EM_Event extends EM_Object{
|
|
98 |
$this->location = new EM_Location ( $event );
|
99 |
}
|
100 |
//Sort out attributes
|
101 |
-
$event
|
102 |
-
$event
|
|
|
103 |
$this->to_object($event, true);
|
|
|
104 |
//Add Contact Person
|
105 |
if($this->contactperson_id){
|
106 |
if($this->contactperson_id > 0){
|
@@ -112,7 +114,7 @@ class EM_Event extends EM_Object{
|
|
112 |
$this->contact = get_userdata($this->contactperson_id);
|
113 |
}
|
114 |
if( is_object($this->contact) ){
|
115 |
-
$this->contact->phone =
|
116 |
}
|
117 |
//Now, if this is a recurrence, get the recurring for caching to the $EM_Recurrences
|
118 |
if( $this->is_recurrence() && !array_key_exists($this->recurrence_id, $EM_Recurrences) ){
|
@@ -170,8 +172,12 @@ class EM_Event extends EM_Object{
|
|
170 |
$this->recurrence_id = ( is_numeric($_POST ['recurrence_id']) ) ? $_POST ['recurrence_id'] : 0 ;
|
171 |
if($_POST ['repeated_event']){
|
172 |
$this->recurrence = 1;
|
173 |
-
$this->freq = $_POST ['recurrence_freq'];
|
174 |
-
|
|
|
|
|
|
|
|
|
175 |
$this->interval = ($_POST ['recurrence_interval'] == "") ? 1 : $_POST ['recurrence_interval'];
|
176 |
$this->byweekno = $_POST ['recurrence_byweekno'];
|
177 |
}
|
@@ -277,8 +283,10 @@ class EM_Event extends EM_Object{
|
|
277 |
//Delete the recurrences then this recurrence event
|
278 |
$this->delete_events();
|
279 |
}
|
280 |
-
$bookings_result = $this->delete_bookings();
|
281 |
$result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". $wpdb->prefix . EVENTS_TBNAME ." WHERE event_id=%d", $this->id) );
|
|
|
|
|
|
|
282 |
}
|
283 |
|
284 |
/**
|
@@ -343,7 +351,7 @@ class EM_Event extends EM_Object{
|
|
343 |
}
|
344 |
|
345 |
/**
|
346 |
-
* Shortcut function for $this->
|
347 |
*/
|
348 |
function delete_bookings(){
|
349 |
global $wpdb;
|
@@ -454,9 +462,8 @@ class EM_Event extends EM_Object{
|
|
454 |
}
|
455 |
if (preg_match('/#_AVAILABLESEATS/', $result)) {
|
456 |
$rsvp_is_active = get_option('dbem_rsvp_enabled');
|
457 |
-
$this->get_bookings();
|
458 |
if ($this->rsvp) {
|
459 |
-
$availble_seats = $this->
|
460 |
} else {
|
461 |
$availble_seats = "0";
|
462 |
}
|
@@ -525,7 +532,7 @@ class EM_Event extends EM_Object{
|
|
525 |
$event_string = str_replace($result, dbem_ascii_encode($this->contact->user_email), $event_string );
|
526 |
}
|
527 |
if (preg_match('/#_CONTACTPHONE$/', $result)) {
|
528 |
-
|
529 |
$event_string = str_replace($result, $phone, $event_string );
|
530 |
}
|
531 |
|
@@ -615,6 +622,7 @@ class EM_Event extends EM_Object{
|
|
615 |
$event['event_start_date'] = date("Y-m-d", $day);
|
616 |
$event['event_end_date'] = $event['event_start_date'];
|
617 |
$event_saves[] = $wpdb->insert($wpdb->prefix.EVENTS_TBNAME, $event, $this->get_types($event));
|
|
|
618 |
if( DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
|
619 |
}
|
620 |
return !in_array(false, $event_saves);
|
@@ -629,7 +637,15 @@ class EM_Event extends EM_Object{
|
|
629 |
*/
|
630 |
function delete_events(){
|
631 |
global $wpdb;
|
632 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
633 |
}
|
634 |
|
635 |
/**
|
@@ -658,67 +674,108 @@ class EM_Event extends EM_Object{
|
|
658 |
}
|
659 |
|
660 |
/**
|
661 |
-
* Returns the days that match the recurrance array passed
|
662 |
* @param array $recurrence
|
663 |
* @return array
|
664 |
*/
|
665 |
function get_recurrence_days(){
|
666 |
if( $this->is_recurring() ){
|
667 |
-
$start_date = mktime(0, 0, 0, substr($this->start_date,5,2), substr($this->start_date,8,2), substr($this->start_date,0,4));
|
668 |
-
$end_date = mktime(0, 0, 0, substr($this->end_date,5,2), substr($this->end_date,8,2), substr($this->end_date,0,4));
|
669 |
-
|
670 |
-
$last_week_start = array(25, 22, 25, 24, 25, 24, 25, 25, 24, 25, 24, 25);
|
671 |
-
$weekdays = explode(",", $this->byday);
|
672 |
|
673 |
-
$
|
674 |
-
$
|
675 |
-
$counter = 0;
|
676 |
-
$cycle_date = $start_date;
|
677 |
-
$matching_days = array();
|
678 |
-
$aDay = 86400; // a day in seconds
|
679 |
-
|
680 |
-
|
681 |
-
while (date("d-M-Y", $cycle_date) != date('d-M-Y', $end_date + $aDay)) {
|
682 |
-
//echo (date("d-M-Y", $cycle_date));
|
683 |
-
$style = "";
|
684 |
-
$monthweek = floor(((date("d", $cycle_date)-1)/7))+1;
|
685 |
-
if($this->freq == 'daily') {
|
686 |
-
|
687 |
-
if($counter % $this->interval == 0 )
|
688 |
-
array_push($matching_days, $cycle_date);
|
689 |
-
$counter++;
|
690 |
-
}
|
691 |
-
$weekday_num = date("w", $cycle_date); if ($weekday_num == 0) { $weekday_num = 7; }
|
692 |
-
if (in_array( $weekday_num, $weekdays )) {
|
693 |
-
$monthday = date("j", $cycle_date);
|
694 |
-
$month = date("n", $cycle_date);
|
695 |
-
|
696 |
-
if($this->freq == 'weekly') {
|
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 |
|
@@ -731,7 +788,7 @@ class EM_Event extends EM_Object{
|
|
731 |
global $EM_Recurrences;
|
732 |
if( $this->is_individual() ) return false;
|
733 |
$recurrence = $EM_Recurrences[$this->recurrence_id]->to_array();
|
734 |
-
$weekdays_name = array(__('Monday'),__('Tuesday'),__('Wednesday'),__('Thursday'),__('Friday'),__('Saturday')
|
735 |
$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'));
|
736 |
$output = sprintf (__('From %1$s to %2$s', 'dbem'), $recurrence['event_start_date'], $recurrence['event_end_date']).", ";
|
737 |
if ($recurrence['recurrence_freq'] == 'daily') {
|
@@ -745,7 +802,7 @@ class EM_Event extends EM_Object{
|
|
745 |
$weekday_array = explode(",", $recurrence['recurrence_byday']);
|
746 |
$natural_days = array();
|
747 |
foreach($weekday_array as $day)
|
748 |
-
array_push($natural_days, $weekdays_name[$day
|
749 |
$output .= implode(" and ", $natural_days);
|
750 |
if ($recurrence['recurrence_interval'] > 1 ) {
|
751 |
$freq_desc = ", ".sprintf (__("every %s weeks", 'dbem'), $recurrence['recurrence_interval']);
|
33 |
'event_category_id' => array( 'name'=>'category_id', 'type'=>'%d' ),
|
34 |
'event_attributes' => array( 'name'=>'attributes', 'type'=>'%s' ),
|
35 |
'recurrence' => array( 'name'=>'recurrence', 'type'=>'%d' ),
|
36 |
+
'recurrence_interval' => array( 'name'=>'interval', 'type'=>'%d' ), //every x day(s)/week(s)/month(s)
|
37 |
+
'recurrence_freq' => array( 'name'=>'freq', 'type'=>'%s' ), //daily,weekly,monthly?
|
38 |
+
'recurrence_byday' => array( 'name'=>'byday', 'type'=>'%s' ), //if weekly or monthly, what days of the week?
|
39 |
+
'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d' ) //if monthly which week (-1 is last)
|
40 |
);
|
41 |
|
42 |
/**
|
98 |
$this->location = new EM_Location ( $event );
|
99 |
}
|
100 |
//Sort out attributes
|
101 |
+
$event['event_attributes'] = @unserialize($event ['event_attributes']);
|
102 |
+
$event['event_attributes'] = (!is_array($event ['event_attributes'])) ? array() : $event ['event_attributes'] ;
|
103 |
+
$event['recurrence_byday'] = ( $event['recurrence_byday'] == 7 ) ? 0:$event['recurrence_byday']; //Backward compatibility (since 3.0.3), using 0 makes more sense due to date() function
|
104 |
$this->to_object($event, true);
|
105 |
+
|
106 |
//Add Contact Person
|
107 |
if($this->contactperson_id){
|
108 |
if($this->contactperson_id > 0){
|
114 |
$this->contact = get_userdata($this->contactperson_id);
|
115 |
}
|
116 |
if( is_object($this->contact) ){
|
117 |
+
$this->contact->phone = get_metadata('user', $this->contact->ID, 'dbem_phone', true);
|
118 |
}
|
119 |
//Now, if this is a recurrence, get the recurring for caching to the $EM_Recurrences
|
120 |
if( $this->is_recurrence() && !array_key_exists($this->recurrence_id, $EM_Recurrences) ){
|
172 |
$this->recurrence_id = ( is_numeric($_POST ['recurrence_id']) ) ? $_POST ['recurrence_id'] : 0 ;
|
173 |
if($_POST ['repeated_event']){
|
174 |
$this->recurrence = 1;
|
175 |
+
$this->freq = in_array($_POST['recurrence_freq'], array('daily','weekly','monthly')) ? $_POST['recurrence_freq']:'daily';
|
176 |
+
if($this->freq == 'weekly' && self::array_is_numeric($_POST ['recurrence_bydays'])){
|
177 |
+
$this->byday = implode ( ",", $_POST ['recurrence_bydays'] );
|
178 |
+
}elseif($this->freq == 'monthly'){
|
179 |
+
$this->byday = $_POST ['recurrence_byday'];
|
180 |
+
}
|
181 |
$this->interval = ($_POST ['recurrence_interval'] == "") ? 1 : $_POST ['recurrence_interval'];
|
182 |
$this->byweekno = $_POST ['recurrence_byweekno'];
|
183 |
}
|
283 |
//Delete the recurrences then this recurrence event
|
284 |
$this->delete_events();
|
285 |
}
|
|
|
286 |
$result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". $wpdb->prefix . EVENTS_TBNAME ." WHERE event_id=%d", $this->id) );
|
287 |
+
if($result !== false){
|
288 |
+
$bookings_result = $this->get_bookings()->delete();
|
289 |
+
}
|
290 |
}
|
291 |
|
292 |
/**
|
351 |
}
|
352 |
|
353 |
/**
|
354 |
+
* Shortcut function for $this->get_bookings()->delete(), because using the EM_Bookings requires loading previous bookings, which isn't neceesary.
|
355 |
*/
|
356 |
function delete_bookings(){
|
357 |
global $wpdb;
|
462 |
}
|
463 |
if (preg_match('/#_AVAILABLESEATS/', $result)) {
|
464 |
$rsvp_is_active = get_option('dbem_rsvp_enabled');
|
|
|
465 |
if ($this->rsvp) {
|
466 |
+
$availble_seats = $this->get_bookings()->get_available_seats();
|
467 |
} else {
|
468 |
$availble_seats = "0";
|
469 |
}
|
532 |
$event_string = str_replace($result, dbem_ascii_encode($this->contact->user_email), $event_string );
|
533 |
}
|
534 |
if (preg_match('/#_CONTACTPHONE$/', $result)) {
|
535 |
+
$phone = ( $this->contact->phone != '') ? $this->contact->phone : __('N/A', 'dbem');
|
536 |
$event_string = str_replace($result, $phone, $event_string );
|
537 |
}
|
538 |
|
622 |
$event['event_start_date'] = date("Y-m-d", $day);
|
623 |
$event['event_end_date'] = $event['event_start_date'];
|
624 |
$event_saves[] = $wpdb->insert($wpdb->prefix.EVENTS_TBNAME, $event, $this->get_types($event));
|
625 |
+
//TODO should be EM_DEBUG, and do we really need it?
|
626 |
if( DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
|
627 |
}
|
628 |
return !in_array(false, $event_saves);
|
637 |
*/
|
638 |
function delete_events(){
|
639 |
global $wpdb;
|
640 |
+
//So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer
|
641 |
+
$EM_Events = EM_Events::get( array('recurrence_id'=>$this->id) );
|
642 |
+
$event_ids = array();
|
643 |
+
foreach($EM_Events as $EM_Event){
|
644 |
+
if($EM_Event->recurrence_id == $this->id){
|
645 |
+
$event_ids[] = $EM_Event->id; //ONLY ADD if id's match - hard coded
|
646 |
+
}
|
647 |
+
}
|
648 |
+
EM_Events::delete( $event_ids );
|
649 |
}
|
650 |
|
651 |
/**
|
674 |
}
|
675 |
|
676 |
/**
|
677 |
+
* Returns the days that match the recurrance array passed (unix timestamps)
|
678 |
* @param array $recurrence
|
679 |
* @return array
|
680 |
*/
|
681 |
function get_recurrence_days(){
|
682 |
if( $this->is_recurring() ){
|
|
|
|
|
|
|
|
|
|
|
683 |
|
684 |
+
$start_date = strtotime($this->start_date);
|
685 |
+
$end_date = strtotime($this->end_date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
|
687 |
+
$weekdays = explode(",", $this->byday); //what days of the week (or if monthly, one value at index 0)
|
688 |
+
|
689 |
+
$matching_days = array();
|
690 |
+
$aDay = 86400; // a day in seconds
|
691 |
+
$aWeek = $aDay * 7;
|
692 |
+
|
693 |
+
//TODO can this be optimized?
|
694 |
+
switch ( $this->freq ){
|
695 |
+
case 'daily':
|
696 |
+
//If daily, it's simple. Get start date, add interval timestamps to that and create matching day for each interval until end date.
|
697 |
+
$current_date = $start_date;
|
698 |
+
while( $current_date <= $end_date ){
|
699 |
+
$matching_days[] = $current_date;
|
700 |
+
$current_date = $current_date + ($aDay * $this->interval);
|
701 |
}
|
702 |
+
break;
|
703 |
+
case 'weekly':
|
704 |
+
//sort out week one, get starting days and then days that match time span of event (i.e. remove past events in week 1)
|
705 |
+
$start_of_week = get_option('start_of_week'); //Start of week depends on wordpress
|
706 |
+
//first, get the start of this week as timestamp
|
707 |
+
$event_start_day = date('w', $start_date);
|
708 |
+
$offset = 0;
|
709 |
+
if( $event_start_day > $start_of_week ){
|
710 |
+
$offset = $event_start_day - $start_of_week; //x days backwards
|
711 |
+
}elseif( $event_start_day < $start_of_week ){
|
712 |
+
$offset = $start_of_week;
|
713 |
}
|
714 |
+
$start_week_date = $start_date - ( ($event_start_day - $start_of_week) * $aDay );
|
715 |
+
//then get the timestamps of weekdays during this first week, regardless if within event range
|
716 |
+
$start_weekday_dates = array(); //Days in week 1 where there would events, regardless of event date range
|
717 |
+
for($i = 0; $i < 7; $i++){
|
718 |
+
$weekday_date = $start_week_date+($aDay*$i); //the date of the weekday we're currently checking
|
719 |
+
$weekday_day = date('w',$weekday_date); //the day of the week we're checking, taking into account wp start of week setting
|
720 |
+
if( in_array( $weekday_day, $weekdays) ){
|
721 |
+
$start_weekday_dates[] = $weekday_date; //it's in our starting week day, so add it
|
722 |
+
}
|
723 |
+
}
|
724 |
+
//for each day of eventful days in week 1, add 7 days * weekly intervals
|
725 |
+
foreach ($start_weekday_dates as $weekday_date){
|
726 |
+
//Loop weeks by interval until we reach or surpass end date
|
727 |
+
while($weekday_date <= $end_date){
|
728 |
+
if( $weekday_date >= $start_date && $weekday_date <= $end_date ){
|
729 |
+
$matching_days[] = $weekday_date;
|
730 |
+
}
|
731 |
+
$weekday_date = $weekday_date + ($aWeek * $this->interval);
|
732 |
+
}
|
733 |
+
}//done!
|
734 |
+
break;
|
735 |
+
case 'monthly':
|
736 |
+
//loop months starting this month by intervals
|
737 |
+
$current_arr = getdate($start_date);
|
738 |
+
$end_arr = getdate($end_date);
|
739 |
+
$end_month_date = strtotime( date('Y-m-t', $end_date) ); //End date on last day of month
|
740 |
+
$current_date = strtotime( date('Y-m-1', $start_date) ); //Start date on first day of month
|
741 |
+
while( $current_date <= $end_month_date ){
|
742 |
+
$last_day_of_month = date('t', $current_date);
|
743 |
+
//Now find which day we're talking about
|
744 |
+
$current_week_day = date('w',$current_date);
|
745 |
+
$matching_month_days = array();
|
746 |
+
//Loop through days of this years month and save matching days to temp array
|
747 |
+
for($day = 1; $day <= $last_day_of_month; $day++){
|
748 |
+
if($current_week_day == $this->byday){
|
749 |
+
$matching_month_days[] = $day;
|
750 |
+
}
|
751 |
+
$current_week_day = ($current_week_day < 6) ? $current_week_day+1 : 0;
|
752 |
+
}
|
753 |
+
//Now grab from the array the x day of the month
|
754 |
+
$matching_day = ($this->byweekno > 0) ? $matching_month_days[$this->byweekno-1] : array_pop($matching_month_days);
|
755 |
+
$matching_date = strtotime(date('Y-m',$current_date).'-'.$matching_day);
|
756 |
+
if($matching_date >= $start_date && $matching_date <= $end_date){
|
757 |
+
$matching_days[] = $matching_date;
|
758 |
+
}
|
759 |
+
//add the number of days in this month to make start of next month
|
760 |
+
$current_arr['mon'] += $this->interval;
|
761 |
+
if($current_arr['mon'] > 12){
|
762 |
+
//FIXME this won't work if interval is more than 12
|
763 |
+
$current_arr['mon'] = $current_arr['mon'] - 12;
|
764 |
+
$current_arr['year']++;
|
765 |
+
}
|
766 |
+
$current_date = strtotime("{$current_arr['year']}-{$current_arr['mon']}-1");
|
767 |
+
}
|
768 |
+
break;
|
769 |
+
}
|
770 |
+
sort($matching_days);
|
771 |
+
//TODO delete this after testing
|
772 |
+
/*Delete*/
|
773 |
+
$test_dates = array();
|
774 |
+
foreach($matching_days as $matching_day){
|
775 |
+
$test_dates[] = date('d/m/Y', $matching_day);
|
776 |
+
}
|
777 |
+
/*end delete*/
|
778 |
+
return $matching_days;
|
779 |
}
|
780 |
}
|
781 |
|
788 |
global $EM_Recurrences;
|
789 |
if( $this->is_individual() ) return false;
|
790 |
$recurrence = $EM_Recurrences[$this->recurrence_id]->to_array();
|
791 |
+
$weekdays_name = array(__('Sunday'),__('Monday'),__('Tuesday'),__('Wednesday'),__('Thursday'),__('Friday'),__('Saturday'));
|
792 |
$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'));
|
793 |
$output = sprintf (__('From %1$s to %2$s', 'dbem'), $recurrence['event_start_date'], $recurrence['event_end_date']).", ";
|
794 |
if ($recurrence['recurrence_freq'] == 'daily') {
|
802 |
$weekday_array = explode(",", $recurrence['recurrence_byday']);
|
803 |
$natural_days = array();
|
804 |
foreach($weekday_array as $day)
|
805 |
+
array_push($natural_days, $weekdays_name[$day]);
|
806 |
$output .= implode(" and ", $natural_days);
|
807 |
if ($recurrence['recurrence_interval'] > 1 ) {
|
808 |
$freq_desc = ", ".sprintf (__("every %s weeks", 'dbem'), $recurrence['recurrence_interval']);
|
classes/events.php
CHANGED
@@ -19,7 +19,7 @@ class EM_Events extends EM_Object {
|
|
19 |
$locations_table = $wpdb->prefix . LOCATIONS_TBNAME;
|
20 |
|
21 |
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
22 |
-
if( self::array_is_numeric($args)
|
23 |
//We can just get all the events here and return them
|
24 |
$sql = "
|
25 |
SELECT * FROM $events_table
|
@@ -34,94 +34,13 @@ class EM_Events extends EM_Object {
|
|
34 |
return $events; //We return all the events matched as an EM_Event array.
|
35 |
}
|
36 |
|
37 |
-
//Format the arguments passed on
|
38 |
//We assume it's either an empty array or array of search arguments to merge with defaults
|
39 |
$args = self::get_default_search($args);
|
40 |
-
$
|
41 |
-
$offset = $args['offset'];
|
42 |
-
$recurring = $args['recurring'];
|
43 |
-
$recurrence = $args['recurrence'];
|
44 |
-
$category = $args['category'];
|
45 |
-
$location = $args['location'];
|
46 |
-
$day = $args['day'];
|
47 |
-
$month = $args['month'];
|
48 |
-
$year = $args['year'];
|
49 |
-
extract($args, EXTR_SKIP);
|
50 |
-
$today = date( 'Y-m-d' );
|
51 |
-
$limit = ( $limit && is_numeric($limit)) ? "LIMIT $limit" : '';
|
52 |
-
$offset = ( $limit != "" && is_numeric($offset) ) ? "OFFSET $offset" : '';
|
53 |
-
//TODO order by?
|
54 |
-
$order = ($order == "DESC") ? "DESC" : "ASC";
|
55 |
|
56 |
-
//
|
57 |
-
|
58 |
-
//Recurrences
|
59 |
-
if( $recurring ){
|
60 |
-
$conditions = array("`recurrence`=1");
|
61 |
-
}elseif( $recurrence > 0 ){
|
62 |
-
$conditions = array("`recurrence_id`=$recurrence");
|
63 |
-
}else{
|
64 |
-
$conditions = array("`recurrence`=0");
|
65 |
-
}
|
66 |
-
//Dates - first check 'month', and 'year'
|
67 |
-
if( !($month=='' && $year=='') ){
|
68 |
-
//Sort out month range, if supplied an array of array(month,month), it'll check between these two months
|
69 |
-
if( self::array_is_numeric($month) ){
|
70 |
-
$date_month_start = $month[0];
|
71 |
-
$date_month_end = $month[1];
|
72 |
-
}else{
|
73 |
-
$date_month_start = $date_month_end = $month;
|
74 |
-
}
|
75 |
-
//Sort out year range, if supplied an array of array(year,year), it'll check between these two years
|
76 |
-
if( self::array_is_numeric($year) ){
|
77 |
-
$date_year_start = $year[0];
|
78 |
-
$date_year_end = $year[1];
|
79 |
-
}else{
|
80 |
-
$date_year_start = $date_year_end = $year;
|
81 |
-
}
|
82 |
-
$date_start = date('Y-m-d', mktime(0,0,0,$date_month_start,1,$date_year_start));
|
83 |
-
$date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
|
84 |
-
$conditions[] = " ((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)))";
|
85 |
-
$search_by_date = true;
|
86 |
-
}
|
87 |
-
if( !isset($search_by_date) ){
|
88 |
-
//No date requested, so let's look at scope
|
89 |
-
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
90 |
-
//Scope can also be a specific date. However, if 'day', 'month', or 'year' are set, that will take precedence
|
91 |
-
$conditions [] = " ( (event_start_date = CAST('$scope' AS DATE)) OR (event_start_date <= CAST('$scope' AS DATE) AND event_end_date >= CAST('$scope' AS DATE)) )";
|
92 |
-
} else {
|
93 |
-
if ($scope == "past"){
|
94 |
-
$conditions [] = " event_start_date < '$today'";
|
95 |
-
}elseif ($scope == "today"){
|
96 |
-
$conditions [] = " ( (event_start_date = CAST('$today' AS DATE)) OR (event_start_date <= CAST('$today' AS DATE) AND event_end_date >= CAST('$today' AS DATE)) )";
|
97 |
-
}elseif ($scope == "future" || $scope != 'all'){
|
98 |
-
$conditions [] = " (event_start_date >= CAST('$today' AS DATE) OR (event_end_date >= CAST('$today' AS DATE) AND event_end_date != '0000-00-00' AND event_end_date IS NOT NULL))";
|
99 |
-
}
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
//Filter by Location - can be object, array, or id
|
104 |
-
if ( is_numeric($location) && $location > 0 ) { //Location ID takes precedence
|
105 |
-
$conditions [] = " {$locations_table}.location_id = $location";
|
106 |
-
}elseif ( self::array_is_numeric($location) ){
|
107 |
-
$conditions [] = "( {$locations_table}.location_id = " . implode(" OR {$locations_table}.location_id = ", $location) .' )';
|
108 |
-
}elseif ( is_object($location) && get_class($location)=='EM_Location' ){ //Now we deal with objects
|
109 |
-
$conditions [] = " {$locations_table}.location_id = $location->id";
|
110 |
-
}elseif ( is_array($location) && @get_class(current($location)=='EM_Location') ){ //we can accept array of ids or EM_Location objects
|
111 |
-
foreach($location as $EM_Location){
|
112 |
-
$location_ids[] = $EM_Location->id;
|
113 |
-
}
|
114 |
-
$conditions[] = "( {$locations_table}.location_id=". implode(" {$locations_table}.location_id=", $location_ids) ." )";
|
115 |
-
}
|
116 |
-
|
117 |
-
//Add conditions for category selection
|
118 |
-
//Filter by category, can be id or comma seperated ids
|
119 |
-
//TODO create an exclude category option
|
120 |
-
if ( $category != '' && is_numeric($category) ){
|
121 |
-
$conditions [] = " event_category_id = $category";
|
122 |
-
}elseif( self::array_is_numeric($category) ){
|
123 |
-
$conditions [] = "( event_category_id = ". implode(' OR event_category_id = ', $category).")";
|
124 |
-
}
|
125 |
|
126 |
//Put it all together
|
127 |
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
@@ -131,12 +50,19 @@ class EM_Events extends EM_Object {
|
|
131 |
SELECT * FROM $events_table
|
132 |
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
133 |
$where
|
134 |
-
ORDER BY event_start_date $order , event_start_time $order
|
135 |
$limit $offset
|
136 |
-
";
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
//Make returned results EM_Event objects
|
|
|
140 |
$events = array();
|
141 |
foreach ( $results as $event ){
|
142 |
$events[] = new EM_Event($event);
|
@@ -190,7 +116,7 @@ class EM_Events extends EM_Object {
|
|
190 |
*/
|
191 |
function output( $args ){
|
192 |
global $EM_Event;
|
193 |
-
$
|
194 |
//Can be either an array for the get search or an array of EM_Event objects
|
195 |
if( is_object(current($args)) && get_class((current($args))) == 'EM_Event' ){
|
196 |
$events = $args;
|
@@ -219,7 +145,7 @@ class EM_Events extends EM_Object {
|
|
219 |
$output = get_option ( 'dbem_no_events_message' );
|
220 |
}
|
221 |
//TODO check if reference is ok when restoring object, due to changes in php5 v 4
|
222 |
-
$
|
223 |
return $output;
|
224 |
}
|
225 |
|
19 |
$locations_table = $wpdb->prefix . LOCATIONS_TBNAME;
|
20 |
|
21 |
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
22 |
+
if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
|
23 |
//We can just get all the events here and return them
|
24 |
$sql = "
|
25 |
SELECT * FROM $events_table
|
34 |
return $events; //We return all the events matched as an EM_Event array.
|
35 |
}
|
36 |
|
|
|
37 |
//We assume it's either an empty array or array of search arguments to merge with defaults
|
38 |
$args = self::get_default_search($args);
|
39 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
40 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
//Get the default conditions
|
43 |
+
$conditions = self::build_sql_conditions($args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
//Put it all together
|
46 |
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
50 |
SELECT * FROM $events_table
|
51 |
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
52 |
$where
|
53 |
+
ORDER BY event_start_date {$args['order']} , event_start_time {$args['order']}
|
54 |
$limit $offset
|
55 |
+
";
|
56 |
+
|
57 |
+
$results = $wpdb->get_results($sql, ARRAY_A);
|
58 |
+
|
59 |
+
//If we want results directly in an array, why not have a shortcut here?
|
60 |
+
if( $args['array'] == true ){
|
61 |
+
return $results;
|
62 |
+
}
|
63 |
|
64 |
//Make returned results EM_Event objects
|
65 |
+
$results = (is_array($results)) ? $results:array();
|
66 |
$events = array();
|
67 |
foreach ( $results as $event ){
|
68 |
$events[] = new EM_Event($event);
|
116 |
*/
|
117 |
function output( $args ){
|
118 |
global $EM_Event;
|
119 |
+
$EM_Event_old = $EM_Event; //When looping, we can replace EM_Event global with the current event in the loop
|
120 |
//Can be either an array for the get search or an array of EM_Event objects
|
121 |
if( is_object(current($args)) && get_class((current($args))) == 'EM_Event' ){
|
122 |
$events = $args;
|
145 |
$output = get_option ( 'dbem_no_events_message' );
|
146 |
}
|
147 |
//TODO check if reference is ok when restoring object, due to changes in php5 v 4
|
148 |
+
$EM_Event_old = $EM_Event;
|
149 |
return $output;
|
150 |
}
|
151 |
|
classes/location.php
CHANGED
@@ -193,7 +193,7 @@ class EM_Location extends EM_Object {
|
|
193 |
}
|
194 |
|
195 |
function output($format, $target="html") {
|
196 |
-
$location_string = $format;
|
197 |
preg_match_all("/#@?_?[A-Za-z]+/", $format, $placeholders);
|
198 |
foreach($placeholders[0] as $result) {
|
199 |
// matches alla fields placeholder
|
@@ -201,7 +201,7 @@ class EM_Location extends EM_Object {
|
|
201 |
$map_div = EM_Map::get_single( array('location' => $this) );
|
202 |
$location_string = str_replace($result, $map_div , $location_string );
|
203 |
}
|
204 |
-
if ( preg_match('/#_(LOC)?(NOTES|EXCERPT)/', $result) ) {
|
205 |
if ($target == "html"){
|
206 |
//If excerpt, we use more link text
|
207 |
if($result == "#_LOCEXCERPT" || $result == "#_EXCERPT"){
|
@@ -226,15 +226,18 @@ class EM_Location extends EM_Object {
|
|
226 |
$field_value = apply_filters('the_content_rss', $field_value);
|
227 |
}
|
228 |
$location_string = str_replace($result, $field_value , $location_string );
|
229 |
-
}
|
230 |
-
if (preg_match('/#_(LOCATION
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
$
|
237 |
-
|
|
|
|
|
|
|
238 |
if (preg_match('/#_(PASTEVENTS|NEXTEVENTS|ALLEVENTS)/', $result)) {
|
239 |
if ($result == '#_PASTEVENTS'){ $scope = 'past'; }
|
240 |
elseif ( $result == '#_NEXTEVENTS' ){ $scope = 'future'; }
|
@@ -258,11 +261,6 @@ class EM_Location extends EM_Object {
|
|
258 |
}
|
259 |
$location_string = str_replace($result, $location_image , $location_string );
|
260 |
}
|
261 |
-
if (preg_match('/#_(LOCATIONPAGEURL)/', $result)) {
|
262 |
-
$joiner = (stristr(EM_URI, "?")) ? "&" : "?";
|
263 |
-
$venue_page_link = EM_URI.$joiner."location_id=".$this->id;
|
264 |
-
$location_string = str_replace($result, $venue_page_link , $location_string );
|
265 |
-
}
|
266 |
if (preg_match('/#_(ADDRESS|TOWN|PROVINCE)/', $result)) { //TODO province in location is not being used
|
267 |
$field = ltrim(strtolower($result), "#_");
|
268 |
if ($target == "html") {
|
@@ -273,6 +271,12 @@ class EM_Location extends EM_Object {
|
|
273 |
$location_string = str_replace($result, $field_value , $location_string );
|
274 |
}
|
275 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
return $location_string;
|
277 |
}
|
278 |
}
|
193 |
}
|
194 |
|
195 |
function output($format, $target="html") {
|
196 |
+
$location_string = $format;
|
197 |
preg_match_all("/#@?_?[A-Za-z]+/", $format, $placeholders);
|
198 |
foreach($placeholders[0] as $result) {
|
199 |
// matches alla fields placeholder
|
201 |
$map_div = EM_Map::get_single( array('location' => $this) );
|
202 |
$location_string = str_replace($result, $map_div , $location_string );
|
203 |
}
|
204 |
+
if ( preg_match('/#_(LOC(ATION)?)?(NOTES|EXCERPT)/', $result) ) {
|
205 |
if ($target == "html"){
|
206 |
//If excerpt, we use more link text
|
207 |
if($result == "#_LOCEXCERPT" || $result == "#_EXCERPT"){
|
226 |
$field_value = apply_filters('the_content_rss', $field_value);
|
227 |
}
|
228 |
$location_string = str_replace($result, $field_value , $location_string );
|
229 |
+
}
|
230 |
+
if (preg_match('/#_(LOCATION(PAGE)?URL)/', $result)) {
|
231 |
+
$joiner = (stristr(EM_URI, "?")) ? "&" : "?";
|
232 |
+
$venue_page_link = EM_URI.$joiner."location_id=".$this->id;
|
233 |
+
$location_string = str_replace($result, $venue_page_link , $location_string );
|
234 |
+
}
|
235 |
+
if (preg_match('/#_(LOCATIONLINK)/', $result)) {
|
236 |
+
$joiner = (stristr(EM_URI, "?")) ? "&" : "?";
|
237 |
+
$venue_page_link = EM_URI.$joiner."location_id=".$this->id;
|
238 |
+
$venue_page_link = '<a href="'.$venue_page_link.'">'.$this->name.'</a>';
|
239 |
+
$location_string = str_replace($result, $venue_page_link , $location_string );
|
240 |
+
}
|
241 |
if (preg_match('/#_(PASTEVENTS|NEXTEVENTS|ALLEVENTS)/', $result)) {
|
242 |
if ($result == '#_PASTEVENTS'){ $scope = 'past'; }
|
243 |
elseif ( $result == '#_NEXTEVENTS' ){ $scope = 'future'; }
|
261 |
}
|
262 |
$location_string = str_replace($result, $location_image , $location_string );
|
263 |
}
|
|
|
|
|
|
|
|
|
|
|
264 |
if (preg_match('/#_(ADDRESS|TOWN|PROVINCE)/', $result)) { //TODO province in location is not being used
|
265 |
$field = ltrim(strtolower($result), "#_");
|
266 |
if ($target == "html") {
|
271 |
$location_string = str_replace($result, $field_value , $location_string );
|
272 |
}
|
273 |
}
|
274 |
+
//TODO all of these should just use str_replace if possible
|
275 |
+
//#_(LOCATION|NAME)
|
276 |
+
$name_filter = ($target == "html") ? 'dbem_general':'dbem_general_rss';
|
277 |
+
$location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name) , $location_string );
|
278 |
+
$location_string = str_replace('#_NAME', apply_filters($name_filter, $this->name) , $location_string );
|
279 |
+
|
280 |
return $location_string;
|
281 |
}
|
282 |
}
|
classes/locations.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Static class which will help bulk add/edit/retrieve/manipulate arrays of EM_Location objects
|
4 |
-
*
|
5 |
-
*
|
6 |
*/
|
7 |
class EM_Locations extends EM_Object {
|
8 |
/**
|
@@ -11,27 +11,134 @@ class EM_Locations extends EM_Object {
|
|
11 |
* @param boolean $return_objects
|
12 |
* @return array
|
13 |
*/
|
14 |
-
function get( $
|
15 |
global $wpdb;
|
16 |
-
$
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
foreach ($locations as $location){
|
28 |
-
$location_objects[] = new EM_Location($location);
|
29 |
}
|
30 |
-
$locations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
return $locations;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
?>
|
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 |
/**
|
11 |
* @param boolean $return_objects
|
12 |
* @return array
|
13 |
*/
|
14 |
+
function get( $args = array() ){
|
15 |
global $wpdb;
|
16 |
+
$events_table = $wpdb->prefix . EVENTS_TBNAME;
|
17 |
+
$locations_table = $wpdb->prefix . LOCATIONS_TBNAME;
|
18 |
+
|
19 |
+
//Quick version, we can accept an array of IDs, which is easy to retrieve
|
20 |
+
if( self::array_is_numeric($args) && count() ){ //Array of numbers, assume they are event IDs to retreive
|
21 |
+
//We can just get all the events here and return them
|
22 |
+
$sql = "SELECT * FROM $locations_table WHERE location_id=".implode(" OR location_id=", $args);
|
23 |
+
$results = $wpdb->get_results($sql);
|
24 |
+
$events = array();
|
25 |
+
foreach($results as $result){
|
26 |
+
$locations[$result['location_id']] = new EM_Location($result);
|
|
|
|
|
27 |
}
|
28 |
+
return $locations; //We return all the events matched as an EM_Event array.
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
//We assume it's either an empty array or array of search arguments to merge with defaults
|
33 |
+
$args = self::get_default_search($args);
|
34 |
+
$limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
|
35 |
+
$offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
|
36 |
+
|
37 |
+
//Get the default conditions
|
38 |
+
$conditions = self::build_sql_conditions($args);
|
39 |
+
|
40 |
+
//Put it all together
|
41 |
+
$EM_Location = new EM_Location(0); //Empty class for strict message avoidance
|
42 |
+
$fields = $locations_table .".". implode(", {$locations_table}.", array_keys($EM_Location->fields));
|
43 |
+
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
44 |
+
|
45 |
+
//Create the SQL statement and execute
|
46 |
+
$sql = "
|
47 |
+
SELECT $fields FROM $locations_table
|
48 |
+
LEFT JOIN $events_table ON {$locations_table}.location_id={$events_table}.location_id
|
49 |
+
$where
|
50 |
+
GROUP BY location_id
|
51 |
+
ORDER BY location_name {$args['order']} , location_address {$args['order']}
|
52 |
+
$limit $offset
|
53 |
+
";
|
54 |
+
|
55 |
+
$results = $wpdb->get_results($sql, ARRAY_A);
|
56 |
+
|
57 |
+
//If we want results directly in an array, why not have a shortcut here?
|
58 |
+
if( $args['array'] == true ){
|
59 |
+
return $results;
|
60 |
+
}
|
61 |
+
|
62 |
+
$locations = array();
|
63 |
+
foreach ($results as $location){
|
64 |
+
$locations[] = new EM_Location($location);
|
65 |
}
|
66 |
return $locations;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Output a set of matched of events
|
71 |
+
* @param array $args
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
function output( $args ){
|
75 |
+
global $EM_Location;
|
76 |
+
$EM_Location_old = $EM_Location; //When looping, we can replace EM_Location global with the current event in the loop
|
77 |
+
//Can be either an array for the get search or an array of EM_Location objects
|
78 |
+
if( is_object(current($args)) && get_class((current($args))) == 'EM_Location' ){
|
79 |
+
$locations = $args;
|
80 |
+
}else{
|
81 |
+
$locations = self::get( $args );
|
82 |
+
}
|
83 |
+
//What format shall we output this to, or use default
|
84 |
+
$format = ( $args['format'] == '' ) ? get_option( 'dbem_location_list_item_format' ) : $args['format'] ;
|
85 |
+
|
86 |
+
$output = "";
|
87 |
+
if ( count($locations) > 0 ) {
|
88 |
+
foreach ( $locations as $location ) {
|
89 |
+
$EM_Location = $location;
|
90 |
+
/* @var EM_Event $event */
|
91 |
+
$output .= $location->output($format);
|
92 |
+
}
|
93 |
+
//Add headers and footers to output
|
94 |
+
if( $format == get_option ( 'dbem_location_list_item_format' ) ){
|
95 |
+
$single_event_format_header = get_option ( 'dbem_location_list_item_format_header' );
|
96 |
+
$single_event_format_header = ( $single_event_format_header != '' ) ? $single_event_format_header : "<ul class='dbem_events_list'>";
|
97 |
+
$single_event_format_footer = get_option ( 'dbem_location_list_item_format_footer' );
|
98 |
+
$single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
|
99 |
+
$output = $single_event_format_header . $output . $single_event_format_footer;
|
100 |
+
}
|
101 |
+
} else {
|
102 |
+
$output = get_option ( 'dbem_no_events_message' );
|
103 |
+
}
|
104 |
+
//FIXME check if reference is ok when restoring object, due to changes in php5 v 4
|
105 |
+
$EM_Location_old= $EM_Location;
|
106 |
+
return $output;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Builds an array of SQL query conditions based on regularly used arguments
|
111 |
+
* @param array $args
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
function build_sql_conditions( $args = array() ){
|
115 |
+
global $wpdb;
|
116 |
+
$events_table = $wpdb->prefix . EVENTS_TBNAME;
|
117 |
+
$locations_table = $wpdb->prefix . LOCATIONS_TBNAME;
|
118 |
+
|
119 |
+
$conditions = parent::build_sql_conditions($args);
|
120 |
+
//eventful locations
|
121 |
+
if( true == $args['eventful'] ){
|
122 |
+
$conditions[] = "{$events_table}.event_id IS NOT NULL";
|
123 |
+
}elseif( true == $args['eventless'] ){
|
124 |
+
$conditions[] = "{$events_table}.event_id IS NULL";
|
125 |
+
}
|
126 |
+
return $conditions;
|
127 |
}
|
128 |
|
129 |
+
/*
|
130 |
+
* Generate a search arguments array from defalut and user-defined.
|
131 |
+
* @see wp-content/plugins/events-manager/classes/EM_Object::get_default_search()
|
132 |
+
*/
|
133 |
+
function get_default_search($args = array()){
|
134 |
+
$defaults = array(
|
135 |
+
'eventful' => false, //Locations that have an event (scope will also play a part here
|
136 |
+
'eventless' => false //Locations WITHOUT events, eventful takes precedence
|
137 |
+
);
|
138 |
+
$args['eventful'] = ($args['eventful'] == true);
|
139 |
+
$args['eventless'] = ($args['eventless'] == true);
|
140 |
+
return parent::get_default_search($defaults, $args);
|
141 |
+
}
|
142 |
+
//TODO for all the static plural classes like this one, we might benefit from bulk actions like delete/add/save etc.... just a random thought.
|
143 |
}
|
144 |
?>
|
classes/map.php
CHANGED
@@ -13,13 +13,15 @@ class EM_Map extends EM_Object {
|
|
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 |
?>
|
17 |
<div id='em-locations-map' style='width:<?php echo $atts['width']; ?>px; height:<?php echo $atts['height']; ?>px'><em><?php _e('Loading Map....', 'dbem'); ?></em></div>
|
18 |
<script src='<?php echo bloginfo('wpurl') ?>/wp-content/plugins/events-manager/includes/js/em_maps.js' type='text/javascript'></script>
|
19 |
<script type='text/javascript'>
|
20 |
<!--//
|
21 |
-
var
|
22 |
-
var scope = '<?php echo $atts['scope']; ?>';
|
23 |
em_load_map('em_map_global');
|
24 |
//-->
|
25 |
</script>
|
@@ -44,12 +46,12 @@ class EM_Map extends EM_Object {
|
|
44 |
ob_start();
|
45 |
?>
|
46 |
<div id='em-location-map' style='background: #CDCDCD; width: <?php echo $width ?>px; height: <?php echo $height ?>px'><?php _e('Loading Map....', 'dbem'); ?></div>
|
47 |
-
|
48 |
<script src='<?php bloginfo('wpurl'); ?>/wp-content/plugins/events-manager/includes/js/em_maps.js' type='text/javascript'></script>
|
49 |
<script type='text/javascript'>
|
50 |
<!--//
|
51 |
-
var
|
52 |
-
var
|
53 |
em_load_map('em_map_single');
|
54 |
//-->
|
55 |
</script>
|
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['ajax'] = true;
|
17 |
+
$atts['query'] = 'GlobalMapData';
|
18 |
+
//build js array of arguments to send to event query
|
19 |
?>
|
20 |
<div id='em-locations-map' style='width:<?php echo $atts['width']; ?>px; height:<?php echo $atts['height']; ?>px'><em><?php _e('Loading Map....', 'dbem'); ?></em></div>
|
21 |
<script src='<?php echo bloginfo('wpurl') ?>/wp-content/plugins/events-manager/includes/js/em_maps.js' type='text/javascript'></script>
|
22 |
<script type='text/javascript'>
|
23 |
<!--//
|
24 |
+
var em_query = <?php echo EM_Object::json_encode($atts); ?>;
|
|
|
25 |
em_load_map('em_map_global');
|
26 |
//-->
|
27 |
</script>
|
46 |
ob_start();
|
47 |
?>
|
48 |
<div id='em-location-map' style='background: #CDCDCD; width: <?php echo $width ?>px; height: <?php echo $height ?>px'><?php _e('Loading Map....', 'dbem'); ?></div>
|
49 |
+
<div id='em-location-map-info' style="display:none; visibility:hidden;"><div id="em-map-balloon" style="font-size:12px;"><div id="content"><?php echo $location->output(get_option('dbem_location_baloon_format')); ?></div></div></div>
|
50 |
<script src='<?php bloginfo('wpurl'); ?>/wp-content/plugins/events-manager/includes/js/em_maps.js' type='text/javascript'></script>
|
51 |
<script type='text/javascript'>
|
52 |
<!--//
|
53 |
+
var em_latitude = parseFloat('<?php echo $location->latitude; ?>');
|
54 |
+
var em_longitude = parseFloat('<?php echo $location->longitude; ?>');
|
55 |
em_load_map('em_map_single');
|
56 |
//-->
|
57 |
</script>
|
classes/object.php
CHANGED
@@ -18,7 +18,7 @@ class EM_Object {
|
|
18 |
$super_defaults = array(
|
19 |
'limit' => false,
|
20 |
'scope' => 'all',
|
21 |
-
'order' => '
|
22 |
'format' => '',
|
23 |
'category' => 0,
|
24 |
'location' => 0,
|
@@ -26,7 +26,8 @@ class EM_Object {
|
|
26 |
'recurrence'=>0,
|
27 |
'recurring'=>false,
|
28 |
'month'=>'',
|
29 |
-
'year'=>''
|
|
|
30 |
);
|
31 |
//TODO decide on search defaults shared across all objects and then validate here
|
32 |
$defaults = array_merge($super_defaults, $defaults);
|
@@ -36,7 +37,6 @@ class EM_Object {
|
|
36 |
if( array_key_exists('location_id', $array) && !array_key_exists('location', $array) ) { $array['location'] = $array['location_id']; }
|
37 |
if( array_key_exists('category_id', $array) && !array_key_exists('category', $array) ) { $array['category'] = $array['category_id']; }
|
38 |
|
39 |
-
|
40 |
if(is_array($array)){
|
41 |
//TODO accept all objects as search options as well as ids (e.g. location vs. location_id, person vs. person_id)
|
42 |
//If there's a location, then remove it and turn it into location_id
|
@@ -67,11 +67,124 @@ class EM_Object {
|
|
67 |
if( !array_key_exists($key, $defaults) ) unset($array[$key]);
|
68 |
}
|
69 |
//return clean array
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
return $defaults;
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
/**
|
77 |
* Save an array into this class.
|
18 |
$super_defaults = array(
|
19 |
'limit' => false,
|
20 |
'scope' => 'all',
|
21 |
+
'order' => 'ASC',
|
22 |
'format' => '',
|
23 |
'category' => 0,
|
24 |
'location' => 0,
|
26 |
'recurrence'=>0,
|
27 |
'recurring'=>false,
|
28 |
'month'=>'',
|
29 |
+
'year'=>'',
|
30 |
+
'array'=>false
|
31 |
);
|
32 |
//TODO decide on search defaults shared across all objects and then validate here
|
33 |
$defaults = array_merge($super_defaults, $defaults);
|
37 |
if( array_key_exists('location_id', $array) && !array_key_exists('location', $array) ) { $array['location'] = $array['location_id']; }
|
38 |
if( array_key_exists('category_id', $array) && !array_key_exists('category', $array) ) { $array['category'] = $array['category_id']; }
|
39 |
|
|
|
40 |
if(is_array($array)){
|
41 |
//TODO accept all objects as search options as well as ids (e.g. location vs. location_id, person vs. person_id)
|
42 |
//If there's a location, then remove it and turn it into location_id
|
67 |
if( !array_key_exists($key, $defaults) ) unset($array[$key]);
|
68 |
}
|
69 |
//return clean array
|
70 |
+
$defaults = array_merge ( $defaults, $array ); //No point using WP's cleaning function, we're doing it already.
|
71 |
+
}
|
72 |
+
//Do some spring cleaning for known values
|
73 |
+
//Month & Year - may be array or single number
|
74 |
+
$month_regex = '/^[0-9]{1,2}$/';
|
75 |
+
$year_regex = '/^[0-9]{4}$/';
|
76 |
+
if( is_array($defaults['month']) ){
|
77 |
+
$defaults['month'] = ( preg_match($month_regex, $defaults['month'][0]) && preg_match($month_regex, $defaults['month'][1]) ) ? $defaults['month']:'';
|
78 |
+
}else{
|
79 |
+
$defaults['month'] = preg_match($month_regex, $defaults['month']) ? $defaults['month']:'';
|
80 |
}
|
81 |
+
if( is_array($defaults['year']) ){
|
82 |
+
$defaults['year'] = ( preg_match($year_regex, $defaults['year'][0]) && preg_match($year_regex, $defaults['year'][1]) ) ? $defaults['year']:'';
|
83 |
+
}else{
|
84 |
+
$defaults['year'] = preg_match($year_regex, $defaults['year']) ? $defaults['year']:'';
|
85 |
+
}
|
86 |
+
//TODO should we clean format of malicious code over here and run everything thorugh this?
|
87 |
+
$defaults['order'] = ($defaults['order'] == "ASC") ? "ASC" : $super_defaults['order'];
|
88 |
+
$defaults['array'] = ($defaults['array'] == true);
|
89 |
+
$defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
|
90 |
+
$defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
|
91 |
+
$defaults['recurring'] = ($defaults['recurring'] == true);
|
92 |
return $defaults;
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* Builds an array of SQL query conditions based on regularly used arguments
|
97 |
+
* @param array $args
|
98 |
+
* @return array
|
99 |
+
*/
|
100 |
+
function build_sql_conditions( $args = array() ){
|
101 |
+
global $wpdb;
|
102 |
+
$events_table = $wpdb->prefix . EVENTS_TBNAME;
|
103 |
+
$locations_table = $wpdb->prefix . LOCATIONS_TBNAME;
|
104 |
+
|
105 |
+
//Format the arguments passed on
|
106 |
+
$scope = $args['scope'];//undefined variable warnings in ZDE, could just delete this (but dont pls!)
|
107 |
+
$recurring = $args['recurring'];
|
108 |
+
$recurrence = $args['recurrence'];
|
109 |
+
$category = $args['category'];
|
110 |
+
$location = $args['location'];
|
111 |
+
$day = $args['day'];
|
112 |
+
$month = $args['month'];
|
113 |
+
$year = $args['year'];
|
114 |
+
$today = date('Y-m-d');
|
115 |
+
//Create the WHERE statement
|
116 |
+
|
117 |
+
//Recurrences
|
118 |
+
if( $recurring ){
|
119 |
+
$conditions = array("`recurrence`=1");
|
120 |
+
}elseif( $recurrence > 0 ){
|
121 |
+
$conditions = array("`recurrence_id`=$recurrence");
|
122 |
+
}else{
|
123 |
+
$conditions = array("(`recurrence`!=1 OR `recurrence` IS NULL)");
|
124 |
+
}
|
125 |
+
//Dates - first check 'month', and 'year'
|
126 |
+
if( !($month=='' && $year=='') ){
|
127 |
+
//Sort out month range, if supplied an array of array(month,month), it'll check between these two months
|
128 |
+
if( self::array_is_numeric($month) ){
|
129 |
+
$date_month_start = $month[0];
|
130 |
+
$date_month_end = $month[1];
|
131 |
+
}else{
|
132 |
+
$date_month_start = $date_month_end = $month;
|
133 |
+
}
|
134 |
+
//Sort out year range, if supplied an array of array(year,year), it'll check between these two years
|
135 |
+
if( self::array_is_numeric($year) ){
|
136 |
+
$date_year_start = $year[0];
|
137 |
+
$date_year_end = $year[1];
|
138 |
+
}else{
|
139 |
+
$date_year_start = $date_year_end = $year;
|
140 |
+
}
|
141 |
+
$date_start = date('Y-m-d', mktime(0,0,0,$date_month_start,1,$date_year_start));
|
142 |
+
$date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
|
143 |
+
$conditions[] = " ((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)))";
|
144 |
+
$search_by_date = true;
|
145 |
+
}
|
146 |
+
if( !isset($search_by_date) ){
|
147 |
+
//No date requested, so let's look at scope
|
148 |
+
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
149 |
+
//Scope can also be a specific date. However, if 'day', 'month', or 'year' are set, that will take precedence
|
150 |
+
$conditions [] = " ( (event_start_date = CAST('$scope' AS DATE)) OR (event_start_date <= CAST('$scope' AS DATE) AND event_end_date >= CAST('$scope' AS DATE)) )";
|
151 |
+
} else {
|
152 |
+
if ($scope == "past"){
|
153 |
+
$conditions [] = " event_start_date < '$today'";
|
154 |
+
}elseif ($scope == "today"){
|
155 |
+
$conditions [] = " ( (event_start_date = CAST('$today' AS DATE)) OR (event_start_date <= CAST('$today' AS DATE) AND event_end_date >= CAST('$today' AS DATE)) )";
|
156 |
+
}elseif ($scope == "future" || $scope != 'all'){
|
157 |
+
$conditions [] = " (event_start_date >= CAST('$today' AS DATE) OR (event_end_date >= CAST('$today' AS DATE) AND event_end_date != '0000-00-00' AND event_end_date IS NOT NULL))";
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
//Filter by Location - can be object, array, or id
|
163 |
+
if ( is_numeric($location) && $location > 0 ) { //Location ID takes precedence
|
164 |
+
$conditions [] = " {$locations_table}.location_id = $location";
|
165 |
+
}elseif ( self::array_is_numeric($location) ){
|
166 |
+
$conditions [] = "( {$locations_table}.location_id = " . implode(" OR {$locations_table}.location_id = ", $location) .' )';
|
167 |
+
}elseif ( is_object($location) && get_class($location)=='EM_Location' ){ //Now we deal with objects
|
168 |
+
$conditions [] = " {$locations_table}.location_id = $location->id";
|
169 |
+
}elseif ( is_array($location) && @get_class(current($location)=='EM_Location') ){ //we can accept array of ids or EM_Location objects
|
170 |
+
foreach($location as $EM_Location){
|
171 |
+
$location_ids[] = $EM_Location->id;
|
172 |
+
}
|
173 |
+
$conditions[] = "( {$locations_table}.location_id=". implode(" {$locations_table}.location_id=", $location_ids) ." )";
|
174 |
+
}
|
175 |
+
|
176 |
+
//Add conditions for category selection
|
177 |
+
//Filter by category, can be id or comma seperated ids
|
178 |
+
//TODO create an exclude category option
|
179 |
+
if ( $category != '' && is_numeric($category) ){
|
180 |
+
$conditions [] = " event_category_id = $category";
|
181 |
+
}elseif( self::array_is_numeric($category) ){
|
182 |
+
$conditions [] = "( event_category_id = ". implode(' OR event_category_id = ', $category).")";
|
183 |
+
}
|
184 |
+
|
185 |
+
return $conditions;
|
186 |
+
}
|
187 |
+
|
188 |
|
189 |
/**
|
190 |
* Save an array into this class.
|
events-manager.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Events Manager
|
4 |
-
Version: 3.0.
|
5 |
Plugin URI: http://davidebenini.it/wordpress-plugins/events-manager/
|
6 |
Description: Manage events specifying precise spatial data (Location, Town, Province, etc).
|
7 |
Author: Davide Benini, Marcus Sykes
|
@@ -46,15 +46,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
46 |
include_once('classes/object.php'); //Base object, any files below may depend on this
|
47 |
//Template Tags & Template Logic
|
48 |
include_once("ajax.php");
|
49 |
-
include_once("events.php");
|
50 |
-
include_once("locations.php");
|
51 |
include_once("bookings.php");
|
|
|
52 |
include_once("functions.php");
|
|
|
|
|
53 |
include_once("shortcode.php");
|
54 |
include_once("template-tags.php");
|
55 |
include_once("template-tags-depreciated.php"); //To depreciate
|
56 |
//Widgets
|
57 |
include_once("widgets/events.php");
|
|
|
58 |
include_once("widgets/calendar.php");
|
59 |
//Classes
|
60 |
include_once('classes/booking.php');
|
@@ -85,7 +87,7 @@ if( is_admin() ){
|
|
85 |
|
86 |
|
87 |
// Setting constants
|
88 |
-
define('EM_VERSION', 3); //self expanatory
|
89 |
define('DBEM_CATEGORIES_TBNAME', 'em_categories'); //TABLE NAME
|
90 |
define('EVENTS_TBNAME','em_events'); //TABLE NAME
|
91 |
define('RECURRENCE_TBNAME','dbem_recurrence'); //TABLE NAME
|
@@ -104,12 +106,14 @@ define('DEFAULT_EVENT_PAGE_TITLE_FORMAT', '#_NAME');
|
|
104 |
define('DEFAULT_RSS_DESCRIPTION_FORMAT',"#j #M #y - #H:#i <br/>#_LOCATION <br/>#_ADDRESS <br/>#_TOWN");
|
105 |
define('DEFAULT_RSS_TITLE_FORMAT',"#_NAME");
|
106 |
define('DEFAULT_MAP_TEXT_FORMAT', '<strong>#_LOCATION</strong><p>#_ADDRESS</p><p>#_TOWN</p>');
|
107 |
-
define('DEFAULT_WIDGET_EVENT_LIST_ITEM_FORMAT','
|
|
|
108 |
define('DEFAULT_NO_EVENTS_MESSAGE', __('No events', 'dbem'));
|
109 |
define('DEFAULT_SINGLE_LOCATION_FORMAT', '<p>#_ADDRESS</p><p>#_TOWN</p>');
|
110 |
define('DEFAULT_LOCATION_PAGE_TITLE_FORMAT', '#_NAME');
|
111 |
define('DEFAULT_LOCATION_BALOON_FORMAT', "<strong>#_NAME</strong><br/>#_ADDRESS - #_TOWN<br/><a href='#_LOCATIONPAGEURL'>Details</a>");
|
112 |
define('DEFAULT_LOCATION_EVENT_LIST_ITEM_FORMAT', "<li>#_NAME - #j #M #Y - #H:#i</li>");
|
|
|
113 |
define('DEFAULT_LOCATION_NO_EVENTS_MESSAGE', __('<li>No events in this location</li>', 'dbem'));
|
114 |
define("IMAGE_UPLOAD_DIR", "wp-content/uploads/locations-pics");
|
115 |
define('DEFAULT_IMAGE_MAX_WIDTH', 700);
|
@@ -176,10 +180,10 @@ function em_load_event(){
|
|
176 |
$EM_Recurrences = array();
|
177 |
if( isset( $_REQUEST['event_id'] ) && is_numeric($_REQUEST['event_id']) ){
|
178 |
$EM_Event = new EM_Event($_REQUEST['event_id']);
|
179 |
-
}elseif( $_REQUEST['recurrence_id'] && is_numeric($_REQUEST['recurrence_id']) ){
|
180 |
//Eventually we can just remove this.... each event has an event_id regardless of what it is.
|
181 |
$EM_Event = new EM_Event($_REQUEST['recurrence_id']);
|
182 |
-
}elseif( $_REQUEST['location_id'] && is_numeric($_REQUEST['location_id']) ){
|
183 |
$EM_Location = new EM_Location($_REQUEST['location_id']);
|
184 |
}
|
185 |
$EM_Mailer = new EM_Mailer();
|
@@ -218,7 +222,7 @@ function em_create_events_submenu () {
|
|
218 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Edit'),__('Edit'),MIN_CAPABILITY,__FILE__,'dbem_events_subpanel');
|
219 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Add new', 'dbem'), __('Add new','dbem'), MIN_CAPABILITY, 'new_event', "dbem_new_event_page");
|
220 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Locations', 'dbem'), __('Locations', 'dbem'), MIN_CAPABILITY, 'locations', "dbem_locations_page");
|
221 |
-
$plugin_pages[] = add_submenu_page(__FILE__, __('People', 'dbem'), __('People', 'dbem'), MIN_CAPABILITY, 'people', "
|
222 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Event Categories','dbem'),__('Categories','dbem'), SETTING_CAPABILITY, "events-manager-categories", 'dbem_categories_subpanel');
|
223 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Events Manager Settings','dbem'),__('Settings','dbem'), SETTING_CAPABILITY, "events-manager-options", 'dbem_options_subpanel');
|
224 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Getting Help for Events Manager','dbem'),__('Help','dbem'), SETTING_CAPABILITY, "events-manager-support", 'em_admin_support');
|
@@ -258,11 +262,11 @@ add_filter ( 'favorite_actions', 'em_favorite_menu' );
|
|
258 |
*/
|
259 |
function em_admin_warnings() {
|
260 |
//If we're editing the events page show hello to new user
|
|
|
261 |
if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true'){
|
262 |
// Disable Hello to new user if requested
|
263 |
update_option ( 'dbem_hello_to_user', 0 );
|
264 |
}else{
|
265 |
-
$events_page_id = get_option ( 'dbem_events_page' );
|
266 |
if ( preg_match( '/(post|page).php/', $_SERVER ['SCRIPT_NAME']) && isset ( $_GET ['action'] ) && $_GET ['action'] == 'edit' && isset ( $_GET ['post'] ) && $_GET ['post'] == "$events_page_id") {
|
267 |
$message = sprintf ( __ ( "This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by <strong>Events Manager</strong>. If you want to display your content, you can can assign another page to <strong>Events Manager</strong> in the the <a href='%s'>Settings</a>. ", 'dbem' ), 'admin.php?page=events-manager-options' );
|
268 |
$notice = "<div class='error'><p>$message</p></div>";
|
@@ -270,10 +274,10 @@ function em_admin_warnings() {
|
|
270 |
}
|
271 |
}
|
272 |
//If events page couldn't be created
|
273 |
-
if( $_GET['em_dismiss_events_page']
|
274 |
update_option('dbem_dismiss_events_page',1);
|
275 |
}else{
|
276 |
-
if ( !get_page(
|
277 |
$dismiss_link_joiner = ( count($_GET) > 0 ) ? '&':'?';
|
278 |
$advice = 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">options 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'), get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'em_dismiss_events_page=1' );
|
279 |
?>
|
@@ -293,8 +297,7 @@ function em_activate() {
|
|
293 |
}
|
294 |
register_activation_hook( __FILE__,'em_activate');
|
295 |
|
296 |
-
if( $_GET['em_reimport']
|
297 |
require_once(WP_PLUGIN_DIR.'/events-manager/install.php');
|
298 |
}
|
299 |
-
|
300 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Events Manager
|
4 |
+
Version: 3.0.3
|
5 |
Plugin URI: http://davidebenini.it/wordpress-plugins/events-manager/
|
6 |
Description: Manage events specifying precise spatial data (Location, Town, Province, etc).
|
7 |
Author: Davide Benini, Marcus Sykes
|
46 |
include_once('classes/object.php'); //Base object, any files below may depend on this
|
47 |
//Template Tags & Template Logic
|
48 |
include_once("ajax.php");
|
|
|
|
|
49 |
include_once("bookings.php");
|
50 |
+
include_once("events.php");
|
51 |
include_once("functions.php");
|
52 |
+
include_once("locations.php");
|
53 |
+
include_once("rss.php");
|
54 |
include_once("shortcode.php");
|
55 |
include_once("template-tags.php");
|
56 |
include_once("template-tags-depreciated.php"); //To depreciate
|
57 |
//Widgets
|
58 |
include_once("widgets/events.php");
|
59 |
+
include_once("widgets/locations.php");
|
60 |
include_once("widgets/calendar.php");
|
61 |
//Classes
|
62 |
include_once('classes/booking.php');
|
87 |
|
88 |
|
89 |
// Setting constants
|
90 |
+
define('EM_VERSION', 3.02); //self expanatory
|
91 |
define('DBEM_CATEGORIES_TBNAME', 'em_categories'); //TABLE NAME
|
92 |
define('EVENTS_TBNAME','em_events'); //TABLE NAME
|
93 |
define('RECURRENCE_TBNAME','dbem_recurrence'); //TABLE NAME
|
106 |
define('DEFAULT_RSS_DESCRIPTION_FORMAT',"#j #M #y - #H:#i <br/>#_LOCATION <br/>#_ADDRESS <br/>#_TOWN");
|
107 |
define('DEFAULT_RSS_TITLE_FORMAT',"#_NAME");
|
108 |
define('DEFAULT_MAP_TEXT_FORMAT', '<strong>#_LOCATION</strong><p>#_ADDRESS</p><p>#_TOWN</p>');
|
109 |
+
define('DEFAULT_WIDGET_EVENT_LIST_ITEM_FORMAT','#_LINKEDNAME<ul><li>#j #M #y</li><li>#_TOWN</li></ul>');
|
110 |
+
define('DEFAULT_WIDGET_LOCATION_LIST_ITEM_FORMAT','#_LOCATIONLINK<ul><li>#_ADDRESS</li><li>#_TOWN</li></ul>');
|
111 |
define('DEFAULT_NO_EVENTS_MESSAGE', __('No events', 'dbem'));
|
112 |
define('DEFAULT_SINGLE_LOCATION_FORMAT', '<p>#_ADDRESS</p><p>#_TOWN</p>');
|
113 |
define('DEFAULT_LOCATION_PAGE_TITLE_FORMAT', '#_NAME');
|
114 |
define('DEFAULT_LOCATION_BALOON_FORMAT', "<strong>#_NAME</strong><br/>#_ADDRESS - #_TOWN<br/><a href='#_LOCATIONPAGEURL'>Details</a>");
|
115 |
define('DEFAULT_LOCATION_EVENT_LIST_ITEM_FORMAT', "<li>#_NAME - #j #M #Y - #H:#i</li>");
|
116 |
+
define('DEFAULT_LOCATION_LIST_ITEM_FORMAT','#_LOCATIONLINK<ul><li>#_ADDRESS</li><li>#_TOWN</li></ul>');
|
117 |
define('DEFAULT_LOCATION_NO_EVENTS_MESSAGE', __('<li>No events in this location</li>', 'dbem'));
|
118 |
define("IMAGE_UPLOAD_DIR", "wp-content/uploads/locations-pics");
|
119 |
define('DEFAULT_IMAGE_MAX_WIDTH', 700);
|
180 |
$EM_Recurrences = array();
|
181 |
if( isset( $_REQUEST['event_id'] ) && is_numeric($_REQUEST['event_id']) ){
|
182 |
$EM_Event = new EM_Event($_REQUEST['event_id']);
|
183 |
+
}elseif( isset($_REQUEST['recurrence_id']) && is_numeric($_REQUEST['recurrence_id']) ){
|
184 |
//Eventually we can just remove this.... each event has an event_id regardless of what it is.
|
185 |
$EM_Event = new EM_Event($_REQUEST['recurrence_id']);
|
186 |
+
}elseif( isset($_REQUEST['location_id']) && is_numeric($_REQUEST['location_id']) ){
|
187 |
$EM_Location = new EM_Location($_REQUEST['location_id']);
|
188 |
}
|
189 |
$EM_Mailer = new EM_Mailer();
|
222 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Edit'),__('Edit'),MIN_CAPABILITY,__FILE__,'dbem_events_subpanel');
|
223 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Add new', 'dbem'), __('Add new','dbem'), MIN_CAPABILITY, 'new_event', "dbem_new_event_page");
|
224 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Locations', 'dbem'), __('Locations', 'dbem'), MIN_CAPABILITY, 'locations', "dbem_locations_page");
|
225 |
+
$plugin_pages[] = add_submenu_page(__FILE__, __('People', 'dbem'), __('People', 'dbem'), MIN_CAPABILITY, 'people', "em_people_page");
|
226 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Event Categories','dbem'),__('Categories','dbem'), SETTING_CAPABILITY, "events-manager-categories", 'dbem_categories_subpanel');
|
227 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Events Manager Settings','dbem'),__('Settings','dbem'), SETTING_CAPABILITY, "events-manager-options", 'dbem_options_subpanel');
|
228 |
$plugin_pages[] = add_submenu_page(__FILE__, __('Getting Help for Events Manager','dbem'),__('Help','dbem'), SETTING_CAPABILITY, "events-manager-support", 'em_admin_support');
|
262 |
*/
|
263 |
function em_admin_warnings() {
|
264 |
//If we're editing the events page show hello to new user
|
265 |
+
$events_page_id = get_option ( 'dbem_events_page' );
|
266 |
if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true'){
|
267 |
// Disable Hello to new user if requested
|
268 |
update_option ( 'dbem_hello_to_user', 0 );
|
269 |
}else{
|
|
|
270 |
if ( preg_match( '/(post|page).php/', $_SERVER ['SCRIPT_NAME']) && isset ( $_GET ['action'] ) && $_GET ['action'] == 'edit' && isset ( $_GET ['post'] ) && $_GET ['post'] == "$events_page_id") {
|
271 |
$message = sprintf ( __ ( "This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by <strong>Events Manager</strong>. If you want to display your content, you can can assign another page to <strong>Events Manager</strong> in the the <a href='%s'>Settings</a>. ", 'dbem' ), 'admin.php?page=events-manager-options' );
|
272 |
$notice = "<div class='error'><p>$message</p></div>";
|
274 |
}
|
275 |
}
|
276 |
//If events page couldn't be created
|
277 |
+
if( !empty($_GET['em_dismiss_events_page']) ){
|
278 |
update_option('dbem_dismiss_events_page',1);
|
279 |
}else{
|
280 |
+
if ( !get_page($events_page_id) && !get_option('dbem_dismiss_events_page') ){
|
281 |
$dismiss_link_joiner = ( count($_GET) > 0 ) ? '&':'?';
|
282 |
$advice = 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">options 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'), get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'em_dismiss_events_page=1' );
|
283 |
?>
|
297 |
}
|
298 |
register_activation_hook( __FILE__,'em_activate');
|
299 |
|
300 |
+
if( !empty($_GET['em_reimport']) || get_option('dbem_import_fail') == '1' ){
|
301 |
require_once(WP_PLUGIN_DIR.'/events-manager/install.php');
|
302 |
}
|
|
|
303 |
?>
|
includes/js/em_admin.js
CHANGED
@@ -75,11 +75,15 @@ jQuery(document).ready( function($) {
|
|
75 |
if( $('#date-to-submit').length > 0 ){
|
76 |
$("#localised-date").datepicker({
|
77 |
altField: "#date-to-submit",
|
78 |
-
altFormat: "yy-mm-dd"
|
|
|
|
|
79 |
});
|
80 |
$("#localised-end-date").datepicker({
|
81 |
altField: "#end-date-to-submit",
|
82 |
-
altFormat: "yy-mm-dd"
|
|
|
|
|
83 |
});
|
84 |
if( $('#date-to-submit').val() != '' ){
|
85 |
date_dateFormat = $("#localised-date").datepicker('option', 'dateFormat');
|
75 |
if( $('#date-to-submit').length > 0 ){
|
76 |
$("#localised-date").datepicker({
|
77 |
altField: "#date-to-submit",
|
78 |
+
altFormat: "yy-mm-dd",
|
79 |
+
changeMonth: true,
|
80 |
+
changeYear: true
|
81 |
});
|
82 |
$("#localised-end-date").datepicker({
|
83 |
altField: "#end-date-to-submit",
|
84 |
+
altFormat: "yy-mm-dd",
|
85 |
+
changeMonth: true,
|
86 |
+
changeYear: true
|
87 |
});
|
88 |
if( $('#date-to-submit').val() != '' ){
|
89 |
date_dateFormat = $("#localised-date").datepicker('option', 'dateFormat');
|
includes/js/em_calendar_ajax.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
//inserted at wp_head
|
2 |
jQuery(document).ready( function($) {
|
3 |
-
$('.dbem-calendar a.em-calnav').live('click', function(e){
|
4 |
e.preventDefault();
|
5 |
$(this).parents('.em-calendar-wrapper').first().load($(this).attr('href'));
|
6 |
} );
|
1 |
//inserted at wp_head
|
2 |
jQuery(document).ready( function($) {
|
3 |
+
$('.dbem-calendar a.em-calnav, .dbem-calendar-full a.em-calnav').live('click', function(e){
|
4 |
e.preventDefault();
|
5 |
$(this).parents('.em-calendar-wrapper').first().load($(this).attr('href'));
|
6 |
} );
|
includes/js/em_maps.js
CHANGED
@@ -9,7 +9,7 @@ function em_load_map( callback ) {
|
|
9 |
|
10 |
//Load a map on a single page
|
11 |
function em_map_single() {
|
12 |
-
em_LatLng = new google.maps.LatLng(
|
13 |
var map = new google.maps.Map( document.getElementById('em-location-map'), {
|
14 |
zoom: 14,
|
15 |
center: em_LatLng,
|
@@ -25,40 +25,43 @@ function em_map_single() {
|
|
25 |
}
|
26 |
|
27 |
function em_map_global() {
|
28 |
-
jQuery.getJSON(document.URL,
|
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 |
|
9 |
|
10 |
//Load a map on a single page
|
11 |
function em_map_single() {
|
12 |
+
em_LatLng = new google.maps.LatLng(em_latitude, em_longitude);
|
13 |
var map = new google.maps.Map( document.getElementById('em-location-map'), {
|
14 |
zoom: 14,
|
15 |
center: em_LatLng,
|
25 |
}
|
26 |
|
27 |
function em_map_global() {
|
28 |
+
jQuery.getJSON(document.URL, em_query, function(data){
|
29 |
+
if(data.length > 0){
|
30 |
+
var myLatlng = new google.maps.LatLng(data[0].location_latitude,data[0].location_longitude);
|
31 |
+
var myOptions = {
|
32 |
+
mapTypeId: google.maps.MapTypeId.ROADMAP
|
33 |
+
};
|
34 |
+
map = new google.maps.Map(document.getElementById("em-locations-map"), myOptions);
|
35 |
+
|
36 |
+
var minLatLngArr = [0,0];
|
37 |
+
var maxLatLngArr = [0,0];
|
38 |
+
|
39 |
+
for (var i = 0; i < data.length; i++) {
|
40 |
+
var latitude = parseFloat( data[i].location_latitude );
|
41 |
+
var longitude = parseFloat( data[i].location_longitude );
|
42 |
+
var location = new google.maps.LatLng( latitude, longitude );
|
43 |
+
var marker = new google.maps.Marker({
|
44 |
+
position: location,
|
45 |
+
map: map
|
46 |
+
});
|
47 |
+
marker.setTitle(data[i].location_name);
|
48 |
+
var myContent = '<div id="em-map-balloon"><div id="content">'+ data[i].location_balloon +'</div></div>';
|
49 |
+
em_map_infobox(marker, myContent);
|
50 |
+
|
51 |
+
//Get min and max long/lats
|
52 |
+
minLatLngArr[0] = (latitude < minLatLngArr[0] || i == 0) ? latitude : minLatLngArr[0];
|
53 |
+
minLatLngArr[1] = (longitude < minLatLngArr[1] || i == 0) ? longitude : minLatLngArr[1];
|
54 |
+
maxLatLngArr[0] = (latitude > maxLatLngArr[0] || i == 0) ? latitude : maxLatLngArr[0];
|
55 |
+
maxLatLngArr[1] = (longitude > maxLatLngArr[1] || i == 0) ? longitude : maxLatLngArr[1];
|
56 |
+
}
|
57 |
+
// Zoom in to the bounds
|
58 |
+
var minLatLng = new google.maps.LatLng(minLatLngArr[0],minLatLngArr[1]);
|
59 |
+
var maxLatLng = new google.maps.LatLng(maxLatLngArr[0],maxLatLngArr[1]);
|
60 |
+
var bounds = new google.maps.LatLngBounds(minLatLng,maxLatLng);
|
61 |
+
map.fitBounds(bounds);
|
62 |
+
}else{
|
63 |
+
jQuery('#em-locations-map').children().first().html('No locations found');
|
64 |
+
}
|
65 |
});
|
66 |
}
|
67 |
|
includes/sample-placeholers/event-single.html
CHANGED
@@ -43,8 +43,11 @@
|
|
43 |
<tr>
|
44 |
<th>Where? </th>
|
45 |
<td>
|
46 |
-
#
|
47 |
-
<
|
|
|
|
|
|
|
48 |
#_LOCEXCERPT
|
49 |
<br />
|
50 |
#_MAP
|
43 |
<tr>
|
44 |
<th>Where? </th>
|
45 |
<td>
|
46 |
+
#_IMAGE
|
47 |
+
<p>#_LOCATION, #_ADDRESS, #_TOWN
|
48 |
+
<br/>
|
49 |
+
Links - #_LOCATIONPAGEURL or #_LOCATIONURL or #_LOCATIONLINK
|
50 |
+
</p>
|
51 |
#_LOCEXCERPT
|
52 |
<br />
|
53 |
#_MAP
|
install.php
CHANGED
@@ -179,6 +179,7 @@ function em_add_options() {
|
|
179 |
'dbem_location_page_title_format' => DEFAULT_LOCATION_PAGE_TITLE_FORMAT,
|
180 |
'dbem_location_baloon_format' => DEFAULT_LOCATION_BALOON_FORMAT,
|
181 |
'dbem_location_event_list_item_format' => DEFAULT_LOCATION_EVENT_LIST_ITEM_FORMAT,
|
|
|
182 |
'dbem_location_no_events_message' => DEFAULT_LOCATION_NO_EVENTS_MESSAGE,
|
183 |
'dbem_single_location_format' => DEFAULT_SINGLE_LOCATION_FORMAT,
|
184 |
'dbem_map_text_format' => DEFAULT_MAP_TEXT_FORMAT,
|
@@ -205,10 +206,10 @@ function em_add_options() {
|
|
205 |
'dbem_small_calendar_event_title_separator' => DEFAULT_SMALL_CALENDAR_EVENT_TITLE_SEPARATOR,
|
206 |
'dbem_hello_to_user' => 1,
|
207 |
'dbem_use_select_for_locations' => DEFAULT_USE_SELECT_FOR_LOCATIONS,
|
208 |
-
'dbem_attributes_enabled'
|
209 |
-
'dbem_recurrence_enabled'
|
210 |
-
'dbem_rsvp_enabled'
|
211 |
-
'dbem_categories_enabled'
|
212 |
|
213 |
foreach($dbem_options as $key => $value){
|
214 |
add_option($key, $value);
|
179 |
'dbem_location_page_title_format' => DEFAULT_LOCATION_PAGE_TITLE_FORMAT,
|
180 |
'dbem_location_baloon_format' => DEFAULT_LOCATION_BALOON_FORMAT,
|
181 |
'dbem_location_event_list_item_format' => DEFAULT_LOCATION_EVENT_LIST_ITEM_FORMAT,
|
182 |
+
'dbem_location_list_item_format' => DEFAULT_LOCATION_LIST_ITEM_FORMAT,
|
183 |
'dbem_location_no_events_message' => DEFAULT_LOCATION_NO_EVENTS_MESSAGE,
|
184 |
'dbem_single_location_format' => DEFAULT_SINGLE_LOCATION_FORMAT,
|
185 |
'dbem_map_text_format' => DEFAULT_MAP_TEXT_FORMAT,
|
206 |
'dbem_small_calendar_event_title_separator' => DEFAULT_SMALL_CALENDAR_EVENT_TITLE_SEPARATOR,
|
207 |
'dbem_hello_to_user' => 1,
|
208 |
'dbem_use_select_for_locations' => DEFAULT_USE_SELECT_FOR_LOCATIONS,
|
209 |
+
'dbem_attributes_enabled' => DEFAULT_ATTRIBUTES_ENABLED,
|
210 |
+
'dbem_recurrence_enabled'=> DEFAULT_RECURRENCE_ENABLED,
|
211 |
+
'dbem_rsvp_enabled'=> DEFAULT_RSVP_ENABLED,
|
212 |
+
'dbem_categories_enabled'=> DEFAULT_CATEGORIES_ENABLED);
|
213 |
|
214 |
foreach($dbem_options as $key => $value){
|
215 |
add_option($key, $value);
|
locations.php
CHANGED
@@ -6,7 +6,10 @@
|
|
6 |
*/
|
7 |
|
8 |
function dbem_get_locations($eventful = false) {
|
9 |
-
|
|
|
|
|
|
|
10 |
}
|
11 |
|
12 |
function dbem_get_location($location_id) {
|
6 |
*/
|
7 |
|
8 |
function dbem_get_locations($eventful = false) {
|
9 |
+
$EM_Locations = EM_Locations::get(array('eventful'=>$eventful));
|
10 |
+
foreach ($EM_Locations as $key => $EM_Location){
|
11 |
+
$EM_Locations[$key] = $EM_Location->to_array();
|
12 |
+
}
|
13 |
}
|
14 |
|
15 |
function dbem_get_location($location_id) {
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: nutsmuggler, netweblogic
|
3 |
Donate link: http://davidebenini.it
|
4 |
Tags: events, manager, calendar, gigs, concert, maps, geotagging, rsvp
|
5 |
-
Requires at least: 2.
|
6 |
Tested up to: 3.0.1
|
7 |
-
Stable tag: 3.0.
|
8 |
|
9 |
Manage events and display them in your blog. Includes recurring events, location management, calendar, Google map integration, RSVP.
|
10 |
|
@@ -108,136 +108,41 @@ At this stage, Events Manager is only available in English and Italian. Yet, the
|
|
108 |
2. The events management page.
|
109 |
3. The Events Manager Options page.
|
110 |
|
|
|
|
|
|
|
|
|
|
|
111 |
== Change Log ==
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
1
|
128 |
-
Fixed a bug that caused trouble in the new post page javascript
|
129 |
-
|
130 |
-
1.0
|
131 |
-
No changes, only made this plugin officially out of beta after weeks without any bug popping out.
|
132 |
-
|
133 |
-
1.0.1
|
134 |
-
Added the `dbem_is_events_page` `dbem_is_single_event_page`, `dbem_is_multiple_events_page()`, `dbem_are_events_available` conditional template tags.
|
135 |
-
Added a "no events message option".
|
136 |
-
Added two important FAQ items, to document how to prevent the "green screen on death" and how to resize the map.
|
137 |
-
Fixed a bug that filtered `the_content` even in unrelated lists.
|
138 |
-
Fixed CSS bug: enclosed list in Events page in "ul" elements, as it should be.
|
139 |
-
Fixed a bug loaded the Google Maps Api when deleting events.
|
140 |
-
Fixed a bug that prevented validation in the default widget list item format.
|
141 |
-
|
142 |
-
1.1b
|
143 |
-
Added a javascript datepicker
|
144 |
-
|
145 |
-
2.0b1
|
146 |
-
Added locations support.
|
147 |
-
Added RSVP and people management.
|
148 |
-
Added repeated events.
|
149 |
-
Added multiple map.
|
150 |
-
Fixed a bug in calendars which displayed only the first events when more are present.
|
151 |
-
|
152 |
-
2.0b2
|
153 |
-
Fixed some bugs
|
154 |
-
|
155 |
-
2.0b3
|
156 |
-
Fixed some bugs affecting EM 1.0 users
|
157 |
-
Added 2 settings: EM page as calendar and change EM page
|
158 |
-
Added Swedish and German localisations
|
159 |
-
|
160 |
-
2.0b4
|
161 |
-
Fixed a bug in the RSS generator
|
162 |
-
Added alternate start and end time selector for those installs not supporting the default system
|
163 |
-
Removed "Mappa totale" from the gloabl map code
|
164 |
-
Fixed a problem in the back button in the events table
|
165 |
-
Removed some debug "echo" from the RSVP form
|
166 |
-
Hopefully fixed a database scheme bug that some users signalled
|
167 |
-
|
168 |
-
2.0rc1
|
169 |
-
Added JS validation and fallback server-side validation
|
170 |
-
Added a dbem\_is\_rsvpable() conditional template tag
|
171 |
-
Fixed a css bug with some themes, preventing the correct visualisation of the map.
|
172 |
-
Fixed MySql bugs in the main view and in the activation page
|
173 |
-
Added the proper expanded PHP tags
|
174 |
-
Fixed links in the RSS feed
|
175 |
-
|
176 |
-
2.0rc2
|
177 |
-
Marcus Skies jumps in as a contributor
|
178 |
-
Made the edit page WP 2.8 compatible (CSS tags)
|
179 |
-
Added a "Duplicate Event", since your reoccurring event doesn't give perfect date flexibility
|
180 |
-
Added a Category option, so you can categorize each event
|
181 |
-
Manage categories with own subpanel
|
182 |
-
DDM available in event page (like with people)
|
183 |
-
Added shortcode option in event_list, so category=ID is an option now
|
184 |
-
Added #_CATEGORY as a placeholder
|
185 |
-
Added the TinyMCE of wordpress to the description of the event. That solves the problem of adding pictures!
|
186 |
-
Added an end date option always on for multi-day events.
|
187 |
-
Added a new placeholder format to deal with the end date. You can now wrap dates in #_{} or #@_{} . The values inside will have a format of date(). For example #_{Y-m-d} #@_{ \u\n\t\i\l Y-m-d} will show as "2009-03-23 until 2009-03-28" (only for end dates with no recurrence) or just "2009-03-23" for normal events.
|
188 |
-
|
189 |
-
2.1
|
190 |
-
Properly added Marcus Sykes as a contributor
|
191 |
-
Added a full calendar
|
192 |
-
Added an #_EDITEVENT placeholder
|
193 |
-
Added Brazialian Portuguese localization and some translatable strings
|
194 |
-
Added a today scope for events lists
|
195 |
-
Increased to 3 te default lists limit
|
196 |
-
Categories are now displayed in the events table
|
197 |
-
Now weeks starts according to WP settings
|
198 |
-
Moved the hide page option up for better access
|
199 |
-
Attributes column was not created when the plugin was upgraded, fixed
|
200 |
-
Added comment field to the RSVP form and #_COMMENT placeholder in RSVP email templates
|
201 |
-
Added customizable title to small calendar
|
202 |
-
Removed php short tags
|
203 |
-
Changed RVSP 'no seats available message' for better English
|
204 |
-
Bugfix: there was a time bug
|
205 |
-
Bugfix: event_time not taken into consideration in ordering events, fixed
|
206 |
-
Bugfix: on calendar for days after 28 on the event calendar view
|
207 |
-
Bugfix: for events in days with single digit
|
208 |
-
Bugfix: events link in the calendar now work with permalink
|
209 |
-
Bugfix: today in next mont was not matched in the calendar
|
210 |
-
Bugfix: _RESPPHONE was not matched in emails
|
211 |
-
Bugfix: fixed security vulnerability, which could lead to sql inject attacks
|
212 |
-
Bugfix: locations with apostrophe were duplicated
|
213 |
-
Bugfix: bloginfo('wpurl') instead of bloginfo('url')
|
214 |
-
Bugfix: now loading textdomain in the new (not deprecated) way
|
215 |
-
|
216 |
-
2.2
|
217 |
-
Adding a option to get events through a select
|
218 |
-
Closed many bugs causing a notices/warning visible only in debug mode
|
219 |
-
Closed a critical security hole discovered by Danilo Massa (to be released on May 10th)
|
220 |
-
|
221 |
-
2.2.1
|
222 |
-
newtweblogic fixed a bug in the install routine
|
223 |
-
|
224 |
-
2.2.2
|
225 |
-
Small fix that stopped custom fields from showing up in events lists.
|
226 |
-
|
227 |
-
3.0
|
228 |
-
Refactored all the underlying achitecture, to make it object oriented. Now classes and templates are separate.
|
229 |
-
Merged the events and recurrences tables
|
230 |
-
Tables migration from dbem to em (to provide a fallback in case the previous merge goes wrong)
|
231 |
-
Bugfix: 127 limit increased (got rid of tinyint types)
|
232 |
-
Bugfix: fixed all major php bugs preventing the use with Wordpress 3.0
|
233 |
-
Bugfix: fixed all major js bugs preventing the use with Wordpress 3.0
|
234 |
-
Restyling of the Settings page
|
235 |
-
Added a setting to revert to 2.2
|
236 |
-
|
237 |
-
=3.0.1=
|
238 |
* Fixed spelling typos
|
239 |
* Fixed warnings for bad location image uploads (e.g. too big etc.)
|
240 |
* Fixed error for #_EXCERPT not showing
|
241 |
|
242 |
-
=3.0
|
243 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
Contributors: nutsmuggler, netweblogic
|
3 |
Donate link: http://davidebenini.it
|
4 |
Tags: events, manager, calendar, gigs, concert, maps, geotagging, rsvp
|
5 |
+
Requires at least: 2.9
|
6 |
Tested up to: 3.0.1
|
7 |
+
Stable tag: 3.0.3
|
8 |
|
9 |
Manage events and display them in your blog. Includes recurring events, location management, calendar, Google map integration, RSVP.
|
10 |
|
108 |
2. The events management page.
|
109 |
3. The Events Manager Options page.
|
110 |
|
111 |
+
== Upgrade Notice ==
|
112 |
+
|
113 |
+
= 3.0.3 =
|
114 |
+
This fixes some recurrence issues along with most other bugs we've been made aware of.
|
115 |
+
|
116 |
== Change Log ==
|
117 |
|
118 |
+
= 3.0.3 =
|
119 |
+
* RSS Showing up again
|
120 |
+
* Fixed some reported fatal errors
|
121 |
+
* Added locations widget
|
122 |
+
* Adding location widget
|
123 |
+
* optimizing EM_Locations and removing redundant code across objects
|
124 |
+
* fixed locations_map shortcode attributes
|
125 |
+
* harmonized search attributes for locations and events
|
126 |
+
* rewrote recurrence code from scratch
|
127 |
+
* got rid of most php notices
|
128 |
+
|
129 |
+
= 3.0.2 =
|
130 |
+
* Recruccence bugfix
|
131 |
+
|
132 |
+
= 3.0.1 =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
* Fixed spelling typos
|
134 |
* Fixed warnings for bad location image uploads (e.g. too big etc.)
|
135 |
* Fixed error for #_EXCERPT not showing
|
136 |
|
137 |
+
= 3.0 =
|
138 |
+
* Refactored all the underlying achitecture, to make it object oriented. Now classes and templates are separate.
|
139 |
+
* Merged the events and recurrences tables
|
140 |
+
* Tables migration from dbem to em (to provide a fallback in case the previous merge goes wrong)
|
141 |
+
* Bugfix: 127 limit increased (got rid of tinyint types)
|
142 |
+
* Bugfix: fixed all major php bugs preventing the use with Wordpress 3.0
|
143 |
+
* Bugfix: fixed all major js bugs preventing the use with Wordpress 3.0
|
144 |
+
* Restyling of the Settings page
|
145 |
+
* Added a setting to revert to 2.2
|
146 |
+
* optimizing EM_Locations and removing redundant code across objects
|
147 |
+
|
148 |
+
For changelog of 2.x and lower, see the readme.txt file of version 2.2.2
|
rss.php
CHANGED
@@ -1,54 +1,43 @@
|
|
1 |
<?php
|
2 |
-
function
|
3 |
-
if (
|
4 |
header ( "Content-type: text/xml" );
|
5 |
echo "<?xml version='1.0'?>\n";
|
6 |
|
7 |
$events_page_id = get_option ( 'dbem_events_page' );
|
8 |
$events_page_link = get_permalink ( $events_page_id );
|
9 |
-
|
10 |
-
$joiner = "&";
|
11 |
-
else
|
12 |
-
$joiner = "?";
|
13 |
-
|
14 |
?>
|
15 |
<rss version="2.0">
|
16 |
-
<channel>
|
17 |
-
<title><?php
|
18 |
-
echo
|
19 |
-
?></
|
20 |
-
<
|
21 |
-
|
22 |
-
|
23 |
-
<
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
echo "<link>$events_page_link" . $joiner . "event_id=" . $event->id . "</link>\n ";
|
42 |
-
echo "<description>$description </description>\n";
|
43 |
-
echo "</item>";
|
44 |
-
}
|
45 |
-
?>
|
46 |
-
</channel>
|
47 |
</rss>
|
48 |
-
|
49 |
-
<?php
|
50 |
die ();
|
51 |
}
|
52 |
}
|
53 |
-
add_action ( 'init', '
|
54 |
?>
|
1 |
<?php
|
2 |
+
function em_rss() {
|
3 |
+
if ( !empty( $_REQUEST ['dbem_rss'] ) ) {
|
4 |
header ( "Content-type: text/xml" );
|
5 |
echo "<?xml version='1.0'?>\n";
|
6 |
|
7 |
$events_page_id = get_option ( 'dbem_events_page' );
|
8 |
$events_page_link = get_permalink ( $events_page_id );
|
9 |
+
$joiner = ( stristr($events_page_link, "?") ) ? "&":"?";
|
|
|
|
|
|
|
|
|
10 |
?>
|
11 |
<rss version="2.0">
|
12 |
+
<channel>
|
13 |
+
<title><?php echo get_option ( 'dbem_rss_main_title' ); ?></title>
|
14 |
+
<link><?php echo $events_page_link; ?></link>
|
15 |
+
<description><?php echo get_option ( 'dbem_rss_main_description' ); ?></description>
|
16 |
+
<docs>
|
17 |
+
http://blogs.law.harvard.edu/tech/rss
|
18 |
+
</docs>
|
19 |
+
<generator>
|
20 |
+
Weblog Editor 2.0
|
21 |
+
</generator>
|
22 |
+
<?php
|
23 |
+
$title_format = get_option ( 'dbem_rss_title_format' );
|
24 |
+
$description_format = str_replace ( ">", ">", str_replace ( "<", "<", get_option ( 'dbem_rss_description_format' ) ) );
|
25 |
+
$events = EM_Events::get( array('limit'=>5) );
|
26 |
+
foreach ( $events as $event ) {
|
27 |
+
$title = $event->output( $title_format, "rss" );
|
28 |
+
$description = $event->output( $description_format, "rss");
|
29 |
+
echo "<item>";
|
30 |
+
echo "<title>$title</title>\n";
|
31 |
+
echo "<link>$events_page_link" . $joiner . "event_id=" . $event->id . "</link>\n ";
|
32 |
+
echo "<description>$description </description>\n";
|
33 |
+
echo "</item>";
|
34 |
+
}
|
35 |
+
?>
|
36 |
+
</channel>
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</rss>
|
38 |
+
<?php
|
|
|
39 |
die ();
|
40 |
}
|
41 |
}
|
42 |
+
add_action ( 'init', 'em_rss' );
|
43 |
?>
|
shortcode.php
CHANGED
@@ -2,39 +2,51 @@
|
|
2 |
//TODO add a shortcode to link for a specific event, e.g. [event id=x]text[/event]
|
3 |
|
4 |
/**
|
5 |
-
* Returns the html of an events calendar.
|
6 |
* @param array $atts
|
7 |
* @return string
|
8 |
*/
|
9 |
function em_get_calendar_shortcode($atts) {
|
10 |
-
$atts =
|
11 |
-
|
12 |
-
$return .= EM_Calendar::get($atts);
|
13 |
-
$return .= '</div>';
|
14 |
-
return $return;
|
15 |
}
|
16 |
add_shortcode('events_calendar', 'em_get_calendar_shortcode');
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
return EM_Map::get_global($atts);
|
21 |
}
|
22 |
add_shortcode('locations_map', 'em_get_locations_map_shortcode');
|
23 |
add_shortcode('locations-map', 'em_get_locations_map_shortcode'); //Depreciate this... confusing for wordpress
|
24 |
|
25 |
/**
|
26 |
-
* Shows a list of events according to given specifications
|
27 |
* @param array $atts
|
28 |
* @return string
|
29 |
*/
|
30 |
function em_get_events_list_shortcode($atts) {
|
31 |
//TODO sort out attributes so it's consistent everywhere
|
32 |
-
$atts =
|
33 |
-
|
34 |
-
return $result;
|
35 |
}
|
36 |
add_shortcode ( 'events_list', 'em_get_events_list_shortcode' );
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* DO NOT DOCUMENT! This should be replaced with shortcodes events-link and events_uri
|
40 |
* @param array $atts
|
2 |
//TODO add a shortcode to link for a specific event, e.g. [event id=x]text[/event]
|
3 |
|
4 |
/**
|
5 |
+
* Returns the html of an events calendar with events that match given query attributes. Accepts any event query attribute.
|
6 |
* @param array $atts
|
7 |
* @return string
|
8 |
*/
|
9 |
function em_get_calendar_shortcode($atts) {
|
10 |
+
$atts = (array) $atts;
|
11 |
+
return EM_Calendar::get($atts);
|
|
|
|
|
|
|
12 |
}
|
13 |
add_shortcode('events_calendar', 'em_get_calendar_shortcode');
|
14 |
|
15 |
+
/**
|
16 |
+
* Generates a map of locations that match given query attributes. Accepts any location query attributes.
|
17 |
+
* @param unknown_type $atts
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
function em_get_locations_map_shortcode($atts){
|
21 |
+
$clean_atts = EM_Locations::get_default_search($atts);
|
22 |
+
$clean_atts['width'] = ( !empty($atts['width']) ) ? $atts['width']:450;
|
23 |
+
$clean_atts['height'] = ( !empty($atts['height']) ) ? $atts['height']:300;
|
24 |
return EM_Map::get_global($atts);
|
25 |
}
|
26 |
add_shortcode('locations_map', 'em_get_locations_map_shortcode');
|
27 |
add_shortcode('locations-map', 'em_get_locations_map_shortcode'); //Depreciate this... confusing for wordpress
|
28 |
|
29 |
/**
|
30 |
+
* Shows a list of events according to given specifications. Accepts any event query attribute.
|
31 |
* @param array $atts
|
32 |
* @return string
|
33 |
*/
|
34 |
function em_get_events_list_shortcode($atts) {
|
35 |
//TODO sort out attributes so it's consistent everywhere
|
36 |
+
$atts = (array) $atts;
|
37 |
+
return EM_Events::output ( $atts );
|
|
|
38 |
}
|
39 |
add_shortcode ( 'events_list', 'em_get_events_list_shortcode' );
|
40 |
|
41 |
+
/**
|
42 |
+
* Returns list of locations according to given specifications. Accepts any location query attribute.
|
43 |
+
*/
|
44 |
+
function em_get_locations_list_shortcode( $atts ){
|
45 |
+
$atts = (array) $atts;
|
46 |
+
return EM_Locations::output( $atts );
|
47 |
+
}
|
48 |
+
add_shortcode('locations_list', 'em_get_locations_list_shortcode');
|
49 |
+
|
50 |
/**
|
51 |
* DO NOT DOCUMENT! This should be replaced with shortcodes events-link and events_uri
|
52 |
* @param array $atts
|
template-tags-depreciated.php
CHANGED
@@ -17,20 +17,7 @@
|
|
17 |
* @return unknown_type
|
18 |
*/
|
19 |
function dbem_get_events_list($limit = "10", $scope = "future", $order = "ASC", $format = '', $echo = 1, $category = '') {
|
20 |
-
|
21 |
-
// allows the use of arguments without breaking the legacy code
|
22 |
-
$defaults = array ('limit' => 10, 'scope' => 'future', 'order' => 'ASC', 'format' => '', 'echo' => 1 , 'category' => '');
|
23 |
-
|
24 |
-
$r = wp_parse_args ( $limit, $defaults );
|
25 |
-
extract ( $r, EXTR_SKIP );
|
26 |
-
$limit = $r ['limit'];
|
27 |
-
$scope = $r ['scope'];
|
28 |
-
$order = $r ['order'];
|
29 |
-
$format = $r ['format'];
|
30 |
-
$echo = $r ['echo'];
|
31 |
-
$category = ( preg_match('/^([0-9],?)+$/', $r ['category'] ) ) ? $r ['category'] : '' ;
|
32 |
-
}
|
33 |
-
$return = EM_Events::output(array('limit'=>$limit, 'scope'=>$scope, 'order'=>$order, 'category'=>$category));
|
34 |
if( $echo ) echo $return;
|
35 |
return $return;
|
36 |
}
|
17 |
* @return unknown_type
|
18 |
*/
|
19 |
function dbem_get_events_list($limit = "10", $scope = "future", $order = "ASC", $format = '', $echo = 1, $category = '') {
|
20 |
+
$return = EM_Events::output(array('limit'=>$limit, 'scope'=>$scope, 'order'=>$order, 'format'=>$format, 'category'=>$category));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
if( $echo ) echo $return;
|
22 |
return $return;
|
23 |
}
|
widgets/events.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
class EM_Widget extends WP_Widget {
|
7 |
/** constructor */
|
8 |
function EM_Widget() {
|
9 |
-
$widget_ops = array('description' => __( "
|
10 |
parent::WP_Widget(false, $name = 'Events', $widget_ops);
|
11 |
}
|
12 |
|
@@ -18,14 +18,17 @@ class EM_Widget extends WP_Widget {
|
|
18 |
echo $args['after_title'];
|
19 |
|
20 |
$events = EM_Events::get($instance);
|
21 |
-
//FIXME Events in widget aren't loading location data
|
22 |
echo "<ul>";
|
23 |
if ( count($events) > 0 ){
|
24 |
-
foreach($events as $event){
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
}else{
|
28 |
-
_e('No events', 'dbem');
|
29 |
}
|
30 |
echo "</ul>";
|
31 |
|
6 |
class EM_Widget extends WP_Widget {
|
7 |
/** constructor */
|
8 |
function EM_Widget() {
|
9 |
+
$widget_ops = array('description' => __( "Display a list of events on Events Manager.", 'dbem') );
|
10 |
parent::WP_Widget(false, $name = 'Events', $widget_ops);
|
11 |
}
|
12 |
|
18 |
echo $args['after_title'];
|
19 |
|
20 |
$events = EM_Events::get($instance);
|
|
|
21 |
echo "<ul>";
|
22 |
if ( count($events) > 0 ){
|
23 |
+
foreach($events as $event){
|
24 |
+
if( strpos($instance['format'], '<li>') == 0 ){
|
25 |
+
echo '<li>'. $event->output($instance['format']) .'</li>';
|
26 |
+
}else{
|
27 |
+
echo $event->output($instance['format']);
|
28 |
+
}
|
29 |
}
|
30 |
}else{
|
31 |
+
echo '<li>'._e('No events', 'dbem').'</li>';
|
32 |
}
|
33 |
echo "</ul>";
|
34 |
|
widgets/locations.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author marcus
|
4 |
+
* Standard events list widget
|
5 |
+
*/
|
6 |
+
class EM_Locations_Widget extends WP_Widget {
|
7 |
+
/** constructor */
|
8 |
+
function EM_Locations_Widget() {
|
9 |
+
$widget_ops = array('description' => __( "Display a list of event locations on Events Manager.", 'dbem') );
|
10 |
+
parent::WP_Widget(false, $name = 'Event Locations', $widget_ops);
|
11 |
+
}
|
12 |
+
|
13 |
+
/** @see WP_Widget::widget */
|
14 |
+
function widget($args, $instance) {
|
15 |
+
echo $args['before_widget'];
|
16 |
+
echo $args['before_title'];
|
17 |
+
echo $instance['title'];
|
18 |
+
echo $args['after_title'];
|
19 |
+
|
20 |
+
$locations = EM_Locations::get($instance);
|
21 |
+
echo "<ul>";
|
22 |
+
if ( count($locations) > 0 ){
|
23 |
+
foreach($locations as $location){
|
24 |
+
if( strpos($instance['format'], '<li>') == 0 ){
|
25 |
+
echo '<li>'. $location->output($instance['format']) .'</li>';
|
26 |
+
}else{
|
27 |
+
echo $location->output($instance['format']);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}else{
|
31 |
+
echo '<li>'.__('No locations', 'dbem').'</li>';
|
32 |
+
}
|
33 |
+
echo "</ul>";
|
34 |
+
|
35 |
+
echo $args['after_widget'];
|
36 |
+
}
|
37 |
+
|
38 |
+
/** @see WP_Widget::update */
|
39 |
+
function update($new_instance, $old_instance) {
|
40 |
+
//filter the new instance and replace blanks with defaults
|
41 |
+
$defaults = array(
|
42 |
+
'title' => __('Event Locations','dbem'),
|
43 |
+
'scope' => 'future',
|
44 |
+
'order' => 'ASC',
|
45 |
+
'limit' => 5,
|
46 |
+
'format' => DEFAULT_WIDGET_LOCATION_LIST_ITEM_FORMAT
|
47 |
+
);
|
48 |
+
foreach($defaults as $key => $value){
|
49 |
+
if($new_instance[$key] == ''){
|
50 |
+
$new_instance[$key] = $value;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
return $new_instance;
|
54 |
+
}
|
55 |
+
|
56 |
+
/** @see WP_Widget::form */
|
57 |
+
function form($instance) {
|
58 |
+
?>
|
59 |
+
<p>
|
60 |
+
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title'); ?>: </label>
|
61 |
+
<input type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
|
62 |
+
</p>
|
63 |
+
<p>
|
64 |
+
<label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e('Show number of locations','dbem'); ?>: </label>
|
65 |
+
<input type="text" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" value="<?php echo $instance['limit']; ?>" />
|
66 |
+
</p>
|
67 |
+
<p>
|
68 |
+
<label for="<?php echo $this->get_field_id('scope'); ?>"><?php _e('Scope of the locations','dbem'); ?>:</label><br/>
|
69 |
+
<select id="<?php echo $this->get_field_id('scope'); ?>" name="<?php echo $this->get_field_name('scope'); ?>" >
|
70 |
+
<option value="future" <?php echo ($instance['scope'] == 'future') ? 'selected="selected"':''; ?>><?php _e('Locations with upcoming events','dbem'); ?></option>
|
71 |
+
<option value="all" <?php echo ($instance['scope'] == 'all') ? 'selected="selected"':''; ?>><?php _e('All locations','dbem'); ?></option>
|
72 |
+
<option value="past" <?php echo ($instance['scope'] == 'past') ? 'selected="selected"':''; ?>><?php _e('Locations with past events ','dbem'); ?></option>
|
73 |
+
</select>
|
74 |
+
</p>
|
75 |
+
<p>
|
76 |
+
<label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order of the locations','dbem'); ?>:</label><br/>
|
77 |
+
<select id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>" >
|
78 |
+
<option value="ASC" <?php echo ($instance['order'] == 'ASC') ? 'selected="selected"':''; ?>><?php _e('Ascendant','dbem'); ?></option>
|
79 |
+
<option value="DESC" <?php echo ($instance['order'] == 'DESC') ? 'selected="selected"':''; ?>><?php _e('Descendant','dbem'); ?></option>
|
80 |
+
</select>
|
81 |
+
</p>
|
82 |
+
<p>
|
83 |
+
<label for="<?php echo $this->get_field_id('format'); ?>"><?php _e('List item format','dbem'); ?>: </label>
|
84 |
+
<textarea rows="5" cols="24" id="<?php echo $this->get_field_id('format'); ?>" name="<?php echo $this->get_field_name('format'); ?>"><?php echo $instance['format']; ?></textarea>
|
85 |
+
</p>
|
86 |
+
<?php
|
87 |
+
}
|
88 |
+
}
|
89 |
+
add_action('widgets_init', create_function('', 'return register_widget("EM_Locations_Widget");'));
|
90 |
+
?>
|