Events Manager - Version 3.0.81

Version Description

  • Fixed pagination bugs
  • Global locations map won't show locations with 0-0 coords
  • Fixed bug in recurrence description
  • Removed most (if not all) php warnings
  • Fixed booked seats calculation errors
  • Removed dependence on php calendar
Download this release

Release Info

Developer netweblogic
Plugin Icon 128x128 Events Manager
Version 3.0.81
Comparing to
See all releases

Code changes from version 3.0.8 to 3.0.81

Files changed (45) hide show
  1. admin/{admin.php → em-admin.php} +0 -0
  2. admin/{bookings.php → em-bookings.php} +3 -3
  3. admin/{categories.php → em-categories.php} +9 -9
  4. admin/{event.php → em-event.php} +8 -8
  5. admin/{events.php → em-events.php} +21 -21
  6. admin/{help.php → em-help.php} +0 -0
  7. admin/{locations-search.php → em-locations-search.php} +0 -0
  8. admin/em-locations.php +237 -0
  9. admin/em-options.php +315 -0
  10. admin/{people.php → em-people.php} +0 -0
  11. admin/locations.php +0 -305
  12. admin/options.php +0 -315
  13. classes/{booking.php → em-booking.php} +0 -0
  14. classes/{bookings.php → em-bookings.php} +5 -4
  15. classes/{calendar.php → em-calendar.php} +5 -5
  16. classes/{category.php → em-category.php} +0 -0
  17. classes/{event.php → em-event.php} +115 -79
  18. classes/{events.php → em-events.php} +46 -19
  19. classes/{location.php → em-location.php} +32 -24
  20. classes/{locations.php → em-locations.php} +18 -10
  21. classes/{mailer.php → em-mailer.php} +0 -0
  22. classes/{map.php → em-map.php} +7 -3
  23. classes/{object.php → em-object.php} +43 -32
  24. classes/{people.php → em-people.php} +0 -0
  25. classes/{person.php → em-person.php} +0 -0
  26. classes/{recurrence.php → em-recurrence.php} +0 -0
  27. ajax.php → em-ajax.php +0 -0
  28. bookings.php → em-bookings.php +7 -7
  29. events.php → em-events.php +26 -15
  30. functions.php → em-functions.php +31 -29
  31. install.php → em-install.php +0 -0
  32. em-rss.php +38 -0
  33. shortcode.php → em-shortcode.php +1 -1
  34. template-tags-depreciated.php → em-template-tags-depreciated.php +66 -0
  35. template-tags.php → em-template-tags.php +0 -0
  36. events-manager.php +42 -43
  37. includes/css/events_manager.css +0 -11
  38. includes/css/events_manager_admin.css +10 -0
  39. includes/js/em_maps.js +18 -16
  40. locations.php +0 -75
  41. readme.txt +20 -4
  42. rss.php +0 -43
  43. widgets/{calendar.php → em-calendar.php} +0 -0
  44. widgets/{events.php → em-events.php} +0 -0
  45. widgets/{locations.php → em-locations.php} +0 -0
admin/{admin.php → em-admin.php} RENAMED
File without changes
admin/{bookings.php → em-bookings.php} RENAMED
@@ -3,7 +3,7 @@
3
  * Check if there's any actions to take for bookings
4
  * @return null
5
  */
6
- function dbem_admin_actions_bookings() {
7
  global $dbem_form_add_message;
8
  global $dbem_form_delete_message;
9
  global $wpdb;
@@ -18,13 +18,13 @@ function dbem_admin_actions_bookings() {
18
  }
19
  }
20
  }
21
- add_action('init','dbem_admin_actions_bookings');
22
 
23
  /**
24
  * Shows table of bookings for an event
25
  * @return null
26
  */
27
- function dbem_bookings_table() {
28
  global $EM_Event;
29
  ?>
30
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
3
  * Check if there's any actions to take for bookings
4
  * @return null
5
  */
6
+ function em_admin_actions_bookings() {
7
  global $dbem_form_add_message;
8
  global $dbem_form_delete_message;
9
  global $wpdb;
18
  }
19
  }
20
  }
21
+ add_action('init','em_admin_actions_bookings');
22
 
23
  /**
24
  * Shows table of bookings for an event
25
  * @return null
26
  */
27
+ function em_bookings_table() {
28
  global $EM_Event;
29
  ?>
30
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
admin/{categories.php → em-categories.php} RENAMED
@@ -1,10 +1,10 @@
1
  <?php
2
- function dbem_categories_subpanel() {
3
  global $wpdb;
4
 
5
  if(isset($_GET['action']) && $_GET['action'] == "edit") {
6
  // edit category
7
- dbem_categories_edit_layout();
8
  } else {
9
  // Insert/Update/Delete Record
10
  $categories_table = $wpdb->prefix.EM_CATEGORIES_TABLE;
@@ -32,20 +32,20 @@ function dbem_categories_subpanel() {
32
  }
33
  }
34
  //die(print_r($_POST));
35
- if ( is_numeric($validation_result) ) {
36
  $message = (isset($message)) ? $message : __("Successfully {$_POST['action']}ed category", "dbem");
37
- dbem_categories_table_layout($message);
38
- } elseif ( $validation_result === false ) {
39
  $message = (isset($message)) ? $message : __("There was a problem {$_POST['action']}ing your category, please try again.");
40
- dbem_categories_table_layout($message);
41
  } else {
42
  // no action, just a categories list
43
- dbem_categories_table_layout();
44
  }
45
  }
46
  }
47
 
48
- function dbem_categories_table_layout($message = "") {
49
  $categories = EM_Category::get();
50
  $destination = get_bloginfo('url')."/wp-admin/admin.php";
51
  ?>
@@ -136,7 +136,7 @@ function dbem_categories_table_layout($message = "") {
136
  }
137
 
138
 
139
- function dbem_categories_edit_layout($message = "") {
140
  $category_id = $_GET['category_ID'];
141
  $category = EM_Category::get($category_id);
142
  ?>
1
  <?php
2
+ function em_categories_subpanel() {
3
  global $wpdb;
4
 
5
  if(isset($_GET['action']) && $_GET['action'] == "edit") {
6
  // edit category
7
+ em_categories_edit_layout();
8
  } else {
9
  // Insert/Update/Delete Record
10
  $categories_table = $wpdb->prefix.EM_CATEGORIES_TABLE;
32
  }
33
  }
34
  //die(print_r($_POST));
35
+ if ( isset($validation_result) && is_numeric($validation_result) ) {
36
  $message = (isset($message)) ? $message : __("Successfully {$_POST['action']}ed category", "dbem");
37
+ em_categories_table_layout($message);
38
+ } elseif ( isset($validation_result) && $validation_result === false ) {
39
  $message = (isset($message)) ? $message : __("There was a problem {$_POST['action']}ing your category, please try again.");
40
+ em_categories_table_layout($message);
41
  } else {
42
  // no action, just a categories list
43
+ em_categories_table_layout();
44
  }
45
  }
46
  }
47
 
48
+ function em_categories_table_layout($message = "") {
49
  $categories = EM_Category::get();
50
  $destination = get_bloginfo('url')."/wp-admin/admin.php";
51
  ?>
136
  }
137
 
138
 
139
+ function em_categories_edit_layout($message = "") {
140
  $category_id = $_GET['category_ID'];
141
  $category = EM_Category::get($category_id);
142
  ?>
admin/{event.php → em-event.php} RENAMED
@@ -1,9 +1,9 @@
1
  <?php
2
- function dbem_new_event_page() {
3
  global $EM_Event;
4
  $title = __ ( "Insert New Event", 'dbem' );
5
  $EM_Event = new EM_Event(); //Empty event
6
- dbem_event_form ( $title );
7
  }
8
 
9
  /**
@@ -11,7 +11,7 @@ function dbem_new_event_page() {
11
  * @param $title
12
  * @return null
13
  */
14
- function dbem_event_form( $title ) {
15
  global $EM_Event;
16
  global $localised_date_formats;
17
  $use_select_for_locations = get_option('dbem_use_select_for_locations');
@@ -78,7 +78,7 @@ function dbem_event_form( $title ) {
78
  <select id="recurrence-frequency" name="recurrence_freq">
79
  <?php
80
  $freq_options = array ("daily" => __ ( 'Daily', 'dbem' ), "weekly" => __ ( 'Weekly', 'dbem' ), "monthly" => __ ( 'Monthly', 'dbem' ) );
81
- dbem_option_items ( $freq_options, $EM_Event->freq );
82
  ?>
83
  </select>
84
  </p>
@@ -102,7 +102,7 @@ function dbem_event_form( $title ) {
102
  <p class="alternate-selector" id="weekly-selector">
103
  <?php
104
  $saved_bydays = ($EM_Event->is_recurring()) ? explode ( ",", $EM_Event->byday ) : array();
105
- dbem_checkbox_items ( 'recurrence_bydays[]', $days_names, $saved_bydays );
106
  ?>
107
  </p>
108
  <p class="alternate-selector" id="monthly-selector">
@@ -110,11 +110,11 @@ function dbem_event_form( $title ) {
110
  <select id="monthly-modifier" name="recurrence_byweekno">
111
  <?php
112
  $weekno_options = array ("1" => __ ( 'first', 'dbem' ), '2' => __ ( 'second', 'dbem' ), '3' => __ ( 'third', 'dbem' ), '4' => __ ( 'fourth', 'dbem' ), '-1' => __ ( 'last', 'dbem' ) );
113
- dbem_option_items ( $weekno_options, $EM_Event->byweekno );
114
  ?>
115
  </select>
116
  <select id="recurrence-weekday" name="recurrence_byday">
117
- <?php dbem_option_items ( $days_names, $EM_Event->byday ); ?>
118
  </select>
119
  &nbsp;
120
  </p>
@@ -510,7 +510,7 @@ function dbem_event_form( $title ) {
510
  <a href="#" rel="<?php echo $count ?>">Remove</a>
511
  </td>
512
  <td>
513
- <input type="text" name="mtm_<?php echo $count ?>_name" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?>" />
514
  </td>
515
  </tr>
516
  <?php
1
  <?php
2
+ function em_new_event_page() {
3
  global $EM_Event;
4
  $title = __ ( "Insert New Event", 'dbem' );
5
  $EM_Event = new EM_Event(); //Empty event
6
+ em_event_form ( $title );
7
  }
8
 
9
  /**
11
  * @param $title
12
  * @return null
13
  */
14
+ function em_event_form( $title ) {
15
  global $EM_Event;
16
  global $localised_date_formats;
17
  $use_select_for_locations = get_option('dbem_use_select_for_locations');
78
  <select id="recurrence-frequency" name="recurrence_freq">
79
  <?php
80
  $freq_options = array ("daily" => __ ( 'Daily', 'dbem' ), "weekly" => __ ( 'Weekly', 'dbem' ), "monthly" => __ ( 'Monthly', 'dbem' ) );
81
+ em_option_items ( $freq_options, $EM_Event->freq );
82
  ?>
83
  </select>
84
  </p>
102
  <p class="alternate-selector" id="weekly-selector">
103
  <?php
104
  $saved_bydays = ($EM_Event->is_recurring()) ? explode ( ",", $EM_Event->byday ) : array();
105
+ em_checkbox_items ( 'recurrence_bydays[]', $days_names, $saved_bydays );
106
  ?>
107
  </p>
108
  <p class="alternate-selector" id="monthly-selector">
110
  <select id="monthly-modifier" name="recurrence_byweekno">
111
  <?php
112
  $weekno_options = array ("1" => __ ( 'first', 'dbem' ), '2' => __ ( 'second', 'dbem' ), '3' => __ ( 'third', 'dbem' ), '4' => __ ( 'fourth', 'dbem' ), '-1' => __ ( 'last', 'dbem' ) );
113
+ em_option_items ( $weekno_options, $EM_Event->byweekno );
114
  ?>
115
  </select>
116
  <select id="recurrence-weekday" name="recurrence_byday">
117
+ <?php em_option_items ( $days_names, $EM_Event->byday ); ?>
118
  </select>
119
  &nbsp;
120
  </p>
510
  <a href="#" rel="<?php echo $count ?>">Remove</a>
511
  </td>
512
  <td>
513
+ <input type="text" name="mtm_<?php echo $count ?>_name" />
514
  </td>
515
  </tr>
516
  <?php
admin/{events.php → em-events.php} RENAMED
@@ -4,17 +4,17 @@
4
  * Determines whether to show event page or events page, and saves any updates to the event or events
5
  * @return null
6
  */
7
- function dbem_events_subpanel() {
8
  //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
9
  global $wpdb;
10
  global $EM_Event;
11
- $action = $_GET ['action'];
12
- $action2 = $_GET ['action2'];
13
- $event_ID = $_GET ['event_id'];
14
- $recurrence_ID = $_GET ['recurrence_id'];
15
- $scope = ($_GET ['scope'] != '') ? $_GET['scope']:'future';
16
- $order = $_GET ['order']; //FIXME order not used consistently in admin area
17
- $selectedEvents = $_GET ['events'];
18
 
19
  if ($order == ""){
20
  $order = "ASC";
@@ -24,7 +24,7 @@ function dbem_events_subpanel() {
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
  }
29
  // UPDATE or CREATE action
30
  if ($action == 'update_event') {
@@ -42,7 +42,7 @@ function dbem_events_subpanel() {
42
  <p><?php echo $EM_Event->feedback_message ?></p>
43
  </div>
44
  <?php
45
- dbem_events_table ( EM_Events::get( array('limit'=>0,'scope'=>$scope) ), "Future events" );
46
  }else{
47
  // saving unsuccessful
48
  ?>
@@ -52,7 +52,7 @@ function dbem_events_subpanel() {
52
  </p>
53
  </div>
54
  <?php
55
- dbem_event_form ( $title );
56
  }
57
  } else {
58
  // validation unsuccessful
@@ -61,7 +61,7 @@ function dbem_events_subpanel() {
61
  <p><?php echo "<strong>" . __( "Ach, there's a problem here:", "dbem" ) . "</strong><br /><br />" . implode('<br />', $EM_Event->errors); ?></p>
62
  </div>
63
  <?php
64
- dbem_event_form ( $title );
65
  }
66
  }
67
 
@@ -74,7 +74,7 @@ function dbem_events_subpanel() {
74
  $title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
75
  }
76
  //Generate Event Form
77
- dbem_event_form ( $title );
78
  }
79
 
80
  //Copy the event
@@ -84,10 +84,10 @@ function dbem_events_subpanel() {
84
  //Now we edit the duplicated item
85
  $title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
86
  echo "<div id='message' class='updated below-h2'>You are now editing the duplicated event.</div>";
87
- dbem_event_form ( $title );
88
  }else{
89
  echo "<div class='error'><p>There was an error duplicating the event. Try again maybe?</div>";
90
- dbem_events_table ( EM_Events::get(array('limit'=>0,'scope'=>$scope)), $title );
91
  }
92
  }
93
 
@@ -105,11 +105,11 @@ function dbem_events_subpanel() {
105
  $scope = "future";
106
  }
107
  $events = EM_Events::get( array('scope'=>$scope, 'limit'=>0, 'order'=>$order ) );
108
- dbem_events_table ( $events, $title );
109
  }
110
  }
111
 
112
- function dbem_events_table($events, $title) {
113
  $limit = ( !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
114
  $page = ( !empty($_GET['p']) ) ? $_GET['p']:1;
115
  $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
@@ -118,7 +118,7 @@ function dbem_events_table($events, $title) {
118
  'all' => __ ( 'All events', 'dbem' ),
119
  'future' => __ ( 'Future events', 'dbem' )
120
  );
121
- $scope = ( array_key_exists( $_GET ['scope'], $scope_names) ) ? $_GET ['scope']:'future';
122
  $events_count = count ( $events );
123
 
124
  $use_events_end = get_option ( 'dbem_use_event_end' );
@@ -165,14 +165,14 @@ function dbem_events_table($events, $title) {
165
  //Pagination (if needed/requested)
166
  if( $events_count >= $limit ){
167
  //Show the pagination links (unless there's less than 10 events
168
- $page_link_template = preg_replace('/p=\d+/i','',$_SERVER['REQUEST_URI']);
169
  $page_link_template = em_add_get_params($page_link_template, array('p'=>'%PAGE%'));
170
  $events_nav = em_paginate( $page_link_template, $events_count, $limit, $page);
171
  echo $events_nav;
172
  }
173
  ?>
174
  </div>
175
- <div class="clear"></div>
176
 
177
  <?php
178
  if (empty ( $events )) {
@@ -270,7 +270,7 @@ function dbem_events_table($events, $title) {
270
 
271
  <div class='tablenav'>
272
  <div class="alignleft actions">
273
- <?php echo $events_nav; ?>
274
  <br class='clear' />
275
  </div>
276
  <br class='clear' />
4
  * Determines whether to show event page or events page, and saves any updates to the event or events
5
  * @return null
6
  */
7
+ function em_events_subpanel() {
8
  //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
9
  global $wpdb;
10
  global $EM_Event;
11
+ $action = ( !empty($_GET ['action']) ) ? $_GET ['action']:'';
12
+ $action2 = ( !empty($_GET ['action2']) ) ? $_GET ['action2']:'';
13
+ $event_ID = ( !empty($_GET ['event_id']) ) ? $_GET ['event_id']:'';
14
+ $recurrence_ID = ( !empty($_GET ['recurrence_id']) ) ? $_GET ['recurrence_id']:'';
15
+ $scope = ( !empty($_GET ['scope']) ) ? $_GET['scope']:'future';
16
+ $order = ( !empty($_GET ['order']) ) ? $_GET ['order']:''; //FIXME order not used consistently in admin area
17
+ $selectedEvents = ( !empty($_GET ['events']) ) ? $_GET ['events']:'';
18
 
19
  if ($order == ""){
20
  $order = "ASC";
24
  // DELETE action
25
  if ( $action == 'deleteEvents' && EM_Object::array_is_numeric($selectedEvents) ) {
26
  EM_Events::delete( $selectedEvents );
27
+ em_events_table ( EM_Events::get( array('scope'=>$scope) ), "Future events" );
28
  }
29
  // UPDATE or CREATE action
30
  if ($action == 'update_event') {
42
  <p><?php echo $EM_Event->feedback_message ?></p>
43
  </div>
44
  <?php
45
+ em_events_table ( EM_Events::get( array('limit'=>0,'scope'=>$scope) ), "Future events" );
46
  }else{
47
  // saving unsuccessful
48
  ?>
52
  </p>
53
  </div>
54
  <?php
55
+ em_event_form ( $title );
56
  }
57
  } else {
58
  // validation unsuccessful
61
  <p><?php echo "<strong>" . __( "Ach, there's a problem here:", "dbem" ) . "</strong><br /><br />" . implode('<br />', $EM_Event->errors); ?></p>
62
  </div>
63
  <?php
64
+ em_event_form ( $title );
65
  }
66
  }
67
 
74
  $title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
75
  }
76
  //Generate Event Form
77
+ em_event_form ( $title );
78
  }
79
 
80
  //Copy the event
84
  //Now we edit the duplicated item
85
  $title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
86
  echo "<div id='message' class='updated below-h2'>You are now editing the duplicated event.</div>";
87
+ em_event_form ( $title );
88
  }else{
89
  echo "<div class='error'><p>There was an error duplicating the event. Try again maybe?</div>";
90
+ em_events_table ( EM_Events::get(array('limit'=>0,'scope'=>$scope)), $title );
91
  }
92
  }
93
 
105
  $scope = "future";
106
  }
107
  $events = EM_Events::get( array('scope'=>$scope, 'limit'=>0, 'order'=>$order ) );
108
+ em_events_table ( $events, $title );
109
  }
110
  }
111
 
112
+ function em_events_table($events, $title) {
113
  $limit = ( !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
114
  $page = ( !empty($_GET['p']) ) ? $_GET['p']:1;
115
  $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
118
  'all' => __ ( 'All events', 'dbem' ),
119
  'future' => __ ( 'Future events', 'dbem' )
120
  );
121
+ $scope = ( !empty($_GET ['scope']) && array_key_exists($_GET ['scope'], $scope_names) ) ? $_GET ['scope']:'future';
122
  $events_count = count ( $events );
123
 
124
  $use_events_end = get_option ( 'dbem_use_event_end' );
165
  //Pagination (if needed/requested)
166
  if( $events_count >= $limit ){
167
  //Show the pagination links (unless there's less than 10 events
168
+ $page_link_template = preg_replace('/(&|\?)p=\d+/i','',$_SERVER['REQUEST_URI']);
169
  $page_link_template = em_add_get_params($page_link_template, array('p'=>'%PAGE%'));
170
  $events_nav = em_paginate( $page_link_template, $events_count, $limit, $page);
171
  echo $events_nav;
172
  }
173
  ?>
174
  </div>
175
+ <br class="clear" />
176
 
177
  <?php
178
  if (empty ( $events )) {
270
 
271
  <div class='tablenav'>
272
  <div class="alignleft actions">
273
+ <?php echo ( !empty($events_nav) ) ? $events_nav:''; ?>
274
  <br class='clear' />
275
  </div>
276
  <br class='clear' />
admin/{help.php → em-help.php} RENAMED
File without changes
admin/{locations-search.php → em-locations-search.php} RENAMED
File without changes
admin/em-locations.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Looks at the request values, saves/updates and then displays the right menu in the admin
4
+ * @return null
5
+ */
6
+ function em_locations_page() {
7
+ //TODO EM_Location is globalized, use it fully here
8
+ global $EM_Location;
9
+
10
+ //Take actions
11
+ if( !empty($_REQUEST['action']) ){
12
+ if( $_REQUEST['action'] == "edit" || $_REQUEST['action'] == "add" ) {
13
+ //edit/add location
14
+ em_admin_location();
15
+ } elseif( $_REQUEST['action'] == "delete" ){
16
+ //delelte location
17
+ $locations = $_REQUEST['locations'];
18
+ foreach($locations as $location_id) {
19
+ $EM_Location = new EM_Location($location_id);
20
+ $EM_Location->delete();
21
+ }
22
+ em_admin_locations(__('Locations Deleted', "dbem" ));
23
+ } elseif( $_REQUEST['action'] == "save") {
24
+ // save (add/update) location
25
+ if( empty($EM_Location) || !is_object($EM_Location) ){
26
+ $EM_Location = new EM_Location(); //blank location
27
+ $success_message = __('The location has been added.', 'dbem');
28
+ }else{
29
+ $success_message = __('The location has been updated.', 'dbem');
30
+ }
31
+ $EM_Location->get_post();
32
+ $validation_result = $EM_Location->validate();
33
+ if ( $validation_result ) {
34
+ $EM_Location->save(); //FIXME better handling of db write fails when saving location
35
+ em_admin_locations($success_message);
36
+ } else {
37
+ ?>
38
+ <div id='message' class='error '>
39
+ <p>
40
+ <strong><?php _e( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br /><?php echo implode('<br />', $EM_Location->errors); ?>
41
+ </p>
42
+ </div>
43
+ <?php
44
+ unset($EM_Location);
45
+ em_admin_location();
46
+ }
47
+ }
48
+ } else {
49
+ // no action, just a locations list
50
+ em_admin_locations();
51
+ }
52
+ }
53
+
54
+ function em_admin_locations($message='', $fill_fields = false) {
55
+ $limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
56
+ $page = ( !empty($_REQUEST['p']) ) ? $_REQUEST['p']:1;
57
+ $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
58
+ $locations = EM_Locations::get();
59
+ $locations_count = count($locations);
60
+ ?>
61
+ <div class='wrap'>
62
+ <div id='icon-edit' class='icon32'>
63
+ <br/>
64
+ </div>
65
+ <h2>
66
+ <?php _e('Locations', 'dbem'); ?>
67
+ <a href="admin.php?page=locations&action=add" class="button add-new-h2"><?php _e('Add New') ?></a>
68
+ </h2>
69
+
70
+ <?php if($message != "") : ?>
71
+ <div id='message' class='updated fade below-h2'>
72
+ <p><?php echo $message ?></p>
73
+ </div>
74
+ <?php endif; ?>
75
+
76
+ <form id='bookings-filter' method='post' action=''>
77
+ <input type='hidden' name='page' value='locations'/>
78
+ <input type='hidden' name='limit' value='<?php echo $limit ?>' />
79
+ <input type='hidden' name='p' value='<?php echo $page ?>' />
80
+ <?php if ( $locations_count > 0 ) : ?>
81
+ <div class='tablenav'>
82
+ <div class="alignleft actions">
83
+ <select name="action">
84
+ <option value="" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
85
+ <option value="delete"><?php _e ( 'Delete selected','dbem' ); ?></option>
86
+ </select>
87
+ <input type="submit" value="<?php _e ( 'Apply' ); ?>" id="doaction2" class="button-secondary action" />
88
+ <?php
89
+ //Pagination (if needed/requested)
90
+ if( $locations_count >= $limit ){
91
+ //Show the pagination links (unless there's less than 10 events
92
+ $page_link_template = preg_replace('/(&|\?)p=\d+/i','',$_SERVER['REQUEST_URI']);
93
+ $page_link_template = em_add_get_params($page_link_template, array('p'=>'%PAGE%'));
94
+ $locations_nav = em_paginate( $page_link_template, $locations_count, $limit, $page);
95
+ echo $locations_nav;
96
+ }
97
+ ?>
98
+ </div>
99
+ </div>
100
+ <table class='widefat'>
101
+ <thead>
102
+ <tr>
103
+ <th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
104
+ <th><?php _e('Name', 'dbem') ?></th>
105
+ <th><?php _e('Address', 'dbem') ?></th>
106
+ <th><?php _e('Town', 'dbem') ?></th>
107
+ </tr>
108
+ </thead>
109
+ <tfoot>
110
+ <tr>
111
+ <th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
112
+ <th><?php _e('Name', 'dbem') ?></th>
113
+ <th><?php _e('Address', 'dbem') ?></th>
114
+ <th><?php _e('Town', 'dbem') ?></th>
115
+ </tr>
116
+ </tfoot>
117
+ <tbody>
118
+ <?php $i = 1; ?>
119
+ <?php foreach ($locations as $EM_Location) : ?>
120
+ <?php if( $i >= $offset && $i <= $offset+$limit ): ?>
121
+ <tr>
122
+ <td><input type='checkbox' class ='row-selector' value='<?php echo $EM_Location->id ?>' name='locations[]'/></td>
123
+ <td><a href='admin.php?page=locations&amp;action=edit&amp;location_id=<?php echo $EM_Location->id ?>'><?php echo $EM_Location->name ?></a></td>
124
+ <td><?php echo $EM_Location->address ?></td>
125
+ <td><?php echo $EM_Location->town ?></td>
126
+ </tr>
127
+ <?php endif; ?>
128
+ <?php $i++; ?>
129
+ <?php endforeach; ?>
130
+ </tbody>
131
+ </table>
132
+ <?php else: ?>
133
+ <p><?php _e('No venues have been inserted yet!', 'dbem') ?></p>
134
+ <?php endif; ?>
135
+ </form>
136
+ </div>
137
+ <?php
138
+ }
139
+
140
+ function em_admin_location($message = "") {
141
+ global $EM_Location;
142
+ if( empty($EM_Location) || !is_object($EM_Location) ){
143
+ $title = __('Add location', 'dbem');
144
+ $EM_Location = new EM_Location();
145
+ }else{
146
+ $title = __('Edit location', 'dbem');
147
+ }
148
+ ?>
149
+ <div class='wrap'>
150
+ <div id='icon-edit' class='icon32'>
151
+ <br/>
152
+ </div>
153
+ <h2><?php echo $title ?></h2>
154
+
155
+ <?php if($message != "") : ?>
156
+ <div id='message' class='updated fade below-h2' style='background-color: rgb(255, 251, 204);'>
157
+ <p><?php echo $message ?></p>
158
+ </div>
159
+ <?php endif; ?>
160
+ <div id='ajax-response'></div>
161
+
162
+ <form enctype='multipart/form-data' name='editcat' id='locationForm' method='post' action='admin.php?page=locations' class='validate'>
163
+ <input type='hidden' name='action' value='save' />
164
+ <input type='hidden' name='location_id' value='<?php echo $EM_Location->id ?>'/>
165
+ <table class='form-table'>
166
+ <tr class='form-field form-required'>
167
+ <th scope='row' valign='top'><label for='location_name'><?php _e('Location name', 'dbem') ?></label></th>
168
+ <td><input name='location_name' id='location-name' type='text' value='<?php echo htmlspecialchars($EM_Location->name, ENT_QUOTES); ?>' size='40' /><br />
169
+ <?php _e('The name of the location', 'dbem') ?></td>
170
+ </tr>
171
+
172
+ <tr class='form-field'>
173
+ <th scope='row' valign='top'><label for='location_address'><?php _e('Location address', 'dbem') ?></label></th>
174
+ <td><input name='location_address' id='location-address' type='text' value='<?php echo htmlspecialchars($EM_Location->address, ENT_QUOTES); ?>' size='40' /><br />
175
+ <?php _e('The address of the location', 'dbem') ?>.</td>
176
+
177
+ </tr>
178
+
179
+ <tr class='form-field'>
180
+ <th scope='row' valign='top'> <label for='location_town'><?php _e('Location town', 'dbem') ?></label></th>
181
+ <td><input name='location_town' id='location-town' type='text' value='<?php echo htmlspecialchars($EM_Location->town, ENT_QUOTES); ?>' size='40' /><br />
182
+ <?php _e('The town where the location is located', 'dbem') ?>.</td>
183
+
184
+ </tr>
185
+
186
+ <tr style='display:none;'>
187
+ <td>Coordinates</td>
188
+ <td><input id='location-latitude' name='location_latitude' id='location_latitude' type='text' value='<?php echo $EM_Location->latitude ?>' size='15' />
189
+ <input id='location-longitude' name='location_longitude' id='location_longitude' type='text' value='<?php echo $EM_Location->longitude ?>' size='15' /></td>
190
+ </tr>
191
+
192
+ <?php if (get_option('dbem_gmap_is_active')) { ?>
193
+ <tr>
194
+ <th scope='row' valign='top'><label for='location_map'><?php _e('Location map', 'dbem') ?></label></th>
195
+ <td>
196
+ <div id='em-map-404' style='width: 450px; height: 350px; vertical-align:middle; text-align: center;'>
197
+ <p><em><?php _e ( 'Location not found', 'dbem' ); ?></em></p>
198
+ </div>
199
+ <div id='em-map' style='width: 450px; height: 350px; display: none;'></div>
200
+ </td>
201
+ </tr>
202
+ <?php
203
+ }
204
+ ?>
205
+ <tr class='form-field'>
206
+ <th scope='row' valign='top'><label for='location_description'><?php _e('Location description', 'dbem') ?></label></th>
207
+ <td>
208
+ <div class="inside">
209
+ <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
210
+ <?php the_editor($EM_Location->description); ?>
211
+ </div>
212
+ <?php _e('A description of the Location. You may include any kind of info here.', 'dbem') ?>
213
+ </div>
214
+ </td>
215
+ </tr>
216
+ <tr class='form-field'>
217
+ <th scope='row' valign='top'><label for='location_picture'><?php _e('Location image', 'dbem') ?></label></th>
218
+ <td>
219
+ <?php if ($EM_Location->image_url != '') : ?>
220
+ <img src='<?php echo $EM_Location->image_url; ?>' alt='<?php echo $EM_Location->name ?>'/>
221
+ <?php else : ?>
222
+ <?php _e('No image uploaded for this location yet', 'debm') ?>
223
+ <?php endif; ?>
224
+ </td>
225
+ </tr>
226
+ <tr>
227
+ <th scope='row' valign='top'><label for='location_image'><?php _e('Upload/change picture', 'dbem') ?></label></th>
228
+ <td><input id='location-image' name='location_image' id='location_image' type='file' size='40' /></td>
229
+ </tr>
230
+ </table>
231
+ <p class='submit'><input type='submit' class='button-primary' name='submit' value='<?php _e('Update location', 'dbem') ?>' /></p>
232
+ </form>
233
+ </div>
234
+ <?php
235
+ }
236
+
237
+ ?>
admin/em-options.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_' ){
8
+ //TODO some more validation/reporting
9
+ $numeric_options = array('dbem_locations_default_limit','dbem_events_default_limit');
10
+ if( in_array($postKey,$numeric_options) && !is_numeric($postValue) ){
11
+ //Do nothing, keep old setting.
12
+ }else{
13
+ //TODO slashes being added?
14
+ //$postValue = EM_Object::sanitize($postValue)
15
+ update_option($postKey, stripslashes($postValue));
16
+ }
17
+ }
18
+ }
19
+ function em_options_saved_notice(){
20
+ ?>
21
+ <div class="updated"><p><strong><?php _e('Changes saved.'); ?></strong></p></div>
22
+ <?php
23
+ }
24
+ add_action ( 'admin_notices', 'em_options_saved_notice' );
25
+ }
26
+ }
27
+ add_action('admin_head', 'em_options_save');
28
+
29
+
30
+
31
+ function em_options_subpanel() {
32
+ //TODO place all options into an array
33
+ $save_button = '<tr><th>&nbsp;</th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" id="dbem_options_submit" name="Submit" value="'. __( 'Save Changes' ) .' ('. __('All','dbem') .')" /></p></ts></td></tr>';
34
+ ?>
35
+ <script type="text/javascript" charset="utf-8">
36
+ jQuery(document).ready(function($){
37
+ var close_text = '<?php _e('Collapse All','dbem'); ?>';
38
+ var open_text = '<?php _e('Expand All','dbem'); ?>';
39
+ var open_close = $('<a href="#" style="display:block; float:right; clear:right; margin:10px;">'+close_text+'</a>');
40
+ $('#icon-options-general').after(open_close);
41
+ open_close.click( function(e){
42
+ e.preventDefault();
43
+ if($(this).text() == close_text){
44
+ $(".postbox").addClass('closed');
45
+ $(this).text(open_text);
46
+ }else{
47
+ $(".postbox").removeClass('closed');
48
+ $(this).text(close_text);
49
+ }
50
+ });
51
+ //For rewrite titles
52
+ $('input:radio[name=dbem_disable_title_rewrites]').live('change',function(){
53
+ checked_check = $('input:radio[name=dbem_disable_title_rewrites]:checked');
54
+ if( checked_check.val() == 1 ){
55
+ $('#dbem_title_html_row').show();
56
+ }else{
57
+ $('#dbem_title_html_row').hide();
58
+ }
59
+ });
60
+ $('input:radio[name=dbem_disable_title_rewrites]').trigger('change');
61
+
62
+ });
63
+ </script>
64
+ <div class="wrap">
65
+ <div id='icon-options-general' class='icon32'><br />
66
+ </div>
67
+ <h2><?php _e ( 'Event Manager Options', 'dbem' ); ?></h2>
68
+
69
+ <form id="dbem_options_form" method="post" action="">
70
+
71
+ <div class="metabox-holder">
72
+ <!-- // TODO Move style in css -->
73
+ <div class='postbox-container' style='width: 99.5%'>
74
+ <div id="" class="meta-box-sortables" >
75
+
76
+ <div class="postbox " >
77
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'General options', 'dbem' ); ?> </span></h3>
78
+ <div class="inside">
79
+ <table class="form-table">
80
+ <?php
81
+ em_options_radio_binary ( __( 'Use dropdown for locations?' ), 'dbem_use_select_for_locations', __( 'Select yes to select location from a drow-down menu; location selection will be faster, but you will lose the ability to insert locations with events','dbem' ) );
82
+ em_options_radio_binary ( __( 'Use recurrence?' ), 'dbem_recurrence_enabled', __( 'Select yes to enable the recurrence features feature','dbem' ) );
83
+ em_options_radio_binary ( __( 'Use RSVP?' ), 'dbem_rsvp_enabled', __( 'Select yes to enable the RSVP feature','dbem' ) );
84
+ em_options_radio_binary ( __( 'Use categories?' ), 'dbem_categories_enabled', __( 'Select yes to enable the category features','dbem' ) );
85
+ em_options_radio_binary ( __( 'Use attributes?' ), 'dbem_attributes_enabled', __( 'Select yes to enable the attributes feature','dbem' ) );
86
+ echo $save_button;
87
+ ?>
88
+ </table>
89
+
90
+ </div> <!-- . inside -->
91
+ </div> <!-- .postbox -->
92
+
93
+ <div class="postbox " >
94
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Events page', 'dbem' ); ?> </span></h3>
95
+ <div class="inside">
96
+ <table class="form-table">
97
+ <?php
98
+ //Wordpress Pages
99
+ global $em_disable_filter; //Using a flag here instead
100
+ $em_disable_filter = true;
101
+ $get_pages = get_pages();
102
+ $events_page_options = array();
103
+ $events_page_options[0] = __('[No Events Page]');
104
+ //TODO Add the hierarchy style ddm, like when choosing page parents
105
+ foreach($get_pages as $page){
106
+ $events_page_options[$page->ID] = $page->post_title;
107
+ }
108
+ em_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' ) );
109
+ $em_disable_filter = false;
110
+ //Rest
111
+ em_options_radio_binary ( __( 'Show events page in lists?', 'dbem' ), 'dbem_list_events_page', __( 'Check this option if you want the events page to appear together with other pages in pages lists.', 'dbem' ) );
112
+ em_options_radio_binary ( __( 'Display calendar in events page?', 'dbem' ), 'dbem_display_calendar_in_events_page', __( 'This options allows to display the calendar in the events page, instead of the default list. It is recommended not to display both the calendar widget and a calendar page.','dbem' ).' '.__('If you would like to show events that span over more than one day, see the Calendar section on this page.','dbem') );
113
+ em_options_radio_binary ( __( 'Disable title rewriting?', 'dbem' ), 'dbem_disable_title_rewrites', __( "Some wordpress themes don't follow best practices when generating navigation menus, and so the automatic title rewriting feature may cause problems, if your menus aren't working correctly on the event pages, try setting this to 'Yes', and provide an appropriate HTML title format below.",'dbem' ) );
114
+ em_options_input_text ( __( 'Event Manager titles', 'dbem' ), 'dbem_title_html', __( "This only setting only matters if you selected 'Yes' to above. You will notice the events page titles aren't being rewritten, and you have a new title underneath the default page name. This is where you control the HTML of this title. Make sure you keep the #_PAGETITLE placeholder here, as that's what is rewritten by events manager. To control what's rewritten in this title, see settings further down for page titles.", 'dbem' ) );
115
+ em_options_input_text ( __( 'Event List Limits', 'dbem' ), 'dbem_events_default_limit', __( "This will control how many events are shown on one list by default.", 'dbem' ) );
116
+ ?>
117
+ <tr valign="top" id='dbem_events_default_orderby_row'>
118
+ <th scope="row"><?php _e('Default event list ordering','dbem'); ?></th>
119
+ <td>
120
+ <select name="dbem_events_default_orderby" >
121
+ <?php
122
+ $orderby_options = apply_filters('em_settings_events_default_orderby_ddm', array(
123
+ 'start_date,start_time,name' => __('Order by start date, start time, then event name','dbem'),
124
+ 'name,start_date,start_time' => __('Order by name, start date, then start time','dbem'),
125
+ 'name,end_date,end_time' => __('Order by name, end date, then end time','dbem'),
126
+ 'end_date,end_time,name' => __('Order by end date, end time, then event name','dbem'),
127
+ ));
128
+ ?>
129
+ <?php foreach($orderby_options as $key => $value) : ?>
130
+ <option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_orderby')) ? "selected='selected'" : ''; ?>>
131
+ <?php echo $value; ?>
132
+ </option>
133
+ <?php endforeach; ?>
134
+ </select>
135
+ <select name="dbem_events_default_order" >
136
+ <?php
137
+ $ascending = __('Ascending','dbem');
138
+ $descending = __('Descending','dbem');
139
+ $order_options = apply_filters('em_settings_events_default_order_ddm', array(
140
+ 'ASC' => __('All Ascending','dbem'),
141
+ 'DESC,ASC,ASC' => __("$descending, $ascending, $ascending",'dbem'),
142
+ 'DESC,DESC,ASC' => __("$descending, $descending, $ascending",'dbem'),
143
+ 'DESC' => __('All Descending','dbem'),
144
+ 'ASC,DESC,ASC' => __("$ascending, $descending, $ascending",'dbem'),
145
+ 'ASC,DESC,DESC' => __("$ascending, $descending, $descending",'dbem'),
146
+ 'ASC,ASC,DESC' => __("$ascending, $ascending, $descending",'dbem'),
147
+ 'DESC,ASC,DESC' => __("$descending, $ascending, $descending",'dbem'),
148
+ ));
149
+ ?>
150
+ <?php foreach( $order_options as $key => $value) : ?>
151
+ <option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_order')) ? "selected='selected'" : ''; ?>>
152
+ <?php echo $value; ?>
153
+ </option>
154
+ <?php endforeach; ?>
155
+ </select>
156
+ <br/>
157
+ <?php _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.','dbem'); ?>
158
+ </td>
159
+ </tr>
160
+ <?php
161
+ echo $save_button;
162
+ ?>
163
+ </table>
164
+ </div> <!-- . inside -->
165
+ </div> <!-- .postbox -->
166
+
167
+ <div class="postbox " >
168
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Events format', 'dbem' ); ?> </span></h3>
169
+ <div class="inside">
170
+ <table class="form-table">
171
+ <?php
172
+ em_options_textarea ( __( 'Default event list format header', 'dbem' ), 'dbem_event_list_item_format_header', __( 'This content will appear just above your code for the default event list format. Default is blank', 'dbem' ) );
173
+ em_options_textarea ( __( 'Default event list format', 'dbem' ), 'dbem_event_list_item_format', __( 'The format of any events in a list.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_LOCATION</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_NOTES</code>.<br/> Use <code>#_EXCERPT</code> to show <code>#_NOTES</code> until you place a &lt;!&ndash;&ndash; more &ndash;&ndash;&gt; marker.<br/> Use <code>#_LINKEDNAME</code> for the event name with a link to the given event page.<br/> Use <code>#_EVENTPAGEURL</code> to print the event page URL and make your own customised links.<br/> Use <code>#_LOCATIONPAGEURL</code> to print the location page URL and make your own customised links.<br/>Use <code>#_EDITEVENTLINK</code> to add add a link to edit page for the event, which will appear only when a user is logged in.<br/>To insert date and time values, use <a href="http://www.php.net/manual/en/function.date.php">PHP time format characters</a> with a <code>#</code> symbol before them, i.e. <code>#m</code>, <code>#M</code>, <code>#j</code>, etc.<br/> For the end time, put <code>#@</code> in front of the character, ie. <code>#@h</code>, <code>#@i</code>, etc.<br/> You can also create a date format without prepending <code>#</code> by wrapping it in #_{} or #@_{} (e.g. <code>#_{d/m/Y}</code>). If there is no end date, the value is not shown.<br/>Feel free to use HTML tags as <code>li</code>, <code>br</code> and so on.<br/>For custom attributes, you use <code>#_ATT{key}{alternative text}</code>, the second braces are optional and will appear if the attribute is not defined or left blank for that event. This key will appear as an option when adding attributes to your event.', 'dbem' ) );
174
+ em_options_textarea ( __( 'Default event list format footer', 'dbem' ), 'dbem_event_list_item_format_footer', __( 'This content will appear just below your code for the default event list format. Default is blank', 'dbem' ) );
175
+ em_options_input_text ( __( 'Single event page title format', 'dbem' ), 'dbem_event_page_title_format', __( 'The format of a single event page title. Follow the previous formatting instructions.', 'dbem' ) );
176
+ em_options_textarea ( __( 'Default single event format', 'dbem' ), 'dbem_single_event_format', __( 'The format of a single event page.<br/>Follow the previous formatting instructions. <br/>Use <code>#_MAP</code> to insert a map.<br/>Use <code>#_CONTACTNAME</code>, <code>#_CONTACTEMAIL</code>, <code>#_CONTACTPHONE</code> to insert respectively the name, e-mail address and phone number of the designated contact person. <br/>Use <code>#_ADDBOOKINGFORM</code> to insert a form to allow the user to respond to your events reserving one or more places (RSVP).<br/> Use <code>#_REMOVEBOOKINGFORM</code> to insert a form where users, inserting their name and e-mail address, can remove their bookings.', 'dbem' ) );
177
+ em_options_input_text ( __( 'Events page title', 'dbem' ), 'dbem_events_page_title', __( 'The title on the multiple events page.', 'dbem' ) );
178
+ em_options_input_text ( __( 'No events message', 'dbem' ), 'dbem_no_events_message', __( 'The message displayed when no events are available.', 'dbem' ) );
179
+ em_options_input_text ( __( 'List events by date title', 'dbem' ), 'dbem_list_date_title', __( 'If viewing a page for events on a specific date, this is the title that would show up. To insert date values, use <a href="http://www.php.net/manual/en/function.date.php">PHP time format characters</a> with a <code>#</code> symbol before them, i.e. <code>#m</code>, <code>#M</code>, <code>#j</code>, etc.<br/>', 'dbem' ) );
180
+ echo $save_button;
181
+ ?>
182
+ </table>
183
+ </div> <!-- . inside -->
184
+ </div> <!-- .postbox -->
185
+
186
+ <div class="postbox " >
187
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Calendar format', 'dbem' ); ?></span></h3>
188
+ <div class="inside">
189
+ <table class="form-table">
190
+ <?php
191
+ em_options_input_text ( __( 'Small calendar title', 'dbem' ), 'dbem_small_calendar_event_title_format', __( 'The format of the title, corresponding to the text that appears when hovering on an eventful calendar day.', 'dbem' ) );
192
+ em_options_input_text ( __( 'Small calendar title separator', 'dbem' ), 'dbem_small_calendar_event_title_separator', __( 'The separator appearing on the above title when more than one events are taking place on the same day.', 'dbem' ) );
193
+ em_options_input_text ( __( 'Full calendar events format', 'dbem' ), 'dbem_full_calendar_event_format', __( 'The format of each event when displayed in the full calendar. Remember to include <code>li</code> tags before and after the event.', 'dbem' ) );
194
+ em_options_radio_binary ( __( 'Show long events on calendar pages?', 'dbem' ), 'dbem_full_calendar_long_events', __( "If you are showing a calendar on the events page (see Events format section on this page), you have the option of showing events that span over days on each day it occurs.",'dbem' ) );
195
+ em_options_radio_binary ( __( 'Show list on day with single event?', 'dbem' ), 'dbem_display_calendar_day_single', __( "By default, if a calendar day only has one event, it display a single event when clicking on the link of that calendar date. If you select Yes here, you will get always see a list of events.",'dbem' ) );
196
+ echo $save_button;
197
+ ?>
198
+ </table>
199
+ </div> <!-- . inside -->
200
+ </div> <!-- .postbox -->
201
+
202
+ <div class="postbox " >
203
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Locations format', 'dbem' ); ?> </span></h3>
204
+ <div class="inside">
205
+ <table class="form-table">
206
+ <?php
207
+ em_options_input_text ( __( 'Single location page title format', 'dbem' ), 'dbem_location_page_title_format', __( 'The format of a single location page title.<br/>Follow the previous formatting instructions.', 'dbem' ) );
208
+ em_options_textarea ( __( 'Default single location page format', 'dbem' ), 'dbem_single_location_format', __( 'The format of a single location page.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_DESCRIPTION</code>.<br/> Use <code>#_MAP</code> to display a map of the event location, and <code>#_IMAGE</code> to display an image of the location.<br/> Use <code>#_NEXTEVENTS</code> to insert a list of the upcoming events, <code>#_PASTEVENTS</code> for a list of past events, <code>#_ALLEVENTS</code> for a list of all events taking place in this location.', 'dbem' ) );
209
+ em_options_textarea ( __( 'Default location balloon format', 'dbem' ), 'dbem_location_baloon_format', __( 'The format of of the text appearing in the baloon describing the location in the map.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_DESCRIPTION</code> or <code>#_IMAGE</code>.', 'dbem' ) );
210
+ em_options_textarea ( __( 'Default location event list format', 'dbem' ), 'dbem_location_event_list_item_format', __( 'The format of the events the list inserted in the location page through the <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> element. <br/> Follow the events formatting instructions', 'dbem' ) );
211
+ em_options_textarea ( __( 'Default no events message', 'dbem' ), 'dbem_location_no_events_message', __( 'The message to be displayed in the list generated by <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> when no events are available.', 'dbem' ) );
212
+ echo $save_button;
213
+ ?>
214
+ </table>
215
+ </div> <!-- . inside -->
216
+ </div> <!-- .postbox -->
217
+
218
+ <div class="postbox " >
219
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'RSS feed format', 'dbem' ); ?> </span></h3>
220
+ <div class="inside">
221
+ <table class="form-table">
222
+ <?php
223
+ em_options_input_text ( __( 'RSS main title', 'dbem' ), 'dbem_rss_main_title', __( 'The main title of your RSS events feed.', 'dbem' ) );
224
+ em_options_input_text ( __( 'RSS main description', 'dbem' ), 'dbem_rss_main_description', __( 'The main description of your RSS events feed.', 'dbem' ) );
225
+ em_options_input_text ( __( 'RSS title format', 'dbem' ), 'dbem_rss_title_format', __( 'The format of the title of each item in the events RSS feed.', 'dbem' ) );
226
+ em_options_input_text ( __( 'RSS description format', 'dbem' ), 'dbem_rss_description_format', __( 'The format of the description of each item in the events RSS feed. Follow the previous formatting instructions.', 'dbem' ) );
227
+ echo $save_button;
228
+ ?>
229
+ </table>
230
+ </div> <!-- . inside -->
231
+ </div> <!-- .postbox -->
232
+
233
+ <div class="postbox " >
234
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Maps and geotagging', 'dbem' ); ?> </span></h3>
235
+ <div class="inside">
236
+ <table class='form-table'>
237
+ <?php $gmap_is_active = get_option ( 'dbem_gmap_is_active' ); ?>
238
+ <tr valign="top">
239
+ <th scope="row"><?php _e ( 'Enable Google Maps integration?', 'dbem' ); ?></th>
240
+ <td>
241
+ <input id="dbem_gmap_is_active_yes" name="dbem_gmap_is_active" type="radio" value="1" <?php echo ($gmap_is_active) ? "checked='checked'":''; ?> /><?php _e ( 'Yes' ); ?><br />
242
+ <input name="dbem_gmap_is_active" type="radio" value="0" <?php echo ($gmap_is_active) ? '':"checked='checked'"; ?> /> <?php _e ( 'No' ); ?> <br />
243
+ <?php _e ( 'Check this option to enable Goggle Map integration.', 'dbem' )?>
244
+ </td>
245
+ </tr>
246
+ <?php
247
+ em_options_textarea ( __( 'Map text format', 'dbem' ), 'dbem_map_text_format', __( 'The text format inside the map balloons.<br/>Follow the previous formatting instructions.', 'dbem' ) );
248
+ echo $save_button;
249
+ ?>
250
+ </table>
251
+ </div> <!-- . inside -->
252
+ </div> <!-- .postbox -->
253
+
254
+ <div class="postbox " >
255
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'RSVP and bookings', 'dbem' ); ?> </span></h3>
256
+ <div class="inside">
257
+ <table class='form-table'>
258
+ <?php
259
+ em_options_select ( __( 'Default contact person', 'dbem' ), 'dbem_default_contact_person', em_get_wp_users (), __( 'Select the default contact person. This user will be employed whenever a contact person is not explicitly specified for an event', 'dbem' ) );
260
+ em_options_radio_binary ( __( 'Enable the RSVP e-mail notifications?', 'dbem' ), 'dbem_rsvp_mail_notify_is_active', __( 'Check this option if you want to receive an email when someone books places for your events.', 'dbem' ) );
261
+ em_options_textarea ( __( 'Contact person email format', 'dbem' ), 'dbem_contactperson_email_body', __( 'The format of the email which will be sent to the contact person. Follow the events formatting instructions. <br/>Use <code>#_RESPNAME</code>, <code>#_RESPEMAIL</code> and <code>#_RESPPHONE</code> to display respectively the name, e-mail, address and phone of the respondent.<br/>Use <code>#_SPACES</code> to display the number of spaces reserved by the respondent. Use <code>#_COMMENT</code> to display the respondent\'s comment. <br/> Use <code>#_BOOKEDSEATS</code> and <code>#_AVAILABLESEATS</code> to display respectively the number of booked and available seats.', 'dbem' ) );
262
+ em_options_textarea ( __( 'Contact person email format', 'dbem' ), 'dbem_respondent_email_body', __( 'The format of the email which will be sent to respondent. Follow the events formatting instructions. <br/>Use <code>#_RESPNAME</code> to display the name of the respondent.<br/>Use <code>#_CONTACTNAME</code> and <code>#_CONTACTEMAIL</code> a to display respectively the name and e-mail of the contact person.<br/>Use <code>#_SPACES</code> to display the number of spaces reserved by the respondent. Use <code>#_COMMENT</code> to display the respondent\'s comment.', 'dbem' ) );
263
+ em_options_input_text ( __( 'Default notification receiver address', 'dbem' ), 'dbem_mail_receiver_address', __( "Insert the address of the receiver of your notifications", 'dbem' ) );
264
+ echo $save_button;
265
+ ?>
266
+ </table>
267
+ </div> <!-- . inside -->
268
+ </div> <!-- .postbox -->
269
+
270
+ <div class="postbox " >
271
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Email Settings', 'dbem' ); ?> </span></h3>
272
+ <div class="inside">
273
+ <table class='form-table'>
274
+ <?php
275
+ em_options_input_text ( __( 'Notification sender name', 'dbem' ), 'dbem_mail_sender_name', __( "Insert the display name of the notification sender.", 'dbem' ) );
276
+ em_options_input_text ( __( 'Notification sender address', 'dbem' ), 'dbem_mail_sender_address', __( "Insert the address of the notification sender.", 'dbem' ) );
277
+ em_options_input_text ( 'Mail sending port', 'dbem_rsvp_mail_port', __( "The port through which you e-mail notifications will be sent. Make sure the firewall doesn't block this port", 'dbem' ) );
278
+ em_options_select ( __( 'Mail sending method', 'dbem' ), 'dbem_rsvp_mail_send_method', array ('smtp' => 'SMTP', 'mail' => __( 'PHP mail function', 'dbem' ), 'sendmail' => 'Sendmail', 'qmail' => 'Qmail' ), __( 'Select the method to send email notification.', 'dbem' ) );
279
+ em_options_radio_binary ( __( 'Use SMTP authentication?', 'dbem' ), 'dbem_rsvp_mail_SMTPAuth', __( 'SMTP authentication is often needed. If you use GMail, make sure to set this parameter to Yes', 'dbem' ) );
280
+ em_options_input_text ( 'SMTP host', 'dbem_smtp_host', __( "The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set this value to 'ssl://smtp.gmail.com:465'.", 'dbem' ) );
281
+ em_options_input_text ( __( 'SMTP username', 'dbem' ), 'dbem_smtp_username', __( "Insert the username to be used to access your SMTP server.", 'dbem' ) );
282
+ em_options_input_password ( __( 'SMTP password', 'dbem' ), "dbem_smtp_password", __( "Insert the password to be used to access your SMTP server", 'dbem' ) );
283
+ echo $save_button;
284
+ ?>
285
+ </table>
286
+ </div> <!-- . inside -->
287
+ </div> <!-- .postbox -->
288
+
289
+ <div class="postbox " >
290
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Images size', 'dbem' ); ?> </span></h3>
291
+ <div class="inside">
292
+ <table class='form-table'>
293
+ <?php
294
+ em_options_input_text ( __( 'Maximum width (px)', 'dbem' ), 'dbem_image_max_width', __( 'The maximum allowed width for images uploades', 'dbem' ) );
295
+ em_options_input_text ( __( 'Maximum height (px)', 'dbem' ), 'dbem_image_max_height', __( "The maximum allowed height for images uploaded, in pixels", 'dbem' ) );
296
+ em_options_input_text ( __( 'Maximum size (bytes)', 'dbem' ), 'dbem_image_max_size', __( "The maximum allowed size for images uploaded, in pixels", 'dbem' ) );
297
+ ?>
298
+ </table>
299
+ </div> <!-- . inside -->
300
+ </div> <!-- .postbox -->
301
+
302
+ <p class="submit">
303
+ <input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
304
+ <input type="hidden" name="em-submitted" value="1" />
305
+ </p>
306
+
307
+ </div> <!-- .metabox-sortables -->
308
+ </div> <!-- .postbox-container -->
309
+
310
+ </div> <!-- .metabox-holder -->
311
+ </form>
312
+ </div>
313
+ <?php
314
+ }
315
+ ?>
admin/{people.php → em-people.php} RENAMED
File without changes
admin/locations.php DELETED
@@ -1,305 +0,0 @@
1
- <?php
2
- /**
3
- * Looks at the request values, saves/updates and then displays the right menu in the admin
4
- * @return null
5
- */
6
- function dbem_locations_page() {
7
- //TODO EM_Location is globalized, use it fully here
8
- global $EM_Location;
9
-
10
- //First Delete any locations
11
- if(isset($_GET['page']) && $_GET['page'] == "locations") {
12
- if(isset($_GET['doaction2']) && $_GET['doaction2'] == "Delete") {
13
- if(isset($_GET['action2']) && $_GET['action2'] == "delete") {
14
- $locations = $_GET['locations'];
15
- foreach($locations as $location_id) {
16
- $EM_Location = new EM_Location($location_id);
17
- $EM_Location->delete();
18
- }
19
- ?>
20
- <div id='message' class='updated'><p><?php _e( "Locations Deleted", "dbem" ) ?></p></div>
21
- <?php
22
- }
23
- }
24
- }
25
- //Now take further actions
26
- if(isset($_GET['action']) && $_GET['action'] == "edit") {
27
- // edit location
28
- dbem_admin_location();
29
- } else {
30
- if(isset($_POST['action']) && $_POST['action'] == "editedlocation") {
31
- // location update required
32
- $EM_Location->get_post();
33
- $validation_result = $EM_Location->validate();
34
- if ( $validation_result ) {
35
- $EM_Location->save();
36
- $message = __('The location has been updated.', 'dbem');
37
- dbem_admin_locations($message);
38
- } else {
39
- ?>
40
- <div id='message' class='error '>
41
- <p>
42
- <strong><?php _e( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br /><?php echo implode('<br />', $EM_Location->errors); ?>
43
- </p>
44
- </div>
45
- <?php
46
- unset($EM_Location);
47
- dbem_admin_location($message);
48
- }
49
- } elseif(isset($_POST['action']) && $_POST['action'] == "addlocation") {
50
- $EM_Location = new EM_Location();
51
- $EM_Location->get_post();
52
- $validation_result = $EM_Location->validate();
53
- if ($validation_result) {
54
- $EM_Location->save();
55
- dbem_admin_locations(__('The location has been added.', 'dbem'));
56
- } else {
57
- ?>
58
- <div id='message' class='error '>
59
- <p>
60
- <strong><?php _e( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br /><?php echo implode('<br />', $EM_Location->errors); ?>
61
- </p>
62
- </div>
63
- <?php
64
- dbem_admin_locations('', true);
65
- }
66
- } else {
67
- // no action, just a locations list
68
- dbem_admin_locations();
69
- }
70
- }
71
- }
72
-
73
- function dbem_admin_locations($message='', $fill_fields = false) {
74
- global $EM_Location;
75
- $locations = EM_Locations::get();
76
- $new_location = (is_object($EM_Location) && get_class($EM_Location) == 'EM_Location' && $fill_fields ) ? $EM_Location->to_array() : array(); //let's avoid php warning for empty object
77
- $destination = get_bloginfo('wpurl')."/wp-admin/admin.php";
78
- ?>
79
- <div class='wrap'>
80
- <div id='icon-edit' class='icon32'>
81
- <br/>
82
- </div>
83
- <h2><?php _e('Locations', 'dbem'); ?></h2>
84
-
85
- <?php if($message != "") : ?>
86
- <div id='message' class='updated fade below-h2'>
87
- <p><?php echo $message ?></p>
88
- </div>
89
- <?php endif; ?>
90
-
91
- <div id='col-container'>
92
- <div id='col-right'>
93
- <div class='col-wrap'>
94
- <form id='bookings-filter' method='get' action='<?php echo $destination ?>'>
95
- <input type='hidden' name='page' value='locations'/>
96
- <input type='hidden' name='action' value='addlocation'/>
97
-
98
- <?php if (count($locations)>0) : ?>
99
- <table class='widefat'>
100
- <thead>
101
- <tr>
102
- <th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
103
- <th><?php echo __('Name', 'dbem') ?></th>
104
- <th><?php echo __('Address', 'dbem') ?></th>
105
- <th><?php echo __('Town', 'dbem') ?></th>
106
- </tr>
107
- </thead>
108
- <tfoot>
109
- <tr>
110
- <th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
111
- <th><?php echo __('Name', 'dbem') ?></th>
112
- <th><?php echo __('Address', 'dbem') ?></th>
113
- <th><?php echo __('Town', 'dbem') ?></th>
114
- </tr>
115
- </tfoot>
116
- <tbody>
117
- <?php foreach ($locations as $location) : ?>
118
- <tr>
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&amp;action=edit&amp;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>
126
-
127
- </table>
128
-
129
- <div class='tablenav'>
130
- <div class='alignleft actions'>
131
- <input type='hidden' name='action2' value='delete'/>
132
- <input class='button-secondary action' type='submit' name='doaction2' value='Delete'/>
133
- <br class='clear'/>
134
- </div>
135
- <br class='clear'/>
136
- </div>
137
- <?php else: ?>
138
- <p><?php echo __('No venues have been inserted yet!', 'dbem') ?></p>
139
- <?php endif; ?>
140
- </form>
141
- </div>
142
- </div> <!-- end col-right -->
143
-
144
- <div id='col-left'>
145
- <div class='col-wrap'>
146
- <div class='form-wrap'>
147
- <div id='ajax-response'/>
148
- <h3><?php echo __('Add location', 'dbem') ?></h3>
149
- <form enctype='multipart/form-data' name='addlocation' id='locationForm' method='post' action='admin.php?page=locations' class='add:the-list: validate'>
150
- <input type='hidden' name='action' value='addlocation' />
151
- <div class='form-field form-required'>
152
- <label for='location_name'><?php echo __('Location name', 'dbem') ?></label>
153
- <input id='location-name' name='location_name' id='location_name' type='text' value='<?php echo $new_location['location_name'] ?>' size='40' />
154
- <p><?php echo __('The name of the location', 'dbem') ?>.</p>
155
- </div>
156
-
157
- <div class='form-field'>
158
- <label for='location_address'><?php echo __('Location address', 'dbem') ?></label>
159
- <input id='location-address' name='location_address' id='location_address' type='text' value='<?php echo $new_location['location_address'] ?>' size='40' />
160
- <p><?php echo __('The address of the location', 'dbem') ?>.</p>
161
- </div>
162
-
163
- <div class='form-field '>
164
- <label for='location_town'><?php echo __('Location town', 'dbem') ?></label>
165
- <input id='location-town' name='location_town' id='location_town' type='text' value='<?php echo $new_location['location_town'] ?>' size='40' />
166
- <p><?php echo __('The town of the location', 'dbem') ?>.</p>
167
- </div>
168
-
169
- <div class='form-field' style='display:none;'>
170
- <label for='location_latitude'>LAT</label>
171
- <input id='location-latitude' name='location_latitude' type='text' value='<?php echo $new_location['location_latitude'] ?>' size='40' />
172
- </div>
173
- <div class='form-field' style='display:none;'>
174
- <label for='location_longitude'>LONG</label>
175
- <input id='location-longitude' name='location_longitude' type='text' value='<?php echo $new_location['location_longitude'] ?>' size='40' />
176
- </div>
177
-
178
- <?php if ( get_option('dbem_gmap_is_active') ) : ?>
179
- <div class="events-map">
180
- <div id='em-map-404' style='width: 450px; vertical-align:middle; text-align: center;'>
181
- <p><em><?php _e ( 'Location not found', 'dbem' ); ?></em></p>
182
- </div>
183
- <div id='em-map' style='width: 450px; height: 350px; display: none;'></div>
184
- <br style='clear:both;' />
185
- </div>
186
- <?php endif; ?>
187
-
188
- <div class='form-field'>
189
- <label for='location_image'><?php echo __('Location image', 'dbem') ?></label>
190
- <input id='location-image' name='location_image' id='location_image' type='file' size='35' />
191
- <p><?php echo __('Select an image to upload', 'dbem') ?>.</p>
192
- </div>
193
-
194
- <div id="poststuff">
195
- <label for='location_description'><?php _e('Location description', 'dbem') ?></label>
196
- <div class="inside">
197
- <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
198
- <?php the_editor($new_location['location_description']); ?>
199
- </div>
200
- <?php _e('A description of the Location. You may include any kind of info here.', 'dbem') ?>
201
- </div>
202
- </div>
203
- <p class='submit'><input type='submit' class='button' name='submit' value='<?php echo __('Add location', 'dbem') ?>' /></p>
204
- </form>
205
- </div>
206
- </div>
207
- </div> <!-- end col-left -->
208
- </div>
209
- </div>
210
- </div>
211
- <?php
212
- }
213
-
214
- function dbem_admin_location($message = "") {
215
- global $EM_Location;
216
- ?>
217
- <div class='wrap'>
218
- <div id='icon-edit' class='icon32'>
219
- <br/>
220
- </div>
221
- <h2><?php echo __('Edit location', 'dbem') ?></h2>
222
-
223
- <?php if($message != "") : ?>
224
- <div id='message' class='updated fade below-h2' style='background-color: rgb(255, 251, 204);'>
225
- <p><?php echo $message ?></p>
226
- </div>
227
- <?php endif; ?>
228
- <div id='ajax-response'></div>
229
-
230
- <form enctype='multipart/form-data' name='editcat' id='locationForm' method='post' action='admin.php?page=locations' class='validate'>
231
- <input type='hidden' name='action' value='editedlocation' />
232
- <input type='hidden' name='location_id' value='<?php echo $EM_Location->id ?>'/>
233
- <table class='form-table'>
234
- <tr class='form-field form-required'>
235
- <th scope='row' valign='top'><label for='location_name'><?php echo __('Location name', 'dbem') ?></label></th>
236
- <td><input name='location_name' id='location-name' type='text' value='<?php echo htmlspecialchars($EM_Location->name, ENT_QUOTES); ?>' size='40' /><br />
237
- <?php echo __('The name of the location', 'dbem') ?></td>
238
- </tr>
239
-
240
- <tr class='form-field'>
241
- <th scope='row' valign='top'><label for='location_address'><?php echo __('Location address', 'dbem') ?></label></th>
242
- <td><input name='location_address' id='location-address' type='text' value='<?php echo htmlspecialchars($EM_Location->address, ENT_QUOTES); ?>' size='40' /><br />
243
- <?php echo __('The address of the location', 'dbem') ?>.</td>
244
-
245
- </tr>
246
-
247
- <tr class='form-field'>
248
- <th scope='row' valign='top'> <label for='location_town'><?php echo __('Location town', 'dbem') ?></label></th>
249
- <td><input name='location_town' id='location-town' type='text' value='<?php echo htmlspecialchars($EM_Location->town, ENT_QUOTES); ?>' size='40' /><br />
250
- <?php echo __('The town where the location is located', 'dbem') ?>.</td>
251
-
252
- </tr>
253
-
254
- <tr style='display:none;'>
255
- <td>Coordinates</td>
256
- <td><input id='location-latitude' name='location_latitude' id='location_latitude' type='text' value='<?php echo $EM_Location->latitude ?>' size='15' />
257
- <input id='location-longitude' name='location_longitude' id='location_longitude' type='text' value='<?php echo $EM_Location->longitude ?>' size='15' /></td>
258
- </tr>
259
-
260
- <?php if (get_option('dbem_gmap_is_active')) { ?>
261
- <tr>
262
- <th scope='row' valign='top'><label for='location_map'><?php echo __('Location map', 'dbem') ?></label></th>
263
- <td>
264
- <div id='em-map-404' style='width: 450px; height: 350px; vertical-align:middle; text-align: center;'>
265
- <p><em><?php _e ( 'Location not found', 'dbem' ); ?></em></p>
266
- </div>
267
- <div id='em-map' style='width: 450px; height: 350px; display: none;'></div>
268
- </td>
269
- </tr>
270
- <?php
271
- }
272
- ?>
273
- <tr class='form-field'>
274
- <th scope='row' valign='top'><label for='location_description'><?php _e('Location description', 'dbem') ?></label></th>
275
- <td>
276
- <div class="inside">
277
- <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
278
- <?php the_editor($EM_Location->description); ?>
279
- </div>
280
- <?php _e('A description of the Location. You may include any kind of info here.', 'dbem') ?>
281
- </div>
282
- </td>
283
- </tr>
284
- <tr class='form-field'>
285
- <th scope='row' valign='top'><label for='location_picture'><?php echo __('Location image', 'dbem') ?></label></th>
286
- <td>
287
- <?php if ($EM_Location->image_url != '') : ?>
288
- <img src='<?php echo $EM_Location->image_url; ?>' alt='<?php echo $EM_Location->name ?>'/>
289
- <?php else : ?>
290
- <?php echo __('No image uploaded for this location yet', 'debm') ?>
291
- <?php endif; ?>
292
- </td>
293
- </tr>
294
- <tr>
295
- <th scope='row' valign='top'><label for='location_image'><?php echo __('Upload/change picture', 'dbem') ?></label></th>
296
- <td><input id='location-image' name='location_image' id='location_image' type='file' size='40' /></td>
297
- </tr>
298
- </table>
299
- <p class='submit'><input type='submit' class='button-primary' name='submit' value='<?php echo __('Update location', 'dbem') ?>' /></p>
300
- </form>
301
- </div>
302
- <?php
303
- }
304
-
305
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/options.php DELETED
@@ -1,315 +0,0 @@
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_' ){
8
- //TODO some more validation/reporting
9
- $numeric_options = array('dbem_locations_default_limit','dbem_events_default_limit');
10
- if( in_array($postKey,$numeric_options) && !is_numeric($postValue) ){
11
- //Do nothing, keep old setting.
12
- }else{
13
- //TODO slashes being added?
14
- //$postValue = EM_Object::sanitize($postValue)
15
- update_option($postKey, stripslashes($postValue));
16
- }
17
- }
18
- }
19
- function em_options_saved_notice(){
20
- ?>
21
- <div class="updated"><p><strong><?php _e('Changes saved.'); ?></strong></p></div>
22
- <?php
23
- }
24
- add_action ( 'admin_notices', 'em_options_saved_notice' );
25
- }
26
- }
27
- add_action('admin_head', 'em_options_save');
28
-
29
-
30
-
31
- function dbem_options_subpanel() {
32
- //TODO place all options into an array
33
- $save_button = '<tr><th>&nbsp;</th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" id="dbem_options_submit" name="Submit" value="'. __( 'Save Changes' ) .' ('. __('All','dbem') .')" /></p></ts></td></tr>';
34
- ?>
35
- <script type="text/javascript" charset="utf-8">
36
- jQuery(document).ready(function($){
37
- var close_text = '<?php _e('Collapse All','dbem'); ?>';
38
- var open_text = '<?php _e('Expand All','dbem'); ?>';
39
- var open_close = $('<a href="#" style="display:block; float:right; clear:right; margin:10px;">'+close_text+'</a>');
40
- $('#icon-options-general').after(open_close);
41
- open_close.click( function(e){
42
- e.preventDefault();
43
- if($(this).text() == close_text){
44
- $(".postbox").addClass('closed');
45
- $(this).text(open_text);
46
- }else{
47
- $(".postbox").removeClass('closed');
48
- $(this).text(close_text);
49
- }
50
- });
51
- //For rewrite titles
52
- $('input:radio[name=dbem_disable_title_rewrites]').live('change',function(){
53
- checked_check = $('input:radio[name=dbem_disable_title_rewrites]:checked');
54
- if( checked_check.val() == 1 ){
55
- $('#dbem_title_html_row').show();
56
- }else{
57
- $('#dbem_title_html_row').hide();
58
- }
59
- });
60
- $('input:radio[name=dbem_disable_title_rewrites]').trigger('change');
61
-
62
- });
63
- </script>
64
- <div class="wrap">
65
- <div id='icon-options-general' class='icon32'><br />
66
- </div>
67
- <h2><?php _e ( 'Event Manager Options', 'dbem' ); ?></h2>
68
-
69
- <form id="dbem_options_form" method="post" action="">
70
-
71
- <div class="metabox-holder">
72
- <!-- // TODO Move style in css -->
73
- <div class='postbox-container' style='width: 99.5%'>
74
- <div id="" class="meta-box-sortables" >
75
-
76
- <div class="postbox " >
77
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'General options', 'dbem' ); ?> </span></h3>
78
- <div class="inside">
79
- <table class="form-table">
80
- <?php
81
- dbem_options_radio_binary ( __( 'Use dropdown for locations?' ), 'dbem_use_select_for_locations', __( 'Select yes to select location from a drow-down menu; location selection will be faster, but you will lose the ability to insert locations with events','dbem' ) );
82
- dbem_options_radio_binary ( __( 'Use recurrence?' ), 'dbem_recurrence_enabled', __( 'Select yes to enable the recurrence features feature','dbem' ) );
83
- dbem_options_radio_binary ( __( 'Use RSVP?' ), 'dbem_rsvp_enabled', __( 'Select yes to enable the RSVP feature','dbem' ) );
84
- dbem_options_radio_binary ( __( 'Use categories?' ), 'dbem_categories_enabled', __( 'Select yes to enable the category features','dbem' ) );
85
- dbem_options_radio_binary ( __( 'Use attributes?' ), 'dbem_attributes_enabled', __( 'Select yes to enable the attributes feature','dbem' ) );
86
- echo $save_button;
87
- ?>
88
- </table>
89
-
90
- </div> <!-- . inside -->
91
- </div> <!-- .postbox -->
92
-
93
- <div class="postbox " >
94
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Events page', 'dbem' ); ?> </span></h3>
95
- <div class="inside">
96
- <table class="form-table">
97
- <?php
98
- //Wordpress Pages
99
- global $em_disable_filter; //Using a flag here instead
100
- $em_disable_filter = true;
101
- $get_pages = get_pages();
102
- $events_page_options = array();
103
- $events_page_options[0] = __('[No Events Page]');
104
- //TODO Add the hierarchy style ddm, like when choosing page parents
105
- foreach($get_pages as $page){
106
- $events_page_options[$page->ID] = $page->post_title;
107
- }
108
- 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' ) );
109
- $em_disable_filter = false;
110
- //Rest
111
- dbem_options_radio_binary ( __( 'Show events page in lists?', 'dbem' ), 'dbem_list_events_page', __( 'Check this option if you want the events page to appear together with other pages in pages lists.', 'dbem' ) );
112
- dbem_options_radio_binary ( __( 'Display calendar in events page?', 'dbem' ), 'dbem_display_calendar_in_events_page', __( 'This options allows to display the calendar in the events page, instead of the default list. It is recommended not to display both the calendar widget and a calendar page.','dbem' ).' '.__('If you would like to show events that span over more than one day, see the Calendar section on this page.','dbem') );
113
- dbem_options_radio_binary ( __( 'Disable title rewriting?', 'dbem' ), 'dbem_disable_title_rewrites', __( "Some wordpress themes don't follow best practices when generating navigation menus, and so the automatic title rewriting feature may cause problems, if your menus aren't working correctly on the event pages, try setting this to 'Yes', and provide an appropriate HTML title format below.",'dbem' ) );
114
- dbem_options_input_text ( __( 'Event Manager titles', 'dbem' ), 'dbem_title_html', __( "This only setting only matters if you selected 'Yes' to above. You will notice the events page titles aren't being rewritten, and you have a new title underneath the default page name. This is where you control the HTML of this title. Make sure you keep the #_PAGETITLE placeholder here, as that's what is rewritten by events manager. To control what's rewritten in this title, see settings further down for page titles.", 'dbem' ) );
115
- dbem_options_input_text ( __( 'Event List Limits', 'dbem' ), 'dbem_events_default_limit', __( "This will control how many events are shown on one list by default.", 'dbem' ) );
116
- ?>
117
- <tr valign="top" id='dbem_events_default_orderby_row'>
118
- <th scope="row"><?php _e('Default event list ordering','dbem'); ?></th>
119
- <td>
120
- <select name="dbem_events_default_orderby" >
121
- <?php
122
- $orderby_options = apply_filters('em_settings_events_default_orderby_ddm', array(
123
- 'start_date,start_time,name' => __('Order by start date, start time, then event name','dbem'),
124
- 'name,start_date,start_time' => __('Order by name, start date, then start time','dbem'),
125
- 'name,end_date,end_time' => __('Order by name, end date, then end time','dbem'),
126
- 'end_date,end_time,name' => __('Order by end date, end time, then event name','dbem'),
127
- ));
128
- ?>
129
- <?php foreach($orderby_options as $key => $value) : ?>
130
- <option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_orderby')) ? "selected='selected'" : ''; ?>>
131
- <?php echo $value; ?>
132
- </option>
133
- <?php endforeach; ?>
134
- </select>
135
- <select name="dbem_events_default_order" >
136
- <?php
137
- $ascending = __('Ascending','dbem');
138
- $descending = __('Descending','dbem');
139
- $order_options = apply_filters('em_settings_events_default_order_ddm', array(
140
- 'ASC' => __('All Ascending','dbem'),
141
- 'DESC,ASC,ASC' => __("$descending, $ascending, $ascending",'dbem'),
142
- 'DESC,DESC,ASC' => __("$descending, $descending, $ascending",'dbem'),
143
- 'DESC' => __('All Descending','dbem'),
144
- 'ASC,DESC,ASC' => __("$ascending, $descending, $ascending",'dbem'),
145
- 'ASC,DESC,DESC' => __("$ascending, $descending, $descending",'dbem'),
146
- 'ASC,ASC,DESC' => __("$ascending, $ascending, $descending",'dbem'),
147
- 'DESC,ASC,DESC' => __("$descending, $ascending, $descending",'dbem'),
148
- ));
149
- ?>
150
- <?php foreach( $order_options as $key => $value) : ?>
151
- <option value='<?php echo $key ?>' <?php echo ($key == get_option('dbem_events_default_order')) ? "selected='selected'" : ''; ?>>
152
- <?php echo $value; ?>
153
- </option>
154
- <?php endforeach; ?>
155
- </select>
156
- <br/>
157
- <?php _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.','dbem'); ?>
158
- </td>
159
- </tr>
160
- <?php
161
- echo $save_button;
162
- ?>
163
- </table>
164
- </div> <!-- . inside -->
165
- </div> <!-- .postbox -->
166
-
167
- <div class="postbox " >
168
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Events format', 'dbem' ); ?> </span></h3>
169
- <div class="inside">
170
- <table class="form-table">
171
- <?php
172
- dbem_options_textarea ( __( 'Default event list format header', 'dbem' ), 'dbem_event_list_item_format_header', __( 'This content will appear just above your code for the default event list format. Default is blank', 'dbem' ) );
173
- dbem_options_textarea ( __( 'Default event list format', 'dbem' ), 'dbem_event_list_item_format', __( 'The format of any events in a list.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_LOCATION</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_NOTES</code>.<br/> Use <code>#_EXCERPT</code> to show <code>#_NOTES</code> until you place a &lt;!&ndash;&ndash; more &ndash;&ndash;&gt; marker.<br/> Use <code>#_LINKEDNAME</code> for the event name with a link to the given event page.<br/> Use <code>#_EVENTPAGEURL</code> to print the event page URL and make your own customised links.<br/> Use <code>#_LOCATIONPAGEURL</code> to print the location page URL and make your own customised links.<br/>Use <code>#_EDITEVENTLINK</code> to add add a link to edit page for the event, which will appear only when a user is logged in.<br/>To insert date and time values, use <a href="http://www.php.net/manual/en/function.date.php">PHP time format characters</a> with a <code>#</code> symbol before them, i.e. <code>#m</code>, <code>#M</code>, <code>#j</code>, etc.<br/> For the end time, put <code>#@</code> in front of the character, ie. <code>#@h</code>, <code>#@i</code>, etc.<br/> You can also create a date format without prepending <code>#</code> by wrapping it in #_{} or #@_{} (e.g. <code>#_{d/m/Y}</code>). If there is no end date, the value is not shown.<br/>Feel free to use HTML tags as <code>li</code>, <code>br</code> and so on.<br/>For custom attributes, you use <code>#_ATT{key}{alternative text}</code>, the second braces are optional and will appear if the attribute is not defined or left blank for that event. This key will appear as an option when adding attributes to your event.', 'dbem' ) );
174
- dbem_options_textarea ( __( 'Default event list format footer', 'dbem' ), 'dbem_event_list_item_format_footer', __( 'This content will appear just below your code for the default event list format. Default is blank', 'dbem' ) );
175
- dbem_options_input_text ( __( 'Single event page title format', 'dbem' ), 'dbem_event_page_title_format', __( 'The format of a single event page title. Follow the previous formatting instructions.', 'dbem' ) );
176
- dbem_options_textarea ( __( 'Default single event format', 'dbem' ), 'dbem_single_event_format', __( 'The format of a single event page.<br/>Follow the previous formatting instructions. <br/>Use <code>#_MAP</code> to insert a map.<br/>Use <code>#_CONTACTNAME</code>, <code>#_CONTACTEMAIL</code>, <code>#_CONTACTPHONE</code> to insert respectively the name, e-mail address and phone number of the designated contact person. <br/>Use <code>#_ADDBOOKINGFORM</code> to insert a form to allow the user to respond to your events reserving one or more places (RSVP).<br/> Use <code>#_REMOVEBOOKINGFORM</code> to insert a form where users, inserting their name and e-mail address, can remove their bookings.', 'dbem' ) );
177
- dbem_options_input_text ( __( 'Events page title', 'dbem' ), 'dbem_events_page_title', __( 'The title on the multiple events page.', 'dbem' ) );
178
- dbem_options_input_text ( __( 'No events message', 'dbem' ), 'dbem_no_events_message', __( 'The message displayed when no events are available.', 'dbem' ) );
179
- dbem_options_input_text ( __( 'List events by date title', 'dbem' ), 'dbem_list_date_title', __( 'If viewing a page for events on a specific date, this is the title that would show up. To insert date values, use <a href="http://www.php.net/manual/en/function.date.php">PHP time format characters</a> with a <code>#</code> symbol before them, i.e. <code>#m</code>, <code>#M</code>, <code>#j</code>, etc.<br/>', 'dbem' ) );
180
- echo $save_button;
181
- ?>
182
- </table>
183
- </div> <!-- . inside -->
184
- </div> <!-- .postbox -->
185
-
186
- <div class="postbox " >
187
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Calendar format', 'dbem' ); ?></span></h3>
188
- <div class="inside">
189
- <table class="form-table">
190
- <?php
191
- dbem_options_input_text ( __( 'Small calendar title', 'dbem' ), 'dbem_small_calendar_event_title_format', __( 'The format of the title, corresponding to the text that appears when hovering on an eventful calendar day.', 'dbem' ) );
192
- dbem_options_input_text ( __( 'Small calendar title separator', 'dbem' ), 'dbem_small_calendar_event_title_separator', __( 'The separator appearing on the above title when more than one events are taking place on the same day.', 'dbem' ) );
193
- dbem_options_input_text ( __( 'Full calendar events format', 'dbem' ), 'dbem_full_calendar_event_format', __( 'The format of each event when displayed in the full calendar. Remember to include <code>li</code> tags before and after the event.', 'dbem' ) );
194
- dbem_options_radio_binary ( __( 'Show long events on calendar pages?', 'dbem' ), 'dbem_full_calendar_long_events', __( "If you are showing a calendar on the events page (see Events format section on this page), you have the option of showing events that span over days on each day it occurs.",'dbem' ) );
195
- dbem_options_radio_binary ( __( 'Show list on day with single event?', 'dbem' ), 'dbem_display_calendar_day_single', __( "By default, if a calendar day only has one event, it display a single event when clicking on the link of that calendar date. If you select Yes here, you will get always see a list of events.",'dbem' ) );
196
- echo $save_button;
197
- ?>
198
- </table>
199
- </div> <!-- . inside -->
200
- </div> <!-- .postbox -->
201
-
202
- <div class="postbox " >
203
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Locations format', 'dbem' ); ?> </span></h3>
204
- <div class="inside">
205
- <table class="form-table">
206
- <?php
207
- dbem_options_input_text ( __( 'Single location page title format', 'dbem' ), 'dbem_location_page_title_format', __( 'The format of a single location page title.<br/>Follow the previous formatting instructions.', 'dbem' ) );
208
- dbem_options_textarea ( __( 'Default single location page format', 'dbem' ), 'dbem_single_location_format', __( 'The format of a single location page.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_DESCRIPTION</code>.<br/> Use <code>#_MAP</code> to display a map of the event location, and <code>#_IMAGE</code> to display an image of the location.<br/> Use <code>#_NEXTEVENTS</code> to insert a list of the upcoming events, <code>#_PASTEVENTS</code> for a list of past events, <code>#_ALLEVENTS</code> for a list of all events taking place in this location.', 'dbem' ) );
209
- dbem_options_textarea ( __( 'Default location balloon format', 'dbem' ), 'dbem_location_baloon_format', __( 'The format of of the text appearing in the baloon describing the location in the map.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_DESCRIPTION</code> or <code>#_IMAGE</code>.', 'dbem' ) );
210
- dbem_options_textarea ( __( 'Default location event list format', 'dbem' ), 'dbem_location_event_list_item_format', __( 'The format of the events the list inserted in the location page through the <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> element. <br/> Follow the events formatting instructions', 'dbem' ) );
211
- dbem_options_textarea ( __( 'Default no events message', 'dbem' ), 'dbem_location_no_events_message', __( 'The message to be displayed in the list generated by <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> when no events are available.', 'dbem' ) );
212
- echo $save_button;
213
- ?>
214
- </table>
215
- </div> <!-- . inside -->
216
- </div> <!-- .postbox -->
217
-
218
- <div class="postbox " >
219
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'RSS feed format', 'dbem' ); ?> </span></h3>
220
- <div class="inside">
221
- <table class="form-table">
222
- <?php
223
- dbem_options_input_text ( __( 'RSS main title', 'dbem' ), 'dbem_rss_main_title', __( 'The main title of your RSS events feed.', 'dbem' ) );
224
- dbem_options_input_text ( __( 'RSS main description', 'dbem' ), 'dbem_rss_main_description', __( 'The main description of your RSS events feed.', 'dbem' ) );
225
- dbem_options_input_text ( __( 'RSS title format', 'dbem' ), 'dbem_rss_title_format', __( 'The format of the title of each item in the events RSS feed.', 'dbem' ) );
226
- dbem_options_input_text ( __( 'RSS description format', 'dbem' ), 'dbem_rss_description_format', __( 'The format of the description of each item in the events RSS feed. Follow the previous formatting instructions.', 'dbem' ) );
227
- echo $save_button;
228
- ?>
229
- </table>
230
- </div> <!-- . inside -->
231
- </div> <!-- .postbox -->
232
-
233
- <div class="postbox " >
234
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Maps and geotagging', 'dbem' ); ?> </span></h3>
235
- <div class="inside">
236
- <table class='form-table'>
237
- <?php $gmap_is_active = get_option ( 'dbem_gmap_is_active' ); ?>
238
- <tr valign="top">
239
- <th scope="row"><?php _e ( 'Enable Google Maps integration?', 'dbem' ); ?></th>
240
- <td>
241
- <input id="dbem_gmap_is_active_yes" name="dbem_gmap_is_active" type="radio" value="1" <?php echo ($gmap_is_active) ? "checked='checked'":''; ?> /><?php _e ( 'Yes' ); ?><br />
242
- <input name="dbem_gmap_is_active" type="radio" value="0" <?php echo ($gmap_is_active) ? '':"checked='checked'"; ?> /> <?php _e ( 'No' ); ?> <br />
243
- <?php _e ( 'Check this option to enable Goggle Map integration.', 'dbem' )?>
244
- </td>
245
- </tr>
246
- <?php
247
- dbem_options_textarea ( __( 'Map text format', 'dbem' ), 'dbem_map_text_format', __( 'The text format inside the map balloons.<br/>Follow the previous formatting instructions.', 'dbem' ) );
248
- echo $save_button;
249
- ?>
250
- </table>
251
- </div> <!-- . inside -->
252
- </div> <!-- .postbox -->
253
-
254
- <div class="postbox " >
255
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'RSVP and bookings', 'dbem' ); ?> </span></h3>
256
- <div class="inside">
257
- <table class='form-table'>
258
- <?php
259
- dbem_options_select ( __( 'Default contact person', 'dbem' ), 'dbem_default_contact_person', em_get_wp_users (), __( 'Select the default contact person. This user will be employed whenever a contact person is not explicitly specified for an event', 'dbem' ) );
260
- dbem_options_radio_binary ( __( 'Enable the RSVP e-mail notifications?', 'dbem' ), 'dbem_rsvp_mail_notify_is_active', __( 'Check this option if you want to receive an email when someone books places for your events.', 'dbem' ) );
261
- dbem_options_textarea ( __( 'Contact person email format', 'dbem' ), 'dbem_contactperson_email_body', __( 'The format of the email which will be sent to the contact person. Follow the events formatting instructions. <br/>Use <code>#_RESPNAME</code>, <code>#_RESPEMAIL</code> and <code>#_RESPPHONE</code> to display respectively the name, e-mail, address and phone of the respondent.<br/>Use <code>#_SPACES</code> to display the number of spaces reserved by the respondent. Use <code>#_COMMENT</code> to display the respondent\'s comment. <br/> Use <code>#_BOOKEDSEATS</code> and <code>#_AVAILABLESEATS</code> to display respectively the number of booked and available seats.', 'dbem' ) );
262
- dbem_options_textarea ( __( 'Contact person email format', 'dbem' ), 'dbem_respondent_email_body', __( 'The format of the email which will be sent to respondent. Follow the events formatting instructions. <br/>Use <code>#_RESPNAME</code> to display the name of the respondent.<br/>Use <code>#_CONTACTNAME</code> and <code>#_CONTACTEMAIL</code> a to display respectively the name and e-mail of the contact person.<br/>Use <code>#_SPACES</code> to display the number of spaces reserved by the respondent. Use <code>#_COMMENT</code> to display the respondent\'s comment.', 'dbem' ) );
263
- dbem_options_input_text ( __( 'Default notification receiver address', 'dbem' ), 'dbem_mail_receiver_address', __( "Insert the address of the receiver of your notifications", 'dbem' ) );
264
- echo $save_button;
265
- ?>
266
- </table>
267
- </div> <!-- . inside -->
268
- </div> <!-- .postbox -->
269
-
270
- <div class="postbox " >
271
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Email Settings', 'dbem' ); ?> </span></h3>
272
- <div class="inside">
273
- <table class='form-table'>
274
- <?php
275
- dbem_options_input_text ( __( 'Notification sender name', 'dbem' ), 'dbem_mail_sender_name', __( "Insert the display name of the notification sender.", 'dbem' ) );
276
- dbem_options_input_text ( __( 'Notification sender address', 'dbem' ), 'dbem_mail_sender_address', __( "Insert the address of the notification sender.", 'dbem' ) );
277
- dbem_options_input_text ( 'Mail sending port', 'dbem_rsvp_mail_port', __( "The port through which you e-mail notifications will be sent. Make sure the firewall doesn't block this port", 'dbem' ) );
278
- dbem_options_select ( __( 'Mail sending method', 'dbem' ), 'dbem_rsvp_mail_send_method', array ('smtp' => 'SMTP', 'mail' => __( 'PHP mail function', 'dbem' ), 'sendmail' => 'Sendmail', 'qmail' => 'Qmail' ), __( 'Select the method to send email notification.', 'dbem' ) );
279
- dbem_options_radio_binary ( __( 'Use SMTP authentication?', 'dbem' ), 'dbem_rsvp_mail_SMTPAuth', __( 'SMTP authentication is often needed. If you use GMail, make sure to set this parameter to Yes', 'dbem' ) );
280
- dbem_options_input_text ( 'SMTP host', 'dbem_smtp_host', __( "The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set this value to 'ssl://smtp.gmail.com:465'.", 'dbem' ) );
281
- dbem_options_input_text ( __( 'SMTP username', 'dbem' ), 'dbem_smtp_username', __( "Insert the username to be used to access your SMTP server.", 'dbem' ) );
282
- dbem_options_input_password ( __( 'SMTP password', 'dbem' ), "dbem_smtp_password", __( "Insert the password to be used to access your SMTP server", 'dbem' ) );
283
- echo $save_button;
284
- ?>
285
- </table>
286
- </div> <!-- . inside -->
287
- </div> <!-- .postbox -->
288
-
289
- <div class="postbox " >
290
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Images size', 'dbem' ); ?> </span></h3>
291
- <div class="inside">
292
- <table class='form-table'>
293
- <?php
294
- dbem_options_input_text ( __( 'Maximum width (px)', 'dbem' ), 'dbem_image_max_width', __( 'The maximum allowed width for images uploades', 'dbem' ) );
295
- dbem_options_input_text ( __( 'Maximum height (px)', 'dbem' ), 'dbem_image_max_height', __( "The maximum allowed height for images uploaded, in pixels", 'dbem' ) );
296
- dbem_options_input_text ( __( 'Maximum size (bytes)', 'dbem' ), 'dbem_image_max_size', __( "The maximum allowed size for images uploaded, in pixels", 'dbem' ) );
297
- ?>
298
- </table>
299
- </div> <!-- . inside -->
300
- </div> <!-- .postbox -->
301
-
302
- <p class="submit">
303
- <input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
304
- <input type="hidden" name="em-submitted" value="1" />
305
- </p>
306
-
307
- </div> <!-- .metabox-sortables -->
308
- </div> <!-- .postbox-container -->
309
-
310
- </div> <!-- .metabox-holder -->
311
- </form>
312
- </div>
313
- <?php
314
- }
315
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/{booking.php → em-booking.php} RENAMED
File without changes
classes/{bookings.php → em-bookings.php} RENAMED
@@ -60,16 +60,18 @@ class EM_Bookings extends EM_Object{
60
  if ( is_object($previous_booking) ) {
61
  //Previously booked, so we add these seats to the booking
62
  $new_seats = $EM_Booking->seats;
63
- $EM_Booking = $previous_booking;
64
- $EM_Booking->seats += $new_seats;
65
  $result = $EM_Booking->save();
66
  if($result){
 
67
  $email = $this->email($EM_Booking);
 
68
  }
69
  } else {
70
  //New booking, so let's save the booking
71
  $result = $EM_Booking->save();
72
  if($result){
 
73
  $email = $this->email($EM_Booking);
74
  }
75
  }
@@ -169,9 +171,8 @@ class EM_Bookings extends EM_Object{
169
  '#_RESPNAME' => '#_BOOKINGNAME',//Depreciated
170
  '#_RESPEMAIL' => '#_BOOKINGEMAIL',//Depreciated
171
  '#_RESPPHONE' => '#_BOOKINGPHONE',//Depreciated
172
- '#_SPACES' => '#_BOOKINGSPACES',//Depreciated
173
  '#_COMMENT' => '#_BOOKINGCOMMENT',//Depreciated
174
- '#_RESERVEDSPACES' => '#_BOOKEDSEATS',//Depreciated
175
  '#_BOOKINGNAME' => $EM_Booking->person->name,
176
  '#_BOOKINGEMAIL' => $EM_Booking->person->email,
177
  '#_BOOKINGPHONE' => $EM_Booking->person->phone,
60
  if ( is_object($previous_booking) ) {
61
  //Previously booked, so we add these seats to the booking
62
  $new_seats = $EM_Booking->seats;
63
+ $EM_Booking = $previous_booking;
 
64
  $result = $EM_Booking->save();
65
  if($result){
66
+ $this->bookings[] = $EM_Booking;
67
  $email = $this->email($EM_Booking);
68
+ $EM_Booking->seats += $new_seats;
69
  }
70
  } else {
71
  //New booking, so let's save the booking
72
  $result = $EM_Booking->save();
73
  if($result){
74
+ $this->bookings[] = $EM_Booking;
75
  $email = $this->email($EM_Booking);
76
  }
77
  }
171
  '#_RESPNAME' => '#_BOOKINGNAME',//Depreciated
172
  '#_RESPEMAIL' => '#_BOOKINGEMAIL',//Depreciated
173
  '#_RESPPHONE' => '#_BOOKINGPHONE',//Depreciated
 
174
  '#_COMMENT' => '#_BOOKINGCOMMENT',//Depreciated
175
+ '#_RESERVEDSPACES' => '#_BOOKEDSPACES',//Depreciated
176
  '#_BOOKINGNAME' => $EM_Booking->person->name,
177
  '#_BOOKINGEMAIL' => $EM_Booking->person->email,
178
  '#_BOOKINGPHONE' => $EM_Booking->person->phone,
classes/{calendar.php → em-calendar.php} RENAMED
@@ -222,8 +222,8 @@ class EM_Calendar extends EM_Object {
222
  foreach($events as $event) {
223
  if( $long_events ){
224
  //If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day
225
- $event_start_date = strtotime($event->start_date);
226
- $event_end_date = strtotime($event->end_date);
227
  if( $event_end_date == '' ) $event_end_date = $event_start_date;
228
  while( $event_start_date <= $event_end_date ){
229
  $event_eventful_date = date('Y-m-d', $event_start_date);
@@ -292,7 +292,7 @@ class EM_Calendar extends EM_Object {
292
  }
293
  }
294
  }
295
- return '<div id="em-calendar-'.rand(100,200).'" class="em-calendar-wrapper">'.$calendar.'</div>';
296
  }
297
 
298
  /**
@@ -309,7 +309,7 @@ class EM_Calendar extends EM_Object {
309
 
310
 
311
  function days_in_month($month, $year) {
312
- return cal_days_in_month(CAL_GREGORIAN, $month, $year);
313
  }
314
 
315
  function translate_and_trim($string, $length = 1) {
@@ -326,7 +326,7 @@ class EM_Calendar extends EM_Object {
326
  $atts = parent::get_default_search($defaults, $array);
327
  $atts['full'] = ($atts['full']==true) ? 1:0;
328
  $atts['long_events'] = ($atts['long_events']==true) ? 1:0;
329
- return $atts;
330
  }
331
  }
332
  add_action('init', array('EM_Calendar', 'init'));
222
  foreach($events as $event) {
223
  if( $long_events ){
224
  //If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day
225
+ $event_start_date = apply_filters('em_calendar_loop_date_start', strtotime($event->start));
226
+ $event_end_date = apply_filters('em_calendar_loop_date_end', strtotime($event->end));
227
  if( $event_end_date == '' ) $event_end_date = $event_start_date;
228
  while( $event_start_date <= $event_end_date ){
229
  $event_eventful_date = date('Y-m-d', $event_start_date);
292
  }
293
  }
294
  }
295
+ return apply_filters('em_calendar_output', '<div id="em-calendar-'.rand(100,200).'" class="em-calendar-wrapper">'.$calendar.'</div>');
296
  }
297
 
298
  /**
309
 
310
 
311
  function days_in_month($month, $year) {
312
+ return date('t', strtotime("$year-$month-1"));
313
  }
314
 
315
  function translate_and_trim($string, $length = 1) {
326
  $atts = parent::get_default_search($defaults, $array);
327
  $atts['full'] = ($atts['full']==true) ? 1:0;
328
  $atts['long_events'] = ($atts['long_events']==true) ? 1:0;
329
+ return apply_filters('em_calendar_get_default_search', $atts, $array, $defaults);
330
  }
331
  }
332
  add_action('init', array('EM_Calendar', 'init'));
classes/{category.php → em-category.php} RENAMED
File without changes
classes/{event.php → em-event.php} RENAMED
@@ -39,6 +39,18 @@ class EM_Event extends EM_Object{
39
  'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d' ) //if monthly which week (-1 is last)
40
  );
41
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  /**
43
  * @var EM_Location
44
  */
@@ -103,6 +115,10 @@ class EM_Event extends EM_Object{
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){
@@ -129,17 +145,17 @@ class EM_Event extends EM_Object{
129
  */
130
  function get_post(){
131
  //Build Event Array
132
- $post = $_POST;
133
- $this->name = stripslashes ( $_POST ["event_name"] );
134
- $this->start_date = $_POST ["event_start_date"];
135
- $this->end_date = ($_POST ['event_end_date'] == '') ? $this->start_date : $_POST ["event_end_date"];
136
- $this->rsvp = ( $_POST ['event_rsvp'] == 1 ) ? 1:0;
137
- $this->seats = ( is_numeric($_POST ['event_seats']) ) ? $_POST ['event_seats']:0;
138
- $this->notes = stripslashes ( $_POST ['content'] ); //WP TinyMCE field
139
  //Sort out time
140
  //TODO make time handling less painful
141
  $match = array();
142
- if( preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_start_time'], $match ) ){
143
  if( $match[3] == 'PM' && $match[1] != 12 ){
144
  $match[1] = 12+$match[1];
145
  }elseif( $match[3] == 'AM' && $match[1] == 12 ){
@@ -149,7 +165,7 @@ class EM_Event extends EM_Object{
149
  }else{
150
  $this->start_time = "00:00:00";
151
  }
152
- if( preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_end_time'], $match ) ){
153
  if( $match[3] == 'PM' && $match[1] != 12 ){
154
  $match[1] = 12+$match[1];
155
  }elseif( $match[3] == 'AM' && $match[1] == 12 ){
@@ -159,45 +175,48 @@ class EM_Event extends EM_Object{
159
  }else{
160
  $this->end_time = $this->start_time;
161
  }
 
 
 
162
  //Contact Person
163
- if ( is_numeric($_POST['event_contactperson_id']) ) {
164
  //TODO contactperson choices needs limiting depending on role
165
- $this->contactperson_id = $_POST ['event_contactperson_id'];
166
  }
167
  //category
168
- if( is_numeric($_POST ['event_category_id']) ){
169
- $this->category_id = $_POST ['event_category_id'];
170
  }
171
  //Attributes
172
  $event_attributes = array();
173
- for($i=1 ; trim($_POST["mtm_{$i}_ref"])!='' ; $i++ ){
174
- if(trim($_POST["mtm_{$i}_name"]) != ''){
175
  $event_attributes[$_POST["mtm_{$i}_ref"]] = stripslashes($_POST["mtm_{$i}_name"]);
176
  }
177
  }
178
  $this->attributes = $event_attributes;
179
  //Recurrence data
180
- $this->recurrence_id = ( is_numeric($_POST ['recurrence_id']) ) ? $_POST ['recurrence_id'] : 0 ;
181
- if($_POST ['repeated_event']){
182
  $this->recurrence = 1;
183
- $this->freq = in_array($_POST['recurrence_freq'], array('daily','weekly','monthly')) ? $_POST['recurrence_freq']:'daily';
184
- if($this->freq == 'weekly' && self::array_is_numeric($_POST ['recurrence_bydays'])){
185
- $this->byday = implode ( ",", $_POST ['recurrence_bydays'] );
186
- }elseif($this->freq == 'monthly'){
187
- $this->byday = $_POST ['recurrence_byday'];
188
  }
189
- $this->interval = ($_POST ['recurrence_interval'] == "") ? 1 : $_POST ['recurrence_interval'];
190
- $this->byweekno = $_POST ['recurrence_byweekno'];
191
  }
192
 
193
  //Add location information, or just link to previous location, this is a requirement...
194
- if( isset($_POST['location-select-id']) && $_POST['location-select-id'] != "" ) {
195
  $this->location = new EM_Location($_POST['location-select-id']);
196
  } else {
197
  $this->location = new EM_Location($_POST);
198
  $this->location->load_similar($_POST);
199
  }
200
- return $this->validate();
201
  }
202
 
203
  /**
@@ -208,12 +227,13 @@ class EM_Event extends EM_Object{
208
  function save(){
209
  //FIXME Event doesn't save title when inserting first time
210
  global $wpdb, $current_user;
211
- get_currentuserinfo();;
 
212
  $events_table = $wpdb->prefix.EM_EVENTS_TABLE;
213
  //First let's save the location, no location no event!
214
  if ( !$this->location->id && !$this->location->save() ){ //shouldn't try to save if location exists
215
  $this->errors[] = __ ( 'There was a problem saving the location so event was not saved.', 'dbem' );
216
- return false;
217
  }
218
  $this->location_id = $this->location->id;
219
  //TODO make contactperson_id NULL if not used
@@ -235,15 +255,15 @@ class EM_Event extends EM_Object{
235
  $this->errors[] = __ ( 'Something went wrong with the recurrence update...', 'dbem' ).
236
  __ ( 'There was a problem saving the recurring events.', 'dbem' );
237
  $this->delete();
238
- return false;
239
  }
240
  //All good! Event Saved
241
  $this->feedback_message = __ ( 'New recurrent event inserted!', 'dbem' );
242
- return true;
243
  }
244
  //Successful individual save
245
  $this->feedback_message = __ ( 'New event successfully inserted!', 'dbem' );
246
- return true;
247
  }else{
248
  $this->errors[] = __ ( 'Could not save the event details due to a database error.', 'dbem' );
249
  }
@@ -262,39 +282,42 @@ class EM_Event extends EM_Object{
262
  if( !$this->save_events() ){
263
  $this->errors[] = __ ( 'Something went wrong with the recurrence update...', 'dbem' ).
264
  __ ( 'There was a problem saving the recurring events.', 'dbem' );
265
- return false;
266
  }
267
  $this->feedback_message = __ ( 'Recurrence updated!', 'dbem' );
268
- return true;
269
  }
270
  }else{
271
  $this->errors[] = __('Could not save the event details due to a database error.', 'dbem');
272
- return false;
273
  }
274
  //Successful individual or recurrence save
275
  $this->feedback_message = "'{$this->name}' " . __ ( 'updated', 'dbem' ) . "!";
276
  if($this->rsvp == 0){
277
  $this->delete_bookings();
278
  }
279
- return true;
280
  }
281
  }
282
 
283
  /**
284
  * Delete whole event, including recurrence and recurring data
285
  * @param $recurrence_id
286
- * @return null
287
  */
288
  function delete(){
289
  global $wpdb;
 
 
290
  if( $this->is_recurring() ){
291
  //Delete the recurrences then this recurrence event
292
  $this->delete_events();
293
  }
294
  $result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". $wpdb->prefix . EM_EVENTS_TABLE ." WHERE event_id=%d", $this->id) );
295
  if($result !== false){
296
- $bookings_result = $this->get_bookings()->delete();
297
  }
 
298
  }
299
 
300
  /**
@@ -312,10 +335,10 @@ class EM_Event extends EM_Object{
312
  //Get the ID of the new item
313
  $event_ID = $wpdb->insert_id;
314
  $EM_Event = new EM_Event( $event_ID );
315
- return $EM_Event;
316
  }else{
317
  //TODO add error notifications for duplication failures.
318
- return false;
319
  }
320
  }
321
 
@@ -336,14 +359,14 @@ class EM_Event extends EM_Object{
336
  // TODO Create friendly equivelant names for missing fields notice in validation
337
  $this->errors[] = __ ( 'Missing fields: ' ) . implode ( ", ", $missing_fields ) . ". ";
338
  }
339
- if ( $_POST ['repeated_event'] == "1" && $this->end_date == "" ){
340
  $this->errors[] = __ ( 'Since the event is repeated, you must specify an event date.', 'dbem' );
341
  }
342
  if( !$this->location->validate() ){
343
  $this->errors = array_merge($this->errors, $this->location->errors);
344
  }
345
  //TODO validate recurrence during event validate
346
- return ( count($this->errors) == 0 );
347
  }
348
 
349
 
@@ -355,7 +378,7 @@ class EM_Event extends EM_Object{
355
  global $wpdb;
356
  $sql = "SELECT category_id, category_name FROM ".$wpdb->prefix.EM_EVENTS_TABLE." LEFT JOIN ".$wpdb->prefix.EM_CATEGORIES_TABLE." ON category_id=event_category_id WHERE event_id ='".$this->id."'";
357
  $category = $wpdb->get_row($sql, ARRAY_A);
358
- return $category;
359
  }
360
 
361
  /**
@@ -363,7 +386,9 @@ class EM_Event extends EM_Object{
363
  */
364
  function delete_bookings(){
365
  global $wpdb;
366
- return $wpdb->query( $wpdb->prepare("DELETE FROM ".$wpdb->prefix.EM_BOOKINGS_TABLE." WHERE event_id=%d", $this->id) );
 
 
367
  }
368
 
369
  /**
@@ -377,7 +402,7 @@ class EM_Event extends EM_Object{
377
  $this->bookings = new EM_Bookings($this);
378
  }
379
  }
380
- return $this->bookings;
381
  }
382
 
383
  /**
@@ -388,7 +413,7 @@ class EM_Event extends EM_Object{
388
  */
389
  function output_single($target='html'){
390
  $format = get_option ( 'dbem_single_event_format' );
391
- return $this->output($format, $target);
392
  }
393
 
394
  /**
@@ -399,7 +424,7 @@ class EM_Event extends EM_Object{
399
  */
400
  function output_list($target='html'){
401
  $format = get_option ( 'dbem_event_list_item_format' );
402
- return $this->output($format, $target);
403
  }
404
 
405
  /**
@@ -459,7 +484,7 @@ class EM_Event extends EM_Object{
459
  case '#_EDITEVENTLINK':
460
  if(is_user_logged_in()){
461
  //TODO user should have permission to edit the event
462
- $replace = "<a href=' ".get_bloginfo('wpurl')."/wp-admin/edit.php?page=events-manager/events-manager.php&action=edit_event&event_id=".$this->id."'>".__('Edit').' '.__('Event', 'dbem')."</a>";
463
  }
464
  break;
465
  //Bookings
@@ -501,7 +526,7 @@ class EM_Event extends EM_Object{
501
  break;
502
  case '#_CONTACTEMAIL':
503
  case '#_CONTACTMAIL': //Depreciated
504
- $replace = dbem_ascii_encode($this->contact->user_email);
505
  break;
506
  case '#_CONTACTPHONE':
507
  $replace = ( $this->contact->phone != '') ? $this->contact->phone : __('N/A', 'dbem');
@@ -512,7 +537,7 @@ class EM_Event extends EM_Object{
512
  }
513
  if($match){ //if true, we've got a placeholder that needs replacing
514
  //TODO FILTER - placeholder filter
515
- $replace = apply_filters('em_placeholder', $replace, $result, $target); //USE WITH CAUTION! THIS MIGHT GET RENAMED
516
  $event_string = str_replace($result, $replace , $event_string );
517
  }
518
  }
@@ -520,12 +545,16 @@ class EM_Event extends EM_Object{
520
  foreach($placeholders[0] as $result) {
521
  // matches all PHP START date and time placeholders
522
  if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
523
- $event_string = str_replace($result, mysql2date(ltrim($result, "#"), $this->start_date.$this->start_time),$event_string );
 
 
524
  }
525
  // matches all PHP END time placeholders for endtime
526
  if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
527
- $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), $this->end_date.$this->end_time), $event_string );
528
- }
 
 
529
  }
530
  //Time place holder that doesn't show if empty.
531
  preg_match_all('/#@?_\{[A-Za-z0-9 -\/,\.\\\]+\}/', $format, $results);
@@ -548,17 +577,19 @@ class EM_Event extends EM_Object{
548
  foreach($results[0] as $resultKey => $result) {
549
  //Strip string of placeholder and just leave the reference
550
  $attRef = substr( substr($result, 0, strpos($result, '}')), 6 );
551
- $attString = $this->attributes[$attRef];
552
- if( trim($attString) == '' && $results[1][$resultKey] != '' ){
553
- //Check to see if we have a second set of braces;
554
- $attString = substr( $results[1][$resultKey], 1, strlen(trim($results[1][$resultKey]))-2 );
 
 
555
  }
556
  $event_string = str_replace($result, $attString ,$event_string );
557
  }
558
 
559
  //Now do dependent objects
560
  $event_string = $this->location->output($event_string, $target);
561
- return $event_string;
562
  }
563
 
564
  /**********************************************************
@@ -571,6 +602,7 @@ class EM_Event extends EM_Object{
571
  */
572
  function save_events() {
573
  if( $this->is_recurring() ){
 
574
  global $wpdb;
575
  $event_saves = array();
576
  $matching_days = $this->get_recurrence_days(); //Get days where events recur
@@ -593,7 +625,7 @@ class EM_Event extends EM_Object{
593
  //TODO should be EM_DEBUG, and do we really need it?
594
  if( DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
595
  }
596
- return !in_array(false, $event_saves);
597
  }
598
  return false;
599
  }
@@ -605,6 +637,7 @@ class EM_Event extends EM_Object{
605
  */
606
  function delete_events(){
607
  global $wpdb;
 
608
  //So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer
609
  $EM_Events = EM_Events::get( array('recurrence_id'=>$this->id) );
610
  $event_ids = array();
@@ -650,7 +683,7 @@ class EM_Event extends EM_Object{
650
  if( $this->is_recurring() ){
651
 
652
  $start_date = strtotime($this->start_date);
653
- $end_date = strtotime($this->end_date);
654
 
655
  $weekdays = explode(",", $this->byday); //what days of the week (or if monthly, one value at index 0)
656
 
@@ -760,7 +793,6 @@ class EM_Event extends EM_Object{
760
  $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'));
761
  $output = sprintf (__('From %1$s to %2$s', 'dbem'), $recurrence['event_start_date'], $recurrence['event_end_date']).", ";
762
  if ($recurrence['recurrence_freq'] == 'daily') {
763
-
764
  $freq_desc =__('everyday', 'dbem');
765
  if ($recurrence['recurrence_interval'] > 1 ) {
766
  $freq_desc = sprintf (__("every %s days", 'dbem'), $recurrence['recurrence_interval']);
@@ -769,20 +801,23 @@ class EM_Event extends EM_Object{
769
  if ($recurrence['recurrence_freq'] == 'weekly') {
770
  $weekday_array = explode(",", $recurrence['recurrence_byday']);
771
  $natural_days = array();
772
- foreach($weekday_array as $day)
773
  array_push($natural_days, $weekdays_name[$day]);
 
774
  $output .= implode(" and ", $natural_days);
 
775
  if ($recurrence['recurrence_interval'] > 1 ) {
776
  $freq_desc = ", ".sprintf (__("every %s weeks", 'dbem'), $recurrence['recurrence_interval']);
777
  }
778
 
779
  }
780
  if ($recurrence['recurrence_freq'] == 'monthly') {
781
- $weekday_array = explode(",", $recurrence['recurrence_byday']);
782
- $natural_days = array();
783
- foreach($weekday_array as $day)
784
- array_push($natural_days, $weekdays_name[$day-1]);
785
- $freq_desc = sprintf (($monthweek_name[$recurrence['recurrence_byweekno']]), implode(" and ", $natural_days));
 
786
  if ($recurrence['recurrence_interval'] > 1 ) {
787
  $freq_desc .= ", ".sprintf (__("every %s months",'dbem'), $recurrence['recurrence_interval']);
788
  }
@@ -823,31 +858,32 @@ class EM_Event extends EM_Object{
823
  //TODO placeholder targets filtering could be streamlined better
824
  /**
825
  * This is a temporary filter function which mimicks the old filters in the old 2.x placeholders function
826
- * @param unknown_type $replace
827
- * @param unknown_type $placeholder
828
- * @param unknown_type $target
 
829
  * @return mixed
830
  */
831
- function em_placeholder_targets($replace,$placeholder,$target){
832
  if( ($placeholder == "#_EXCERPT" || $placeholder == "#_LOCATIONEXCERPT") && $target == 'html' ){
833
- $replace = apply_filters('dbem_notes_excerpt', $replace);
834
  }elseif( $placeholder == "#_NOTES" || $placeholder == "#_EXCERPT" || $placeholder == "#_LOCATIONEXCERPT" ){
835
  if($target == 'html'){
836
- $replace = apply_filters('dbem_notes', $replace);
837
  }elseif($target == 'map'){
838
- $replace = apply_filters('dbem_notes_map', $replace);
839
  }else{
840
- $replace = apply_filters('dbem_notes_rss', $replace);
841
- $replace = apply_filters('the_content_rss', $replace);
842
  }
843
  }elseif( in_array($placeholder, array("#_NAME",'#_ADDRESS','#_LOCATION','#_TOWN')) ){
844
  if ($target == "html"){
845
- $replace = apply_filters('dbem_general', $replace);
846
  }else{
847
- $replace = apply_filters('dbem_general_rss', $replace);
848
  }
849
  }
850
- return $replace;
851
  }
852
- add_filter('em_placeholder','em_placeholder_targets',1,3);
853
  ?>
39
  'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d' ) //if monthly which week (-1 is last)
40
  );
41
 
42
+ /**
43
+ * Timestamp of start date/time
44
+ * @var int
45
+ */
46
+ var $start;
47
+
48
+ /**
49
+ * Timestamp of end date/time
50
+ * @var int
51
+ */
52
+ var $end;
53
+
54
  /**
55
  * @var EM_Location
56
  */
115
  $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
116
  $this->to_object($event, true);
117
 
118
+ //Start/End times should be available as timestamp
119
+ $this->start = strtotime($this->start_date." ".$this->start_time);
120
+ $this->end = strtotime($this->end_date." ".$this->end_time);
121
+
122
  //Add Contact Person
123
  if($this->contactperson_id){
124
  if($this->contactperson_id > 0){
145
  */
146
  function get_post(){
147
  //Build Event Array
148
+ do_action('em_event_get_post_pre', $this);
149
+ $this->name = ( !empty($_POST['event_name']) ) ? stripslashes($_POST['event_name']) : '' ;
150
+ $this->start_date = ( !empty($_POST['event_start_date']) ) ? $_POST['event_start_date'] : '';
151
+ $this->end_date = ( !empty($_POST['event_end_date']) ) ? $_POST['event_end_date'] : $this->start_date;
152
+ $this->rsvp = ( !empty($_POST['event_rsvp']) ) ? 1:0;
153
+ $this->seats = ( !empty($_POST['event_seats']) && is_numeric($_POST['event_seats']) ) ? $_POST['event_seats']:0;
154
+ $this->notes = ( !empty($_POST['content']) ) ? stripslashes($_POST['content']) : ''; //WP TinyMCE field
155
  //Sort out time
156
  //TODO make time handling less painful
157
  $match = array();
158
+ if( !empty($_POST['event_start_time']) && preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_start_time'], $match ) ){
159
  if( $match[3] == 'PM' && $match[1] != 12 ){
160
  $match[1] = 12+$match[1];
161
  }elseif( $match[3] == 'AM' && $match[1] == 12 ){
165
  }else{
166
  $this->start_time = "00:00:00";
167
  }
168
+ if( !empty($_POST['event_end_time']) && preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_end_time'], $match ) ){
169
  if( $match[3] == 'PM' && $match[1] != 12 ){
170
  $match[1] = 12+$match[1];
171
  }elseif( $match[3] == 'AM' && $match[1] == 12 ){
175
  }else{
176
  $this->end_time = $this->start_time;
177
  }
178
+ //Start/End times should be available as timestamp
179
+ $this->start = strtotime($this->start_date." ".$this->start_time);
180
+ $this->end = strtotime($this->end_date." ".$this->end_time);
181
  //Contact Person
182
+ if ( !empty($_POST['event_contactperson_id']) && is_numeric($_POST['event_contactperson_id']) ) {
183
  //TODO contactperson choices needs limiting depending on role
184
+ $this->contactperson_id = $_POST['event_contactperson_id'];
185
  }
186
  //category
187
+ if( !empty($_POST['event_category_id']) && is_numeric($_POST['event_category_id']) ){
188
+ $this->category_id = $_POST['event_category_id'];
189
  }
190
  //Attributes
191
  $event_attributes = array();
192
+ for($i=1 ; !empty($_POST["mtm_{$i}_ref"]) && trim($_POST["mtm_{$i}_ref"]) != '' ; $i++ ){
193
+ if( !empty($_POST["mtm_{$i}_name"]) && trim($_POST["mtm_{$i}_name"]) != '' ){
194
  $event_attributes[$_POST["mtm_{$i}_ref"]] = stripslashes($_POST["mtm_{$i}_name"]);
195
  }
196
  }
197
  $this->attributes = $event_attributes;
198
  //Recurrence data
199
+ $this->recurrence_id = ( !empty($_POST['recurrence_id']) && is_numeric($_POST['recurrence_id']) ) ? $_POST['recurrence_id'] : 0 ;
200
+ if( !empty($_POST['repeated_event']) ){
201
  $this->recurrence = 1;
202
+ $this->freq = ( !empty($_POST['recurrence_freq']) && in_array($_POST['recurrence_freq'], array('daily','weekly','monthly')) ) ? $_POST['recurrence_freq']:'daily';
203
+ if( !empty($_POST['recurrence_bydays']) && $this->freq == 'weekly' && self::array_is_numeric($_POST['recurrence_bydays']) ){
204
+ $this->byday = implode ( ",", $_POST['recurrence_bydays'] );
205
+ }elseif( !empty($_POST['recurrence_byday']) && $this->freq == 'monthly' ){
206
+ $this->byday = $_POST['recurrence_byday'];
207
  }
208
+ $this->interval = ( !empty($_POST['recurrence_interval']) ) ? $_POST['recurrence_interval']:1;
209
+ $this->byweekno = ( !empty($_POST['recurrence_byweekno']) ) ? $_POST['recurrence_byweekno']:'';
210
  }
211
 
212
  //Add location information, or just link to previous location, this is a requirement...
213
+ if( !empty($_POST['location-select-id']) ) {
214
  $this->location = new EM_Location($_POST['location-select-id']);
215
  } else {
216
  $this->location = new EM_Location($_POST);
217
  $this->location->load_similar($_POST);
218
  }
219
+ return apply_filters('em_event_get_post', $this->validate(), $this);
220
  }
221
 
222
  /**
227
  function save(){
228
  //FIXME Event doesn't save title when inserting first time
229
  global $wpdb, $current_user;
230
+ do_action('em_event_save_pre', $this);
231
+ get_currentuserinfo();
232
  $events_table = $wpdb->prefix.EM_EVENTS_TABLE;
233
  //First let's save the location, no location no event!
234
  if ( !$this->location->id && !$this->location->save() ){ //shouldn't try to save if location exists
235
  $this->errors[] = __ ( 'There was a problem saving the location so event was not saved.', 'dbem' );
236
+ return apply_filters('em_event_save', false, $this);
237
  }
238
  $this->location_id = $this->location->id;
239
  //TODO make contactperson_id NULL if not used
255
  $this->errors[] = __ ( 'Something went wrong with the recurrence update...', 'dbem' ).
256
  __ ( 'There was a problem saving the recurring events.', 'dbem' );
257
  $this->delete();
258
+ return apply_filters('em_event_save', false, $this);
259
  }
260
  //All good! Event Saved
261
  $this->feedback_message = __ ( 'New recurrent event inserted!', 'dbem' );
262
+ return apply_filters('em_event_save', true, $this);
263
  }
264
  //Successful individual save
265
  $this->feedback_message = __ ( 'New event successfully inserted!', 'dbem' );
266
+ return apply_filters('em_event_save', true, $this);
267
  }else{
268
  $this->errors[] = __ ( 'Could not save the event details due to a database error.', 'dbem' );
269
  }
282
  if( !$this->save_events() ){
283
  $this->errors[] = __ ( 'Something went wrong with the recurrence update...', 'dbem' ).
284
  __ ( 'There was a problem saving the recurring events.', 'dbem' );
285
+ return apply_filters('em_event_save', false, $this);
286
  }
287
  $this->feedback_message = __ ( 'Recurrence updated!', 'dbem' );
288
+ return apply_filters('em_event_save', true, $this);
289
  }
290
  }else{
291
  $this->errors[] = __('Could not save the event details due to a database error.', 'dbem');
292
+ return apply_filters('em_event_save', false, $this);
293
  }
294
  //Successful individual or recurrence save
295
  $this->feedback_message = "'{$this->name}' " . __ ( 'updated', 'dbem' ) . "!";
296
  if($this->rsvp == 0){
297
  $this->delete_bookings();
298
  }
299
+ return apply_filters('em_event_save', true, $this);
300
  }
301
  }
302
 
303
  /**
304
  * Delete whole event, including recurrence and recurring data
305
  * @param $recurrence_id
306
+ * @return boolean
307
  */
308
  function delete(){
309
  global $wpdb;
310
+ //TODO when only php5, no need to pass by reference
311
+ do_action('em_event_delete_pre', $this);
312
  if( $this->is_recurring() ){
313
  //Delete the recurrences then this recurrence event
314
  $this->delete_events();
315
  }
316
  $result = $wpdb->query ( $wpdb->prepare("DELETE FROM ". $wpdb->prefix . EM_EVENTS_TABLE ." WHERE event_id=%d", $this->id) );
317
  if($result !== false){
318
+ $result = $this->get_bookings()->delete();
319
  }
320
+ return apply_filters('em_event_delete', $result, $this);
321
  }
322
 
323
  /**
335
  //Get the ID of the new item
336
  $event_ID = $wpdb->insert_id;
337
  $EM_Event = new EM_Event( $event_ID );
338
+ return apply_filters('em_event_duplicate', $EM_Event, $this);
339
  }else{
340
  //TODO add error notifications for duplication failures.
341
+ return apply_filters('em_event_duplicate', false, $this);;
342
  }
343
  }
344
 
359
  // TODO Create friendly equivelant names for missing fields notice in validation
360
  $this->errors[] = __ ( 'Missing fields: ' ) . implode ( ", ", $missing_fields ) . ". ";
361
  }
362
+ if ( !empty($_POST['repeated_event']) && $_POST['repeated_event'] == "1" && $this->end_date == "" ){
363
  $this->errors[] = __ ( 'Since the event is repeated, you must specify an event date.', 'dbem' );
364
  }
365
  if( !$this->location->validate() ){
366
  $this->errors = array_merge($this->errors, $this->location->errors);
367
  }
368
  //TODO validate recurrence during event validate
369
+ return apply_filters('em_event_validate', count($this->errors) == 0, $this );
370
  }
371
 
372
 
378
  global $wpdb;
379
  $sql = "SELECT category_id, category_name FROM ".$wpdb->prefix.EM_EVENTS_TABLE." LEFT JOIN ".$wpdb->prefix.EM_CATEGORIES_TABLE." ON category_id=event_category_id WHERE event_id ='".$this->id."'";
380
  $category = $wpdb->get_row($sql, ARRAY_A);
381
+ return apply_filters('em_event_get_category', $category, $this);
382
  }
383
 
384
  /**
386
  */
387
  function delete_bookings(){
388
  global $wpdb;
389
+ do_action('em_event_delete_bookings_pre', $this);
390
+ $result = $wpdb->query( $wpdb->prepare("DELETE FROM ".$wpdb->prefix.EM_BOOKINGS_TABLE." WHERE event_id=%d", $this->id) );
391
+ return apply_filters('em_event_delete_bookings', $result, $this);
392
  }
393
 
394
  /**
402
  $this->bookings = new EM_Bookings($this);
403
  }
404
  }
405
+ return apply_filters('em_event_get_bookings', $this->bookings, $this);
406
  }
407
 
408
  /**
413
  */
414
  function output_single($target='html'){
415
  $format = get_option ( 'dbem_single_event_format' );
416
+ return apply_filters('em_event_output_single', $this->output($format, $target), $this, $target);
417
  }
418
 
419
  /**
424
  */
425
  function output_list($target='html'){
426
  $format = get_option ( 'dbem_event_list_item_format' );
427
+ return apply_filters('em_event_output_list', $this->output($format, $target), $this, $target);
428
  }
429
 
430
  /**
484
  case '#_EDITEVENTLINK':
485
  if(is_user_logged_in()){
486
  //TODO user should have permission to edit the event
487
+ $replace = "<a href=' ".get_bloginfo('wpurl')."/wp-admin/edit.php?page=events-manager/events-manager.php&amp;action=edit_event&amp;event_id=".$this->id."'>".__('Edit').' '.__('Event', 'dbem')."</a>";
488
  }
489
  break;
490
  //Bookings
526
  break;
527
  case '#_CONTACTEMAIL':
528
  case '#_CONTACTMAIL': //Depreciated
529
+ $replace = em_ascii_encode($this->contact->user_email);
530
  break;
531
  case '#_CONTACTPHONE':
532
  $replace = ( $this->contact->phone != '') ? $this->contact->phone : __('N/A', 'dbem');
537
  }
538
  if($match){ //if true, we've got a placeholder that needs replacing
539
  //TODO FILTER - placeholder filter
540
+ $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
541
  $event_string = str_replace($result, $replace , $event_string );
542
  }
543
  }
545
  foreach($placeholders[0] as $result) {
546
  // matches all PHP START date and time placeholders
547
  if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
548
+ $replace = date(ltrim($result, "#"), $this->start);
549
+ $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
550
+ $event_string = str_replace($result, $replace, $event_string );
551
  }
552
  // matches all PHP END time placeholders for endtime
553
  if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
554
+ $replace = date(ltrim($result, "#@"), $this->end);
555
+ $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
556
+ $event_string = str_replace($result, $replace, $event_string );
557
+ }
558
  }
559
  //Time place holder that doesn't show if empty.
560
  preg_match_all('/#@?_\{[A-Za-z0-9 -\/,\.\\\]+\}/', $format, $results);
577
  foreach($results[0] as $resultKey => $result) {
578
  //Strip string of placeholder and just leave the reference
579
  $attRef = substr( substr($result, 0, strpos($result, '}')), 6 );
580
+ if( array_key_exists($attRef, $this->attributes) ){
581
+ $attString = $this->attributes[$attRef];
582
+ if( trim($attString) == '' && $results[1][$resultKey] != '' ){
583
+ //Check to see if we have a second set of braces;
584
+ $attString = substr( $results[1][$resultKey], 1, strlen(trim($results[1][$resultKey]))-2 );
585
+ }
586
  }
587
  $event_string = str_replace($result, $attString ,$event_string );
588
  }
589
 
590
  //Now do dependent objects
591
  $event_string = $this->location->output($event_string, $target);
592
+ return apply_filters('em_event_output', $event_string, $this, $target);
593
  }
594
 
595
  /**********************************************************
602
  */
603
  function save_events() {
604
  if( $this->is_recurring() ){
605
+ do_action('em_event_save_events_pre', $this); //actions/filters only run if event is recurring
606
  global $wpdb;
607
  $event_saves = array();
608
  $matching_days = $this->get_recurrence_days(); //Get days where events recur
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 apply_filters('em_event_save_events', !in_array(false, $event_saves), $this);
629
  }
630
  return false;
631
  }
637
  */
638
  function delete_events(){
639
  global $wpdb;
640
+ do_action('em_event_delete_events_pre', $this);
641
  //So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer
642
  $EM_Events = EM_Events::get( array('recurrence_id'=>$this->id) );
643
  $event_ids = array();
683
  if( $this->is_recurring() ){
684
 
685
  $start_date = strtotime($this->start_date);
686
+ $end_date = strtotime($this->end_date);
687
 
688
  $weekdays = explode(",", $this->byday); //what days of the week (or if monthly, one value at index 0)
689
 
793
  $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'));
794
  $output = sprintf (__('From %1$s to %2$s', 'dbem'), $recurrence['event_start_date'], $recurrence['event_end_date']).", ";
795
  if ($recurrence['recurrence_freq'] == 'daily') {
 
796
  $freq_desc =__('everyday', 'dbem');
797
  if ($recurrence['recurrence_interval'] > 1 ) {
798
  $freq_desc = sprintf (__("every %s days", 'dbem'), $recurrence['recurrence_interval']);
801
  if ($recurrence['recurrence_freq'] == 'weekly') {
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
+ }
807
  $output .= implode(" and ", $natural_days);
808
+ $freq_desc = ", " . __("every week", 'dbem');
809
  if ($recurrence['recurrence_interval'] > 1 ) {
810
  $freq_desc = ", ".sprintf (__("every %s weeks", 'dbem'), $recurrence['recurrence_interval']);
811
  }
812
 
813
  }
814
  if ($recurrence['recurrence_freq'] == 'monthly') {
815
+ $weekday_array = explode(",", $recurrence['recurrence_byday']);
816
+ $natural_days = array();
817
+ foreach($weekday_array as $day){
818
+ array_push($natural_days, $weekdays_name[$day]);
819
+ }
820
+ $freq_desc = sprintf (($monthweek_name[$recurrence['recurrence_byweekno']]), implode(" and ", $natural_days));
821
  if ($recurrence['recurrence_interval'] > 1 ) {
822
  $freq_desc .= ", ".sprintf (__("every %s months",'dbem'), $recurrence['recurrence_interval']);
823
  }
858
  //TODO placeholder targets filtering could be streamlined better
859
  /**
860
  * This is a temporary filter function which mimicks the old filters in the old 2.x placeholders function
861
+ * @param string $result
862
+ * @param EM_Event $event
863
+ * @param string $placeholder
864
+ * @param string $target
865
  * @return mixed
866
  */
867
+ function em_event_output_placeholder($result,$event,$placeholder,$target='html'){
868
  if( ($placeholder == "#_EXCERPT" || $placeholder == "#_LOCATIONEXCERPT") && $target == 'html' ){
869
+ $result = apply_filters('dbem_notes_excerpt', $result);
870
  }elseif( $placeholder == "#_NOTES" || $placeholder == "#_EXCERPT" || $placeholder == "#_LOCATIONEXCERPT" ){
871
  if($target == 'html'){
872
+ $result = apply_filters('dbem_notes', $result);
873
  }elseif($target == 'map'){
874
+ $result = apply_filters('dbem_notes_map', $result);
875
  }else{
876
+ $result = apply_filters('dbem_notes_rss', $result);
877
+ $result = apply_filters('the_content_rss', $result);
878
  }
879
  }elseif( in_array($placeholder, array("#_NAME",'#_ADDRESS','#_LOCATION','#_TOWN')) ){
880
  if ($target == "html"){
881
+ $result = apply_filters('dbem_general', $result);
882
  }else{
883
+ $result = apply_filters('dbem_general_rss', $result);
884
  }
885
  }
886
+ return $result;
887
  }
888
+ add_filter('em_event_output_placeholder','em_event_output_placeholder',1,3);
889
  ?>
classes/{events.php → em-events.php} RENAMED
@@ -26,7 +26,7 @@ class EM_Events extends EM_Object {
26
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
27
  WHERE event_id=".implode(" OR event_id=", $args)."
28
  ";
29
- $results = $wpdb->get_results($sql);
30
  $events = array();
31
  foreach($results as $result){
32
  $events[$result['event_id']] = new EM_Event($result);
@@ -60,7 +60,7 @@ class EM_Events extends EM_Object {
60
  $limit $offset
61
  ";
62
 
63
- $results = $wpdb->get_results($sql, ARRAY_A);
64
 
65
  //If we want results directly in an array, why not have a shortcut here?
66
  if( $args['array'] == true ){
@@ -74,7 +74,7 @@ class EM_Events extends EM_Object {
74
  $events[] = new EM_Event($event);
75
  }
76
 
77
- return $events;
78
  }
79
 
80
  /**
@@ -86,7 +86,7 @@ class EM_Events extends EM_Object {
86
  global $wpdb;
87
  $table_name = $wpdb->prefix . EM_EVENTS_TABLE;
88
  $sql = "SELECT COUNT(*) FROM $table_name WHERE (event_start_date like '$date') OR (event_start_date <= '$date' AND event_end_date >= '$date');";
89
- return $wpdb->get_var ( $sql );
90
  }
91
 
92
  /**
@@ -105,20 +105,24 @@ class EM_Events extends EM_Object {
105
  $event_ids = $array;
106
  }
107
  if(self::array_is_numeric($event_ids)){
 
108
  $condition = implode(" OR event_id=", $event_ids);
109
  //Delete all the bookings
110
  $result_bookings = $wpdb->query("DELETE FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." WHERE event_id=$condition;");
111
  //Now delete the events
112
  $result = $wpdb->query ( "DELETE FROM ". $wpdb->prefix . EM_EVENTS_TABLE ." WHERE event_id=$condition;" );
 
113
  }
114
- return true;
 
115
  }
116
 
117
 
118
  /**
119
- * Output a set of matched of events
120
- * Note that you can pass a 'pagination' boolean attribute to enable pagination, default is enabled (true)
121
  * @param array $args
 
122
  * @return string
123
  */
124
  function output( $args ){
@@ -126,25 +130,33 @@ class EM_Events extends EM_Object {
126
  $EM_Event_old = $EM_Event; //When looping, we can replace EM_Event global with the current event in the loop
127
  //Can be either an array for the get search or an array of EM_Event objects
128
  if( is_object(current($args)) && get_class((current($args))) == 'EM_Event' ){
129
- $events = $args;
 
 
 
 
 
130
  }else{
131
  //Firstly, let's check for a limit/offset here, because if there is we need to remove it and manually do this
 
132
  $limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
133
  $offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:false;
134
  $args['limit'] = false;
135
- $args['offset'] = false;
136
  $events = self::get( $args );
137
  }
138
  //What format shall we output this to, or use default
139
- $format = ( $args['format'] == '') ? get_option( 'dbem_event_list_item_format' ) : $args['format'] ;
140
 
141
  $output = "";
142
  $events_count = count($events);
 
 
143
  if ( $events_count > 0 ) {
144
  $event_count = 0;
145
  $events_shown = 0;
146
  foreach ( $events as $EM_Event ) {
147
- if( $events_shown < $limit && ($event_count >= $offset || $offset === 0) ){
148
  $output .= $EM_Event->output($format);
149
  $events_shown++;
150
  }
@@ -156,27 +168,42 @@ class EM_Events extends EM_Object {
156
  $single_event_format_header = ( $single_event_format_header != '' ) ? $single_event_format_header : "<ul class='dbem_events_list'>";
157
  $single_event_format_footer = get_option ( 'dbem_event_list_item_format_footer' );
158
  $single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
159
- $output = $single_event_format_header . $output . $single_event_format_footer;
160
  }
161
  //Pagination (if needed/requested)
162
- if( (!empty($args['pagination']) && $args['pagination'] !== false || empty($args['pagination'])) && $events_count >= $limit ){
163
  //Calculate the page number by offset/limit
164
- $page = ($offset > 0) ? floor($offset/$limit)+1 : 1;
165
  //Show the pagination links (unless there's less than 10 events
166
- $event_page_link = get_permalink(get_option('dbem_events_page'));
167
- $output .= em_paginate(em_add_get_params($event_page_link, array_merge($_GET, array('page'=>'%PAGE%'))), $events_count, $limit, $page);
 
168
  }
169
  } else {
170
  $output = get_option ( 'dbem_no_events_message' );
171
  }
172
  //TODO check if reference is ok when restoring object, due to changes in php5 v 4
173
  $EM_Event = $EM_Event_old;
174
- return $output;
175
  }
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  /*
178
  * Adds custom Events search defaults
179
- * @param array $args
180
  * @return array
181
  * @uses EM_Object#get_default_search()
182
  */
@@ -185,7 +212,7 @@ class EM_Events extends EM_Object {
185
  'orderby' => get_option('dbem_events_default_orderby'),
186
  'order' => get_option('dbem_events_default_order')
187
  );
188
- return parent::get_default_search($defaults,$array);
189
  }
190
  }
191
  ?>
26
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
27
  WHERE event_id=".implode(" OR event_id=", $args)."
28
  ";
29
+ $results = $wpdb->get_results(apply_filters('em_events_get_sql',$sql));
30
  $events = array();
31
  foreach($results as $result){
32
  $events[$result['event_id']] = new EM_Event($result);
60
  $limit $offset
61
  ";
62
 
63
+ $results = $wpdb->get_results( apply_filters('em_events_get_sql',$sql, $args), ARRAY_A);
64
 
65
  //If we want results directly in an array, why not have a shortcut here?
66
  if( $args['array'] == true ){
74
  $events[] = new EM_Event($event);
75
  }
76
 
77
+ return apply_filters('em_events_get', $events);
78
  }
79
 
80
  /**
86
  global $wpdb;
87
  $table_name = $wpdb->prefix . EM_EVENTS_TABLE;
88
  $sql = "SELECT COUNT(*) FROM $table_name WHERE (event_start_date like '$date') OR (event_start_date <= '$date' AND event_end_date >= '$date');";
89
+ return apply_filters('em_events_count_date', $wpdb->get_var($sql));
90
  }
91
 
92
  /**
105
  $event_ids = $array;
106
  }
107
  if(self::array_is_numeric($event_ids)){
108
+ apply_filters('em_events_delete', $event_ids);
109
  $condition = implode(" OR event_id=", $event_ids);
110
  //Delete all the bookings
111
  $result_bookings = $wpdb->query("DELETE FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." WHERE event_id=$condition;");
112
  //Now delete the events
113
  $result = $wpdb->query ( "DELETE FROM ". $wpdb->prefix . EM_EVENTS_TABLE ." WHERE event_id=$condition;" );
114
+ do_action('em_events_delete', $event_ids);
115
  }
116
+ //TODO add error detection on events delete fails
117
+ return apply_filters('em_events_delete', true, $event_ids);
118
  }
119
 
120
 
121
  /**
122
+ * Output a set of matched of events. You can pass on an array of EM_Events as well, in this event you can pass args in second param.
123
+ * Note that you can pass a 'pagination' boolean attribute to enable pagination, default is enabled (true).
124
  * @param array $args
125
+ * @param array $secondary_args
126
  * @return string
127
  */
128
  function output( $args ){
130
  $EM_Event_old = $EM_Event; //When looping, we can replace EM_Event global with the current event in the loop
131
  //Can be either an array for the get search or an array of EM_Event objects
132
  if( is_object(current($args)) && get_class((current($args))) == 'EM_Event' ){
133
+ $func_args = func_get_args();
134
+ $events = $func_args[0];
135
+ $args = $func_args[1];
136
+ $args = apply_filters('em_events_output_args', $args, $events);
137
+ $limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
138
+ $offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:false;
139
  }else{
140
  //Firstly, let's check for a limit/offset here, because if there is we need to remove it and manually do this
141
+ $args = apply_filters('em_events_output_args', $args);
142
  $limit = ( !empty($args['limit']) && is_numeric($args['limit']) ) ? $args['limit']:false;
143
  $offset = ( !empty($args['offset']) && is_numeric($args['offset']) ) ? $args['offset']:false;
144
  $args['limit'] = false;
145
+ $args['offset'] = false;
146
  $events = self::get( $args );
147
  }
148
  //What format shall we output this to, or use default
149
+ $format = ( empty($args['format']) ) ? get_option( 'dbem_event_list_item_format' ) : $args['format'] ;
150
 
151
  $output = "";
152
  $events_count = count($events);
153
+ $events = apply_filters('em_events_output_events', $events);
154
+
155
  if ( $events_count > 0 ) {
156
  $event_count = 0;
157
  $events_shown = 0;
158
  foreach ( $events as $EM_Event ) {
159
+ if( ($events_shown < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ){
160
  $output .= $EM_Event->output($format);
161
  $events_shown++;
162
  }
168
  $single_event_format_header = ( $single_event_format_header != '' ) ? $single_event_format_header : "<ul class='dbem_events_list'>";
169
  $single_event_format_footer = get_option ( 'dbem_event_list_item_format_footer' );
170
  $single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
171
+ $output = $single_event_format_header . $output . $single_event_format_footer;
172
  }
173
  //Pagination (if needed/requested)
174
+ if( !empty($args['pagination']) && !empty($limit) && $events_count >= $limit ){
175
  //Calculate the page number by offset/limit
176
+ $page = ($offset > 0) ? floor($offset/$limit)+1:1;
177
  //Show the pagination links (unless there's less than 10 events
178
+ $page_link_template = preg_replace('/(&|\?)page=\d+/i','',$_SERVER['REQUEST_URI']);
179
+ $page_link_template = em_add_get_params($page_link_template, array('page'=>'%PAGE%'));
180
+ $output .= apply_filters('em_events_output_pagination', em_paginate( $page_link_template, $events_count, $limit, $page), $page_link_template, $events_count, $limit, $page);
181
  }
182
  } else {
183
  $output = get_option ( 'dbem_no_events_message' );
184
  }
185
  //TODO check if reference is ok when restoring object, due to changes in php5 v 4
186
  $EM_Event = $EM_Event_old;
187
+ return apply_filters('em_events_output', $output, $events, $args);
188
  }
189
 
190
+ /* Overrides EM_Object method to apply a filter to result
191
+ * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
192
+ */
193
+ function build_sql_conditions( $args = array() ){
194
+ return apply_filters( 'em_events_build_sql_conditions', parent::build_sql_conditions($args), $args );
195
+ }
196
+
197
+ /* Overrides EM_Object method to apply a filter to result
198
+ * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
199
+ */
200
+ function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
201
+ return apply_filters( 'em_events_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order')), $args, $accepted_fields, $default_order );
202
+ }
203
+
204
  /*
205
  * Adds custom Events search defaults
206
+ * @param array $array
207
  * @return array
208
  * @uses EM_Object#get_default_search()
209
  */
212
  'orderby' => get_option('dbem_events_default_orderby'),
213
  'order' => get_option('dbem_events_default_order')
214
  );
215
+ return apply_filters('em_events_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
216
  }
217
  }
218
  ?>
classes/{location.php → em-location.php} RENAMED
@@ -60,19 +60,21 @@ class EM_Location extends EM_Object {
60
 
61
  function get_post(){
62
  //We are getting the values via POST or GET
 
63
  $location = array();
64
- $location['location_id'] = $_POST['location_id'];
65
- $location['location_name'] = stripslashes($_POST['location_name']);
66
- $location['location_address'] = stripslashes($_POST['location_address']);
67
- $location['location_town'] = stripslashes($_POST['location_town']);
68
- $location['location_latitude'] = $_POST['location_latitude'];
69
- $location['location_longitude'] = $_POST['location_longitude'];
70
- $location['location_description'] = stripslashes($_POST['content']);
71
- $this->to_object($location);
72
  }
73
 
74
  function save(){
75
  global $wpdb;
 
76
  $table = $wpdb->prefix.EM_LOCATIONS_TABLE;
77
  $data = $this->to_array();
78
  unset($data['location_id']);
@@ -85,15 +87,17 @@ class EM_Location extends EM_Object {
85
  $this->id = $wpdb->insert_id;
86
  }
87
  $image_upload = $this->image_upload();
88
- return ( $this->id > 0 && $image_upload );
89
  }
90
 
91
  function delete(){
92
  global $wpdb;
 
93
  $table_name = $wpdb->prefix.EM_LOCATIONS_TABLE;
94
  $sql = "DELETE FROM $table_name WHERE location_id = '{$this->id}';";
95
- $wpdb->query($sql);
96
- $this->image_delete();
 
97
  }
98
 
99
  function get_image_url(){
@@ -106,19 +110,23 @@ class EM_Location extends EM_Object {
106
  }
107
  }
108
  }
109
- return $this->image_url;
110
  }
111
 
112
  function image_delete() {
113
  $file_name= ABSPATH.EM_IMAGE_UPLOAD_DIR."/location-".$this->id;
 
114
  foreach($this->mime_types as $type) {
115
  if (file_exists($file_name.".".$type))
116
- unlink($file_name.".".$type);
117
  }
 
118
  }
119
 
120
  function image_upload(){
121
  //TODO better image upload error handling
 
 
122
  if ($_FILES['location_image']['size'] > 0 ) {
123
  if( !file_exists(ABSPATH.EM_IMAGE_UPLOAD_DIR) ){
124
  mkdir(ABSPATH.EM_IMAGE_UPLOAD_DIR, 0777);
@@ -128,12 +136,12 @@ class EM_Location extends EM_Object {
128
  $image_path = ABSPATH.EM_IMAGE_UPLOAD_DIR."/location-".$this->id.".".$this->mime_types[$type];
129
  if (!move_uploaded_file($_FILES['location_image']['tmp_name'], $image_path)){
130
  $this->errors = __('The image could not be loaded','dbem');
131
- return false;
132
  }else{
133
- return true;
134
  }
135
  }
136
- return true;
137
  }
138
 
139
  function load_similar($criteria){
@@ -145,7 +153,7 @@ class EM_Location extends EM_Object {
145
  if( is_array($location) ){
146
  $this->to_object($location);
147
  }
148
- return $location;
149
  }
150
 
151
  /**
@@ -158,7 +166,7 @@ class EM_Location extends EM_Object {
158
  $this->errors[] = $description.__(" is missing!", "dbem");
159
  }
160
  }
161
- if ($_FILES['location_image']['size'] > 0 ) {
162
  if (is_uploaded_file($_FILES['location_image']['tmp_name'])) {
163
  $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
164
  $maximum_size = get_option('dbem_image_max_size');
@@ -176,7 +184,7 @@ class EM_Location extends EM_Object {
176
  }
177
  }
178
  }
179
- return ( count($this->errors) == 0 );
180
  }
181
 
182
  function has_events(){
@@ -184,12 +192,12 @@ class EM_Location extends EM_Object {
184
  $events_table = $wpdb->prefix.EM_EVENTS_TABLE;
185
  $sql = "SELECT event_id FROM $events_table WHERE location_id = {$this->id}";
186
  $affected_events = $wpdb->get_results($sql);
187
- return (count($affected_events) > 0);
188
  }
189
 
190
  function output_single($target = 'html'){
191
  $format = get_option ( 'dbem_single_location_format' );
192
- return $this->output($format, $target);
193
  }
194
 
195
  function output($format, $target="html") {
@@ -262,12 +270,12 @@ class EM_Location extends EM_Object {
262
  }
263
  if($match){ //if true, we've got a placeholder that needs replacing
264
  //TODO FILTER - placeholder filter
265
- $replace = apply_filters('em_placeholder', $replace, $result, $target); //USE WITH CAUTION! THIS MIGHT GET RENAMED
266
  $location_string = str_replace($result, $replace , $location_string );
267
  }
268
  }
269
- $name_filter = ($target == "html") ? 'dbem_general':'dbem_general_rss';
270
  $location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name) , $location_string ); //Depreciated
271
- return $location_string;
272
  }
273
  }
60
 
61
  function get_post(){
62
  //We are getting the values via POST or GET
63
+ do_action('em_location_get_post_pre', $this);
64
  $location = array();
65
+ $location['location_id'] = ( !empty($_POST['location_id']) ) ? $_POST['location_id']:'';
66
+ $location['location_name'] = ( !empty($_POST['location_name']) ) ? stripslashes($_POST['location_name']):'';
67
+ $location['location_address'] = ( !empty($_POST['location_address']) ) ? stripslashes($_POST['location_address']):'';
68
+ $location['location_town'] = ( !empty($_POST['location_town']) ) ? stripslashes($_POST['location_town']):'';
69
+ $location['location_latitude'] = ( !empty($_POST['location_latitude']) ) ? $_POST['location_latitude']:'';
70
+ $location['location_longitude'] = ( !empty($_POST['location_longitude']) ) ? $_POST['location_longitude']:'';
71
+ $location['location_description'] = ( !empty($_POST['content']) ) ? stripslashes($_POST['content']):'';
72
+ $this->to_object( apply_filters('em_location_get_post', $location, $this) );
73
  }
74
 
75
  function save(){
76
  global $wpdb;
77
+ do_action('em_location_save_pre', $this);
78
  $table = $wpdb->prefix.EM_LOCATIONS_TABLE;
79
  $data = $this->to_array();
80
  unset($data['location_id']);
87
  $this->id = $wpdb->insert_id;
88
  }
89
  $image_upload = $this->image_upload();
90
+ return apply_filters('em_location_save', ( $this->id > 0 && $image_upload ), $this, $image_upload);
91
  }
92
 
93
  function delete(){
94
  global $wpdb;
95
+ do_action('em_location_delete_pre', $this);
96
  $table_name = $wpdb->prefix.EM_LOCATIONS_TABLE;
97
  $sql = "DELETE FROM $table_name WHERE location_id = '{$this->id}';";
98
+ $result = $wpdb->query($sql);
99
+ $result = $this->image_delete() && $result;
100
+ return apply_filters('em_location_delete', $result, $this);
101
  }
102
 
103
  function get_image_url(){
110
  }
111
  }
112
  }
113
+ return apply_filters('em_location_get_image_url', $this->image_url, $this);
114
  }
115
 
116
  function image_delete() {
117
  $file_name= ABSPATH.EM_IMAGE_UPLOAD_DIR."/location-".$this->id;
118
+ $result = false;
119
  foreach($this->mime_types as $type) {
120
  if (file_exists($file_name.".".$type))
121
+ $result = unlink($file_name.".".$type);
122
  }
123
+ return apply_filters('em_location_image_delete', $result, $this);
124
  }
125
 
126
  function image_upload(){
127
  //TODO better image upload error handling
128
+ do_action('em_location_image_upload_pre', $this);
129
+ $result = true;
130
  if ($_FILES['location_image']['size'] > 0 ) {
131
  if( !file_exists(ABSPATH.EM_IMAGE_UPLOAD_DIR) ){
132
  mkdir(ABSPATH.EM_IMAGE_UPLOAD_DIR, 0777);
136
  $image_path = ABSPATH.EM_IMAGE_UPLOAD_DIR."/location-".$this->id.".".$this->mime_types[$type];
137
  if (!move_uploaded_file($_FILES['location_image']['tmp_name'], $image_path)){
138
  $this->errors = __('The image could not be loaded','dbem');
139
+ $result = false;
140
  }else{
141
+ $result = true;
142
  }
143
  }
144
+ return apply_filters('em_location_image_upload', $result, $this);
145
  }
146
 
147
  function load_similar($criteria){
153
  if( is_array($location) ){
154
  $this->to_object($location);
155
  }
156
+ return apply_filters('em_location_load_similar', $location, $this);
157
  }
158
 
159
  /**
166
  $this->errors[] = $description.__(" is missing!", "dbem");
167
  }
168
  }
169
+ if ( !empty($_FILES['location_image']) && $_FILES['location_image']['size'] > 0 ) {
170
  if (is_uploaded_file($_FILES['location_image']['tmp_name'])) {
171
  $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
172
  $maximum_size = get_option('dbem_image_max_size');
184
  }
185
  }
186
  }
187
+ return apply_filters('em_location_validate', ( count($this->errors) == 0 ), $this);
188
  }
189
 
190
  function has_events(){
192
  $events_table = $wpdb->prefix.EM_EVENTS_TABLE;
193
  $sql = "SELECT event_id FROM $events_table WHERE location_id = {$this->id}";
194
  $affected_events = $wpdb->get_results($sql);
195
+ return apply_filters('em_location_has_events', (count($affected_events) > 0), $this);
196
  }
197
 
198
  function output_single($target = 'html'){
199
  $format = get_option ( 'dbem_single_location_format' );
200
+ return apply_filters('em_location_output_single', $this->output($format, $target), $this, $target);
201
  }
202
 
203
  function output($format, $target="html") {
270
  }
271
  if($match){ //if true, we've got a placeholder that needs replacing
272
  //TODO FILTER - placeholder filter
273
+ $replace = apply_filters('em_location_output_placeholder', $replace, $this, $result, $target); //USE WITH CAUTION! THIS MIGHT GET RENAMED
274
  $location_string = str_replace($result, $replace , $location_string );
275
  }
276
  }
277
+ $name_filter = ($target == "html") ? 'dbem_general':'dbem_general_rss'; //TODO remove dbem_ filters
278
  $location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name) , $location_string ); //Depreciated
279
+ return apply_filters('em_location_output', $location_string, $this, $format, $target);
280
  }
281
  }
classes/{locations.php → em-locations.php} RENAMED
@@ -72,7 +72,7 @@ class EM_Locations extends EM_Object {
72
  foreach ($results as $location){
73
  $locations[] = new EM_Location($location);
74
  }
75
- return $locations;
76
  }
77
 
78
  /**
@@ -107,12 +107,13 @@ class EM_Locations extends EM_Object {
107
  $single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
108
  $output = $single_event_format_header . $output . $single_event_format_footer;
109
  }
 
110
  } else {
111
  $output = get_option ( 'dbem_no_events_message' );
112
  }
113
  //FIXME check if reference is ok when restoring object, due to changes in php5 v 4
114
  $EM_Location_old= $EM_Location;
115
- return $output;
116
  }
117
 
118
  /**
@@ -128,27 +129,34 @@ class EM_Locations extends EM_Object {
128
  $conditions = parent::build_sql_conditions($args);
129
  //eventful locations
130
  if( true == $args['eventful'] ){
131
- $conditions[] = "{$events_table}.event_id IS NOT NULL";
132
  }elseif( true == $args['eventless'] ){
133
- $conditions[] = "{$events_table}.event_id IS NULL";
134
  }
135
- return $conditions;
 
 
 
 
 
 
 
136
  }
137
 
138
  /*
139
  * Generate a search arguments array from defalut and user-defined.
140
  * @see wp-content/plugins/events-manager/classes/EM_Object::get_default_search()
141
  */
142
- function get_default_search($args = array()){
143
  $defaults = array(
144
  'eventful' => false, //Locations that have an event (scope will also play a part here
145
  'eventless' => false, //Locations WITHOUT events, eventful takes precedence
146
  'orderby' => 'name',
147
- 'scope' => 'all'
148
  );
149
- $args['eventful'] = ($args['eventful'] == true);
150
- $args['eventless'] = ($args['eventless'] == true);
151
- return parent::get_default_search($defaults, $args);
152
  }
153
  //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.
154
  }
72
  foreach ($results as $location){
73
  $locations[] = new EM_Location($location);
74
  }
75
+ return apply_filters('em_locations_get', $locations, $args);
76
  }
77
 
78
  /**
107
  $single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
108
  $output = $single_event_format_header . $output . $single_event_format_footer;
109
  }
110
+ //TODO pagination for locations
111
  } else {
112
  $output = get_option ( 'dbem_no_events_message' );
113
  }
114
  //FIXME check if reference is ok when restoring object, due to changes in php5 v 4
115
  $EM_Location_old= $EM_Location;
116
+ return apply_filters('em_locations_output', $output, $locations, $args);
117
  }
118
 
119
  /**
129
  $conditions = parent::build_sql_conditions($args);
130
  //eventful locations
131
  if( true == $args['eventful'] ){
132
+ $conditions['eventful'] = "{$events_table}.event_id IS NOT NULL";
133
  }elseif( true == $args['eventless'] ){
134
+ $conditions['eventless'] = "{$events_table}.event_id IS NULL";
135
  }
136
+ return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
137
+ }
138
+
139
+ /* Overrides EM_Object method to apply a filter to result
140
+ * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
141
+ */
142
+ function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
143
+ return apply_filters( 'em_locations_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order')), $args, $accepted_fields, $default_order );
144
  }
145
 
146
  /*
147
  * Generate a search arguments array from defalut and user-defined.
148
  * @see wp-content/plugins/events-manager/classes/EM_Object::get_default_search()
149
  */
150
+ function get_default_search($array = array()){
151
  $defaults = array(
152
  'eventful' => false, //Locations that have an event (scope will also play a part here
153
  'eventless' => false, //Locations WITHOUT events, eventful takes precedence
154
  'orderby' => 'name',
155
+ 'scope' => 'all' //we probably want to search all locations by default, not like events
156
  );
157
+ $array['eventful'] = ( !empty($array['eventful']) && $array['eventful'] == true );
158
+ $array['eventless'] = ( !empty($array['eventless']) && $array['eventless'] == true );
159
+ return apply_filters('em_locations_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults);
160
  }
161
  //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.
162
  }
classes/{mailer.php → em-mailer.php} RENAMED
File without changes
classes/{map.php → em-map.php} RENAMED
@@ -21,9 +21,10 @@ class EM_Map extends EM_Object {
21
  <div class='em-locations-map' id='em-locations-map-<?php echo $rand; ?>' style='width:<?php echo $atts['width']; ?>px; height:<?php echo $atts['height']; ?>px'><em><?php _e('Loading Map....', 'dbem'); ?></em></div>
22
  <div class='em-locations-map-coords' id='em-locations-map-coords-<?php echo $rand; ?>' style="display:none; visibility:hidden;"><?php echo EM_Object::json_encode($atts); ?></div>
23
  <?php
24
- return ob_get_clean();
 
 
25
  }
26
- return '';
27
  }
28
 
29
 
@@ -50,7 +51,10 @@ class EM_Map extends EM_Object {
50
  </div>
51
  <?php
52
  return ob_get_clean();
 
 
 
 
53
  }
54
- return '<i>'. __('Map Unavailable', 'dbem') .'</i>';
55
  }
56
  }
21
  <div class='em-locations-map' id='em-locations-map-<?php echo $rand; ?>' style='width:<?php echo $atts['width']; ?>px; height:<?php echo $atts['height']; ?>px'><em><?php _e('Loading Map....', 'dbem'); ?></em></div>
22
  <div class='em-locations-map-coords' id='em-locations-map-coords-<?php echo $rand; ?>' style="display:none; visibility:hidden;"><?php echo EM_Object::json_encode($atts); ?></div>
23
  <?php
24
+ return apply_filters('em_map_get_global', ob_get_clean());
25
+ }else{
26
+ return '';
27
  }
 
28
  }
29
 
30
 
51
  </div>
52
  <?php
53
  return ob_get_clean();
54
+ }elseif( is_object($location) && $location->latitude == 0 && $location->longitude == 0 ){
55
+ return '<i>'. __('Map Unavailable', 'dbem') .'</i>';
56
+ }else{
57
+ return '';
58
  }
 
59
  }
60
  }
classes/{object.php → em-object.php} RENAMED
@@ -14,6 +14,7 @@ class EM_Object {
14
  * @return array
15
  */
16
  function get_default_search($defaults=array(), $array = array()){
 
17
  //Create minimal defaults array, merge it with supplied defaults array
18
  $super_defaults = array(
19
  'limit' => false,
@@ -28,8 +29,13 @@ class EM_Object {
28
  'recurring'=>false,
29
  'month'=>'',
30
  'year'=>'',
 
31
  'array'=>false
32
  );
 
 
 
 
33
  //TODO decide on search defaults shared across all objects and then validate here
34
  $defaults = array_merge($super_defaults, $defaults);
35
 
@@ -39,7 +45,6 @@ class EM_Object {
39
  if( array_key_exists('category_id', $array) && !array_key_exists('category', $array) ) { $array['category'] = $array['category_id']; }
40
 
41
  if(is_array($array)){
42
- //TODO accept all objects as search options as well as ids (e.g. location vs. location_id, person vs. person_id)
43
  //If there's a location, then remove it and turn it into location_id
44
  if( array_key_exists('location', $array)){
45
  if ( is_numeric($array['location']) ) {
@@ -91,20 +96,22 @@ class EM_Object {
91
  $defaults['year'] = preg_match($year_regex, $defaults['year']) ? $defaults['year']:'';
92
  }
93
  //Order - it's either ASC or DESC, so let's just validate
94
- if( preg_match('/,/', $defaults['order']) ) {
95
  $defaults['order'] = explode(',', $defaults['order']);
96
  }elseif( !in_array($defaults['order'], array('ASC','DESC')) ){
97
  $defaults['order'] = $super_defaults['order'];
98
  }
99
  //ORDER BY, split if an array
100
- if( preg_match('/,/', $defaults['orderby']) ) {
101
  $defaults['orderby'] = explode(',', $defaults['orderby']);
102
  }
103
  //TODO should we clean format of malicious code over here and run everything thorugh this?
104
  $defaults['array'] = ($defaults['array'] == true);
 
105
  $defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
106
  $defaults['recurring'] = ($defaults['recurring'] == true);
107
- return $defaults;
 
108
  }
109
 
110
  /**
@@ -117,25 +124,27 @@ class EM_Object {
117
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
118
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
119
 
 
 
120
  //Format the arguments passed on
121
  $scope = $args['scope'];//undefined variable warnings in ZDE, could just delete this (but dont pls!)
122
  $recurring = $args['recurring'];
123
  $recurrence = $args['recurrence'];
124
  $category = $args['category'];
125
  $location = $args['location'];
126
- $day = $args['day'];
127
  $month = $args['month'];
128
  $year = $args['year'];
129
- $today = date('Y-m-d');
130
  //Create the WHERE statement
131
 
132
  //Recurrences
 
133
  if( $recurring ){
134
- $conditions = array("`recurrence`=1");
135
  }elseif( $recurrence > 0 ){
136
- $conditions = array("`recurrence_id`=$recurrence");
137
  }else{
138
- $conditions = array("(`recurrence`!=1 OR `recurrence` IS NULL)");
139
  }
140
  //Dates - first check 'month', and 'year'
141
  if( !($month=='' && $year=='') ){
@@ -155,7 +164,7 @@ class EM_Object {
155
  }
156
  $date_start = date('Y-m-d', mktime(0,0,0,$date_month_start,1,$date_year_start));
157
  $date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
158
- $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)))";
159
  $search_by_monthyear = true;
160
  }
161
  if( !isset($search_by_monthyear) ){
@@ -165,49 +174,50 @@ class EM_Object {
165
  $dates = explode(',', $scope);
166
  $date_start = $dates[0];
167
  $date_end = $dates[1];
168
- $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)))";
169
  } elseif ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
170
  //Scope can also be a specific date. However, if 'day', 'month', or 'year' are set, that will take precedence
171
- $conditions [] = " ( (event_start_date = CAST('$scope' AS DATE)) OR (event_start_date <= CAST('$scope' AS DATE) AND event_end_date >= CAST('$scope' AS DATE)) )";
172
  } else {
173
  if ($scope == "past"){
174
- $conditions [] = " event_start_date < '$today'";
175
  }elseif ($scope == "today"){
176
- $conditions [] = " ( (event_start_date = CAST('$today' AS DATE)) OR (event_start_date <= CAST('$today' AS DATE) AND event_end_date >= CAST('$today' AS DATE)) )";
177
  }elseif ($scope == "future" || $scope != 'all'){
178
- $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))";
179
  }
180
  }
181
  }
182
 
183
  //Filter by Location - can be object, array, or id
184
  if ( is_numeric($location) && $location > 0 ) { //Location ID takes precedence
185
- $conditions [] = " {$locations_table}.location_id = $location";
186
  }elseif ( self::array_is_numeric($location) ){
187
- $conditions [] = "( {$locations_table}.location_id = " . implode(" OR {$locations_table}.location_id = ", $location) .' )';
188
  }elseif ( is_object($location) && get_class($location)=='EM_Location' ){ //Now we deal with objects
189
- $conditions [] = " {$locations_table}.location_id = $location->id";
190
  }elseif ( is_array($location) && @get_class(current($location)=='EM_Location') ){ //we can accept array of ids or EM_Location objects
191
  foreach($location as $EM_Location){
192
  $location_ids[] = $EM_Location->id;
193
  }
194
- $conditions[] = "( {$locations_table}.location_id=". implode(" {$locations_table}.location_id=", $location_ids) ." )";
195
- }
196
 
197
  //Add conditions for category selection
198
  //Filter by category, can be id or comma seperated ids
199
  //TODO create an exclude category option
200
  if ( $category != '' && is_numeric($category) ){
201
- $conditions [] = " event_category_id = $category";
202
  }elseif( self::array_is_numeric($category) ){
203
- $conditions [] = "( event_category_id = ". implode(' OR event_category_id = ', $category).")";
204
  }
205
 
206
- return $conditions;
207
  }
208
 
209
  function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
210
  //First, ORDER BY
 
211
  $orderby = array();
212
  if(is_array($args['orderby'])){
213
  //Clean orderby array so we only have accepted values
@@ -240,7 +250,7 @@ class EM_Object {
240
  $orderby[$i] .= ( in_array($args['order'], array('ASC','DESC')) ) ? $args['order'] : $default_order;
241
  }
242
  }
243
- return $orderby;
244
  }
245
 
246
  /**
@@ -251,6 +261,7 @@ class EM_Object {
251
  */
252
  function to_object( $array = array(), $addslashes = false ){
253
  //Save core data
 
254
  foreach ( $this->fields as $key => $val ) {
255
  if(array_key_exists($key, $array)){
256
  if( !is_object($array[$key]) && !is_array($array[$key]) ){
@@ -265,12 +276,12 @@ class EM_Object {
265
  * Returns this object in the form of an array, useful for saving directly into a database table.
266
  * @return array
267
  */
268
- function to_array(){
269
  $array = array();
270
  foreach ( $this->fields as $key => $val ) {
271
  $array[$key] = $this->$val['name'];
272
  }
273
- return $array;
274
  }
275
 
276
 
@@ -292,7 +303,7 @@ class EM_Object {
292
  $types[] = $field['type'];
293
  }
294
  }
295
- return $types;
296
  }
297
 
298
  function get_fields( $inverted_array=false ){
@@ -305,9 +316,9 @@ class EM_Object {
305
  $return[$fieldName] = $fieldArray['name'];
306
  }
307
  }
308
- return $return;
309
  }
310
- return array();
311
  }
312
 
313
  /**
@@ -326,7 +337,7 @@ class EM_Object {
326
  } else {
327
  $value = addslashes( $value );
328
  }
329
- return $value;
330
  }
331
 
332
  /**
@@ -341,7 +352,7 @@ class EM_Object {
341
  $results[] = (is_numeric($item)&&is_numeric($key));
342
  }
343
  }
344
- return ( !in_array(false, $results) && count($results) > 0 );
345
  }
346
 
347
  /**
@@ -358,7 +369,7 @@ class EM_Object {
358
  if( isset($_GET['callback']) ){
359
  $return = $_GET['callback']."($return)";
360
  }
361
- return $return;
362
  }
363
 
364
  /**
14
  * @return array
15
  */
16
  function get_default_search($defaults=array(), $array = array()){
17
+ //TODO accept all objects as search options as well as ids (e.g. location vs. location_id, person vs. person_id)
18
  //Create minimal defaults array, merge it with supplied defaults array
19
  $super_defaults = array(
20
  'limit' => false,
29
  'recurring'=>false,
30
  'month'=>'',
31
  'year'=>'',
32
+ 'pagination'=>false,
33
  'array'=>false
34
  );
35
+ //Return default if nothing passed
36
+ if( empty($defaults) && empty($array) ){
37
+ return $super_defaults;
38
+ }
39
  //TODO decide on search defaults shared across all objects and then validate here
40
  $defaults = array_merge($super_defaults, $defaults);
41
 
45
  if( array_key_exists('category_id', $array) && !array_key_exists('category', $array) ) { $array['category'] = $array['category_id']; }
46
 
47
  if(is_array($array)){
 
48
  //If there's a location, then remove it and turn it into location_id
49
  if( array_key_exists('location', $array)){
50
  if ( is_numeric($array['location']) ) {
96
  $defaults['year'] = preg_match($year_regex, $defaults['year']) ? $defaults['year']:'';
97
  }
98
  //Order - it's either ASC or DESC, so let's just validate
99
+ if( !is_array($defaults['order']) && preg_match('/,/', $defaults['order']) ) {
100
  $defaults['order'] = explode(',', $defaults['order']);
101
  }elseif( !in_array($defaults['order'], array('ASC','DESC')) ){
102
  $defaults['order'] = $super_defaults['order'];
103
  }
104
  //ORDER BY, split if an array
105
+ if( !is_array($defaults['orderby']) && preg_match('/,/', $defaults['orderby']) ) {
106
  $defaults['orderby'] = explode(',', $defaults['orderby']);
107
  }
108
  //TODO should we clean format of malicious code over here and run everything thorugh this?
109
  $defaults['array'] = ($defaults['array'] == true);
110
+ $defaults['pagination'] = ($defaults['pagination'] == true);
111
  $defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
112
  $defaults['recurring'] = ($defaults['recurring'] == true);
113
+
114
+ return apply_filters('em_object_get_default_search', $defaults, $array, $super_defaults);
115
  }
116
 
117
  /**
124
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
125
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
126
 
127
+ $args = apply_filters('em_object_build_sql_conditions_args',$args);
128
+
129
  //Format the arguments passed on
130
  $scope = $args['scope'];//undefined variable warnings in ZDE, could just delete this (but dont pls!)
131
  $recurring = $args['recurring'];
132
  $recurrence = $args['recurrence'];
133
  $category = $args['category'];
134
  $location = $args['location'];
 
135
  $month = $args['month'];
136
  $year = $args['year'];
137
+ $today = date('Y-m-d', current_time('timestamp'));
138
  //Create the WHERE statement
139
 
140
  //Recurrences
141
+ $conditions = array();
142
  if( $recurring ){
143
+ $conditions['recurring'] = "`recurrence`=1";
144
  }elseif( $recurrence > 0 ){
145
+ $conditions['recurrence'] = "`recurrence_id`=$recurrence";
146
  }else{
147
+ $conditions['recurring'] = "(`recurrence`!=1 OR `recurrence` IS NULL)";
148
  }
149
  //Dates - first check 'month', and 'year'
150
  if( !($month=='' && $year=='') ){
164
  }
165
  $date_start = date('Y-m-d', mktime(0,0,0,$date_month_start,1,$date_year_start));
166
  $date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
167
+ $conditions['scope'] = " ((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)))";
168
  $search_by_monthyear = true;
169
  }
170
  if( !isset($search_by_monthyear) ){
174
  $dates = explode(',', $scope);
175
  $date_start = $dates[0];
176
  $date_end = $dates[1];
177
+ $conditions['scope'] = " ((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)))";
178
  } elseif ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
179
  //Scope can also be a specific date. However, if 'day', 'month', or 'year' are set, that will take precedence
180
+ $conditions['scope'] = " ( (event_start_date = CAST('$scope' AS DATE)) OR (event_start_date <= CAST('$scope' AS DATE) AND event_end_date >= CAST('$scope' AS DATE)) )";
181
  } else {
182
  if ($scope == "past"){
183
+ $conditions['scope'] = " event_start_date < '$today'";
184
  }elseif ($scope == "today"){
185
+ $conditions['scope'] = " ( (event_start_date = CAST('$today' AS DATE)) OR (event_start_date <= CAST('$today' AS DATE) AND event_end_date >= CAST('$today' AS DATE)) )";
186
  }elseif ($scope == "future" || $scope != 'all'){
187
+ $conditions['scope'] = " (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))";
188
  }
189
  }
190
  }
191
 
192
  //Filter by Location - can be object, array, or id
193
  if ( is_numeric($location) && $location > 0 ) { //Location ID takes precedence
194
+ $conditions['location'] = " {$locations_table}.location_id = $location";
195
  }elseif ( self::array_is_numeric($location) ){
196
+ $conditions['location'] = "( {$locations_table}.location_id = " . implode(" OR {$locations_table}.location_id = ", $location) .' )';
197
  }elseif ( is_object($location) && get_class($location)=='EM_Location' ){ //Now we deal with objects
198
+ $conditions['location'] = " {$locations_table}.location_id = $location->id";
199
  }elseif ( is_array($location) && @get_class(current($location)=='EM_Location') ){ //we can accept array of ids or EM_Location objects
200
  foreach($location as $EM_Location){
201
  $location_ids[] = $EM_Location->id;
202
  }
203
+ $conditions['location'] = "( {$locations_table}.location_id=". implode(" {$locations_table}.location_id=", $location_ids) ." )";
204
+ }
205
 
206
  //Add conditions for category selection
207
  //Filter by category, can be id or comma seperated ids
208
  //TODO create an exclude category option
209
  if ( $category != '' && is_numeric($category) ){
210
+ $conditions['category'] = " event_category_id = $category";
211
  }elseif( self::array_is_numeric($category) ){
212
+ $conditions['category'] = "( event_category_id = ". implode(' OR event_category_id = ', $category).")";
213
  }
214
 
215
+ return apply_filters('em_object_build_sql_conditions', $conditions);
216
  }
217
 
218
  function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
219
  //First, ORDER BY
220
+ $args = apply_filters('em_object_build_sql_orderby_args', $args);
221
  $orderby = array();
222
  if(is_array($args['orderby'])){
223
  //Clean orderby array so we only have accepted values
250
  $orderby[$i] .= ( in_array($args['order'], array('ASC','DESC')) ) ? $args['order'] : $default_order;
251
  }
252
  }
253
+ return apply_filters('em_object_build_sql_orderby', $orderby);
254
  }
255
 
256
  /**
261
  */
262
  function to_object( $array = array(), $addslashes = false ){
263
  //Save core data
264
+ $array = apply_filters('em_to_object', $array);
265
  foreach ( $this->fields as $key => $val ) {
266
  if(array_key_exists($key, $array)){
267
  if( !is_object($array[$key]) && !is_array($array[$key]) ){
276
  * Returns this object in the form of an array, useful for saving directly into a database table.
277
  * @return array
278
  */
279
+ function to_array(){
280
  $array = array();
281
  foreach ( $this->fields as $key => $val ) {
282
  $array[$key] = $this->$val['name'];
283
  }
284
+ return apply_filters('em_to_array', $array);
285
  }
286
 
287
 
303
  $types[] = $field['type'];
304
  }
305
  }
306
+ return apply_filters('em_object_get_types', $types, $this, $array);
307
  }
308
 
309
  function get_fields( $inverted_array=false ){
316
  $return[$fieldName] = $fieldArray['name'];
317
  }
318
  }
319
+ return apply_filters('em_object_get_fields', $return, $this, $inverted_array);
320
  }
321
+ return apply_filters('em_object_get_fields', array(), $this, $inverted_array);
322
  }
323
 
324
  /**
337
  } else {
338
  $value = addslashes( $value );
339
  }
340
+ return apply_filters('em_object_sanitize', $value);
341
  }
342
 
343
  /**
352
  $results[] = (is_numeric($item)&&is_numeric($key));
353
  }
354
  }
355
+ return (!in_array(false, $results) && count($results) > 0);
356
  }
357
 
358
  /**
369
  if( isset($_GET['callback']) ){
370
  $return = $_GET['callback']."($return)";
371
  }
372
+ return apply_filters('em_object_json_encode', $return, $array);
373
  }
374
 
375
  /**
classes/{people.php → em-people.php} RENAMED
File without changes
classes/{person.php → em-person.php} RENAMED
File without changes
classes/{recurrence.php → em-recurrence.php} RENAMED
File without changes
ajax.php → em-ajax.php RENAMED
File without changes
bookings.php → em-bookings.php RENAMED
@@ -56,7 +56,7 @@ function em_add_booking_form() {
56
  $destination = "?".$_SERVER['QUERY_STRING']."#dbem-rsvp";
57
  $booked_places_options = array();
58
  for ( $i = 1; $i <= 10; $i++ ) {
59
- $booking_seats = ($_POST['booking_seats'] == $i) ? 'selected="selected"':'';
60
  array_push($booked_places_options, "<option value='$i' $booking_seats>$i</option>");
61
  }
62
  ob_start();
@@ -75,9 +75,9 @@ function em_add_booking_form() {
75
 
76
  <form id='dbem-rsvp-form' name='booking-form' method='post' action='<?php echo $destination ?>'>
77
  <table class='dbem-rsvp-form'>
78
- <tr><th scope='row'><?php _e('Name', 'dbem') ?>:</th><td><input type='text' name='person_name' value='<?php echo $_POST['person_name'] ?>'/></td></tr>
79
- <tr><th scope='row'><?php _e('E-Mail', 'dbem') ?>:</th><td><input type='text' name='person_email' value='<?php echo $_POST['person_email'] ?>'/></td></tr>
80
- <tr><th scope='row'><?php _e('Phone number', 'dbem') ?>:</th><td><input type='text' name='person_phone' value='<?php echo $_POST['person_phone'] ?>'/></td></tr>
81
  <tr>
82
  <th scope='row'><?php _e('Seats', 'dbem') ?>:</th>
83
  <td>
@@ -90,7 +90,7 @@ function em_add_booking_form() {
90
  </select>
91
  </td>
92
  </tr>
93
- <tr><th scope='row'><?php _e('Comment', 'dbem') ?>:</th><td><textarea name='booking_comment'><?php echo $_POST['booking_comment'] ?></textarea></td></tr>
94
  </table>
95
  <p>
96
  <input type='submit' value='<?php _e('Send your booking', 'dbem') ?>'/>&nbsp;&nbsp;&nbsp;&nbsp;
@@ -146,10 +146,10 @@ function em_delete_booking_form() {
146
  <form name='booking-delete-form' method='post' action='<?php echo $destination ?>#dbem-booking-delete'>
147
  <table class='dbem-rsvp-form'>
148
  <tr>
149
- <th scope='row'><?php _e('Name', 'dbem') ?>:</th><td><input type='text' name='person_name' value='<?php echo $_POST['person_name'] ?>'/></td>
150
  </tr>
151
  <tr>
152
- <th scope='row'><?php _e('E-Mail', 'dbem') ?>:</th><td><input type='text' name='person_email' value='<?php echo $_POST['person_email'] ?>'/></td>
153
  </tr>
154
  </table>
155
  <input type='hidden' name='eventAction' value='delete_booking'/>
56
  $destination = "?".$_SERVER['QUERY_STRING']."#dbem-rsvp";
57
  $booked_places_options = array();
58
  for ( $i = 1; $i <= 10; $i++ ) {
59
+ $booking_seats = (!empty($_POST['booking_seats']) && $_POST['booking_seats'] == $i) ? 'selected="selected"':'';
60
  array_push($booked_places_options, "<option value='$i' $booking_seats>$i</option>");
61
  }
62
  ob_start();
75
 
76
  <form id='dbem-rsvp-form' name='booking-form' method='post' action='<?php echo $destination ?>'>
77
  <table class='dbem-rsvp-form'>
78
+ <tr><th scope='row'><?php _e('Name', 'dbem') ?>:</th><td><input type='text' name='person_name' value='<?php echo !empty($_POST['person_name']) ? $_POST['person_name'] : ''; ?>'/></td></tr>
79
+ <tr><th scope='row'><?php _e('E-Mail', 'dbem') ?>:</th><td><input type='text' name='person_email' value='<?php echo !empty($_POST['person_email']) ? $_POST['person_email'] : ''; ?>'/></td></tr>
80
+ <tr><th scope='row'><?php _e('Phone number', 'dbem') ?>:</th><td><input type='text' name='person_phone' value='<?php echo !empty($_POST['person_phone']) ? $_POST['person_phone'] : ''; ?>'/></td></tr>
81
  <tr>
82
  <th scope='row'><?php _e('Seats', 'dbem') ?>:</th>
83
  <td>
90
  </select>
91
  </td>
92
  </tr>
93
+ <tr><th scope='row'><?php _e('Comment', 'dbem') ?>:</th><td><textarea name='booking_comment'><?php echo !empty($_POST['booking_comment']) ? $_POST['booking_comment']:'' ?></textarea></td></tr>
94
  </table>
95
  <p>
96
  <input type='submit' value='<?php _e('Send your booking', 'dbem') ?>'/>&nbsp;&nbsp;&nbsp;&nbsp;
146
  <form name='booking-delete-form' method='post' action='<?php echo $destination ?>#dbem-booking-delete'>
147
  <table class='dbem-rsvp-form'>
148
  <tr>
149
+ <th scope='row'><?php _e('Name', 'dbem') ?>:</th><td><input type='text' name='person_name' value='<?php echo !empty($_POST['person_name']) ? $_POST['person_name'] : ''; ?>'/></td>
150
  </tr>
151
  <tr>
152
+ <th scope='row'><?php _e('E-Mail', 'dbem') ?>:</th><td><input type='text' name='person_email' value='<?php echo !empty($_POST['person_email']) ? $_POST['person_email'] : ''; ?>'/></td>
153
  </tr>
154
  </table>
155
  <input type='hidden' name='eventAction' value='delete_booking'/>
events.php → em-events.php RENAMED
@@ -14,28 +14,38 @@ function em_content($content) {
14
  global $wpdb, $EM_Event;
15
  //TODO FILTER - filter em page content before placeholder replacing
16
  //TODO any loop should put the current $EM_Event etc. into the global variable
17
- if ( isset( $_REQUEST['calendar_day'] ) && $_REQUEST['calendar_day'] != '' ) {
18
  //Events for a specific day
19
- $events = EM_Events::get( array( 'scope'=>$_REQUEST['calendar_day'] ) );
20
- if ( count($events) > 1 || get_option('dbem_display_calendar_day_single') == 1 ) {
21
- $content = EM_Events::output($events);
 
 
 
 
 
 
 
 
 
22
  } else {
23
  $EM_Event = $events[0];
24
  $content = $EM_Event->output_single();
25
  }
26
- } elseif ( is_numeric($_REQUEST['location_id']) ) {
27
  //Just a single location
28
  $location = new EM_Location($_REQUEST['location_id']);
29
  $content = $location->output_single();
30
- } elseif ( is_numeric($_REQUEST['event_id']) ) {
31
  // single event page
32
  $event = new EM_Event( $_REQUEST['event_id'] );
33
  $content = $event->output_single();
34
  } else {
35
  // Multiple events page
36
- $scope = ($_REQUEST['scope']) ? EM_Object::sanitize($_REQUEST['scope']) : "future";
37
  if (get_option ( 'dbem_display_calendar_in_events_page' )){
38
- $content = EM_Calendar::output( array('full'=>1,'long_events'=>get_option('dbem_full_calendar_long_events')) );
 
39
  }else{
40
  //If we have a $_GET['page'] var, use it to calculate the offset/limit ratios (safer than offset/limit get vars)
41
  $page = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : 1;
@@ -43,10 +53,11 @@ function em_content($content) {
43
  'limit'=> get_option('dbem_events_default_limit'),
44
  'orderby' => get_option('dbem_events_default_orderby'),
45
  'order' => get_option('dbem_events_default_order'),
46
- 'scope' => $scope
 
47
  );
48
  $args['offset'] = $args['limit'] * ($page-1);
49
- $content = EM_Events::output( $args );
50
  }
51
  }
52
  //If disable rewrite flag is on, then we need to add a placeholder here
@@ -55,7 +66,7 @@ function em_content($content) {
55
  }
56
  //TODO FILTER - filter em page content before display
57
  }
58
- return '<div id="em-wrapper">'.$content.'</div>';
59
  }
60
  add_filter ( 'the_content', 'em_content' );
61
 
@@ -98,7 +109,7 @@ function em_events_page_title($content) {
98
  }
99
  //TODO FILTER - filter titles before em output
100
  }
101
- return $content;
102
  }
103
  add_filter ( 'single_post_title', 'em_events_page_title' ); //Filter for the wp_title of page, can directly reference page title function
104
 
@@ -115,7 +126,7 @@ function em_wp_the_title($data){
115
  return em_events_page_title($data) ;
116
  }
117
  }
118
- return $data ;
119
  }
120
  add_filter ( 'the_title', 'em_wp_the_title' );
121
 
@@ -135,9 +146,9 @@ function em_filter_get_pages($data) {
135
  $output[] = $page;
136
  }
137
  }
138
- return $output;
139
  }
140
- return $data;
141
  }
142
  add_filter ( 'get_pages', 'em_filter_get_pages' );
143
 
14
  global $wpdb, $EM_Event;
15
  //TODO FILTER - filter em page content before placeholder replacing
16
  //TODO any loop should put the current $EM_Event etc. into the global variable
17
+ if ( !empty($_REQUEST['calendar_day']) ) {
18
  //Events for a specific day
19
+ $args = array(
20
+ 'orderby' => get_option('dbem_events_default_orderby'),
21
+ 'order' => get_option('dbem_events_default_order'),
22
+ 'scope'=> $_REQUEST['calendar_day'],
23
+ 'pagination' => 1
24
+ );
25
+ $page = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : 1;
26
+ $events = EM_Events::get( apply_filters('em_content_calendar_day_args', $args) ); //Get events first, so we know how many there are in advance
27
+ if ( count($events) > 1 || $page > 1 || get_option('dbem_display_calendar_day_single') == 1 ) {
28
+ $args['limit'] = get_option('dbem_events_default_limit');
29
+ $args['offset'] = $args['limit'] * ($page-1);
30
+ $content = EM_Events::output($events, apply_filters('em_content_calendar_day_output_args', $args) );
31
  } else {
32
  $EM_Event = $events[0];
33
  $content = $EM_Event->output_single();
34
  }
35
+ } elseif ( !empty($_REQUEST['location_id']) && is_numeric($_REQUEST['location_id']) ) {
36
  //Just a single location
37
  $location = new EM_Location($_REQUEST['location_id']);
38
  $content = $location->output_single();
39
+ } elseif ( !empty($_REQUEST['event_id']) && is_numeric($_REQUEST['event_id']) ) {
40
  // single event page
41
  $event = new EM_Event( $_REQUEST['event_id'] );
42
  $content = $event->output_single();
43
  } else {
44
  // Multiple events page
45
+ $scope = (!empty($_REQUEST['scope'])) ? EM_Object::sanitize($_REQUEST['scope']) : "future";
46
  if (get_option ( 'dbem_display_calendar_in_events_page' )){
47
+ $args = array('full'=>1,'long_events'=>get_option('dbem_full_calendar_long_events'));
48
+ $content = EM_Calendar::output( apply_filters('em_content_calendar_args', $args) );
49
  }else{
50
  //If we have a $_GET['page'] var, use it to calculate the offset/limit ratios (safer than offset/limit get vars)
51
  $page = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : 1;
53
  'limit'=> get_option('dbem_events_default_limit'),
54
  'orderby' => get_option('dbem_events_default_orderby'),
55
  'order' => get_option('dbem_events_default_order'),
56
+ 'scope' => $scope,
57
+ 'pagination' => 1
58
  );
59
  $args['offset'] = $args['limit'] * ($page-1);
60
+ $content = EM_Events::output( apply_filters('em_content_events_args', $args) );
61
  }
62
  }
63
  //If disable rewrite flag is on, then we need to add a placeholder here
66
  }
67
  //TODO FILTER - filter em page content before display
68
  }
69
+ return apply_filters('em_content', '<div id="em-wrapper">'.$content.'</div>');
70
  }
71
  add_filter ( 'the_content', 'em_content' );
72
 
109
  }
110
  //TODO FILTER - filter titles before em output
111
  }
112
+ return apply_filters('em_events_page_title', $content);
113
  }
114
  add_filter ( 'single_post_title', 'em_events_page_title' ); //Filter for the wp_title of page, can directly reference page title function
115
 
126
  return em_events_page_title($data) ;
127
  }
128
  }
129
+ return apply_filters('em_wp_the_title', $data) ;
130
  }
131
  add_filter ( 'the_title', 'em_wp_the_title' );
132
 
146
  $output[] = $page;
147
  }
148
  }
149
+ return apply_filters('em_filter_get_pages', $output);
150
  }
151
+ return apply_filters('em_filter_get_pages', $data);
152
  }
153
  add_filter ( 'get_pages', 'em_filter_get_pages' );
154
 
functions.php → em-functions.php RENAMED
@@ -24,26 +24,28 @@ function em_hello_to_new_user() {
24
  * @return string
25
  */
26
  function em_paginate($link, $total, $limit, $page=1, $pagesToShow=10){
27
- $maxPages = ceil($total/$limit); //Total number of pages
28
- $startPage = ($page <= $pagesToShow) ? 1 : $pagesToShow * (floor($page/$pagesToShow)) ; //Which page to start the pagination links from (in case we're on say page 12 and $pagesToShow is 10 pages)
29
- $placeholder = urlencode('%PAGE%');
30
- $link = str_replace('%PAGE%', urlencode('%PAGE%'), $link); //To avoid url encoded/non encoded placeholders
31
- //Add the back and first buttons
32
- $string = ($page>1) ? '<a href="'.str_replace($placeholder,1,$link).'">&lt;&lt;</a> ' : '&lt;&lt; ';
33
- $string .= ($page>1) ? ' <a href="'.str_replace($placeholder,$page-1,$link).'">&lt;</a> ' : '&lt; ';
34
- //Loop each page and create a link or just a bold number if its the current page
35
- for ($i = $startPage ; $i < $startPage+$pagesToShow && $i <= $maxPages ; $i++){
36
- if($i == $page){
37
- $string .= " <strong>$i</strong>";
38
- }else{
39
- $string .= ' <a href="'.str_replace($placeholder,$i,$link).'">'.$i.'</a> ';
40
- }
41
- }
42
- //Add the forward and last buttons
43
- $string .= ($page<$total) ? ' <a href="'.str_replace($placeholder,$page+1,$link).'">&gt;</a> ' :' &gt; ' ;
44
- $string .= ($page<$total) ? ' <a href="'.str_replace($placeholder,$maxPages,$link).'">&gt;&gt;</a> ' : '&gt;&gt; ';
45
- //Return the string
46
- return $string;
 
 
47
  }
48
 
49
  /**
@@ -95,7 +97,7 @@ function em_get_wp_users() {
95
  * previously dbem_UI_helpers.php functions
96
  */
97
 
98
- function dbem_option_items($array, $saved_value) {
99
  $output = "";
100
  foreach($array as $key => $item) {
101
  $selected ='';
@@ -107,7 +109,7 @@ function dbem_option_items($array, $saved_value) {
107
  echo $output;
108
  }
109
 
110
- function dbem_checkbox_items($name, $array, $saved_values, $horizontal = true) {
111
  $output = "";
112
  foreach($array as $key => $item) {
113
  $checked = "";
@@ -121,7 +123,7 @@ function dbem_checkbox_items($name, $array, $saved_values, $horizontal = true) {
121
 
122
  }
123
 
124
- function dbem_options_input_text($title, $name, $description) {
125
  ?>
126
  <tr valign="top" id='<?php echo $name;?>_row'>
127
  <th scope="row"><?php _e($title, 'dbem') ?></th>
@@ -132,7 +134,7 @@ function dbem_options_input_text($title, $name, $description) {
132
  </tr>
133
  <?php
134
  }
135
- function dbem_options_input_password($title, $name, $description) {
136
  ?>
137
  <tr valign="top" id='<?php echo $name;?>_row'>
138
  <th scope="row"><?php _e($title, 'dbem') ?></th>
@@ -144,7 +146,7 @@ function dbem_options_input_password($title, $name, $description) {
144
  <?php
145
  }
146
 
147
- function dbem_options_textarea($title, $name, $description) {
148
  ?>
149
  <tr valign="top" id='<?php echo $name;?>_row'>
150
  <th scope="row"><?php _e($title,'dbem')?></th>
@@ -154,7 +156,7 @@ function dbem_options_textarea($title, $name, $description) {
154
  <?php
155
  }
156
 
157
- function dbem_options_radio_binary($title, $name, $description) {
158
  $list_events_page = get_option($name); ?>
159
 
160
  <tr valign="top" id='<?php echo $name;?>_row'>
@@ -167,7 +169,7 @@ function dbem_options_radio_binary($title, $name, $description) {
167
  </tr>
168
  <?php
169
  }
170
- function dbem_options_select($title, $name, $list, $description) {
171
  $option_value = get_option($name);
172
  if( $name == 'dbem_events_page' && !is_object(get_page($option_value)) ){
173
  $option_value = 0; //Special value
@@ -189,8 +191,8 @@ function dbem_options_select($title, $name, $list, $description) {
189
  <?php
190
  }
191
  // got from http://davidwalsh.name/php-email-encode-prevent-spam
192
- function dbem_ascii_encode($e)
193
- {
194
  for ($i = 0; $i < strlen($e); $i++) { $output .= '&#'.ord($e[$i]).';'; }
195
  return $output;
196
  }
24
  * @return string
25
  */
26
  function em_paginate($link, $total, $limit, $page=1, $pagesToShow=10){
27
+ if($limit > 0){
28
+ $maxPages = ceil($total/$limit); //Total number of pages
29
+ $startPage = ($page <= $pagesToShow) ? 1 : $pagesToShow * (floor($page/$pagesToShow)) ; //Which page to start the pagination links from (in case we're on say page 12 and $pagesToShow is 10 pages)
30
+ $placeholder = urlencode('%PAGE%');
31
+ $link = str_replace('%PAGE%', urlencode('%PAGE%'), $link); //To avoid url encoded/non encoded placeholders
32
+ //Add the back and first buttons
33
+ $string = ($page>1) ? '<a href="'.str_replace($placeholder,1,$link).'">&lt;&lt;</a> ' : '&lt;&lt; ';
34
+ $string .= ($page>1) ? ' <a href="'.str_replace($placeholder,$page-1,$link).'">&lt;</a> ' : '&lt; ';
35
+ //Loop each page and create a link or just a bold number if its the current page
36
+ for ($i = $startPage ; $i < $startPage+$pagesToShow && $i <= $maxPages ; $i++){
37
+ if($i == $page){
38
+ $string .= " <strong>$i</strong>";
39
+ }else{
40
+ $string .= ' <a href="'.str_replace($placeholder,$i,$link).'">'.$i.'</a> ';
41
+ }
42
+ }
43
+ //Add the forward and last buttons
44
+ $string .= ($i < $maxPages) ? ' <a href="'.str_replace($placeholder,$page+1,$link).'">&gt;</a> ' :' &gt; ' ;
45
+ $string .= ($i < $maxPages) ? ' <a href="'.str_replace($placeholder,$maxPages,$link).'">&gt;&gt;</a> ' : '&gt;&gt; ';
46
+ //Return the string
47
+ return $string;
48
+ }
49
  }
50
 
51
  /**
97
  * previously dbem_UI_helpers.php functions
98
  */
99
 
100
+ function em_option_items($array, $saved_value) {
101
  $output = "";
102
  foreach($array as $key => $item) {
103
  $selected ='';
109
  echo $output;
110
  }
111
 
112
+ function em_checkbox_items($name, $array, $saved_values, $horizontal = true) {
113
  $output = "";
114
  foreach($array as $key => $item) {
115
  $checked = "";
123
 
124
  }
125
 
126
+ function em_options_input_text($title, $name, $description) {
127
  ?>
128
  <tr valign="top" id='<?php echo $name;?>_row'>
129
  <th scope="row"><?php _e($title, 'dbem') ?></th>
134
  </tr>
135
  <?php
136
  }
137
+ function em_options_input_password($title, $name, $description) {
138
  ?>
139
  <tr valign="top" id='<?php echo $name;?>_row'>
140
  <th scope="row"><?php _e($title, 'dbem') ?></th>
146
  <?php
147
  }
148
 
149
+ function em_options_textarea($title, $name, $description) {
150
  ?>
151
  <tr valign="top" id='<?php echo $name;?>_row'>
152
  <th scope="row"><?php _e($title,'dbem')?></th>
156
  <?php
157
  }
158
 
159
+ function em_options_radio_binary($title, $name, $description) {
160
  $list_events_page = get_option($name); ?>
161
 
162
  <tr valign="top" id='<?php echo $name;?>_row'>
169
  </tr>
170
  <?php
171
  }
172
+ function em_options_select($title, $name, $list, $description) {
173
  $option_value = get_option($name);
174
  if( $name == 'dbem_events_page' && !is_object(get_page($option_value)) ){
175
  $option_value = 0; //Special value
191
  <?php
192
  }
193
  // got from http://davidwalsh.name/php-email-encode-prevent-spam
194
+ function em_ascii_encode($e){
195
+ $output = '';
196
  for ($i = 0; $i < strlen($e); $i++) { $output .= '&#'.ord($e[$i]).';'; }
197
  return $output;
198
  }
install.php → em-install.php RENAMED
File without changes
em-rss.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <rss version="2.0">
8
+ <channel>
9
+ <title><?php echo get_option ( 'dbem_rss_main_title' ); ?></title>
10
+ <link><?php echo get_permalink ( get_option('dbem_events_page') ); ?></link>
11
+ <description><?php echo get_option ( 'dbem_rss_main_description' ); ?></description>
12
+ <docs>http://blogs.law.harvard.edu/tech/rss</docs>
13
+ <generator>Weblog Editor 2.0</generator>
14
+
15
+ <?php
16
+ $description_format = str_replace ( ">", "&gt;", str_replace ( "<", "&lt;", get_option ( 'dbem_rss_description_format' ) ) );
17
+ $events = EM_Events::get( array('limit'=>5) );
18
+ foreach ( $events as $event ) {
19
+ $description = $event->output( get_option ( 'dbem_rss_description_format' ), "rss");
20
+ $description = ent2ncr(convert_chars(strip_tags($description))); //Some RSS filtering
21
+ ?>
22
+ <item>
23
+ <title><?php echo $event->output( get_option('dbem_rss_title_format'), "rss" ); ?></title>
24
+ <link><?php echo $event->output('#_EVENTURL'); ?></link>
25
+ <description><?php echo $description; ?></description>
26
+ </item>
27
+ <?php
28
+ }
29
+ ?>
30
+
31
+ </channel>
32
+ </rss>
33
+ <?php
34
+ die ();
35
+ }
36
+ }
37
+ add_action ( 'init', 'em_rss' );
38
+ ?>
shortcode.php → em-shortcode.php RENAMED
@@ -34,7 +34,7 @@ add_shortcode('locations-map', 'em_get_locations_map_shortcode'); //Depreciate t
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
 
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
 
template-tags-depreciated.php → em-template-tags-depreciated.php RENAMED
@@ -111,4 +111,70 @@ function dbem_rss_link($justurl = 0, $echo = 1, $text = "RSS") {
111
  return $result;
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  ?>
111
  return $result;
112
  }
113
 
114
+ /*
115
+ * Currently these are location template tags that refer to the main objects.
116
+ * Please replace calls to these with direct object methods.
117
+ */
118
+
119
+ function dbem_get_locations($eventful = false) {
120
+ $EM_Locations = EM_Locations::get(array('eventful'=>$eventful));
121
+ foreach ($EM_Locations as $key => $EM_Location){
122
+ $EM_Locations[$key] = $EM_Location->to_array();
123
+ }
124
+ }
125
+
126
+ function dbem_get_location($location_id) {
127
+ $EM_Location = new EM_Location($location_id);
128
+ return $EM_Location->to_array();
129
+ }
130
+
131
+ /**
132
+ * Find a location with same name, address and town as supplied array
133
+ * @param $location
134
+ * @return array
135
+ */
136
+ function dbem_get_identical_location($location) {
137
+ $EM_Location = new EM_Location($location);
138
+ return $EM_Location->load_similar();
139
+ }
140
+
141
+ function dbem_validate_location($location) {
142
+ $EM_Location = new EM_Location($location);
143
+ if ( $EM_Location->validate() ){
144
+ return "OK";
145
+ }else{
146
+ return '<strong>'.__('Ach, some problems here:', 'dbem').'</strong><br /><br />'."\n".implode('<br />', $EM_Location->errors);
147
+ }
148
+ }
149
+
150
+ function dbem_update_location($location) {
151
+ $EM_Location = new EM_Location($location);
152
+ $EM_Location->update();
153
+ }
154
+
155
+ function dbem_insert_location($location) {
156
+ $EM_Location = new EM_Location($location);
157
+ $EM_Location->insert();
158
+ return $EM_Location->to_array();
159
+ }
160
+
161
+ function dbem_location_has_events($location_id) {
162
+ $EM_Location = new EM_Location($location_id);
163
+ return $EM_Location->has_events();
164
+ }
165
+
166
+ function dbem_upload_location_picture($location) {
167
+ $EM_Location = new EM_Location($location);
168
+ $EM_Location->image_upload();
169
+ }
170
+
171
+ function dbem_delete_image_files_for_location_id($location_id) {
172
+ $EM_Location = new EM_Location($location_id);
173
+ $EM_Location->image_delete();
174
+ }
175
+
176
+ function dbem_replace_locations_placeholders($format, $location, $target="html") {
177
+ $EM_Location = new EM_Location($location);
178
+ return $EM_Location->output($format, $target);
179
+ }
180
  ?>
template-tags.php → em-template-tags.php RENAMED
File without changes
events-manager.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
- Version: 3.0.8
5
  Plugin URI: http://wp-events-plugin.com
6
  Description: Manage events specifying precise spatial data (Location, Town, Province, etc).
7
  Author: Davide Benini, Marcus Sykes
@@ -43,45 +43,44 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
43
 
44
 
45
  // INCLUDES
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');
63
- include_once('classes/bookings.php');
64
- include_once('classes/calendar.php');
65
- include_once('classes/category.php');
66
- include_once('classes/event.php');
67
- include_once('classes/events.php');
68
- include_once('classes/location.php');
69
- include_once('classes/locations.php');
70
- include_once("classes/mailer.php") ;
71
- include_once('classes/map.php');
72
- include_once('classes/people.php');
73
- include_once('classes/person.php');
74
  //Admin Files
75
  if( is_admin() ){
76
- include_once('admin/admin.php');
77
- include_once('admin/bookings.php');
78
- include_once('admin/categories.php');
79
- include_once('admin/event.php');
80
- include_once('admin/events.php');
81
- include_once('admin/help.php');
82
- include_once('admin/locations.php');
83
- include_once('admin/options.php');
84
- include_once('admin/people.php');
85
  }
86
 
87
 
@@ -176,15 +175,15 @@ add_filter( 'plugin_row_meta', 'em_set_plugin_meta', 10, 2 );
176
  function em_create_events_submenu () {
177
  if(function_exists('add_submenu_page')) {
178
  //TODO Add flexible permissions
179
- add_object_page(__('Events', 'dbem'),__('Events', 'dbem'),EM_MIN_CAPABILITY,__FILE__,'dbem_events_subpanel', '../wp-content/plugins/events-manager/includes/images/calendar-16.png');
180
  // Add a submenu to the custom top-level menu:
181
  $plugin_pages = array();
182
- $plugin_pages[] = add_submenu_page(__FILE__, __('Edit'),__('Edit'),EM_MIN_CAPABILITY,__FILE__,'dbem_events_subpanel');
183
- $plugin_pages[] = add_submenu_page(__FILE__, __('Add new', 'dbem'), __('Add new','dbem'), EM_MIN_CAPABILITY, 'new_event', "dbem_new_event_page");
184
- $plugin_pages[] = add_submenu_page(__FILE__, __('Locations', 'dbem'), __('Locations', 'dbem'), EM_MIN_CAPABILITY, 'locations', "dbem_locations_page");
185
  $plugin_pages[] = add_submenu_page(__FILE__, __('People', 'dbem'), __('People', 'dbem'), EM_MIN_CAPABILITY, 'people', "em_people_page");
186
- $plugin_pages[] = add_submenu_page(__FILE__, __('Event Categories','dbem'),__('Categories','dbem'), EM_SETTING_CAPABILITY, "events-manager-categories", 'dbem_categories_subpanel');
187
- $plugin_pages[] = add_submenu_page(__FILE__, __('Events Manager Settings','dbem'),__('Settings','dbem'), EM_SETTING_CAPABILITY, "events-manager-options", 'dbem_options_subpanel');
188
  $plugin_pages[] = add_submenu_page(__FILE__, __('Getting Help for Events Manager','dbem'),__('Help','dbem'), EM_SETTING_CAPABILITY, "events-manager-help", 'em_admin_help');
189
  foreach($plugin_pages as $plugin_page){
190
  add_action( 'admin_print_scripts-'. $plugin_page, 'em_admin_load_scripts' );
@@ -220,12 +219,12 @@ add_filter ( 'favorite_actions', 'em_favorite_menu' );
220
 
221
  /* Creating the wp_events table to store event data*/
222
  function em_activate() {
223
- require_once(WP_PLUGIN_DIR.'/events-manager/install.php');
224
  em_install();
225
  }
226
  register_activation_hook( __FILE__,'em_activate');
227
 
228
  if( !empty($_GET['em_reimport']) || get_option('dbem_import_fail') == '1' ){
229
- require_once(WP_PLUGIN_DIR.'/events-manager/install.php');
230
  }
231
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
+ Version: 3.0.81
5
  Plugin URI: http://wp-events-plugin.com
6
  Description: Manage events specifying precise spatial data (Location, Town, Province, etc).
7
  Author: Davide Benini, Marcus Sykes
43
 
44
 
45
  // INCLUDES
46
+ include_once('classes/em-object.php'); //Base object, any files below may depend on this
47
  //Template Tags & Template Logic
48
+ include_once("em-ajax.php");
49
+ include_once("em-bookings.php");
50
+ include_once("em-events.php");
51
+ include_once("em-functions.php");
52
+ include_once("em-rss.php");
53
+ include_once("em-shortcode.php");
54
+ include_once("em-template-tags.php");
55
+ include_once("em-template-tags-depreciated.php"); //To depreciate
 
56
  //Widgets
57
+ include_once("widgets/em-events.php");
58
+ include_once("widgets/em-locations.php");
59
+ include_once("widgets/em-calendar.php");
60
  //Classes
61
+ include_once('classes/em-booking.php');
62
+ include_once('classes/em-bookings.php');
63
+ include_once('classes/em-calendar.php');
64
+ include_once('classes/em-category.php');
65
+ include_once('classes/em-event.php');
66
+ include_once('classes/em-events.php');
67
+ include_once('classes/em-location.php');
68
+ include_once('classes/em-locations.php');
69
+ include_once("classes/em-mailer.php") ;
70
+ include_once('classes/em-map.php');
71
+ include_once('classes/em-people.php');
72
+ include_once('classes/em-person.php');
73
  //Admin Files
74
  if( is_admin() ){
75
+ include_once('admin/em-admin.php');
76
+ include_once('admin/em-bookings.php');
77
+ include_once('admin/em-categories.php');
78
+ include_once('admin/em-event.php');
79
+ include_once('admin/em-events.php');
80
+ include_once('admin/em-help.php');
81
+ include_once('admin/em-locations.php');
82
+ include_once('admin/em-options.php');
83
+ include_once('admin/em-people.php');
84
  }
85
 
86
 
175
  function em_create_events_submenu () {
176
  if(function_exists('add_submenu_page')) {
177
  //TODO Add flexible permissions
178
+ add_object_page(__('Events', 'dbem'),__('Events', 'dbem'),EM_MIN_CAPABILITY,__FILE__,'em_events_subpanel', '../wp-content/plugins/events-manager/includes/images/calendar-16.png');
179
  // Add a submenu to the custom top-level menu:
180
  $plugin_pages = array();
181
+ $plugin_pages[] = add_submenu_page(__FILE__, __('Edit'),__('Edit'),EM_MIN_CAPABILITY,__FILE__,'em_events_subpanel');
182
+ $plugin_pages[] = add_submenu_page(__FILE__, __('Add new', 'dbem'), __('Add new','dbem'), EM_MIN_CAPABILITY, 'new_event', "em_new_event_page");
183
+ $plugin_pages[] = add_submenu_page(__FILE__, __('Locations', 'dbem'), __('Locations', 'dbem'), EM_MIN_CAPABILITY, 'locations', "em_locations_page");
184
  $plugin_pages[] = add_submenu_page(__FILE__, __('People', 'dbem'), __('People', 'dbem'), EM_MIN_CAPABILITY, 'people', "em_people_page");
185
+ $plugin_pages[] = add_submenu_page(__FILE__, __('Event Categories','dbem'),__('Categories','dbem'), EM_SETTING_CAPABILITY, "events-manager-categories", 'em_categories_subpanel');
186
+ $plugin_pages[] = add_submenu_page(__FILE__, __('Events Manager Settings','dbem'),__('Settings','dbem'), EM_SETTING_CAPABILITY, "events-manager-options", 'em_options_subpanel');
187
  $plugin_pages[] = add_submenu_page(__FILE__, __('Getting Help for Events Manager','dbem'),__('Help','dbem'), EM_SETTING_CAPABILITY, "events-manager-help", 'em_admin_help');
188
  foreach($plugin_pages as $plugin_page){
189
  add_action( 'admin_print_scripts-'. $plugin_page, 'em_admin_load_scripts' );
219
 
220
  /* Creating the wp_events table to store event data*/
221
  function em_activate() {
222
+ require_once(WP_PLUGIN_DIR.'/events-manager/em-install.php');
223
  em_install();
224
  }
225
  register_activation_hook( __FILE__,'em_activate');
226
 
227
  if( !empty($_GET['em_reimport']) || get_option('dbem_import_fail') == '1' ){
228
+ require_once(WP_PLUGIN_DIR.'/events-manager/em-install.php');
229
  }
230
  ?>
includes/css/events_manager.css CHANGED
@@ -85,17 +85,6 @@ table#bookings-table tr#booked-seats td.seats-number, table#bookings-table tr#av
85
  font-weight: bold;
86
  }
87
 
88
- p#recurrence_warning {
89
- border: 2px solid #FD0000;
90
- background: #FF7146;
91
- color: #fff;
92
- font-weight: bold;
93
- padding: 5px;
94
- }
95
- div#icon-events{
96
- background:url('../images/calendar-32.png') no-repeat center;
97
- }
98
-
99
  table#dbem-location-data th {
100
  text-align: right;
101
  width: 50px;
85
  font-weight: bold;
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
88
  table#dbem-location-data th {
89
  text-align: right;
90
  width: 50px;
includes/css/events_manager_admin.css CHANGED
@@ -1,6 +1,13 @@
1
  #location_info td { vertical-align:top; text-align:left; }
2
  #location_info th { vertical-align:top; text-align:left; padding:5px 10px 0 0; }
3
 
 
 
 
 
 
 
 
4
  .debug{
5
  color: green;
6
  background: #B7F98C;
@@ -40,4 +47,7 @@
40
  #new-event {
41
  float: left;
42
 
 
 
 
43
  }
1
  #location_info td { vertical-align:top; text-align:left; }
2
  #location_info th { vertical-align:top; text-align:left; padding:5px 10px 0 0; }
3
 
4
+ p#recurrence_warning {
5
+ border: 2px solid #FD0000;
6
+ background: #FF7146;
7
+ color: #fff;
8
+ font-weight: bold;
9
+ padding: 5px;
10
+ }
11
  .debug{
12
  color: green;
13
  background: #B7F98C;
47
  #new-event {
48
  float: left;
49
 
50
+ }
51
+ div#icon-events{
52
+ background:url('../images/calendar-32.png') no-repeat center;
53
  }
includes/js/em_maps.js CHANGED
@@ -45,22 +45,24 @@ function em_maps() {
45
  var maxLatLngArr = [0,0];
46
 
47
  for (var i = 0; i < data.length; i++) {
48
- var latitude = parseFloat( data[i].location_latitude );
49
- var longitude = parseFloat( data[i].location_longitude );
50
- var location = new google.maps.LatLng( latitude, longitude );
51
- var marker = new google.maps.Marker({
52
- position: location,
53
- map: maps[map_id]
54
- });
55
- marker.setTitle(data[i].location_name);
56
- var myContent = '<div class="em-map-balloon"><div id="em-map-balloon-'+map_id+'" class="em-map-balloon-content">'+ data[i].location_balloon +'</div></div>';
57
- em_map_infobox(marker, myContent, maps[map_id]);
58
-
59
- //Get min and max long/lats
60
- minLatLngArr[0] = (latitude < minLatLngArr[0] || i == 0) ? latitude : minLatLngArr[0];
61
- minLatLngArr[1] = (longitude < minLatLngArr[1] || i == 0) ? longitude : minLatLngArr[1];
62
- maxLatLngArr[0] = (latitude > maxLatLngArr[0] || i == 0) ? latitude : maxLatLngArr[0];
63
- maxLatLngArr[1] = (longitude > maxLatLngArr[1] || i == 0) ? longitude : maxLatLngArr[1];
 
 
64
  }
65
  // Zoom in to the bounds
66
  var minLatLng = new google.maps.LatLng(minLatLngArr[0],minLatLngArr[1]);
45
  var maxLatLngArr = [0,0];
46
 
47
  for (var i = 0; i < data.length; i++) {
48
+ if( !(data[i].location_latitude == 0 && data[i].location_longitude == 0) ){
49
+ var latitude = parseFloat( data[i].location_latitude );
50
+ var longitude = parseFloat( data[i].location_longitude );
51
+ var location = new google.maps.LatLng( latitude, longitude );
52
+ var marker = new google.maps.Marker({
53
+ position: location,
54
+ map: maps[map_id]
55
+ });
56
+ marker.setTitle(data[i].location_name);
57
+ var myContent = '<div class="em-map-balloon"><div id="em-map-balloon-'+map_id+'" class="em-map-balloon-content">'+ data[i].location_balloon +'</div></div>';
58
+ em_map_infobox(marker, myContent, maps[map_id]);
59
+
60
+ //Get min and max long/lats
61
+ minLatLngArr[0] = (latitude < minLatLngArr[0] || i == 0) ? latitude : minLatLngArr[0];
62
+ minLatLngArr[1] = (longitude < minLatLngArr[1] || i == 0) ? longitude : minLatLngArr[1];
63
+ maxLatLngArr[0] = (latitude > maxLatLngArr[0] || i == 0) ? latitude : maxLatLngArr[0];
64
+ maxLatLngArr[1] = (longitude > maxLatLngArr[1] || i == 0) ? longitude : maxLatLngArr[1];
65
+ }
66
  }
67
  // Zoom in to the bounds
68
  var minLatLng = new google.maps.LatLng(minLatLngArr[0],minLatLngArr[1]);
locations.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- /*
3
- * Currently these are template tags that refer to the main objects.
4
- * Please replace calls to these with direct object methods when possible.
5
- * These will be phased out unless they are specifically template tags for public use.
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) {
16
- $EM_Location = new EM_Location($location_id);
17
- return $EM_Location->to_array();
18
- }
19
-
20
- /**
21
- * Find a location with same name, address and town as supplied array
22
- * @param $location
23
- * @return array
24
- */
25
- function dbem_get_identical_location($location) {
26
- $EM_Location = new EM_Location($location);
27
- return $EM_Location->load_similar();
28
- }
29
-
30
- function dbem_validate_location($location) {
31
- $EM_Location = new EM_Location($location);
32
- if ( $EM_Location->validate() ){
33
- return "OK";
34
- }else{
35
- return '<strong>'.__('Ach, some problems here:', 'dbem').'</strong><br /><br />'."\n".implode('<br />', $EM_Location->errors);
36
- }
37
- }
38
-
39
- function dbem_update_location($location) {
40
- $EM_Location = new EM_Location($location);
41
- $EM_Location->update();
42
- }
43
-
44
- function dbem_insert_location($location) {
45
- $EM_Location = new EM_Location($location);
46
- $EM_Location->insert();
47
- return $EM_Location->to_array();
48
- }
49
-
50
- function dbem_location_has_events($location_id) {
51
- $EM_Location = new EM_Location($location_id);
52
- return $EM_Location->has_events();
53
- }
54
-
55
- function dbem_upload_location_picture($location) {
56
- $EM_Location = new EM_Location($location);
57
- $EM_Location->image_upload();
58
- }
59
-
60
- function dbem_delete_image_files_for_location_id($location_id) {
61
- $EM_Location = new EM_Location($location_id);
62
- $EM_Location->image_delete();
63
- }
64
-
65
- function dbem_replace_locations_placeholders($format, $location, $target="html") {
66
- $EM_Location = new EM_Location($location);
67
- return $EM_Location->output($format, $target);
68
- }
69
-
70
- /*
71
- Deleted these functions due to not being used (and unecessary):
72
- function dbem_cache_location($event){}
73
- function dbem_get_location_by_name($name) {}
74
- function dbem_insert_location_from_event($event) {}
75
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: nutsmuggler, netweblogic
3
  Donate link: http://wp-events-plugin.com
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.8
8
 
9
  Manage events and display them in your blog. Includes recurring events, location management, calendar, Google map integration, RSVP.
10
 
@@ -20,7 +20,7 @@ Events manager is fully customisable; you can customise the amount of data displ
20
 
21
  Events Manager is fully localisable and already localised in Italian, Spanish, German and Swedish.
22
 
23
- For more information visit the [Documentation Page](http://wp-events-plugin.com/documentation/) and [Support Forum](http://davidebenini.it/events-manager-forum/).
24
 
25
  == Installation ==
26
 
@@ -53,7 +53,7 @@ After the installation, Events Manager add a top level "Events" menu to your Wor
53
  * The *Settings* page allows a fine-grained control over the plugin. Here you can set the [format](#formatting-events) of events in the Events page.
54
  * The *Help* page will provide you with information on troubleshooting and where to ask for support.
55
 
56
- Events list and calendars can be added to your blogs through widgets, shortcodes and template tags. See the full documentation at the [Events Manager Support Page](http://davidebenini.it/wordpress-plugins/events-manager/).
57
 
58
  == Frequently Asked Questions ==
59
 
@@ -109,6 +109,22 @@ At this stage, Events Manager is only available in English and Italian. Yet, the
109
  3. The Events Manager Options page.
110
 
111
  == Change Log ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  = 3.0.8 =
113
  * Event lists now have pagination links for both admin and public areas!
114
  * Fixed timezone issue with calendars, now taking time from WP settings, not server
3
  Donate link: http://wp-events-plugin.com
4
  Tags: events, manager, calendar, gigs, concert, maps, geotagging, rsvp
5
  Requires at least: 2.9
6
+ Tested up to: 3.0.3
7
+ Stable tag: 3.0.81
8
 
9
  Manage events and display them in your blog. Includes recurring events, location management, calendar, Google map integration, RSVP.
10
 
20
 
21
  Events Manager is fully localisable and already localised in Italian, Spanish, German and Swedish.
22
 
23
+ For more information visit the [Documentation Page](http://wp-events-plugin.com/documentation/) and [Support Forum](http://wp-events-plugin.com/forums/).
24
 
25
  == Installation ==
26
 
53
  * The *Settings* page allows a fine-grained control over the plugin. Here you can set the [format](#formatting-events) of events in the Events page.
54
  * The *Help* page will provide you with information on troubleshooting and where to ask for support.
55
 
56
+ Events list and calendars can be added to your blogs through widgets, shortcodes and template tags. See the full documentation at the [Events Manager Support Pages](http://wp-events-plugin.com).
57
 
58
  == Frequently Asked Questions ==
59
 
109
  3. The Events Manager Options page.
110
 
111
  == Change Log ==
112
+ = 3.0.9 =
113
+ * Fixed small calendar discrepencies
114
+ * added event and location single shortcodes
115
+ * shortcodes now accept html within format attribute or within the shortcode tags [like]<p>this</p>[/like]
116
+ * fixed pagination functionality (or lack thereof) in shortcodes
117
+ * improved user experience when navigating/editing events in admin area
118
+
119
+
120
+ = 3.0.81 =
121
+ * Fixed pagination bugs
122
+ * Global locations map won't show locations with 0-0 coords
123
+ * Fixed bug in recurrence description
124
+ * Removed most (if not all) php warnings
125
+ * Fixed booked seats calculation errors
126
+ * Removed dependence on php calendar
127
+
128
  = 3.0.8 =
129
  * Event lists now have pagination links for both admin and public areas!
130
  * Fixed timezone issue with calendars, now taking time from WP settings, not server
rss.php DELETED
@@ -1,43 +0,0 @@
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, "?") ) ? "&amp;":"?";
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 ( ">", "&gt;", str_replace ( "<", "&lt;", 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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
widgets/{calendar.php → em-calendar.php} RENAMED
File without changes
widgets/{events.php → em-events.php} RENAMED
File without changes
widgets/{locations.php → em-locations.php} RENAMED
File without changes