Events Manager - Version 3.0.96

Version Description

  • fixed js hook bug, you must now bind your function to the document's custom em_maps_locations_hook and em_maps_location_hook event triggers using jquery
  • fixed tinymce bug with linking which cropped up in 3.1 due to new WP linking window.
  • event_date_modified now properly updated
Download this release

Release Info

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

Code changes from version 3.0.95 to 3.0.96

Files changed (75) hide show
  1. admin/bookings/em-cancelled.php +16 -13
  2. admin/bookings/em-confirmed.php +19 -16
  3. admin/bookings/em-events.php +4 -5
  4. admin/bookings/em-pending.php +27 -22
  5. admin/bookings/em-person.php +12 -10
  6. admin/bookings/em-rejected.php +17 -14
  7. admin/em-admin.php +16 -117
  8. admin/em-bookings.php +137 -56
  9. admin/em-categories.php +3 -3
  10. admin/em-docs.php +8 -4
  11. admin/em-event.php +296 -198
  12. admin/em-events.php +56 -54
  13. admin/em-locations-search.php +6 -2
  14. admin/em-locations.php +68 -72
  15. admin/em-options.php +81 -32
  16. admin/em-people.php +9 -124
  17. buddypress/bp-em-activity.php +106 -0
  18. buddypress/bp-em-admin.php +65 -0
  19. buddypress/bp-em-core.php +175 -0
  20. buddypress/bp-em-notifications.php +157 -0
  21. buddypress/bp-em-templatetags.php +7 -0
  22. buddypress/screens/attending.php +40 -0
  23. buddypress/screens/my-events.php +65 -0
  24. buddypress/screens/my-locations.php +72 -0
  25. buddypress/screens/profile.php +54 -0
  26. buddypress/screens/settings.php +56 -0
  27. classes/em-booking.php +229 -64
  28. classes/em-bookings.php +222 -114
  29. classes/em-calendar.php +367 -365
  30. classes/em-categories.php +19 -18
  31. classes/em-category.php +55 -31
  32. classes/em-event.php +243 -87
  33. classes/em-events.php +69 -22
  34. classes/em-location.php +152 -71
  35. classes/em-locations.php +35 -27
  36. classes/em-notices.php +170 -0
  37. classes/em-object.php +78 -10
  38. classes/em-people.php +9 -71
  39. classes/em-permalinks.php +200 -0
  40. classes/em-person.php +43 -128
  41. classes/em-recurrence.php +0 -89
  42. classes/em-ticket-booking.php +209 -0
  43. classes/em-ticket.php +333 -0
  44. classes/em-tickets-bookings.php +261 -0
  45. classes/em-tickets.php +204 -0
  46. em-actions.php +241 -0
  47. em-ajax.php +0 -101
  48. em-bookings.php +248 -148
  49. em-debug.php +46 -0
  50. em-events.php +39 -18
  51. em-functions.php +72 -37
  52. em-ical.php +80 -0
  53. em-install.php +178 -319
  54. em-rss.php +5 -2
  55. events-manager.php +174 -57
  56. includes/css/events_manager.css +9 -33
  57. includes/css/events_manager_admin.css +29 -1
  58. includes/images/close.png +0 -0
  59. includes/js/em_admin.js +196 -77
  60. includes/js/em_maps.js +90 -90
  61. includes/js/em_ui.js +13 -1
  62. includes/langs/events-manager.pot +1547 -1014
  63. includes/{sample-placeholers → sample-placeholders}/booking-email.html +0 -0
  64. includes/{sample-placeholers → sample-placeholders}/event-single.html +0 -0
  65. readme.txt +8 -3
  66. templates/buddypress/events/my-events.php +191 -0
  67. templates/buddypress/locations/my-locations.php +86 -0
  68. templates/forms/events/attributes-box.php +14 -0
  69. templates/forms/events/bookings-box.php +46 -0
  70. templates/forms/events/categories-box.php +25 -0
  71. templates/forms/events/editor.php +201 -0
  72. templates/forms/events/recurrence-box.php +64 -0
  73. templates/forms/locations/editor.php +117 -0
  74. templates/placeholders/attendees.php +12 -0
  75. widgets/em-events.php +4 -4
admin/bookings/em-cancelled.php CHANGED
@@ -5,7 +5,7 @@
5
  * @param int $event_id
6
  */
7
  function em_bookings_cancelled_table(){
8
- global $EM_Event, $wpdb, $current_user;
9
 
10
  $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_cancelled_table' );
11
  $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
@@ -14,12 +14,16 @@ function em_bookings_cancelled_table(){
14
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
15
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
16
 
17
- if( is_object($EM_Event) ){
18
- $bookings = $EM_Event->get_bookings()->get_cancelled_bookings();
19
  }else{
20
- return false;
 
 
 
 
21
  }
22
- $bookings_count = (is_array($bookings)) ? count($bookings):0;
23
  ?>
24
  <div class='wrap em_bookings_pending_table em_obj'>
25
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
@@ -61,8 +65,7 @@ function em_bookings_cancelled_table(){
61
  -->
62
  <?php
63
  if ( $bookings_count >= $limit ) {
64
- $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
65
- $bookings_nav = em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
66
  echo $bookings_nav;
67
  }
68
  ?>
@@ -89,23 +92,23 @@ function em_bookings_cancelled_table(){
89
  <?php
90
  $rowno = 0;
91
  $event_count = 0;
92
- foreach ($bookings as $EM_Booking) {
93
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
94
  $rowno++;
95
  ?>
96
  <tr>
97
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
98
- <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
99
- <td><?php echo $EM_Booking->person->email ?></td>
100
  <td><?php echo $EM_Booking->person->phone ?></td>
101
- <td><?php echo $EM_Booking->seats ?></td>
102
  <td>
103
  <?php
104
  $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
105
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
106
  ?>
107
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Restore','dbem'); ?></a> |
108
- <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a> |
109
  <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
110
  </td>
111
  </tr>
@@ -121,7 +124,7 @@ function em_bookings_cancelled_table(){
121
  <?php _e('No cancelled bookings.', 'dbem'); ?>
122
  <?php endif; ?>
123
  </form>
124
- <?php if( !empty($bookings_nav) ) : ?>
125
  <div class='tablenav'>
126
  <?php echo $bookings_nav; ?>
127
  <div class="clear"></div>
5
  * @param int $event_id
6
  */
7
  function em_bookings_cancelled_table(){
8
+ global $EM_Event, $EM_Ticket, $wpdb, $current_user;
9
 
10
  $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_cancelled_table' );
11
  $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
14
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
15
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
16
 
17
+ if( is_object($EM_Ticket) ){
18
+ $EM_Bookings = $EM_Ticket->get_bookings()->get_cancelled_bookings();
19
  }else{
20
+ if( is_object($EM_Event) ){
21
+ $EM_Bookings = $EM_Event->get_bookings()->get_cancelled_bookings();
22
+ }else{
23
+ return false;
24
+ }
25
  }
26
+ $bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
27
  ?>
28
  <div class='wrap em_bookings_pending_table em_obj'>
29
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
65
  -->
66
  <?php
67
  if ( $bookings_count >= $limit ) {
68
+ $bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
 
69
  echo $bookings_nav;
70
  }
71
  ?>
92
  <?php
93
  $rowno = 0;
94
  $event_count = 0;
95
+ foreach ($EM_Bookings->bookings as $EM_Booking) {
96
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
97
  $rowno++;
98
  ?>
99
  <tr>
100
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
101
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->ID; ?>"><?php echo $EM_Booking->person->display_name ?></a></td>
102
+ <td><?php echo $EM_Booking->person->user_email ?></td>
103
  <td><?php echo $EM_Booking->person->phone ?></td>
104
+ <td><?php echo $EM_Booking->get_spaces() ?></td>
105
  <td>
106
  <?php
107
  $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
108
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
109
  ?>
110
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Restore','dbem'); ?></a> |
111
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit/View','dbem'); ?></a> |
112
  <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
113
  </td>
114
  </tr>
124
  <?php _e('No cancelled bookings.', 'dbem'); ?>
125
  <?php endif; ?>
126
  </form>
127
+ <?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
128
  <div class='tablenav'>
129
  <?php echo $bookings_nav; ?>
130
  <div class="clear"></div>
admin/bookings/em-confirmed.php CHANGED
@@ -6,7 +6,7 @@
6
  * @param int $event_id
7
  */
8
  function em_bookings_confirmed_table(){
9
- global $EM_Event, $wpdb, $current_user;
10
 
11
  $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
12
  $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
@@ -15,12 +15,16 @@ function em_bookings_confirmed_table(){
15
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
16
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
17
 
18
- if( is_object($EM_Event) ){
19
- $bookings = $EM_Event->get_bookings()->get_bookings();
20
  }else{
21
- return false;
 
 
 
 
22
  }
23
- $bookings_count = (is_array($bookings)) ? count($bookings):0;
24
  ?>
25
  <div class='wrap em_bookings_pending_table em_obj'>
26
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
@@ -62,8 +66,7 @@ function em_bookings_confirmed_table(){
62
  -->
63
  <?php
64
  if ( $bookings_count >= $limit ) {
65
- $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
66
- $bookings_nav = em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
67
  echo $bookings_nav;
68
  }
69
  ?>
@@ -90,29 +93,29 @@ function em_bookings_confirmed_table(){
90
  <?php
91
  $rowno = 0;
92
  $event_count = 0;
93
- foreach ($bookings as $EM_Booking) {
94
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
95
  $rowno++;
96
  ?>
97
  <tr>
98
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
99
- <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person_id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
100
- <td><?php echo $EM_Booking->person->email ?></td>
101
  <td><?php echo $EM_Booking->person->phone ?></td>
102
- <td><?php echo $EM_Booking->seats ?></td>
103
- <td>
104
  <?php
105
  $unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_unapprove', 'booking_id'=>$EM_Booking->id));
106
  $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->id));
107
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
108
  ?>
109
- <?php if( get_option('dbem_bookings_approval') ): ?>
110
  <a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
111
  <?php else: ?>
112
  <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
113
  <?php endif; ?>
114
- <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a> |
115
- <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a>
116
  </td>
117
  </tr>
118
  <?php
@@ -127,7 +130,7 @@ function em_bookings_confirmed_table(){
127
  <?php _e('No confirmed bookings.', 'dbem'); ?>
128
  <?php endif; ?>
129
  </form>
130
- <?php if( !empty($bookings_nav) ) : ?>
131
  <div class='tablenav'>
132
  <?php echo $bookings_nav; ?>
133
  <div class="clear"></div>
6
  * @param int $event_id
7
  */
8
  function em_bookings_confirmed_table(){
9
+ global $EM_Event, $EM_Ticket, $wpdb, $current_user;
10
 
11
  $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
12
  $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
15
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
16
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
17
 
18
+ if( is_object($EM_Ticket) ){
19
+ $EM_Bookings = $EM_Ticket->get_bookings()->get_bookings();
20
  }else{
21
+ if( is_object($EM_Event) ){
22
+ $EM_Bookings = $EM_Event->get_bookings()->get_bookings();
23
+ }else{
24
+ return false;
25
+ }
26
  }
27
+ $bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
28
  ?>
29
  <div class='wrap em_bookings_pending_table em_obj'>
30
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
66
  -->
67
  <?php
68
  if ( $bookings_count >= $limit ) {
69
+ $bookings_nav = em_admin_paginate($bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
 
70
  echo $bookings_nav;
71
  }
72
  ?>
93
  <?php
94
  $rowno = 0;
95
  $event_count = 0;
96
+ foreach ($EM_Bookings->bookings as $EM_Booking) {
97
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
98
  $rowno++;
99
  ?>
100
  <tr>
101
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
102
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person_id; ?>"><?php echo $EM_Booking->person->display_name ?></a></td>
103
+ <td><?php echo $EM_Booking->person->user_email ?></td>
104
  <td><?php echo $EM_Booking->person->phone ?></td>
105
+ <td><?php echo $EM_Booking->get_spaces() ?></td>
106
+ <td>
107
  <?php
108
  $unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_unapprove', 'booking_id'=>$EM_Booking->id));
109
  $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->id));
110
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
111
  ?>
112
+ <?php if( current_user_can('manage_bookings') ): ?>
113
  <a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
114
  <?php else: ?>
115
  <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
116
  <?php endif; ?>
117
+ <span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span> |
118
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit/View','dbem'); ?></a>
119
  </td>
120
  </tr>
121
  <?php
130
  <?php _e('No confirmed bookings.', 'dbem'); ?>
131
  <?php endif; ?>
132
  </form>
133
+ <?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
134
  <div class='tablenav'>
135
  <?php echo $bookings_nav; ?>
136
  <div class="clear"></div>
admin/bookings/em-events.php CHANGED
@@ -77,8 +77,7 @@ function em_bookings_events_table() {
77
  -->
78
  <?php
79
  if ( $events_count >= $limit ) {
80
- $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_events_table'));
81
- $events_nav = em_admin_paginate( $page_link_template, $events_count, $limit, $page, 5);
82
  echo $events_nav;
83
  }
84
  ?>
@@ -131,9 +130,9 @@ function em_bookings_events_table() {
131
  <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $event->id ?>"><?php echo ($event->name); ?></a>
132
  </strong>
133
  &ndash;
134
- <?php _e("Booked Seats",'dbem') ?>: <?php echo $event->get_bookings()->get_booked_seats()."/".$event->seats ?>
135
  <?php if( get_option('dbem_bookings_approval') == 1 ) : ?>
136
- | <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_seats(); ?>
137
  <?php endif; ?>
138
  </td>
139
 
@@ -162,7 +161,7 @@ function em_bookings_events_table() {
162
  <div class="alignleft actions">
163
  <br class='clear' />
164
  </div>
165
- <?php if( !empty($events_nav) ) : ?>
166
  <div class="tablenav-pages">
167
  <?php
168
  echo $events_nav;
77
  -->
78
  <?php
79
  if ( $events_count >= $limit ) {
80
+ $events_nav = em_admin_paginate( $events_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_events_table'));
 
81
  echo $events_nav;
82
  }
83
  ?>
130
  <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $event->id ?>"><?php echo ($event->name); ?></a>
131
  </strong>
132
  &ndash;
133
+ <?php _e("Booked Spaces",'dbem') ?>: <?php echo $event->get_bookings()->get_booked_spaces()."/".$event->get_spaces() ?>
134
  <?php if( get_option('dbem_bookings_approval') == 1 ) : ?>
135
+ | <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_spaces(); ?>
136
  <?php endif; ?>
137
  </td>
138
 
161
  <div class="alignleft actions">
162
  <br class='clear' />
163
  </div>
164
+ <?php if (!empty($events_nav) && $events_count >= $limit ) : ?>
165
  <div class="tablenav-pages">
166
  <?php
167
  echo $events_nav;
admin/bookings/em-pending.php CHANGED
@@ -7,7 +7,7 @@
7
  * @param int $event_id
8
  */
9
  function em_bookings_pending_table($event_id = false){
10
- global $EM_Event, $wpdb, $current_user;
11
 
12
  if( get_option('dbem_bookings_approval') == 0 ){
13
  return false;
@@ -20,21 +20,25 @@ function em_bookings_pending_table($event_id = false){
20
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
21
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
22
 
23
- if( is_object($EM_Event) ){
24
- $bookings = $EM_Event->get_bookings()->get_pending();
25
  }else{
26
- //To optimize performance, we can do one query here for all pending bookings to show.
27
- $bookings = EM_Bookings::get(array('status'=>0));
28
- $events = array();
29
- //Now let's create events and bookings for this:
30
- foreach($bookings as $EM_Booking){
31
- //create event
32
- if( !array_key_exists($EM_Booking->event_id,$events) ){
33
- $events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
 
 
 
 
34
  }
35
  }
36
  }
37
- $bookings_count = (is_array($bookings)) ? count($bookings):0;
38
  ?>
39
  <div class='wrap em_bookings_pending_table em_obj'>
40
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
@@ -76,8 +80,7 @@ function em_bookings_pending_table($event_id = false){
76
  -->
77
  <?php
78
  if ( $bookings_count >= $limit ) {
79
- $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_pending_table'));
80
- $bookings_nav = em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
81
  echo $bookings_nav;
82
  }
83
  ?>
@@ -94,7 +97,7 @@ function em_bookings_pending_table($event_id = false){
94
  <input class='select-all' type="checkbox" value='1' />
95
  </th>
96
  <th class='manage-column' scope='col'>Booker</th>
97
- <?php if( !is_object($EM_Event) ): ?>
98
  <th class='manage-column' scope="col">Event</th>
99
  <?php endif; ?>
100
  <th class='manage-column' scope='col'>E-mail</th>
@@ -107,27 +110,29 @@ function em_bookings_pending_table($event_id = false){
107
  <?php
108
  $rowno = 0;
109
  $event_count = 0;
110
- foreach ($bookings as $EM_Booking) {
111
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
112
  $rowno++;
113
  ?>
114
  <tr>
115
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
116
- <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
117
- <?php if( !is_object($EM_Event) ): ?>
118
  <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Booking->event_id; ?>"><?php echo $events[$EM_Booking->event_id]->name ?></a></td>
119
  <?php endif; ?>
120
- <td><?php echo $EM_Booking->person->email ?></td>
121
  <td><?php echo $EM_Booking->person->phone ?></td>
122
- <td><?php echo $EM_Booking->seats ?></td>
123
  <td>
124
  <?php
125
  $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
126
  $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->id));
 
127
  ?>
128
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
129
  <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
130
- <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a>
 
131
  </td>
132
  </tr>
133
  <?php
@@ -142,7 +147,7 @@ function em_bookings_pending_table($event_id = false){
142
  <?php _e('No pending bookings.', 'dbem'); ?>
143
  <?php endif; ?>
144
  </form>
145
- <?php if( !empty($bookings_nav) ) : ?>
146
  <div class='tablenav'>
147
  <?php echo $bookings_nav; ?>
148
  <div class="clear"></div>
7
  * @param int $event_id
8
  */
9
  function em_bookings_pending_table($event_id = false){
10
+ global $EM_Event, $EM_Ticket, $wpdb, $current_user;
11
 
12
  if( get_option('dbem_bookings_approval') == 0 ){
13
  return false;
20
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
21
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
22
 
23
+ if( is_object($EM_Ticket) ){
24
+ $EM_Bookings = $EM_Ticket->get_bookings()->get_pending_bookings();
25
  }else{
26
+ if( is_object($EM_Event) ){
27
+ $EM_Bookings = $EM_Event->get_bookings()->get_pending_bookings();
28
+ }else{
29
+ //To optimize performance, we can do one query here for all pending bookings to show.
30
+ $EM_Bookings = EM_Bookings::get(array('status'=>0));
31
+ $events = array();
32
+ //Now let's create events and bookings for this:
33
+ foreach($EM_Bookings->bookings as $EM_Booking){
34
+ //create event
35
+ if( !array_key_exists($EM_Booking->event_id,$events) ){
36
+ $events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
37
+ }
38
  }
39
  }
40
  }
41
+ $bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
42
  ?>
43
  <div class='wrap em_bookings_pending_table em_obj'>
44
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
80
  -->
81
  <?php
82
  if ( $bookings_count >= $limit ) {
83
+ $bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_pending_table'));
 
84
  echo $bookings_nav;
85
  }
86
  ?>
97
  <input class='select-all' type="checkbox" value='1' />
98
  </th>
99
  <th class='manage-column' scope='col'>Booker</th>
100
+ <?php if( !is_object($EM_Event) && !is_object($EM_Ticket) ): ?>
101
  <th class='manage-column' scope="col">Event</th>
102
  <?php endif; ?>
103
  <th class='manage-column' scope='col'>E-mail</th>
110
  <?php
111
  $rowno = 0;
112
  $event_count = 0;
113
+ foreach ($EM_Bookings->bookings as $EM_Booking) {
114
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
115
  $rowno++;
116
  ?>
117
  <tr>
118
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
119
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->ID; ?>"><?php echo $EM_Booking->person->display_name ?></a></td>
120
+ <?php if( !is_object($EM_Event) && !is_object($EM_Ticket) ): ?>
121
  <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Booking->event_id; ?>"><?php echo $events[$EM_Booking->event_id]->name ?></a></td>
122
  <?php endif; ?>
123
+ <td><?php echo $EM_Booking->person->user_email ?></td>
124
  <td><?php echo $EM_Booking->person->phone ?></td>
125
+ <td><?php echo $EM_Booking->get_spaces() ?></td>
126
  <td>
127
  <?php
128
  $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
129
  $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->id));
130
+ $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
131
  ?>
132
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
133
  <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
134
+ <span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span> |
135
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit/View','dbem'); ?></a>
136
  </td>
137
  </tr>
138
  <?php
147
  <?php _e('No pending bookings.', 'dbem'); ?>
148
  <?php endif; ?>
149
  </form>
150
+ <?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
151
  <div class='tablenav'>
152
  <?php echo $bookings_nav; ?>
153
  <div class="clear"></div>
admin/bookings/em-person.php CHANGED
@@ -18,7 +18,7 @@ function em_bookings_person_table(){
18
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
19
 
20
  $bookings = $EM_Person->get_bookings();
21
- $bookings_count = (is_array($bookings)) ? count($bookings):0;
22
  if($bookings_count > 0){
23
  //Get events here in one query to speed things up
24
  foreach($bookings as $EM_Booking){
@@ -67,8 +67,7 @@ function em_bookings_person_table(){
67
  -->
68
  <?php
69
  if ( $bookings_count >= $limit ) {
70
- $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
71
- $bookings_nav = em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
72
  echo $bookings_nav;
73
  }
74
  ?>
@@ -96,13 +95,13 @@ function em_bookings_person_table(){
96
  $event_count = 0;
97
  foreach ($bookings as $EM_Booking) {
98
  $EM_Event = $events[$EM_Booking->event_id];
99
- if( $EM_Event->can_manage() && ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
100
  $rowno++;
101
  ?>
102
  <tr>
103
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
104
  <td><a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Event->id ?>"><?php echo ($EM_Event->name); ?></a></td>
105
- <td><?php echo $EM_Booking->seats ?></td>
106
  <td><?php echo $EM_Booking->status_array[$EM_Booking->status]; ?>
107
  </td>
108
  <td>
@@ -112,17 +111,20 @@ function em_bookings_person_table(){
112
  $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'bookings'=>$EM_Booking->id));
113
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'bookings'=>$EM_Booking->id));
114
  ?>
115
- <?php if( $EM_Booking->status == 0 || $EM_Booking->status == 2 ): ?>
116
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
117
  <?php endif; ?>
118
- <?php if( $EM_Booking->status == 2 ): ?>
119
  <a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
120
  <?php endif; ?>
 
 
 
121
  <?php if( $EM_Booking->status == 0 || $EM_Booking->status == 1 ): ?>
122
  <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
123
  <?php endif; ?>
124
- <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a> |
125
- <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
126
  </td>
127
  </tr>
128
  <?php
@@ -137,7 +139,7 @@ function em_bookings_person_table(){
137
  <?php _e('No confirmed bookings.', 'dbem'); ?>
138
  <?php endif; ?>
139
  </form>
140
- <?php if( !empty($bookings_nav) ) : ?>
141
  <div class='tablenav'>
142
  <?php echo $bookings_nav; ?>
143
  <div class="clear"></div>
18
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
19
 
20
  $bookings = $EM_Person->get_bookings();
21
+ $bookings_count = count($bookings);
22
  if($bookings_count > 0){
23
  //Get events here in one query to speed things up
24
  foreach($bookings as $EM_Booking){
67
  -->
68
  <?php
69
  if ( $bookings_count >= $limit ) {
70
+ $bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
 
71
  echo $bookings_nav;
72
  }
73
  ?>
95
  $event_count = 0;
96
  foreach ($bookings as $EM_Booking) {
97
  $EM_Event = $events[$EM_Booking->event_id];
98
+ if( $EM_Event->can_manage('edit_events','edit_others_events') && ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
99
  $rowno++;
100
  ?>
101
  <tr>
102
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
103
  <td><a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Event->id ?>"><?php echo ($EM_Event->name); ?></a></td>
104
+ <td><?php echo $EM_Booking->get_spaces() ?></td>
105
  <td><?php echo $EM_Booking->status_array[$EM_Booking->status]; ?>
106
  </td>
107
  <td>
111
  $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'bookings'=>$EM_Booking->id));
112
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'bookings'=>$EM_Booking->id));
113
  ?>
114
+ <?php if( get_option('dbem_bookings_approval') && ($EM_Booking->status == 0 ) ): ?>
115
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
116
  <?php endif; ?>
117
+ <?php if( get_option('dbem_bookings_approval') && $EM_Booking->status == 1 ): ?>
118
  <a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
119
  <?php endif; ?>
120
+ <?php if( $EM_Booking->status == 2 ): ?>
121
+ <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Restore','dbem'); ?></a> |
122
+ <?php endif; ?>
123
  <?php if( $EM_Booking->status == 0 || $EM_Booking->status == 1 ): ?>
124
  <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
125
  <?php endif; ?>
126
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit/View','dbem'); ?></a> |
127
+ <span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span>
128
  </td>
129
  </tr>
130
  <?php
139
  <?php _e('No confirmed bookings.', 'dbem'); ?>
140
  <?php endif; ?>
141
  </form>
142
+ <?php if( !empty($bookings_nav) && $bookings >= $limit ) : ?>
143
  <div class='tablenav'>
144
  <?php echo $bookings_nav; ?>
145
  <div class="clear"></div>
admin/bookings/em-rejected.php CHANGED
@@ -5,7 +5,7 @@
5
  * @param int $event_id
6
  */
7
  function em_bookings_rejected_table(){
8
- global $EM_Event, $wpdb, $current_user;
9
 
10
  $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
11
  $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
@@ -14,12 +14,16 @@ function em_bookings_rejected_table(){
14
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
15
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
16
 
17
- if( is_object($EM_Event) ){
18
- $bookings = $EM_Event->get_bookings()->get_rejected_bookings();
19
  }else{
20
- return false;
 
 
 
 
21
  }
22
- $bookings_count = (is_array($bookings)) ? count($bookings):0;
23
  ?>
24
  <div class='wrap em_bookings_pending_table em_obj'>
25
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
@@ -61,8 +65,7 @@ function em_bookings_rejected_table(){
61
  -->
62
  <?php
63
  if ( $bookings_count >= $limit ) {
64
- $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
65
- $bookings_nav = em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
66
  echo $bookings_nav;
67
  }
68
  ?>
@@ -89,24 +92,24 @@ function em_bookings_rejected_table(){
89
  <?php
90
  $rowno = 0;
91
  $event_count = 0;
92
- foreach ($bookings as $EM_Booking) {
93
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
94
  $rowno++;
95
  ?>
96
  <tr>
97
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
98
- <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
99
- <td><?php echo $EM_Booking->person->email ?></td>
100
  <td><?php echo $EM_Booking->person->phone ?></td>
101
- <td><?php echo $EM_Booking->seats ?></td>
102
  <td>
103
  <?php
104
  $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
105
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
106
  ?>
107
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
108
- <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a> |
109
- <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
110
  </td>
111
  </tr>
112
  <?php
@@ -121,7 +124,7 @@ function em_bookings_rejected_table(){
121
  <?php _e('No rejected bookings.', 'dbem'); ?>
122
  <?php endif; ?>
123
  </form>
124
- <?php if( !empty($bookings_nav) ) : ?>
125
  <div class='tablenav'>
126
  <?php echo $bookings_nav; ?>
127
  <div class="clear"></div>
5
  * @param int $event_id
6
  */
7
  function em_bookings_rejected_table(){
8
+ global $EM_Event, $EM_Ticket, $wpdb, $current_user;
9
 
10
  $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
11
  $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
14
  $page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
15
  $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
16
 
17
+ if( is_object($EM_Ticket) ){
18
+ $EM_Bookings = $EM_Ticket->get_bookings()->get_rejected_bookings();
19
  }else{
20
+ if( is_object($EM_Event) ){
21
+ $EM_Bookings = $EM_Event->get_bookings()->get_rejected_bookings();
22
+ }else{
23
+ return false;
24
+ }
25
  }
26
+ $bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
27
  ?>
28
  <div class='wrap em_bookings_pending_table em_obj'>
29
  <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
65
  -->
66
  <?php
67
  if ( $bookings_count >= $limit ) {
68
+ $bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
 
69
  echo $bookings_nav;
70
  }
71
  ?>
92
  <?php
93
  $rowno = 0;
94
  $event_count = 0;
95
+ foreach ($EM_Bookings->bookings as $EM_Booking) {
96
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
97
  $rowno++;
98
  ?>
99
  <tr>
100
  <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
101
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->ID; ?>"><?php echo $EM_Booking->person->display_name ?></a></td>
102
+ <td><?php echo $EM_Booking->person->user_email ?></td>
103
  <td><?php echo $EM_Booking->person->phone ?></td>
104
+ <td><?php echo $EM_Booking->get_spaces() ?></td>
105
  <td>
106
  <?php
107
  $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
108
  $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
109
  ?>
110
  <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
111
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit/View','dbem'); ?></a> |
112
+ <span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a></span> |
113
  </td>
114
  </tr>
115
  <?php
124
  <?php _e('No rejected bookings.', 'dbem'); ?>
125
  <?php endif; ?>
126
  </form>
127
+ <?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
128
  <div class='tablenav'>
129
  <?php echo $bookings_nav; ?>
130
  <div class="clear"></div>
admin/em-admin.php CHANGED
@@ -9,7 +9,7 @@ function em_admin_warnings() {
9
  $events_page_id = get_option ( 'dbem_events_page' );
10
  $dismiss_link_joiner = ( count($_GET) > 0 ) ? '&amp;':'?';
11
 
12
- if( em_verify_admin() ){
13
  //New User Intro
14
  if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true'){
15
  // Disable Hello to new user if requested
@@ -74,14 +74,21 @@ add_action ( 'admin_notices', 'em_admin_warnings' );
74
  * @return string
75
  * @uses em_paginate()
76
  */
77
- function em_admin_paginate($link, $total, $limit, $page=1, $pagesToShow=5){
78
  $return = '<div class="tablenav-pages">';
79
- $return .= sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>',
80
- number_format_i18n( ( $page - 1 ) * $limit + 1 ),
81
- number_format_i18n( min( $page * $limit, $total ) ),
82
- number_format_i18n( $total )
83
- );
84
- $return .= em_paginate($link, $total, $limit, $page, $pagesToShow);
 
 
 
 
 
 
 
85
  $return .= '</div>';
86
  return $return;
87
  }
@@ -144,118 +151,10 @@ function em_admin_general_script() {
144
  ?>
145
  <script type="text/javascript">
146
  //<![CDATA[
147
- // TODO: make more general, to support also latitude and longitude (when added)
148
-
149
  jQuery(document).ready( function($) {
150
-
151
- function updateIntervalDescriptor () {
152
- $(".interval-desc").hide();
153
- var number = "-plural";
154
- if ($('input#recurrence-interval').val() == 1 || $('input#recurrence-interval').val() == "")
155
- number = "-singular"
156
- var descriptor = "span#interval-"+$("select#recurrence-frequency").val()+number;
157
- $(descriptor).show();
158
- }
159
- function updateIntervalSelectors () {
160
- $('p.alternate-selector').hide();
161
- $('p#'+ $('select#recurrence-frequency').val() + "-selector").show();
162
- }
163
- function updateShowHideRsvp () {
164
- if($('input#rsvp-checkbox').attr("checked")) {
165
- $("div#rsvp-data").fadeIn();
166
- } else {
167
- $("div#rsvp-data").hide();
168
- }
169
- }
170
- function updateShowHideRecurrence () {
171
- if( $('input#event-recurrence').attr("checked")) {
172
- $("#event_recurrence_pattern").fadeIn();
173
- $("#event-date-explanation").hide();
174
- $("#recurrence-dates-explanation").show();
175
- $("h3#recurrence-dates-title").show();
176
- $("h3#event-date-title").hide();
177
- } else {
178
- $("#event_recurrence_pattern").hide();
179
- $("#recurrence-dates-explanation").hide();
180
- $("#event-date-explanation").show();
181
- $("h3#recurrence-dates-title").hide();
182
- $("h3#event-date-title").show();
183
- }
184
- }
185
- $("#recurrence-dates-explanation").hide();
186
- $("#localised-date").show();
187
- $("#localised-end-date").show();
188
-
189
- $("#date-to-submit").hide();
190
- $("#end-date-to-submit").hide();
191
-
192
  $("#start-time").timeEntry({spinnerImage: '', show24Hours: <?php echo $show24Hours; ?> });
193
  $("#end-time").timeEntry({spinnerImage: '', show24Hours: <?php echo $show24Hours; ?>});
194
-
195
- $('input.select-all').change(function(){
196
- if($(this).is(':checked'))
197
- $('input.row-selector').attr('checked', true);
198
- else
199
- $('input.row-selector').attr('checked', false);
200
- });
201
-
202
- updateIntervalDescriptor();
203
- updateIntervalSelectors();
204
- updateShowHideRecurrence();
205
- updateShowHideRsvp();
206
- $('input#event-recurrence').change(updateShowHideRecurrence);
207
- $('input#rsvp-checkbox').change(updateShowHideRsvp);
208
-
209
- // recurrency elements
210
- $('input#recurrence-interval').keyup(updateIntervalDescriptor);
211
- $('select#recurrence-frequency').change(updateIntervalDescriptor);
212
- $('select#recurrence-frequency').change(updateIntervalSelectors);
213
-
214
- // hiding or showing notes according to their content
215
- $('.postbox h3').prepend('<a class="togbox">+</a> ');
216
- $('#event_notes h3').click( function() {
217
- $(this).parent().first().toggleClass('closed');
218
- });
219
-
220
- // users cannot submit the event form unless some fields are filled
221
- function validateEventForm(){
222
- errors = "";
223
- var recurring = $("input[@name=repeated_event]:checked").val();
224
- requiredFields= new Array('event_name', 'localised_event_date', 'location_name','location_address','location_town');
225
- var localisedRequiredFields = {
226
- 'event_name':"<?php _e ( 'Name', 'dbem' )?>",
227
- 'localised_event_date':"<?php _e ( 'Date', 'dbem' )?>",
228
- 'location_name':"<?php _e ( 'Location', 'dbem' )?>",
229
- 'location_address':"<?php _e ( 'Address', 'dbem' )?>",
230
- 'location_town':"<?php _e ( 'Town', 'dbem' )?>"
231
- };
232
- missingFields = new Array;
233
- for (var i in requiredFields) {
234
- if ($("input[@name=" + requiredFields[i]+ "]").val() == 0) {
235
- missingFields.push(localisedRequiredFields[requiredFields[i]]);
236
- $("input[@name=" + requiredFields[i]+ "]").css('border','2px solid red');
237
- } else {
238
- $("input[@name=" + requiredFields[i]+ "]").css('border','1px solid #DFDFDF');
239
- }
240
- }
241
-
242
- // alert('ciao ' + recurring+ " end: " + $("input[@name=localised_event_end_date]").val());
243
- if (missingFields.length > 0) {
244
- errors = "<?php _e ( 'Some required fields are missing:', 'dbem' )?> " + missingFields.join(", ") + ".\n";
245
- }
246
- if(recurring && $("input[@name=localised_event_end_date]").val() == "") {
247
- errors = errors + "<?php _e ( 'Since the event is repeated, you must specify an end date', 'dbem' )?>.";
248
- $("input[@name=localised_event_end_date]").css('border','2px solid red');
249
- } else {
250
- $("input[@name=localised_event_end_date]").css('border','1px solid #DFDFDF');
251
- }
252
- if(errors != "") {
253
- alert(errors);
254
- return false;
255
- }
256
- return true;
257
- }
258
- $('#event-form').bind("submit", validateEventForm);
259
  });
260
  //]]>
261
  </script>
9
  $events_page_id = get_option ( 'dbem_events_page' );
10
  $dismiss_link_joiner = ( count($_GET) > 0 ) ? '&amp;':'?';
11
 
12
+ if( current_user_can('activate_plugins') ){
13
  //New User Intro
14
  if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true'){
15
  // Disable Hello to new user if requested
74
  * @return string
75
  * @uses em_paginate()
76
  */
77
+ function em_admin_paginate($total, $limit, $page=1, $vars=false){
78
  $return = '<div class="tablenav-pages">';
79
+ $events_nav = paginate_links( array(
80
+ 'base' => add_query_arg( 'pno', '%#%' ),
81
+ 'format' => '',
82
+ 'total' => ceil($total / $limit),
83
+ 'current' => $page,
84
+ 'add_args' => $vars
85
+ ));
86
+ $return .= sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
87
+ number_format_i18n( ( $page - 1 ) * $limit + 1 ),
88
+ number_format_i18n( min( $page * $limit, $total ) ),
89
+ number_format_i18n( $total ),
90
+ $events_nav
91
+ );
92
  $return .= '</div>';
93
  return $return;
94
  }
151
  ?>
152
  <script type="text/javascript">
153
  //<![CDATA[
154
+ // TODO: make more general, to support also latitude and longitude (when added)
 
155
  jQuery(document).ready( function($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  $("#start-time").timeEntry({spinnerImage: '', show24Hours: <?php echo $show24Hours; ?> });
157
  $("#end-time").timeEntry({spinnerImage: '', show24Hours: <?php echo $show24Hours; ?>});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  });
159
  //]]>
160
  </script>
admin/em-bookings.php CHANGED
@@ -64,6 +64,8 @@ function em_bookings_page(){
64
  em_bookings_person();
65
  }elseif( !empty($_REQUEST['event_id']) ){
66
  em_bookings_event();
 
 
67
  }else{
68
  em_bookings_dashboard();
69
  }
@@ -81,12 +83,13 @@ function em_bookings_dashboard(){
81
  <h2>
82
  <?php _e('Event Bookings Dashboard', 'dbem'); ?>
83
  </h2>
84
- <?php if( get_option('dbem_bookings_approval') ): ?>
85
  <h2><?php _e('Pending Bookings','dbem'); ?></h2>
86
  <?php em_bookings_pending_table(); ?>
87
  <?php endif; ?>
88
  <h2><?php _e('Events With Bookings Enabled','dbem'); ?></h2>
89
  <?php em_bookings_events_table(); ?>
 
90
  </div>
91
  <?php
92
  }
@@ -97,7 +100,7 @@ function em_bookings_dashboard(){
97
  function em_bookings_event(){
98
  global $EM_Event,$EM_Person;
99
  //check that user can access this page
100
- if( is_object($EM_Event) && !$EM_Event->can_manage() ){
101
  ?>
102
  <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
103
  <?php
@@ -117,7 +120,7 @@ function em_bookings_event(){
117
  <div><a href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=".$EM_Event->id ?>'><?php _e('export csv','dbem')?></a></div>
118
  <div>
119
  <p><strong><?php _e('Event Name','dbem'); ?></strong> : <?php echo ($EM_Event->name); ?></p>
120
- <p><strong>Availability :</strong> <?php echo $EM_Event->get_bookings()->get_booked_seats() . '/'. $EM_Event->seats ." ". __('Seats confirmed','dbem'); ?></p>
121
  <p>
122
  <strong><?php _e('Date','dbem'); ?></strong> :
123
  <?php echo $localised_start_date; ?>
@@ -129,7 +132,7 @@ function em_bookings_event(){
129
  <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-locations&amp;location_id=<?php echo $EM_Event->location->id ?>"><?php echo ($EM_Event->location->name); ?></a>
130
  </p>
131
  </div>
132
- <?php if( get_option('dbem_bookings_approval') ): ?>
133
  <h2><?php _e('Pending Bookings','dbem'); ?></h2>
134
  <?php em_bookings_pending_table(); ?>
135
  <?php endif; ?>
@@ -139,10 +142,61 @@ function em_bookings_event(){
139
  <?php em_bookings_rejected_table(); ?>
140
  <h2><?php _e('Cancelled Bookings','dbem'); ?></h2>
141
  <?php em_bookings_cancelled_table(); ?>
 
142
  </div>
143
  <?php
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  /**
147
  * Shows a single booking for a single person.
148
  */
@@ -163,24 +217,84 @@ function em_bookings_single(){
163
  <h2>
164
  <?php _e('Edit Booking', 'dbem'); ?>
165
  </h2>
166
- <div id="poststuff" class="metabox-holder has-right-sidebar">
167
  <div id="post-body">
168
  <div id="post-body-content">
169
- <div id="event_name" class="stuffbox">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  <h3>
171
  <?php _e ( 'Booking Details', 'dbem' ); ?>
172
  </h3>
173
  <div class="inside">
174
- <?php em_bookings_edit_form(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  </div>
176
- </div>
177
- </div>
178
- </div>
179
- </div>
180
- <br style="clear:both;" />
181
- <div id="poststuff" class="metabox-holder has-right-sidebar">
182
- <div id="post-body">
183
- <div id="post-body-content">
184
  <div id="event_name" class="stuffbox">
185
  <h3>
186
  <?php _e ( 'Booking Notes', 'dbem' ); ?>
@@ -206,7 +320,7 @@ function em_bookings_single(){
206
  </div>
207
  </div>
208
  <br style="clear:both;" />
209
- <?php do_action('em_bookings_single_footer'); ?>
210
  </div>
211
  <?php
212
 
@@ -224,8 +338,11 @@ function em_bookings_person(){
224
  </div>
225
  <h2>
226
  <?php _e('Manage Person\'s Booking', 'dbem'); ?>
227
- <a href="admin.php?page=events-manager-bookings&action=person_delete&person_id=<?php echo $EM_Person->id; ?>" onclick="if( !confirm('<?php _e('Are you sure you want to delete this person? All bookings corresponding to this person will be deleted and this is not reversible.','dbem') ?>') ){ return false; }" class="button add-new-h2"><?php _e('Delete Person','dbem') ?></a>
 
 
228
  </h2>
 
229
  <div id="poststuff" class="metabox-holder has-right-sidebar">
230
  <div id="post-body">
231
  <div id="post-body-content">
@@ -234,55 +351,19 @@ function em_bookings_person(){
234
  <?php _e ( 'Personal Details', 'dbem' ); ?>
235
  </h3>
236
  <div class="inside">
237
- <?php em_person_edit_form(); ?>
238
  </div>
239
  </div>
240
  </div>
241
  </div>
242
  </div>
243
  <br style="clear:both;" />
 
244
  <h3><?php _e('Past And Present Bookings','dbem'); ?></h3>
245
  <?php em_bookings_person_table(); ?>
 
246
  </div>
247
  <?php
248
  }
249
 
250
- function em_bookings_edit_form(){
251
- global $EM_Booking;
252
- $EM_Event = new EM_Event($EM_Booking->event_id);
253
- $localised_start_date = date_i18n('D d M Y', $EM_Event->start);
254
- $localised_end_date = date_i18n('D d M Y', $EM_Event->end);
255
- ?>
256
- <form action="" method="post" id="em-person-form">
257
- <h4>Event Details</h4>
258
- <table>
259
- <tr><td><strong><?php _e('Name','dbem'); ?></strong></td><td><a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Event->id ?>"><?php echo ($EM_Event->name); ?></a></td></tr>
260
- <tr>
261
- <td><strong><?php _e('Date/Time','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
262
- <td>
263
- <?php echo $localised_start_date; ?>
264
- <?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
265
- <?php echo substr ( $EM_Event->start_time, 0, 5 ) . " - " . substr ( $EM_Event->end_time, 0, 5 ); ?>
266
- </td>
267
- </tr>
268
- </table>
269
- <h4>Personal Details</h4>
270
- <table>
271
- <tr><td><strong><?php _e('Name','dbem'); ?> </strong></td><td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person_id; ?>"><?php echo $EM_Booking->person->name ?></a></td></tr>
272
- <tr><td><strong><?php _e('Phone','dbem'); ?> </strong></td><td><?php echo $EM_Booking->person->phone; ?></td></tr>
273
- <tr><td><strong><?php _e('E-mail','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td><td><?php echo $EM_Booking->person->email; ?></td></tr>
274
- </table>
275
- <h4>Booking Details</h4>
276
- <table>
277
- <tr><td><strong><?php _e('Spaces','dbem'); ?> </strong></td><td><input type="text" name="booking_seats" value="<?php echo $EM_Booking->seats; ?>" /></td></tr>
278
- <tr><td><strong><?php _e('Comment','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td><td><textarea name="booking_comment"><?php echo $EM_Booking->comment; ?></textarea></td></tr>
279
- </table>
280
- <p class="submit">
281
- <input type="submit" name="events_update" value="<?php _e ( 'Save' ); ?> &raquo;" />
282
- </p>
283
- <input type="hidden" name="action" value="bookings_edit" />
284
- <input type="hidden" name="booking_id" value="<?php echo $EM_Booking->id; ?>" />
285
- </form>
286
- <?php
287
- }
288
  ?>
64
  em_bookings_person();
65
  }elseif( !empty($_REQUEST['event_id']) ){
66
  em_bookings_event();
67
+ }elseif( !empty($_REQUEST['ticket_id']) ){
68
+ em_bookings_ticket();
69
  }else{
70
  em_bookings_dashboard();
71
  }
83
  <h2>
84
  <?php _e('Event Bookings Dashboard', 'dbem'); ?>
85
  </h2>
86
+ <?php if( get_option('dbem_bookings_approval')): ?>
87
  <h2><?php _e('Pending Bookings','dbem'); ?></h2>
88
  <?php em_bookings_pending_table(); ?>
89
  <?php endif; ?>
90
  <h2><?php _e('Events With Bookings Enabled','dbem'); ?></h2>
91
  <?php em_bookings_events_table(); ?>
92
+ <?php do_action('em_bookings_dashboard'); ?>
93
  </div>
94
  <?php
95
  }
100
  function em_bookings_event(){
101
  global $EM_Event,$EM_Person;
102
  //check that user can access this page
103
+ if( is_object($EM_Event) && !$EM_Event->can_manage('manage_bookings','manage_others_bookings') ){
104
  ?>
105
  <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
106
  <?php
120
  <div><a href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=".$EM_Event->id ?>'><?php _e('export csv','dbem')?></a></div>
121
  <div>
122
  <p><strong><?php _e('Event Name','dbem'); ?></strong> : <?php echo ($EM_Event->name); ?></p>
123
+ <p><strong>Availability :</strong> <?php echo $EM_Event->get_bookings()->get_booked_spaces() . '/'. $EM_Event->get_spaces() ." ". __('Spaces confirmed','dbem'); ?></p>
124
  <p>
125
  <strong><?php _e('Date','dbem'); ?></strong> :
126
  <?php echo $localised_start_date; ?>
132
  <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-locations&amp;location_id=<?php echo $EM_Event->location->id ?>"><?php echo ($EM_Event->location->name); ?></a>
133
  </p>
134
  </div>
135
+ <?php if( get_option('dbem_bookings_approval')): ?>
136
  <h2><?php _e('Pending Bookings','dbem'); ?></h2>
137
  <?php em_bookings_pending_table(); ?>
138
  <?php endif; ?>
142
  <?php em_bookings_rejected_table(); ?>
143
  <h2><?php _e('Cancelled Bookings','dbem'); ?></h2>
144
  <?php em_bookings_cancelled_table(); ?>
145
+ <?php do_action('em_bookings_event_footer', $EM_Event); ?>
146
  </div>
147
  <?php
148
  }
149
 
150
+ /**
151
+ * Shows a ticket view
152
+ */
153
+ function em_bookings_ticket(){
154
+ global $EM_Ticket;
155
+ $EM_Event = $EM_Ticket->get_event();
156
+ //check that user can access this page
157
+ if( is_object($EM_Ticket) && !$EM_Ticket->can_manage() ){
158
+ ?>
159
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this ticket.','dbem'); ?></p></div>
160
+ <?php
161
+ return false;
162
+ }
163
+ ?>
164
+ <div class='wrap'>
165
+ <div id='icon-users' class='icon32'>
166
+ <br/>
167
+ </div>
168
+ <h2>
169
+ <?php echo sprintf(__('Ticket for %s', 'dbem'), "'{$EM_Event->name}'"); ?>
170
+ <a href="admin.php?page=events-manager-event&event_id=<?php echo $EM_Event->id; ?>" class="button add-new-h2"><?php _e('View/Edit Event','dbem') ?></a>
171
+ <a href="admin.php?page=events-manager-bookings&event_id=<?php echo $EM_Event->id; ?>" class="button add-new-h2"><?php _e('View Event Bookings','dbem') ?></a>
172
+ </h2>
173
+ <div>
174
+ <table>
175
+ <tr><td><?php echo __('Name','dbem'); ?></td><td></td><td><?php echo $EM_Ticket->name; ?></td></tr>
176
+ <tr><td><?php echo __('Description','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td></td><td><?php echo ($EM_Ticket->description) ? $EM_Ticket->description : '-'; ?></td></tr>
177
+ <tr><td><?php echo __('Price','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->price) ? $EM_Ticket->price : '-'; ?></td></tr>
178
+ <tr><td><?php echo __('Spaces','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->spaces) ? $EM_Ticket->spaces : '-'; ?></td></tr>
179
+ <tr><td><?php echo __('Min','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->min) ? $EM_Ticket->min : '-'; ?></td></tr>
180
+ <tr><td><?php echo __('Max','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->max) ? $EM_Ticket->max : '-'; ?></td></tr>
181
+ <tr><td><?php echo __('Start','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->start) ? $EM_Ticket->start : '-'; ?></td></tr>
182
+ <tr><td><?php echo __('End','dbem'); ?></td><td></td><td><?php echo ($EM_Ticket->end) ? $EM_Ticket->end : '-'; ?></td></tr>
183
+ </table>
184
+ </div>
185
+ <?php if( get_option('dbem_bookings_approval')): ?>
186
+ <h2><?php _e('Pending Bookings','dbem'); ?></h2>
187
+ <?php em_bookings_pending_table(); ?>
188
+ <?php endif; ?>
189
+ <h2><?php _e('Confirmed Bookings','dbem'); ?></h2>
190
+ <?php em_bookings_confirmed_table(); ?>
191
+ <h2><?php _e('Rejected Bookings','dbem'); ?></h2>
192
+ <?php em_bookings_rejected_table(); ?>
193
+ <h2><?php _e('Cancelled Bookings','dbem'); ?></h2>
194
+ <?php em_bookings_cancelled_table(); ?>
195
+ <?php do_action('em_bookings_ticket_footer', $EM_Ticket); ?>
196
+ </div>
197
+ <?php
198
+ }
199
+
200
  /**
201
  * Shows a single booking for a single person.
202
  */
217
  <h2>
218
  <?php _e('Edit Booking', 'dbem'); ?>
219
  </h2>
220
+ <div id="poststuff" class="metabox-holder">
221
  <div id="post-body">
222
  <div id="post-body-content">
223
+ <div id="em-booking-details" class="stuffbox">
224
+ <h3>
225
+ <?php _e ( 'Event Details', 'dbem' ); ?>
226
+ </h3>
227
+ <div class="inside">
228
+ <?php
229
+ $EM_Event = $EM_Booking->get_event();
230
+ $localised_start_date = date_i18n('D d M Y', $EM_Event->start);
231
+ $localised_end_date = date_i18n('D d M Y', $EM_Event->end);
232
+ ?>
233
+ <table>
234
+ <tr><td><strong><?php _e('Name','dbem'); ?></strong></td><td><a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Event->id ?>"><?php echo ($EM_Event->name); ?></a></td></tr>
235
+ <tr>
236
+ <td><strong><?php _e('Date/Time','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
237
+ <td>
238
+ <?php echo $localised_start_date; ?>
239
+ <?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
240
+ <?php echo substr ( $EM_Event->start_time, 0, 5 ) . " - " . substr ( $EM_Event->end_time, 0, 5 ); ?>
241
+ </td>
242
+ </tr>
243
+ </table>
244
+ </div>
245
+ </div>
246
+ <div id="em-booking-details" class="stuffbox">
247
+ <h3>
248
+ <?php _e ( 'Personal Details', 'dbem' ); ?>
249
+ </h3>
250
+ <div class="inside">
251
+ <?php echo $EM_Booking->get_person()->display_summary(); ?>
252
+ </div>
253
+ </div>
254
+ <div id="em-booking-details" class="stuffbox">
255
  <h3>
256
  <?php _e ( 'Booking Details', 'dbem' ); ?>
257
  </h3>
258
  <div class="inside">
259
+ <?php
260
+ $EM_Event = $EM_Booking->get_event();
261
+ $localised_start_date = date_i18n('D d M Y', $EM_Event->start);
262
+ $localised_end_date = date_i18n('D d M Y', $EM_Event->end);
263
+ ?>
264
+ <table class="em-tickets-bookings-table" cellspacing="0" cellpadding="0">
265
+ <thead>
266
+ <tr>
267
+ <th><?php _e('Ticket Type','dbem'); ?></th>
268
+ <th><?php _e('Spaces','dbem'); ?></th>
269
+ <th><?php _e('Price','dbem'); ?></th>
270
+ </tr>
271
+ </thead>
272
+ <tbody>
273
+ <?php foreach($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking): ?>
274
+ <tr>
275
+ <td class="ticket-type"><a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;ticket_id=<?php echo $EM_Ticket_Booking->get_ticket()->id ?>"><?php echo $EM_Ticket_Booking->get_ticket()->name ?></a></td>
276
+ <td><?php echo $EM_Ticket_Booking->get_spaces(); ?></td>
277
+ <td><?php echo $EM_Ticket_Booking->get_price(); ?></td>
278
+ </tr>
279
+ <?php endforeach; ?>
280
+ </tbody>
281
+ <tfoot>
282
+ <tr>
283
+ <th><?php _e('Totals','dbem'); ?></th>
284
+ <th><?php echo $EM_Booking->get_spaces(); ?></th>
285
+ <th><?php echo $EM_Booking->get_price(); ?></th>
286
+ </tr>
287
+ </tfoot>
288
+ </table>
289
+ <table cellspacing="0" cellpadding="0">
290
+ <tr><td><strong><?php _e('Comment','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td><td><?php echo $EM_Booking->comment; ?></td></tr>
291
+ <?php foreach( $EM_Booking->get_custom() as $custom_option ){
292
+ ?><tr><td><strong><?php echo $custom_option['name'] ?></strong></td><td><?php echo $custom_option['value'] ?></td></tr><?php
293
+ }
294
+ ?>
295
+ </table>
296
  </div>
297
+ </div>
 
 
 
 
 
 
 
298
  <div id="event_name" class="stuffbox">
299
  <h3>
300
  <?php _e ( 'Booking Notes', 'dbem' ); ?>
320
  </div>
321
  </div>
322
  <br style="clear:both;" />
323
+ <?php do_action('em_bookings_single_footer', $EM_Booking); ?>
324
  </div>
325
  <?php
326
 
338
  </div>
339
  <h2>
340
  <?php _e('Manage Person\'s Booking', 'dbem'); ?>
341
+ <?php if( current_user_can('edit_users') ) : ?>
342
+ <a href="user-edit.php?user_id=<?php echo $EM_Person->ID; ?>" class="button add-new-h2"><?php _e('Edit User','dbem') ?></a>
343
+ <?php endif; ?>
344
  </h2>
345
+ <?php do_action('em_bookings_person_header'); ?>
346
  <div id="poststuff" class="metabox-holder has-right-sidebar">
347
  <div id="post-body">
348
  <div id="post-body-content">
351
  <?php _e ( 'Personal Details', 'dbem' ); ?>
352
  </h3>
353
  <div class="inside">
354
+ <?php echo $EM_Person->display_summary(); ?>
355
  </div>
356
  </div>
357
  </div>
358
  </div>
359
  </div>
360
  <br style="clear:both;" />
361
+ <?php do_action('em_bookings_person_body_1'); ?>
362
  <h3><?php _e('Past And Present Bookings','dbem'); ?></h3>
363
  <?php em_bookings_person_table(); ?>
364
+ <?php do_action('em_bookings_person_footer', $EM_Person); ?>
365
  </div>
366
  <?php
367
  }
368
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
  ?>
admin/em-categories.php CHANGED
@@ -35,7 +35,7 @@ function em_admin_categories_page() {
35
  em_categories_table_layout($message);
36
  }
37
  }else{
38
- em_categories_table_layout($message);
39
  }
40
  }
41
 
@@ -136,9 +136,9 @@ function em_categories_edit_layout($message = "") {
136
  $EM_Category = new EM_Category();
137
  }
138
  //check that user can access this page
139
- if( is_object($EM_Category) && !$EM_Category->can_manage() ){
140
  ?>
141
- <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
142
  <?php
143
  return;
144
  }
35
  em_categories_table_layout($message);
36
  }
37
  }else{
38
+ em_categories_table_layout();
39
  }
40
  }
41
 
136
  $EM_Category = new EM_Category();
137
  }
138
  //check that user can access this page
139
+ if( is_object($EM_Category) && !$EM_Category->can_manage('edit_categories') ){
140
  ?>
141
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php implode('<br/>',$EM_Category->get_errors()); ?></p></div>
142
  <?php
143
  return;
144
  }
admin/em-docs.php CHANGED
@@ -99,8 +99,10 @@ function em_docs_init(){
99
  '#_REMOVEBOOKINGFORM' => array( 'desc' => 'Adds a form which allows the visitors to remove their booking.' ),
100
  '#_BOOKINGFORM' => array( 'desc' => 'Adds a both booking forms (add and remove).' ),
101
  '#_AVAILABLESPACES' => array( 'desc' => 'Shows available spaces for the event.' ),
102
- '#_BOOKEDSPACES' => array( 'desc' => 'Shows the amount of currently booked seats for the event.' ),
103
- '#_SPACES' => array( 'desc' => 'Shows the total spaces for the event.' )
 
 
104
  )
105
  ),
106
  'Contact Details' => array(
@@ -158,7 +160,9 @@ function em_docs_init(){
158
  )
159
  )
160
  ),
161
- )
 
 
162
  );
163
  }
164
  }
@@ -175,7 +179,7 @@ function em_docs_placeholders($atts){
175
  foreach($data as $sectionTitle => $details) : ?>
176
  <div>
177
  <h3><?php echo $sectionTitle; ?></h3>
178
- <?php if($details['desc'] != ''): ?>
179
  <p><?php echo $details['desc']; ?></p>
180
  <?php endif; ?>
181
  <dl>
99
  '#_REMOVEBOOKINGFORM' => array( 'desc' => 'Adds a form which allows the visitors to remove their booking.' ),
100
  '#_BOOKINGFORM' => array( 'desc' => 'Adds a both booking forms (add and remove).' ),
101
  '#_AVAILABLESPACES' => array( 'desc' => 'Shows available spaces for the event.' ),
102
+ '#_BOOKEDSPACES' => array( 'desc' => 'Shows the amount of currently booked spaces for the event.' ),
103
+ '#_PENDINGSPACES' => array( 'desc' => 'Shows the amount of pending spaces for the event.' ),
104
+ '#_SPACES' => array( 'desc' => 'Shows the total spaces for the event.' ),
105
+ '#_ATTENDEES' => array( 'desc' => 'Shows the list of user avatars attending events.' )
106
  )
107
  ),
108
  'Contact Details' => array(
160
  )
161
  )
162
  ),
163
+ ),
164
+ //TODO add capabilites explanations
165
+ 'capabilities' => array()
166
  );
167
  }
168
  }
179
  foreach($data as $sectionTitle => $details) : ?>
180
  <div>
181
  <h3><?php echo $sectionTitle; ?></h3>
182
+ <?php if( !empty($details['desc']) ): ?>
183
  <p><?php echo $details['desc']; ?></p>
184
  <?php endif; ?>
185
  <dl>
admin/em-event.php CHANGED
@@ -3,38 +3,10 @@ function em_admin_event_actions(){
3
  if( current_user_can(EM_MIN_CAPABILITY) && !empty($_GET['page']) && $_GET['page'] == 'events-manager-event' && !empty($_REQUEST ['action']) ){
4
  global $wpdb;
5
  global $EM_Event;
6
-
7
  //if dealing with new event, we still want an event object
8
  if( !is_object($EM_Event) ){
9
  $EM_Event = new EM_Event();
10
  }
11
-
12
- // UPDATE or CREATE action
13
- if ($_REQUEST['action'] == 'save') {
14
- $validation = $EM_Event->get_post();
15
- if ( $validation ) { //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
16
- //Save
17
- if( $EM_Event->save() ) {
18
- $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno']:'';
19
- $scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope']:'';
20
- wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager&p='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
21
- }
22
- }//errors added automatically to event global object
23
- }
24
-
25
- //Copy the event
26
- if ($_REQUEST['action'] == 'duplicate') {
27
- global $EZSQL_ERROR;
28
- $EM_Event = $EM_Event->duplicate();
29
- if( $EM_Event === false ){
30
- $redirect_url = em_add_get_params($_SERVER['HTTP_REFERER'], array('error' => __('There was an error duplicating the event. Try again maybe?', 'dbem'), 'message'=>''), false);
31
- wp_redirect($redirect_url);
32
- }else{
33
- $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno']:'';
34
- $scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope']:'';
35
- wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-event&event_id='.$EM_Event->id.'&p='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
36
- }
37
- }
38
  }
39
  }
40
  add_action('admin_init', 'em_admin_event_actions');
@@ -45,13 +17,13 @@ add_action('admin_init', 'em_admin_event_actions');
45
  * @return null
46
  */
47
  function em_admin_event_page() {
48
- global $EM_Event, $current_user;
49
- global $localised_date_formats;
50
 
51
  //check that user can access this page
52
- if( is_object($EM_Event) && !$EM_Event->can_manage() ){
53
  ?>
54
- <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
55
  <?php
56
  return false;
57
  }
@@ -93,49 +65,22 @@ function em_admin_event_page() {
93
 
94
  $days_names = array (1 => __ ( 'Mon' ), 2 => __ ( 'Tue' ), 3 => __ ( 'Wed' ), 4 => __ ( 'Thu' ), 5 => __ ( 'Fri' ), 6 => __ ( 'Sat' ), 0 => __ ( 'Sun' ) );
95
  ?>
96
- <?php if ( count($EM_Event->errors) > 0 || !empty($_GET['error']) ) : ?>
97
- <div id='message' class='error '>
98
- <p>
99
- <?php if( count($EM_Event->errors) ){ ?>
100
- <strong><?php echo __( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br />
101
- <?php echo implode('<br />', $EM_Event->errors); ?>
102
- <?php } else { echo $_GET['error']; } ?>
103
- </p>
104
- </div>
105
- <?php endif; ?>
106
- <?php if ( !empty($EM_Event->feedback_message) || !empty($_GET['message']) ) : ?>
107
- <div id='message' class='updated fade'>
108
- <p><?php echo !empty($EM_Event->feedback_message) ? $EM_Event->feedback_message : $_GET['message']; ?></p>
109
- </div>
110
- <?php endif; ?>
111
  <form id="event-form" method="post" action="">
112
  <div class="wrap">
113
  <div id="icon-events" class="icon32"><br /></div>
114
  <h2><?php echo $title; ?></h2>
115
- <?php if ( $EM_Event->is_recurrence() || $EM_Event->is_recurring() ) : ?>
116
- <p id='recurrence_warning'>
117
- <?php
118
- //TODO better warning system when changing a recurring event (e.g. when removing recurrences).
119
- if ( $EM_Event->is_recurring() ) {
120
- _e ( 'WARNING: This is a recurring event.', 'dbem' );
121
- echo "<br />";
122
- _e ( 'Modifying these data all the events linked to this recurrence will be rescheduled', 'dbem' );
123
- echo " ";
124
- _e ( 'and all booking information will be deleted!', 'dbem' );
125
- } elseif ( $EM_Event->is_recurrence() ) {
126
- //TODO Terminology confusing with methods, maybe worth changing?
127
- _e ( 'WARNING: This is a recurrence.', 'dbem' );
128
- echo "<br />";
129
- _e ( 'If you change these data and save, this will become an independent event.', 'dbem' );
130
- }
131
- ?>
132
- </p>
133
  <?php endif; ?>
134
  <div id="poststuff" class="metabox-holder has-right-sidebar">
135
  <!-- SIDEBAR -->
136
  <div id="side-info-column" class='inner-sidebar'>
137
  <div id='side-sortables'>
138
- <?php if(get_option('dbem_recurrence_enabled')) : ?>
139
  <!-- START recurrence postbox -->
140
  <div class="postbox ">
141
  <div class="handlediv" title="Fare clic per cambiare."><br />
@@ -218,57 +163,37 @@ function em_admin_event_page() {
218
  <?php endif; ?>
219
  <?php if(get_option('dbem_rsvp_enabled')) : ?>
220
  <!-- START RSVP -->
221
- <?php if ( em_verify_admin() ): ?>
222
  <div class="postbox ">
223
  <div class="handlediv" title="Fare clic per cambiare."><br />
224
  </div>
225
- <h3 class='hndle'><span>
226
- <?php _e ( 'Contact Person', 'dbem' ); ?>
227
- </span></h3>
228
  <div class="inside">
229
- <p><?php _e('Contact','dbem'); ?>
230
- <?php
231
- wp_dropdown_users ( array ('name' => 'event_contactperson_id', 'show_option_none' => __ ( "Select...", 'dbem' ), 'selected' => $EM_Event->contactperson_id ) );
232
- ?>
233
- </p>
234
  </div>
235
  </div>
236
  <?php else: ?>
237
- <input type="hidden" name="event_contactperson_id" value="<?php get_current_user_id() ?>" />
238
  <?php endif; ?>
239
- <div class="postbox ">
240
  <div class="handlediv" title="Fare clic per cambiare."><br />
241
  </div>
242
- <h3 class='hndle'><span><?php _e('RSVP','dbem'); ?></span></h3>
243
  <div class="inside">
244
- <p>
245
- <input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox' <?php echo ($EM_Event->rsvp) ? 'checked="checked"' : ''; ?> />
246
- <?php _e ( 'Enable registration for this event', 'dbem' )?>
247
- </p>
248
- <div id='rsvp-data'>
249
- <?php
250
- if ($EM_Event->contactperson_id != NULL){
251
- $selected = $EM_Event->contactperson_id;
252
- }else{
253
- $selected = '0';
254
- }
255
- ?>
256
- <p>
257
- <?php _e ( 'Spaces','dbem' ); ?> :
258
- <input id="seats-input" type="text" name="event_seats" size='5' value="<?php echo $EM_Event->seats ?>" />
259
- </p>
260
  <!-- START RSVP Stats -->
261
  <?php
262
- if ($EM_Event->rsvp ) {
263
- $available_seats = $EM_Event->get_bookings()->get_available_seats();
264
- $booked_seats = $EM_Event->get_bookings()->get_booked_seats();
265
 
266
  if ( count($EM_Event->get_bookings()->bookings) > 0 ) {
267
  ?>
268
  <div class='wrap'>
269
- <p><strong><?php echo __('Available Spaces','dbem').': '.$EM_Event->get_bookings()->get_available_seats(); ?></strong></p>
270
- <p><strong><?php echo __('Confirmed Spaces','dbem').': '.$EM_Event->get_bookings()->get_booked_seats(); ?></strong></p>
271
- <p><strong><?php echo __('Pending Spaces','dbem').': '.$EM_Event->get_bookings()->get_pending_seats(); ?></strong></p>
272
  </div>
273
 
274
  <br class='clear'/>
@@ -288,7 +213,6 @@ function em_admin_event_page() {
288
  <p><em><?php _e('No responses yet!')?></em></p>
289
  <?php
290
  }
291
- }
292
  ?>
293
  <!-- END RSVP Stats -->
294
  </div>
@@ -345,12 +269,8 @@ function em_admin_event_page() {
345
  </div>
346
  </div>
347
  <div id="event_start_date" class="stuffbox">
348
- <h3 id='event-date-title'>
349
- <?php _e ( 'Event date', 'dbem' ); ?>
350
- </h3>
351
- <h3 id='recurrence-dates-title'>
352
- <?php _e ( 'Recurrence dates', 'dbem' ); ?>
353
- </h3>
354
  <div class="inside">
355
  <input id="localised-date" type="text" name="localised_event_date" style="display: none;" />
356
  <input id="date-to-submit" type="text" name="event_start_date" value="<?php echo $EM_Event->start_date ?>" style="background: #FCFFAA" />
@@ -388,9 +308,9 @@ function em_admin_event_page() {
388
  <?php _e ( 'Coordinates', 'dbem' ); ?>
389
  </h3>
390
  <div class="inside">
391
- <input id='location-latitude' name='location_latitude' type='text' value='<?php echo $EM_Event->latitude; ?>' size='15' />
392
  -
393
- <input id='location-longitude' name='location_longitude' type='text' value='<?php echo $EM_Event->longitude; ?>' size='15' />
394
  </div>
395
  </div>
396
  <div id="location_info" class="stuffbox">
@@ -400,7 +320,7 @@ function em_admin_event_page() {
400
  <div class="inside">
401
  <table id="dbem-location-data">
402
  <tr>
403
- <td style="padding-right:20px">
404
  <table>
405
  <?php if($use_select_for_locations) : ?>
406
  <tr>
@@ -411,9 +331,8 @@ function em_admin_event_page() {
411
  $locations = EM_Locations::get();
412
  foreach($locations as $location) {
413
  $selected = "";
414
- if( is_object($EM_Event->location) ) {
415
- if ($EM_Event->location->id == $location->id)
416
- $selected = "selected='selected' ";
417
  }
418
  ?>
419
  <option value="<?php echo $location->id ?>" title="<?php echo "{$location->latitude},{$location->longitude}" ?>" <?php echo $selected ?>><?php echo $location->name; ?></option>
@@ -428,22 +347,43 @@ function em_admin_event_page() {
428
  <tr>
429
  <th><?php _e ( 'Name:' )?></th>
430
  <td>
 
431
  <input id="location-name" type="text" name="location_name" value="<?php echo htmlspecialchars($EM_Event->location->name, ENT_QUOTES); ?>" />
432
- <p><?php _e ( 'Select a location for your event', 'dbem' )?></p>
433
  </td>
434
  </tr>
435
  <tr>
436
  <th><?php _e ( 'Address:' )?>&nbsp;</th>
437
  <td>
438
- <input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Event->location->address, ENT_QUOTES); ; ?>" />
439
- <p><?php _e ( 'The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem' )?></p>
440
  </td>
441
  </tr>
442
  <tr>
443
- <th><?php _e ( 'Town:' )?>&nbsp;</th>
444
  <td>
445
- <input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Event->location->town, ENT_QUOTES); ?>" />
446
- <p><?php _e ( 'The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem' )?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  </td>
448
  </tr>
449
  <?php endif; ?>
@@ -461,7 +401,7 @@ function em_admin_event_page() {
461
  </table>
462
  </div>
463
  </div>
464
- <div id="event_notes" class="postbox">
465
  <h3>
466
  <?php _e ( 'Details', 'dbem' ); ?>
467
  </h3>
@@ -474,107 +414,229 @@ function em_admin_event_page() {
474
  </div>
475
  </div>
476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  <?php if(get_option('dbem_attributes_enabled')) : ?>
478
- <div id="event_attributes" class="postbox">
479
  <h3>
480
  <?php _e ( 'Attributes', 'dbem' ); ?>
481
  </h3>
482
  <div class="inside">
483
  <?php
484
- //We also get a list of attribute names and create a ddm list (since placeholders are fixed)
485
- $formats =
486
- get_option ( 'dbem_event_list_item_format' ).
487
- get_option ( 'dbem_event_page_title_format' ).
488
- get_option ( 'dbem_full_calendar_event_format' ).
489
- get_option ( 'dbem_location_baloon_format' ).
490
- get_option ( 'dbem_location_event_list_item_format' ).
491
- get_option ( 'dbem_location_page_title_format' ).
492
- get_option ( 'dbem_map_text_format' ).
493
- get_option ( 'dbem_rss_description_format' ).
494
- get_option ( 'dbem_rss_title_format' ).
495
- get_option ( 'dbem_single_event_format' ).
496
- get_option ( 'dbem_single_location_format' ).
497
- get_option ( 'dbem_placeholders_custom' );
498
- //We now have one long string of formats, get all the attribute placeholders
499
- preg_match_all('/#_ATT\{.+?\}(\{.+?\})?/', $formats, $placeholders);
500
- //Now grab all the unique attributes we can use in our event.
501
- $attributes = array();
502
- foreach($placeholders[0] as $result) {
503
- $attribute = substr( substr($result, 0, strpos($result, '}')), 6 );
504
- if( !in_array($attribute, $attributes) ){
505
- $attributes[] = $attribute ;
506
- }
507
- }
508
  ?>
509
  <div class="wrap">
510
  <?php if( count( $attributes ) > 0 ) : ?>
511
- <h2>Attributes</h2>
512
- <p>Add attributes here</p>
513
  <table class="form-table">
514
  <thead>
515
  <tr valign="top">
516
  <td><strong>Attribute Name</strong></td>
517
  <td><strong>Value</strong></td>
518
  </tr>
519
- </thead>
520
- <tfoot>
521
- <tr valign="top">
522
- <td colspan="3"><a href="#" id="mtm_add_tag">Add new tag</a></td>
523
- </tr>
524
- </tfoot>
525
  <tbody id="mtm_body">
526
  <?php
527
  $count = 1;
528
- if( is_array($EM_Event->attributes) and count($EM_Event->attributes) > 0){
529
- foreach( $EM_Event->attributes as $name => $value){
530
- ?>
531
- <tr valign="top" id="mtm_<?php echo $count ?>">
532
- <td scope="row">
533
- <select name="mtm_<?php echo $count ?>_ref">
534
- <?php
535
- if( !in_array($name, $attributes) ){
536
- echo "<option value='$name'>$name (".__('Not defined in templates', 'dbem').")</option>";
537
- }
538
- foreach( $attributes as $attribute ){
539
- if( $attribute == $name ) {
540
- echo "<option selected='selected'>$attribute</option>";
541
- }else{
542
- echo "<option>$attribute</option>";
543
- }
544
- }
545
- ?>
546
- </select>
547
- <a href="#" rel="<?php echo $count ?>">Remove</a>
548
- </td>
549
- <td>
550
- <input type="text" name="mtm_<?php echo $count ?>_name" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?>" />
551
- </td>
552
- </tr>
553
- <?php
554
- $count++;
555
- }
556
- }else{
557
  ?>
558
- <tr valign="top" id="mtm_<?php echo $count ?>">
559
- <td scope="row">
560
- <select name="mtm_<?php echo $count ?>_ref">
561
- <?php
562
- foreach( $attributes as $attribute ){
563
- echo "<option>$attribute</option>";
564
- }
565
- ?>
566
- </select>
567
- <a href="#" rel="<?php echo $count ?>">Remove</a>
568
- </td>
569
  <td>
570
- <input type="text" name="mtm_<?php echo $count ?>_name" />
571
  </td>
572
  </tr>
573
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
  }
575
  ?>
576
  </tbody>
577
  </table>
 
578
  <?php else : ?>
579
  <p>
580
  <?php _e('In order to use attributes, you must define some in your templates, otherwise they\'ll never show. Go to Events > Settings to add attribute placeholders.', 'dbem'); ?>
@@ -593,11 +655,35 @@ function em_admin_event_page() {
593
  </p>
594
  <input type="hidden" name="p" value="<?php echo ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:''; ?>" /><a>
595
  <input type="hidden" name="scope" value="<?php echo ( !empty($_REQUEST['scope']) ) ? $_REQUEST['scope']:'' ?>" /></a>
596
- <input type="hidden" name="action" value="save" />
 
 
597
  </div>
598
  </div>
599
  </div>
600
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
  <script type="text/javascript">
602
  jQuery(document).ready( function($) {
603
  <?php if( $EM_Event->is_recurring() ): ?>
@@ -609,16 +695,28 @@ function em_admin_event_page() {
609
  }
610
  });
611
  <?php endif; ?>
612
- <?php if( $EM_Event->rsvp == 1 ): ?>
613
  //RSVP Warning
614
- $('#rsvp-checkbox').click( function(event){
615
  if( !this.checked ){
616
- confirmation = confirm('<?php _e('Are you sure you want to disable bookings? If you do this and save, you will lose all previous bookings. If you wish to prevent further bookings, reduce the number of seats available to the amount of bookings you currently have', 'dbem'); ?>');
617
  if( confirmation == false ){
618
  event.preventDefault();
 
 
 
619
  }
 
 
 
620
  }
621
  });
 
 
 
 
 
 
622
  <?php endif; ?>
623
  });
624
  </script>
3
  if( current_user_can(EM_MIN_CAPABILITY) && !empty($_GET['page']) && $_GET['page'] == 'events-manager-event' && !empty($_REQUEST ['action']) ){
4
  global $wpdb;
5
  global $EM_Event;
 
6
  //if dealing with new event, we still want an event object
7
  if( !is_object($EM_Event) ){
8
  $EM_Event = new EM_Event();
9
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
  }
12
  add_action('admin_init', 'em_admin_event_actions');
17
  * @return null
18
  */
19
  function em_admin_event_page() {
20
+ global $EM_Event, $current_user, $EM_Notices, $localised_date_formats;
21
+ //$EM_Event->get_bookings()->get_tickets()->get_ticket_bookings(); print_r($EM_Event);die();
22
 
23
  //check that user can access this page
24
+ if( is_object($EM_Event) && !$EM_Event->can_manage('edit_events','edit_others_events') ){
25
  ?>
26
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php echo sprintf(__('You do not have the rights to manage this %s.','dbem'),__('Event','dbem')); ?></p></div>
27
  <?php
28
  return false;
29
  }
65
 
66
  $days_names = array (1 => __ ( 'Mon' ), 2 => __ ( 'Tue' ), 3 => __ ( 'Wed' ), 4 => __ ( 'Thu' ), 5 => __ ( 'Fri' ), 6 => __ ( 'Sat' ), 0 => __ ( 'Sun' ) );
67
  ?>
68
+ <?php echo $EM_Notices; ?>
69
+
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  <form id="event-form" method="post" action="">
71
  <div class="wrap">
72
  <div id="icon-events" class="icon32"><br /></div>
73
  <h2><?php echo $title; ?></h2>
74
+ <?php if ( count($EM_Event->warnings) > 0 ) : ?>
75
+ <?php foreach($EM_Event->warnings as $warning): ?>
76
+ <p class="warning"><?php echo $warning; ?></p>
77
+ <?php endforeach; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  <?php endif; ?>
79
  <div id="poststuff" class="metabox-holder has-right-sidebar">
80
  <!-- SIDEBAR -->
81
  <div id="side-info-column" class='inner-sidebar'>
82
  <div id='side-sortables'>
83
+ <?php if(get_option('dbem_recurrence_enabled') && ($EM_Event->is_recurrence() || $EM_Event->is_recurring() || $EM_Event->id == '')) : ?>
84
  <!-- START recurrence postbox -->
85
  <div class="postbox ">
86
  <div class="handlediv" title="Fare clic per cambiare."><br />
163
  <?php endif; ?>
164
  <?php if(get_option('dbem_rsvp_enabled')) : ?>
165
  <!-- START RSVP -->
166
+ <?php if ( current_user_can('edit_others_events') ): ?>
167
  <div class="postbox ">
168
  <div class="handlediv" title="Fare clic per cambiare."><br />
169
  </div>
170
+ <h3 class='hndle'><span><?php _e ( 'Event Owner/Contact Person', 'dbem' ); ?></span></h3>
 
 
171
  <div class="inside">
172
+ <?php
173
+ wp_dropdown_users ( array ('name' => 'event_owner', 'show_option_none' => __ ( "Select...", 'dbem' ), 'selected' => $EM_Event->owner ) );
174
+ ?>
 
 
175
  </div>
176
  </div>
177
  <?php else: ?>
178
+ <input type="hidden" name="event_owner" value="<?php get_current_user_id() ?>" />
179
  <?php endif; ?>
180
+ <div class="postbox " id='rsvp-data'>
181
  <div class="handlediv" title="Fare clic per cambiare."><br />
182
  </div>
183
+ <h3 class='hndle'><span><?php _e('Bookings Stats','dbem'); ?></span></h3>
184
  <div class="inside">
185
+ <div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  <!-- START RSVP Stats -->
187
  <?php
188
+ $available_spaces = $EM_Event->get_bookings()->get_available_spaces();
189
+ $booked_spaces = $EM_Event->get_bookings()->get_booked_spaces();
 
190
 
191
  if ( count($EM_Event->get_bookings()->bookings) > 0 ) {
192
  ?>
193
  <div class='wrap'>
194
+ <p><strong><?php echo __('Available Spaces','dbem').': '.$EM_Event->get_bookings()->get_available_spaces(); ?></strong></p>
195
+ <p><strong><?php echo __('Confirmed Spaces','dbem').': '.$EM_Event->get_bookings()->get_booked_spaces(); ?></strong></p>
196
+ <p><strong><?php echo __('Pending Spaces','dbem').': '.$EM_Event->get_bookings()->get_pending_spaces(); ?></strong></p>
197
  </div>
198
 
199
  <br class='clear'/>
213
  <p><em><?php _e('No responses yet!')?></em></p>
214
  <?php
215
  }
 
216
  ?>
217
  <!-- END RSVP Stats -->
218
  </div>
269
  </div>
270
  </div>
271
  <div id="event_start_date" class="stuffbox">
272
+ <h3 id='event-date-title'><?php _e ( 'Event date', 'dbem' ); ?></h3>
273
+ <h3 id='recurrence-dates-title'><?php _e ( 'Recurrence dates', 'dbem' ); ?></h3>
 
 
 
 
274
  <div class="inside">
275
  <input id="localised-date" type="text" name="localised_event_date" style="display: none;" />
276
  <input id="date-to-submit" type="text" name="event_start_date" value="<?php echo $EM_Event->start_date ?>" style="background: #FCFFAA" />
308
  <?php _e ( 'Coordinates', 'dbem' ); ?>
309
  </h3>
310
  <div class="inside">
311
+ <input id='location-latitude' name='location_latitude' type='text' value='<?php echo $EM_Event->get_location()->latitude; ?>' size='15' />
312
  -
313
+ <input id='location-longitude' name='location_longitude' type='text' value='<?php echo $EM_Event->get_location()->longitude; ?>' size='15' />
314
  </div>
315
  </div>
316
  <div id="location_info" class="stuffbox">
320
  <div class="inside">
321
  <table id="dbem-location-data">
322
  <tr>
323
+ <td style="padding-right:20px; width:100%;">
324
  <table>
325
  <?php if($use_select_for_locations) : ?>
326
  <tr>
331
  $locations = EM_Locations::get();
332
  foreach($locations as $location) {
333
  $selected = "";
334
+ if ($EM_Event->get_location()->id == $location->id){
335
+ $selected = "selected='selected' ";
 
336
  }
337
  ?>
338
  <option value="<?php echo $location->id ?>" title="<?php echo "{$location->latitude},{$location->longitude}" ?>" <?php echo $selected ?>><?php echo $location->name; ?></option>
347
  <tr>
348
  <th><?php _e ( 'Name:' )?></th>
349
  <td>
350
+ <input id='location-id' name='location_id' type='hidden' value='<?php echo $EM_Event->get_location()->id; ?>' size='15' />
351
  <input id="location-name" type="text" name="location_name" value="<?php echo htmlspecialchars($EM_Event->location->name, ENT_QUOTES); ?>" />
352
+ <p><?php _e ( 'Create a location or start typing to search a previously created location.', 'dbem' )?></p>
353
  </td>
354
  </tr>
355
  <tr>
356
  <th><?php _e ( 'Address:' )?>&nbsp;</th>
357
  <td>
358
+ <input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Event->location->address, ENT_QUOTES); ; ?>" /> <?php echo $required; ?>
 
359
  </td>
360
  </tr>
361
  <tr>
362
+ <th><?php _e ( 'City/Town:' )?>&nbsp;</th>
363
  <td>
364
+ <input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Event->location->town, ENT_QUOTES); ?>" /> <?php echo $required; ?>
365
+ </td>
366
+ </tr>
367
+ <tr>
368
+ <th><?php _e ( 'State/County:' )?>&nbsp;</th>
369
+ <td>
370
+ <input id="location-state" type="text" name="location_state" value="<?php echo htmlspecialchars($EM_Event->location->state, ENT_QUOTES); ?>" />
371
+ </td>
372
+ </tr>
373
+ <tr>
374
+ <th><?php _e ( 'Postcode:' )?>&nbsp;</th>
375
+ <td>
376
+ <input id="location-postcode" type="text" name="location_postcode" value="<?php echo htmlspecialchars($EM_Event->location->postcode, ENT_QUOTES); ?>" />
377
+ </td>
378
+ </tr>
379
+ <tr>
380
+ <th><?php _e ( 'Country:' )?>&nbsp;</th>
381
+ <td>
382
+ <select id="location-country" name="location_country">
383
+ <?php foreach(em_get_countries(__('none selected','dbem')) as $country_key => $country_name): ?>
384
+ <option value="<?php echo $country_key; ?>" <?php echo ( $EM_Event->location->country === $country_key || ($EM_Event->location->country == '' && $EM_Event->location->id == '' && get_option('dbem_location_default_country')==$country_key) ) ? 'selected="selected"':''; ?>><?php echo $country_name; ?></option>
385
+ <?php endforeach; ?>
386
+ </select> <?php echo $required; ?>
387
  </td>
388
  </tr>
389
  <?php endif; ?>
401
  </table>
402
  </div>
403
  </div>
404
+ <div id="event_notes" class="stuffbox">
405
  <h3>
406
  <?php _e ( 'Details', 'dbem' ); ?>
407
  </h3>
414
  </div>
415
  </div>
416
 
417
+ <?php if(get_option('dbem_rsvp_enabled')) : ?>
418
+ <div id="event-bookings" class="stuffbox">
419
+ <h3><span><?php _e('Bookings/Registration','dbem'); ?></span></h3>
420
+ <div class="inside">
421
+ <div class="wrap">
422
+ <p>
423
+ <input id="event-rsvp" name='event_rsvp' value='1' type='checkbox' <?php echo ($EM_Event->rsvp) ? 'checked="checked"' : ''; ?> />
424
+ <?php _e ( 'Enable registration for this event', 'dbem' )?>
425
+ </p>
426
+ <br />
427
+ <div id="event-tickets" style="<?php echo ($EM_Event->rsvp) ? '':'display:none;' ?>">
428
+ <p><strong><?php _e('Tickets','dbem'); ?></strong></p>
429
+ <p><em><?php _e('You have single or multiple tickets, where certain tickets become availalble under certain conditions, e.g. early bookings, group discounts, maximum bookings per ticket, etc.', 'dbem'); ?></em></p>
430
+ <table class="form-table">
431
+ <thead>
432
+ <tr valign="top">
433
+ <th class="ticket-status">&nbsp;</th>
434
+ <th><?php _e('Ticket Name','dbem'); ?></th>
435
+ <th><?php _e('Price','dbem'); ?></th>
436
+ <th><?php _e('Min/Max','dbem'); ?></th>
437
+ <th><?php _e('Start/End','dbem'); ?></th>
438
+ <th><?php _e('Avail. Spaces','dbem'); ?></th>
439
+ <th><?php _e('Booked Spaces','dbem'); ?></th>
440
+ <th>&nbsp;</th>
441
+ </tr>
442
+ </thead>
443
+ <tfoot>
444
+ <tr valign="top">
445
+ <td colspan="6">
446
+ <a href="#" id="em-tickets-add" rel="#em-tickets-form"><?php _e('Add new ticket','dbem'); ?></a>
447
+ </td>
448
+ </tr>
449
+ </tfoot>
450
+ <tbody id="em-tickets-body">
451
+ <?php
452
+ $EM_Tickets = $EM_Event->get_bookings()->get_tickets();
453
+ if( count($EM_Tickets->tickets) > 0 ){
454
+ $count = 1;
455
+ foreach( $EM_Tickets->tickets as $EM_Ticket){
456
+ ?>
457
+ <tr valign="top" id="em-tickets-row-<?php echo $count ?>" class="em-tickets-row">
458
+ <td class="ticket-status"><span class="<?php echo ($EM_Ticket->is_available()) ? 'ticket_on':'ticket_off'; ?>"></span></td>
459
+ <td class="ticket-name"><span class="ticket_name"><?php echo $EM_Ticket->name ?></span><br /><span class="ticket_description"></span></td>
460
+ <td class="ticket-price">
461
+ <span class="ticket_price"><?php echo ($EM_Ticket->price) ? $EM_Ticket->price : __('Free','dbem'); ?></span>
462
+ </td>
463
+ <td class="ticket-limit">
464
+ <span class="ticket_min">
465
+ <?php echo ( !empty($EM_Ticket->min) ) ? $EM_Ticket->min:'-'; ?>
466
+ </span> /
467
+ <span class="ticket_max"><?php echo ( !empty($EM_Ticket->max) ) ? $EM_Ticket->max:'-'; ?></span>
468
+ </td>
469
+ <td class="ticket-time">
470
+ <span class="ticket_start"><?php echo ( !empty($EM_Ticket->start) ) ? date($localised_date_format, $EM_Ticket->start_timestamp):''; ?></span> -
471
+ <span class="ticket_end"><?php echo ( !empty($EM_Ticket->end) ) ? date($localised_date_format, $EM_Ticket->end_timestamp):''; ?></span>
472
+ </td>
473
+ <td class="ticket-qty">
474
+ <span class="ticket_available_spaces"><?php echo $EM_Ticket->get_available_spaces(); ?></span>/
475
+ <span class="ticket_spaces">
476
+ <?php
477
+ if( $EM_Ticket->get_spaces() ){
478
+ echo $EM_Ticket->get_spaces();
479
+ echo ($EM_Ticket->spaces_limit) ? '':'*';
480
+ }else{
481
+ echo '-';
482
+ }
483
+ ?>
484
+ </span>
485
+ </td>
486
+ <td class="ticket-booked-spaces">
487
+ <span class="ticket_booked_spaces"><?php echo $EM_Ticket->get_booked_spaces(); ?></span>
488
+ </td>
489
+ <td class="ticket-actions">
490
+ <a href="#" class="ticket-actions-edit"><?php _e('Edit','dbem'); ?></a>
491
+ <?php if( count($EM_Ticket->get_bookings()->bookings) == 0 ): ?>
492
+ | <a href="<?php bloginfo('wpurl'); ?>/wp-load.php" class="ticket-actions-delete"><?php _e('Delete','dbem'); ?></a>
493
+ <?php else: ?>
494
+ | <a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=events-manager-bookings&ticket_id=<?php echo $EM_Ticket->id ?>"><?php _e('View Bookings','dbem'); ?></a>
495
+ <?php endif; ?>
496
+
497
+ <input type="hidden" class="ticket_id" name="em_tickets[<?php echo $count; ?>][ticket_id]" value="<?php echo $EM_Ticket->id ?>" />
498
+ <input type="hidden" class="ticket_name" name="em_tickets[<?php echo $count; ?>][ticket_name]" value="<?php echo $EM_Ticket->name ?>" />
499
+ <input type="hidden" class="ticket_description" name="em_tickets[<?php echo $count; ?>][ticket_description]" value="<?php echo $EM_Ticket->description ?>" />
500
+ <input type="hidden" class="ticket_price" name="em_tickets[<?php echo $count; ?>][ticket_price]" value="<?php echo $EM_Ticket->price ?>" />
501
+ <input type="hidden" class="ticket_spaces" name="em_tickets[<?php echo $count; ?>][ticket_spaces]" value="<?php echo $EM_Ticket->spaces ?>" />
502
+ <input type="hidden" class="ticket_start" name="em_tickets[<?php echo $count; ?>][ticket_start]" value="<?php echo ( !empty($EM_Ticket->start) ) ? date("Y-m-d H:i", $EM_Ticket->start_timestamp):''; ?>" />
503
+ <input type="hidden" class="ticket_end" name="em_tickets[<?php echo $count; ?>][ticket_end]" value="<?php echo ( !empty($EM_Ticket->end) ) ? date("Y-m-d H:i", $EM_Ticket->end_timestamp):''; ?>" />
504
+ <input type="hidden" class="ticket_min" name="em_tickets[<?php echo $count; ?>][ticket_min]" value="<?php echo $EM_Ticket->min ?>" />
505
+ <input type="hidden" class="ticket_max" name="em_tickets[<?php echo $count; ?>][ticket_max]" value="<?php echo $EM_Ticket->max ?>" />
506
+ </td>
507
+ </tr>
508
+ <?php
509
+ $count++;
510
+ }
511
+ }else{
512
+ ?>
513
+ <tr valign="top" id="em-tickets-row-1" class="em-tickets-row">
514
+ <td class="ticket-status"><span class="ticket_off"></span></td>
515
+ <td class="ticket-name"><span class="ticket_name">Free Ticket</span><br><span class="ticket_description"></span></td>
516
+ <td class="ticket-price"><span class="ticket_price">Free</span></td>
517
+ <td class="ticket-limit"><span class="ticket_min">-</span> / <span class="ticket_max">-</span></td>
518
+ <td class="ticket-time"><span class="ticket_start"></span> - <span class="ticket_end"></span></td>
519
+ <td class="ticket-qty"><span class="ticket_available_spaces">10</span>/<span class="ticket_spaces">10</span></td>
520
+ <td class="ticket-booked-spaces"><span class="ticket_booked_spaces">0</span></td>
521
+ <td class="ticket-actions">
522
+ <a href="#" class="ticket-actions-edit">Edit</a>| <a href="http://wordpress.lan/wp-load.php" class="ticket-actions-delete">Delete</a>
523
+ <input type="hidden" class="ticket_id" name="em_tickets[1][ticket_id]" value="">
524
+ <input type="hidden" class="ticket_name" name="em_tickets[1][ticket_name]" value="Free Ticket">
525
+ <input type="hidden" class="ticket_description" name="em_tickets[1][ticket_description]" value="">
526
+ <input type="hidden" class="ticket_price" name="em_tickets[1][ticket_price]" value="">
527
+ <input type="hidden" class="ticket_spaces" name="em_tickets[1][ticket_spaces]" value="10">
528
+ <input type="hidden" class="ticket_start" name="em_tickets[1][ticket_start]" value="">
529
+ <input type="hidden" class="ticket_end" name="em_tickets[1][ticket_end]" value="">
530
+ <input type="hidden" class="ticket_min" name="em_tickets[1][ticket_min]" value="">
531
+ <input type="hidden" class="ticket_max" name="em_tickets[1][ticket_max]" value="">
532
+ </td>
533
+ </tr>
534
+ <?php
535
+ }
536
+ ?>
537
+ </tbody>
538
+ </table>
539
+ <table style="display:none; visibility:hidden;">
540
+ <tr valign="top" id="em-tickets-template">
541
+ <td class="ticket-status"><span class="ticket_new"></span></td>
542
+ <td class="ticket-name"><span class="ticket_name"></span><br /><span class="ticket_description"></span></td>
543
+ <td class="ticket-price"><span class="ticket_price"></span></td>
544
+ <td class="ticket-limit"><span class="ticket_min"></span> / <span class="ticket_max"></span></td>
545
+ <td class="ticket-time"><span class="ticket_start"></span> - <span class="ticket_end"></span></td>
546
+ <td class="ticket-qty"><span class="ticket_available_spaces">0</span>/<span class="ticket_spaces"></span></td>
547
+ <td class="ticket-booked-spaces"><span class="ticket_booked_spaces">0</span></td>
548
+ <td class="ticket-actions">
549
+ <a href="#" class="ticket-actions-edit"><?php _e('Edit','dbem'); ?></a> | <a href="<?php bloginfo('wpurl'); ?>/wp-load.php" class="ticket-actions-delete"><?php _e('Delete','dbem'); ?></a>
550
+ <input type="hidden" class="ticket_id" />
551
+ <input type="hidden" class="ticket_name" />
552
+ <input type="hidden" class="ticket_description" />
553
+ <input type="hidden" class="ticket_price" />
554
+ <input type="hidden" class="ticket_spaces" />
555
+ <input type="hidden" class="ticket_start" />
556
+ <input type="hidden" class="ticket_end" />
557
+ <input type="hidden" class="ticket_min" />
558
+ <input type="hidden" class="ticket_max" />
559
+ </td>
560
+ </tr>
561
+ </table>
562
+ </div>
563
+ </div>
564
+ </div>
565
+ </div>
566
+ <?php endif; ?>
567
+
568
  <?php if(get_option('dbem_attributes_enabled')) : ?>
569
+ <div id="event_attributes" class="stuffbox">
570
  <h3>
571
  <?php _e ( 'Attributes', 'dbem' ); ?>
572
  </h3>
573
  <div class="inside">
574
  <?php
575
+ $attributes = em_get_attributes();
576
+ $has_depreciated = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
  ?>
578
  <div class="wrap">
579
  <?php if( count( $attributes ) > 0 ) : ?>
 
 
580
  <table class="form-table">
581
  <thead>
582
  <tr valign="top">
583
  <td><strong>Attribute Name</strong></td>
584
  <td><strong>Value</strong></td>
585
  </tr>
586
+ </thead>
 
 
 
 
 
587
  <tbody id="mtm_body">
588
  <?php
589
  $count = 1;
590
+ foreach( $attributes as $name){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
  ?>
592
+ <tr valign="top" id="em_attribute_<?php echo $count ?>">
593
+ <td scope="row"><?php echo $name ?></td>
 
 
 
 
 
 
 
 
 
594
  <td>
595
+ <input type="text" name="em_attributes[<?php echo $name ?>]" value="<?php echo array_key_exists($name, $EM_Event->attributes) ? htmlspecialchars($EM_Event->attributes[$name], ENT_QUOTES):''; ?>" />
596
  </td>
597
  </tr>
598
  <?php
599
+ $count++;
600
+ }
601
+ if($count == 1){
602
+ ?>
603
+ <tr><td colspan="2"><?php echo sprintf(__("You don't have any custom attributes defined in any of your Events Manager template settings. Please add them the <a href='%s'>settings page</a>",'dbem'),get_bloginfo('wpurl')."/wp-admin/admin.php?page=events-manager-options"); ?></td></tr>
604
+ <?php
605
+ }
606
+ ?>
607
+ </tbody>
608
+ </table>
609
+ <?php if( count(array_diff(array_keys($EM_Event->attributes), $attributes)) > 0 ): ?>
610
+ <p><strong><?php _e('Depreciated Attributes')?></strong></p>
611
+ <p><em><?php _e("If you see any attributes under here, that means they're not used in Events Manager anymore. To add them, you need to add the custom attribute again to a formatting option in the settings page. To remove any of these depreciated attributes, give it a blank value and save.") ?></em></p>
612
+ <table class="form-table">
613
+ <thead>
614
+ <tr valign="top">
615
+ <td><strong>Attribute Name</strong></td>
616
+ <td><strong>Value</strong></td>
617
+ </tr>
618
+ </thead>
619
+ <tbody id="mtm_body">
620
+ <?php
621
+ if( is_array($EM_Event->attributes) and count($EM_Event->attributes) > 0){
622
+ foreach( $EM_Event->attributes as $name => $value){
623
+ if( !in_array($name, $attributes) ){
624
+ ?>
625
+ <tr valign="top" id="em_attribute_<?php echo $count ?>">
626
+ <td scope="row"><?php echo $name ?></td>
627
+ <td>
628
+ <input type="text" name="em_attributes[<?php echo $name ?>]" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?>" />
629
+ </td>
630
+ </tr>
631
+ <?php
632
+ $count++;
633
+ }
634
+ }
635
  }
636
  ?>
637
  </tbody>
638
  </table>
639
+ <?php endif; ?>
640
  <?php else : ?>
641
  <p>
642
  <?php _e('In order to use attributes, you must define some in your templates, otherwise they\'ll never show. Go to Events > Settings to add attribute placeholders.', 'dbem'); ?>
655
  </p>
656
  <input type="hidden" name="p" value="<?php echo ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:''; ?>" /><a>
657
  <input type="hidden" name="scope" value="<?php echo ( !empty($_REQUEST['scope']) ) ? $_REQUEST['scope']:'' ?>" /></a>
658
+ <input type="hidden" name="event_id" value="<?php echo $EM_Event->id; ?>" />
659
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('wpnonce_event_save'); ?>" />
660
+ <input type="hidden" name="action" value="event_save" />
661
  </div>
662
  </div>
663
  </div>
664
  </form>
665
+ <div id="em-tickets-form">
666
+ <h4><?php _e('Create a ticket', 'dbem'); ?></h4>
667
+ <form action="" method="post">
668
+ <div><label><?php _e('Name','dbem'); ?></label><input type="text" name="ticket_name" /></div>
669
+ <div><label><?php _e('Description','dbem') ?></label><br /><textarea name="ticket_description"></textarea></div>
670
+ <div><label><?php _e('Price','dbem') ?></label><input type="text" name="ticket_price" /></div>
671
+ <div>
672
+ <label><?php _e('Available ticket spaces','dbem') ?></label><input type="text" name="ticket_spaces" /><br />
673
+ <em><?php _e('If left blank, spaces are determined by event limit.','dbem'); ?></em>
674
+ </div><br />
675
+ <div><label><?php _e('Start date of ticket availability','dbem') ?></label><input type="hidden" name="ticket_start" /><input type="text" name="ticket_start_pub" /></div>
676
+ <div><label><?php _e('End date of ticket availability','dbem') ?></label><input type="hidden" name="ticket_end" /><input type="text" name="ticket_end_pub" /></div>
677
+ <div><label><?php _e('Minimum tickets required per booking','dbem') ?></label><input type="text" name="ticket_min" /></div>
678
+ <div><label><?php _e('Maximum tickets required per booking','dbem') ?></label><input type="text" name="ticket_max" /></div>
679
+ <p class="submit">
680
+ <input type="hidden" name="ticket_id" />
681
+ <input type="hidden" name="event_id" />
682
+ <input type="hidden" name="prev_slot" />
683
+ <input type="submit" value="<?php _e('Add Ticket','dbem'); ?>" />
684
+ </p>
685
+ </form>
686
+ </div>
687
  <script type="text/javascript">
688
  jQuery(document).ready( function($) {
689
  <?php if( $EM_Event->is_recurring() ): ?>
695
  }
696
  });
697
  <?php endif; ?>
698
+ <?php if( get_option('dbem_rsvp_enabled') ): ?>
699
  //RSVP Warning
700
+ $('#event-rsvp').click( function(event){
701
  if( !this.checked ){
702
+ confirmation = confirm('<?php _e('Are you sure you want to disable bookings? If you do this and save, you will lose all previous bookings. If you wish to prevent further bookings, reduce the number of spaces available to the amount of bookings you currently have', 'dbem'); ?>');
703
  if( confirmation == false ){
704
  event.preventDefault();
705
+ }else{
706
+ $('#event-tickets').hide();
707
+ $("div#rsvp-data").hide();
708
  }
709
+ }else{
710
+ $('#event-tickets').fadeIn();
711
+ $("div#rsvp-data").fadeIn();
712
  }
713
  });
714
+
715
+ if($('input#event-rsvp').attr("checked")) {
716
+ $("div#rsvp-data").fadeIn();
717
+ } else {
718
+ $("div#rsvp-data").hide();
719
+ }
720
  <?php endif; ?>
721
  });
722
  </script>
admin/em-events.php CHANGED
@@ -6,54 +6,44 @@
6
  */
7
  function em_admin_events_page() {
8
  //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
9
- global $wpdb;
10
- global $EM_Event;
11
- $action = ( !empty($_GET ['action']) ) ? $_GET ['action']:'';
12
- $order = ( !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
13
- $limit = ( !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
14
- $page = ( !empty($_GET['pno']) ) ? $_GET['pno']:1;
15
  $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
 
16
  $scope_names = array (
17
  'past' => __ ( 'Past events', 'dbem' ),
18
  'all' => __ ( 'All events', 'dbem' ),
19
  'future' => __ ( 'Future events', 'dbem' )
20
  );
21
- $scope = ( !empty($_GET ['scope']) && array_key_exists($_GET ['scope'], $scope_names) ) ? $_GET ['scope']:'future';
22
- $selectedEvents = ( !empty($_GET ['events']) ) ? $_GET ['events']:'';
23
 
24
- // DELETE action
25
- if ( $action == 'deleteEvents' && EM_Object::array_is_numeric($selectedEvents) ) {
26
- EM_Events::delete( $selectedEvents );
27
- }
28
 
29
- // No action, only showing the events list
30
- switch ($scope) {
31
- case "past" :
32
- $title = __ ( 'Past Events', 'dbem' );
33
- break;
34
- case "all" :
35
- $title = __ ( 'All Events', 'dbem' );
36
- break;
37
- default :
38
- $title = __ ( 'Future Events', 'dbem' );
39
- $scope = "future";
40
- }
41
- $args = array('scope'=>$scope, 'limit'=>0, 'order'=>$order );
42
-
43
- if( !get_option('dbem_permissions_events') && !em_verify_admin() ){
44
  $args['owner'] = get_current_user_id();
45
  }
46
-
 
 
47
  $events = EM_Events::get( $args );
48
  $events_count = count ( $events );
 
 
 
49
 
50
- $use_events_end = get_option ( 'dbem_use_event_end' );
 
51
  ?>
52
  <div class="wrap">
53
  <div id="icon-events" class="icon32"><br />
54
  </div>
55
  <h2>
56
- <?php echo $title; ?>
57
  <a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php _e('Add New','dbem'); ?></a>
58
  </h2>
59
  <?php
@@ -62,23 +52,27 @@ function em_admin_events_page() {
62
  $link ['all'] = " <a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&amp;scope=all&amp;order=desc'>" . __ ( 'All events', 'dbem' ) . "</a>";
63
  $link ['future'] = " <a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&amp;scope=future'>" . __ ( 'Future events', 'dbem' ) . "</a>";
64
  ?>
65
- <?php if ( !empty($_GET['error']) ) : ?>
66
  <div id='message' class='error'>
67
- <p><?php echo $_GET['error']; ?></p>
68
  </div>
69
  <?php endif; ?>
70
- <?php if ( !empty($_GET['message']) ) : ?>
71
  <div id='message' class='updated fade'>
72
- <p><?php echo $_GET['message']; ?></p>
73
  </div>
74
  <?php endif; ?>
75
  <form id="posts-filter" action="" method="get"><input type='hidden' name='page' value='events-manager' />
76
  <ul class="subsubsub">
77
- <li><a href='#' class="current"><?php _e ( 'Total', 'dbem' ); ?> <span class="count">(<?php echo (count ( $events )); ?>)</span></a></li>
 
 
 
 
78
  </ul>
79
  <p class="search-box">
80
  <label class="screen-reader-text" for="post-search-input"><?php _e('Search Events','dbem'); ?>:</label>
81
- <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
82
  <input type="submit" value="<?php _e('Search Events','dbem'); ?>" class="button" />
83
  </p>
84
  <div class="tablenav">
@@ -86,7 +80,7 @@ function em_admin_events_page() {
86
  <div class="alignleft actions">
87
  <select name="action">
88
  <option value="-1" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
89
- <option value="deleteEvents"><?php _e ( 'Delete selected','dbem' ); ?></option>
90
  </select>
91
  <input type="submit" value="<?php _e ( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
92
  <select name="scope">
@@ -106,10 +100,9 @@ function em_admin_events_page() {
106
  <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
107
  </div>
108
  -->
109
- <?php
110
  if ( $events_count >= $limit ) {
111
- $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%'));
112
- $events_nav = em_admin_paginate( $page_link_template, $events_count, $limit, $page, 5);
113
  echo $events_nav;
114
  }
115
  ?>
@@ -123,7 +116,7 @@ function em_admin_events_page() {
123
  } else {
124
  ?>
125
 
126
- <table class="widefat">
127
  <thead>
128
  <tr>
129
  <th class='manage-column column-cb check-column' scope='col'>
@@ -143,7 +136,7 @@ function em_admin_events_page() {
143
  /* @var $event EM_Event */
144
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
145
  $rowno++;
146
- $class = ($rowno % 2) ? ' class="alternate"' : '';
147
  // FIXME set to american
148
  $localised_start_date = date_i18n('D d M Y', $event->start);
149
  $localised_end_date = date_i18n('D d M Y', $event->end);
@@ -153,40 +146,49 @@ function em_admin_events_page() {
153
  $category = new EM_Category($event->category_id);
154
 
155
  if ($event->start_date < $today && $event->end_date < $today){
156
- $style = "style ='background-color: #FADDB7;'";
157
- }
 
 
 
 
158
  ?>
159
- <tr <?php echo "$class $style"; ?>>
160
-
161
  <td>
162
  <input type='checkbox' class='row-selector' value='<?php echo $event->id; ?>' name='events[]' />
163
  </td>
164
  <td>
165
  <strong>
166
- <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php echo $event->id ?>&amp;scope=<?php echo $scope ?>&amp;p=<?php echo $page ?>"><?php echo ($event->name); ?></a>
167
  </strong>
168
- <?php if( is_object($category) ) : ?>
169
- <br/><span title='<?php echo __( 'Category', 'dbem' ).": ".$category->name ?>'><?php echo $category->name ?></span>
170
- <?php endif; ?>
171
  <?php
172
  if( get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1 ){
173
  ?>
174
  <br/>
175
  <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $event->id ?>"><?php echo __("Bookings",'dbem'); ?></a> &ndash;
176
- <?php _e("Booked",'dbem'); ?>: <?php echo $event->get_bookings()->get_booked_seats()."/".$event->seats; ?>
177
  <?php if( get_option('dbem_bookings_approval') == 1 ): ?>
178
- | <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_seats(); ?>
179
  <?php endif;
180
  }
181
  ?>
 
 
 
 
 
 
182
  </td>
183
  <td>
184
- <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;action=duplicate&amp;event_id=<?php echo $event->id; ?>&amp;scope=<?php echo $scope ?>&amp;p=<?php echo $page ?>" title="<?php _e ( 'Duplicate this event', 'dbem' ); ?>">
185
  <strong>+</strong>
186
  </a>
187
  </td>
188
  <td>
189
  <?php echo $location_summary; ?>
 
 
 
190
  </td>
191
 
192
  <td>
@@ -204,7 +206,7 @@ function em_admin_events_page() {
204
  ?>
205
  <strong>
206
  <?php echo $event->get_recurrence_description(); ?> <br />
207
- <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php echo $event->recurrence_id ?>&amp;scope=<?php echo $scope ?>&amp;p=<?php echo $page ?>"><?php _e ( 'Reschedule', 'dbem' ); ?></a>
208
  </strong>
209
  <?php
210
  }
6
  */
7
  function em_admin_events_page() {
8
  //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
9
+ global $wpdb, $EM_Notices, $EM_Event;
10
+
11
+ $action = ( !empty($_REQUEST ['action']) ) ? $_REQUEST ['action']:'';
12
+ $order = ( !empty($_REQUEST ['order']) ) ? $_REQUEST ['order']:'ASC';
13
+ $limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
14
+ $page = ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:1;
15
  $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
16
+ $search = ( !empty($_REQUEST['em_search']) ) ? $_REQUEST['em_search']:'';
17
  $scope_names = array (
18
  'past' => __ ( 'Past events', 'dbem' ),
19
  'all' => __ ( 'All events', 'dbem' ),
20
  'future' => __ ( 'Future events', 'dbem' )
21
  );
22
+ $scope = ( !empty($_REQUEST ['scope']) && array_key_exists($_REQUEST ['scope'], $scope_names) ) ? $_REQUEST ['scope']:'future';
23
+ $selectedEvents = ( !empty($_REQUEST ['events']) ) ? $_REQUEST ['events']:'';
24
 
25
+ $args = array('scope'=>$scope, 'limit'=>0, 'order'=>$order, 'search'=>$search );
 
 
 
26
 
27
+ if( !current_user_can('edit_others_events') ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  $args['owner'] = get_current_user_id();
29
  }
30
+ //Figure out what status to search for
31
+ $args['status'] = ( isset($_REQUEST['status']) && is_numeric($_REQUEST['status']) ) ? $_REQUEST['status'] : false;
32
+
33
  $events = EM_Events::get( $args );
34
  $events_count = count ( $events );
35
+ $pending_count = EM_Events::count( array('status'=>0) );
36
+ $approved_count = EM_Events::count( array('status'=> 1) );
37
+ $total_count = EM_Events::count( array('status'=> false) );
38
 
39
+ $use_events_end = get_option('dbem_use_event_end');
40
+ echo $EM_Notices;
41
  ?>
42
  <div class="wrap">
43
  <div id="icon-events" class="icon32"><br />
44
  </div>
45
  <h2>
46
+ <?php echo $scope_names[$scope]; ?>
47
  <a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php _e('Add New','dbem'); ?></a>
48
  </h2>
49
  <?php
52
  $link ['all'] = " <a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&amp;scope=all&amp;order=desc'>" . __ ( 'All events', 'dbem' ) . "</a>";
53
  $link ['future'] = " <a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&amp;scope=future'>" . __ ( 'Future events', 'dbem' ) . "</a>";
54
  ?>
55
+ <?php if ( !empty($_REQUEST['error']) ) : ?>
56
  <div id='message' class='error'>
57
+ <p><?php echo $_REQUEST['error']; ?></p>
58
  </div>
59
  <?php endif; ?>
60
+ <?php if ( !empty($_REQUEST['message']) ) : ?>
61
  <div id='message' class='updated fade'>
62
+ <p><?php echo $_REQUEST['message']; ?></p>
63
  </div>
64
  <?php endif; ?>
65
  <form id="posts-filter" action="" method="get"><input type='hidden' name='page' value='events-manager' />
66
  <ul class="subsubsub">
67
+ <li><a href='<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager' <?php echo ( !isset($_REQUEST['status']) ) ? 'class="current"':''; ?>><?php _e ( 'Total', 'dbem' ); ?> <span class="count">(<?php echo $total_count; ?>)</span></a></li>
68
+ <?php if( current_user_can('publish_events') ): ?>
69
+ <li>| <a href='<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager&amp;status=1' <?php echo ( isset($_REQUEST['status']) && $_REQUEST['status']=='1' ) ? 'class="current"':''; ?>><?php _e ( 'Approved', 'dbem' ); ?> <span class="count">(<?php echo $approved_count; ?>)</span></a></li>
70
+ <li>| <a href='<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager&amp;status=0' <?php echo ( isset($_REQUEST['status']) && $_REQUEST['status']=='0' ) ? 'class="current"':''; ?>><?php _e ( 'Pending', 'dbem' ); ?> <span class="count">(<?php echo $pending_count; ?>)</span></a></li>
71
+ <?php endif; ?>
72
  </ul>
73
  <p class="search-box">
74
  <label class="screen-reader-text" for="post-search-input"><?php _e('Search Events','dbem'); ?>:</label>
75
+ <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_REQUEST['em_search'])) ? $_REQUEST['em_search']:''; ?>" />
76
  <input type="submit" value="<?php _e('Search Events','dbem'); ?>" class="button" />
77
  </p>
78
  <div class="tablenav">
80
  <div class="alignleft actions">
81
  <select name="action">
82
  <option value="-1" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
83
+ <option value="event_delete"><?php _e ( 'Delete selected','dbem' ); ?></option>
84
  </select>
85
  <input type="submit" value="<?php _e ( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
86
  <select name="scope">
100
  <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
101
  </div>
102
  -->
103
+ <?php
104
  if ( $events_count >= $limit ) {
105
+ $events_nav = em_admin_paginate( $events_count, $limit, $page);
 
106
  echo $events_nav;
107
  }
108
  ?>
116
  } else {
117
  ?>
118
 
119
+ <table class="widefat events-table">
120
  <thead>
121
  <tr>
122
  <th class='manage-column column-cb check-column' scope='col'>
136
  /* @var $event EM_Event */
137
  if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
138
  $rowno++;
139
+ $class = ($rowno % 2) ? 'alternate' : '';
140
  // FIXME set to american
141
  $localised_start_date = date_i18n('D d M Y', $event->start);
142
  $localised_end_date = date_i18n('D d M Y', $event->end);
146
  $category = new EM_Category($event->category_id);
147
 
148
  if ($event->start_date < $today && $event->end_date < $today){
149
+ $class .= " past";
150
+ }
151
+ //Check pending approval events
152
+ if ( !$event->status ){
153
+ $class .= " pending";
154
+ }
155
  ?>
156
+ <tr class="event <?php echo trim($class); ?>" <?php echo $style; ?> id="event_<?php echo $event->id ?>">
 
157
  <td>
158
  <input type='checkbox' class='row-selector' value='<?php echo $event->id; ?>' name='events[]' />
159
  </td>
160
  <td>
161
  <strong>
162
+ <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php echo $event->id ?>&amp;scope=<?php echo $scope ?>&amp;pno=<?php echo $page ?>"><?php echo ($event->name); ?></a>
163
  </strong>
 
 
 
164
  <?php
165
  if( get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1 ){
166
  ?>
167
  <br/>
168
  <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $event->id ?>"><?php echo __("Bookings",'dbem'); ?></a> &ndash;
169
+ <?php _e("Booked",'dbem'); ?>: <?php echo $event->get_bookings()->get_booked_spaces()."/".$event->get_spaces(); ?>
170
  <?php if( get_option('dbem_bookings_approval') == 1 ): ?>
171
+ | <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_spaces(); ?>
172
  <?php endif;
173
  }
174
  ?>
175
+ <div class="row-actions">
176
+ <span class="trash"><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager&amp;action=event_delete&amp;event_id=<?php echo $event->id ?>&amp;scope=<?php echo $scope ?>&amp;pno=<?php echo $page ?>" class="em-event-delete"><?php _e('Delete','dbem'); ?></a></span>
177
+ <?php if( !$event->status && $event->can_manage('publish_events','publish_others_events') ): ?>
178
+ | <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager&amp;action=event_approve&amp;event_id=<?php echo $event->id ?>&amp;scope=<?php echo $scope ?>&amp;pno=<?php echo $page ?>" class="em-event-approve" style="color:green"><?php _e('Approve','dbem'); ?></a>
179
+ <?php endif; ?>
180
+ </div>
181
  </td>
182
  <td>
183
+ <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;action=event_duplicate&amp;event_id=<?php echo $event->id; ?>&amp;scope=<?php echo $scope ?>&amp;pno=<?php echo $page ?>" title="<?php _e ( 'Duplicate this event', 'dbem' ); ?>">
184
  <strong>+</strong>
185
  </a>
186
  </td>
187
  <td>
188
  <?php echo $location_summary; ?>
189
+ <?php if( is_object($category) && !empty($category->name) ) : ?>
190
+ <br/><span class="category"><strong><?php _e( 'Category', 'dbem' ); ?>: </strong><?php echo $category->name ?></span>
191
+ <?php endif; ?>
192
  </td>
193
 
194
  <td>
206
  ?>
207
  <strong>
208
  <?php echo $event->get_recurrence_description(); ?> <br />
209
+ <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php echo $event->recurrence_id ?>&amp;scope=<?php echo $scope ?>&amp;pno=<?php echo $page ?>"><?php _e ( 'Reschedule', 'dbem' ); ?></a>
210
  </strong>
211
  <?php
212
  }
admin/em-locations-search.php CHANGED
@@ -3,20 +3,24 @@
3
  * This page will search for either a specific location via GET "id" variable
4
  * or will search for events by name via the GET "q" variable.
5
  */
 
6
  require_once('../../../../wp-load.php');
7
  global $wpdb;
8
 
9
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
10
- $location_cond = ( get_option('dbem_permissions_locations') < 1 && !em_verify_admin() ) ? "AND location_owner=".get_current_user_id() : '';
11
 
12
  $term = (isset($_GET['term'])) ? '%'.$_GET['term'].'%' : '%'.$_GET['q'].'%';
13
  $sql = $wpdb->prepare("
14
  SELECT
 
15
  Concat( location_name, ', ', location_address, ', ', location_town) AS `label`,
16
  location_name AS `value`,
17
  location_address AS `address`,
18
  location_town AS `town`,
19
- location_id AS `id`
 
 
20
  FROM $locations_table
21
  WHERE ( `location_name` LIKE %s ) $location_cond LIMIT 10
22
  ", $term);
3
  * This page will search for either a specific location via GET "id" variable
4
  * or will search for events by name via the GET "q" variable.
5
  */
6
+ //FIXME just plug loc search into ajax catcher
7
  require_once('../../../../wp-load.php');
8
  global $wpdb;
9
 
10
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
11
+ $location_cond = ( !current_user_can('edit_others_locations') ) ? "AND location_owner=".get_current_user_id() : '';
12
 
13
  $term = (isset($_GET['term'])) ? '%'.$_GET['term'].'%' : '%'.$_GET['q'].'%';
14
  $sql = $wpdb->prepare("
15
  SELECT
16
+ location_id AS `id`,
17
  Concat( location_name, ', ', location_address, ', ', location_town) AS `label`,
18
  location_name AS `value`,
19
  location_address AS `address`,
20
  location_town AS `town`,
21
+ location_state AS `state`,
22
+ location_postcode AS `postcode`,
23
+ location_country AS `country`
24
  FROM $locations_table
25
  WHERE ( `location_name` LIKE %s ) $location_cond LIMIT 10
26
  ", $term);
admin/em-locations.php CHANGED
@@ -7,54 +7,30 @@ function em_admin_locations_page() {
7
  //TODO EM_Location is globalized, use it fully here
8
  global $EM_Location;
9
  //Take actions
10
- if( !empty($_REQUEST['action']) || !empty($_REQUEST['location_id']) ){
11
- if( $_REQUEST['action'] == "edit" || $_REQUEST['action'] == "add" ) {
12
- //edit/add location
13
- em_admin_location();
14
- } elseif( $_REQUEST['action'] == "delete" ){
15
- //delelte location
16
- $locations = $_REQUEST['locations'];
17
- foreach($locations as $location_id) {
18
- $EM_Location = new EM_Location($location_id);
19
- $EM_Location->delete();
20
- }
21
- em_admin_locations(__('Locations Deleted', "dbem" ));
22
- } elseif( $_REQUEST['action'] == "save") {
23
- // save (add/update) location
24
- if( empty($EM_Location) || !is_object($EM_Location) ){
25
- $EM_Location = new EM_Location(); //blank location
26
- $success_message = __('The location has been added.', 'dbem');
27
- }else{
28
- $success_message = __('The location has been updated.', 'dbem');
29
- }
30
- $EM_Location->get_post();
31
- $validation_result = $EM_Location->validate();
32
- if ( $validation_result ) {
33
- $EM_Location->save(); //FIXME better handling of db write fails when saving location
34
- em_admin_locations($success_message);
35
- } else {
36
- ?>
37
- <div id='message' class='error '>
38
- <p>
39
- <strong><?php _e( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br /><?php echo implode('<br />', $EM_Location->errors); ?>
40
- </p>
41
- </div>
42
- <?php
43
- unset($EM_Location);
44
- em_admin_location();
45
- }
46
- }
47
- } else {
48
  // no action, just a locations list
49
  em_admin_locations();
50
  }
51
  }
52
 
53
  function em_admin_locations($message='', $fill_fields = false) {
 
54
  $limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
55
  $page = ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:1;
56
  $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
57
- $locations = EM_Locations::get();
 
 
 
 
 
 
 
 
58
  $locations_count = count($locations);
59
  ?>
60
  <div class='wrap'>
@@ -66,35 +42,34 @@ function em_admin_locations($message='', $fill_fields = false) {
66
  <a href="admin.php?page=events-manager-locations&action=add" class="button add-new-h2"><?php _e('Add New') ?></a>
67
  </h2>
68
 
69
- <?php if($message != "") : ?>
70
- <div id='message' class='updated fade below-h2'>
71
- <p><?php echo $message ?></p>
72
- </div>
73
- <?php endif; ?>
74
 
75
- <form id='bookings-filter' method='post' action=''>
76
  <input type='hidden' name='page' value='locations'/>
77
  <input type='hidden' name='limit' value='<?php echo $limit ?>' />
78
- <input type='hidden' name='p' value='<?php echo $page ?>' />
 
 
 
 
 
 
 
79
  <?php if ( $locations_count > 0 ) : ?>
80
  <div class='tablenav'>
81
  <div class="alignleft actions">
82
  <select name="action">
83
  <option value="" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
84
- <option value="delete"><?php _e ( 'Delete selected','dbem' ); ?></option>
85
  </select>
86
  <input type="submit" value="<?php _e ( 'Apply' ); ?>" id="doaction2" class="button-secondary action" />
87
- <?php
88
- //Pagination (if needed/requested)
89
- if( $locations_count >= $limit ){
90
- //Show the pagination links (unless there's less than 10 events
91
- $page_link_template = preg_replace('/(&|\?)p=\d+/i','',$_SERVER['REQUEST_URI']);
92
- $page_link_template = em_add_get_params($page_link_template, array('pno'=>'%PAGE%'));
93
- $locations_nav = em_paginate( $page_link_template, $locations_count, $limit, $page);
94
- echo $locations_nav;
95
- }
96
- ?>
97
  </div>
 
 
 
 
 
 
98
  </div>
99
  <table class='widefat'>
100
  <thead>
@@ -137,9 +112,9 @@ function em_admin_locations($message='', $fill_fields = false) {
137
  }
138
 
139
  function em_admin_location($message = "") {
140
- global $EM_Location, $EM_Event;
141
  //check that user can access this page
142
- if( is_object($EM_Location) && !$EM_Location->can_manage() ){
143
  ?>
144
  <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this location.','dbem'); ?></p></div>
145
  <?php
@@ -151,9 +126,12 @@ function em_admin_location($message = "") {
151
  }else{
152
  $title = __('Edit location', 'dbem');
153
  }
 
 
154
  ?>
155
- <form enctype='multipart/form-data' name='editcat' id='locationForm' method='post' action='admin.php?page=events-manager-locations' class='validate'>
156
- <input type='hidden' name='action' value='save' />
 
157
  <input type='hidden' name='location_id' value='<?php echo $EM_Location->id ?>'/>
158
  <div class='wrap'>
159
  <div id='icon-edit' class='icon32'>
@@ -161,11 +139,7 @@ function em_admin_location($message = "") {
161
  </div>
162
  <h2><?php echo $title ?></h2>
163
 
164
- <?php if($message != "") : ?>
165
- <div id='message' class='updated fade below-h2' style='background-color: rgb(255, 251, 204);'>
166
- <p><?php echo $message ?></p>
167
- </div>
168
- <?php endif; ?>
169
  <div id='ajax-response'></div>
170
 
171
  <div id="poststuff" class="metabox-holder">
@@ -196,22 +170,43 @@ function em_admin_location($message = "") {
196
  <?php _e ( 'Location', 'dbem' ); ?>
197
  </h3>
198
  <div class="inside">
 
199
  <table id="dbem-location-data">
200
  <tr>
201
- <td style="padding-right:20px">
202
  <table>
203
  <tr>
204
  <th><?php _e ( 'Address:' )?>&nbsp;</th>
205
  <td>
206
- <input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Location->address, ENT_QUOTES); ; ?>" />
207
- <p><?php _e ( 'The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem' )?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  </td>
209
  </tr>
210
  <tr>
211
- <th><?php _e ( 'Town:' )?>&nbsp;</th>
212
  <td>
213
- <input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Location->town, ENT_QUOTES); ?>" />
214
- <p><?php _e ( 'The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem' )?></p>
 
 
 
215
  </td>
216
  </tr>
217
  </table>
@@ -256,6 +251,7 @@ function em_admin_location($message = "") {
256
  <label for='location_image'><?php _e('Upload/change picture', 'dbem') ?></label> <input id='location-image' name='location_image' id='location_image' type='file' size='40' />
257
  </div>
258
  </div>
 
259
  </div>
260
  </div>
261
  </div>
7
  //TODO EM_Location is globalized, use it fully here
8
  global $EM_Location;
9
  //Take actions
10
+ if( (!empty($_REQUEST['action']) && ( ($_REQUEST['action'] == "edit" && !empty($_REQUEST['location_id'])) || $_REQUEST['action'] == "add")) ) {
11
+ em_admin_location();
12
+ } elseif( !empty($_REQUEST['action']) && $_REQUEST['action'] == "location_save" ) {
13
+ em_admin_location();
14
+ } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  // no action, just a locations list
16
  em_admin_locations();
17
  }
18
  }
19
 
20
  function em_admin_locations($message='', $fill_fields = false) {
21
+ global $EM_Notices;
22
  $limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
23
  $page = ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:1;
24
  $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
25
+ if( !empty($_REQUEST['owner']) && current_user_can('read_others_locations') ){
26
+ $locations = EM_Locations::get();
27
+ $locations_mine_count = EM_Locations::count( array('owner'=>get_current_user_id()) );
28
+ $locations_all_count = count($locations);
29
+ }else{
30
+ $locations = EM_Locations::get( array('owner'=>get_current_user_id()) );
31
+ $locations_mine_count = count($locations);
32
+ $locations_all_count = current_user_can('read_others_locations') ? EM_Locations::count():0;
33
+ }
34
  $locations_count = count($locations);
35
  ?>
36
  <div class='wrap'>
42
  <a href="admin.php?page=events-manager-locations&action=add" class="button add-new-h2"><?php _e('Add New') ?></a>
43
  </h2>
44
 
45
+ <?php echo $EM_Notices; ?>
 
 
 
 
46
 
47
+ <form id='locations-filter' method='post' action=''>
48
  <input type='hidden' name='page' value='locations'/>
49
  <input type='hidden' name='limit' value='<?php echo $limit ?>' />
50
+ <input type='hidden' name='p' value='<?php echo $page ?>' />
51
+ <div class="subsubsub">
52
+ <a href='admin.php?page=events-manager-locations' <?php echo (empty($_REQUEST['owner'])) ? 'class="current"':''; ?>><?php echo sprintf( __( 'My %s', 'dbem' ), __('Locations','dbem')); ?> <span class="count">(<?php echo $locations_mine_count; ?>)</span></a>
53
+ <?php if( current_user_can('read_others_locations') ): ?>
54
+ &nbsp;|&nbsp;
55
+ <a href='admin.php?page=events-manager-locations&amp;owner=all' <?php echo (!empty($_REQUEST['owner'])) ? 'class="current"':''; ?>><?php echo sprintf( __( 'All %s', 'dbem' ), __('Locations','dbem')); ?> <span class="count">(<?php echo $locations_all_count; ?>)</span></a>
56
+ <?php endif; ?>
57
+ </div>
58
  <?php if ( $locations_count > 0 ) : ?>
59
  <div class='tablenav'>
60
  <div class="alignleft actions">
61
  <select name="action">
62
  <option value="" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
63
+ <option value="location_delete"><?php _e ( 'Delete selected','dbem' ); ?></option>
64
  </select>
65
  <input type="submit" value="<?php _e ( 'Apply' ); ?>" id="doaction2" class="button-secondary action" />
 
 
 
 
 
 
 
 
 
 
66
  </div>
67
+ <?php
68
+ if ( $locations_count >= $limit ) {
69
+ $locations_nav = em_admin_paginate( $locations_count, $limit, $page );
70
+ echo $locations_nav;
71
+ }
72
+ ?>
73
  </div>
74
  <table class='widefat'>
75
  <thead>
112
  }
113
 
114
  function em_admin_location($message = "") {
115
+ global $EM_Location, $EM_Notices;
116
  //check that user can access this page
117
+ if( is_object($EM_Location) && !$EM_Location->can_manage('edit_locations','edit_others_locations') ){
118
  ?>
119
  <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this location.','dbem'); ?></p></div>
120
  <?php
126
  }else{
127
  $title = __('Edit location', 'dbem');
128
  }
129
+ $required = "<i>(".__('required','dbem').")</i>";
130
+ echo $EM_Notices;
131
  ?>
132
+ <form enctype='multipart/form-data' name='editcat' id='location-form' method='post' action='admin.php?page=events-manager-locations' class='validate'>
133
+ <input type='hidden' name='action' value='location_save' />
134
+ <input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('location_save'); ?>' />
135
  <input type='hidden' name='location_id' value='<?php echo $EM_Location->id ?>'/>
136
  <div class='wrap'>
137
  <div id='icon-edit' class='icon32'>
139
  </div>
140
  <h2><?php echo $title ?></h2>
141
 
142
+ <?php global $EM_Notices; echo $EM_Notices; ?>
 
 
 
 
143
  <div id='ajax-response'></div>
144
 
145
  <div id="poststuff" class="metabox-holder">
170
  <?php _e ( 'Location', 'dbem' ); ?>
171
  </h3>
172
  <div class="inside">
173
+ <p><?php _e("If you're using the Google Maps, the more detail you provide, the more accurate Google can be at finding your location. If your address isn't being found, please <a='http://maps.google.com'>try it on maps.google.com</a> by adding all the fields below seperated by commas.",'dbem')?></p>
174
  <table id="dbem-location-data">
175
  <tr>
176
+ <td style="padding-right:20px; width:100%;">
177
  <table>
178
  <tr>
179
  <th><?php _e ( 'Address:' )?>&nbsp;</th>
180
  <td>
181
+ <input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Location->address, ENT_QUOTES); ; ?>" /> <?php echo $required; ?>
182
+ </td>
183
+ </tr>
184
+ <tr>
185
+ <th><?php _e ( 'City/Town:' )?>&nbsp;</th>
186
+ <td>
187
+ <input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Location->town, ENT_QUOTES); ?>" /> <?php echo $required; ?>
188
+ </td>
189
+ </tr>
190
+ <tr>
191
+ <th><?php _e ( 'State/County:' )?>&nbsp;</th>
192
+ <td>
193
+ <input id="location-state" type="text" name="location_state" value="<?php echo htmlspecialchars($EM_Location->state, ENT_QUOTES); ?>" />
194
+ </td>
195
+ </tr>
196
+ <tr>
197
+ <th><?php _e ( 'Postcode:' )?>&nbsp;</th>
198
+ <td>
199
+ <input id="location-postcode" type="text" name="location_postcode" value="<?php echo htmlspecialchars($EM_Location->postcode, ENT_QUOTES); ?>" />
200
  </td>
201
  </tr>
202
  <tr>
203
+ <th><?php _e ( 'Country:' )?>&nbsp;</th>
204
  <td>
205
+ <select id="location-country" name="location_country">
206
+ <?php foreach(em_get_countries(__('none selected','dbem')) as $country_key => $country_name): ?>
207
+ <option value="<?php echo $country_key; ?>" <?php echo ( $EM_Location->country === $country_key || ($EM_Location->country == '' && $EM_Location->id == '' && get_option('dbem_location_default_country')==$country_key) ) ? 'selected="selected"':''; ?>><?php echo $country_name; ?></option>
208
+ <?php endforeach; ?>
209
+ </select> <?php echo $required; ?>
210
  </td>
211
  </tr>
212
  </table>
251
  <label for='location_image'><?php _e('Upload/change picture', 'dbem') ?></label> <input id='location-image' name='location_image' id='location_image' type='file' size='40' />
252
  </div>
253
  </div>
254
+
255
  </div>
256
  </div>
257
  </div>
admin/em-options.php CHANGED
@@ -18,12 +18,30 @@ function em_options_save(){
18
  }
19
  }
20
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  function em_options_saved_notice(){
22
  ?>
23
  <div class="updated"><p><strong><?php _e('Changes saved.'); ?></strong></p></div>
24
  <?php
25
  }
26
  add_action ( 'admin_notices', 'em_options_saved_notice' );
 
 
 
27
  }
28
  }
29
  add_action('admin_head', 'em_options_save');
@@ -67,7 +85,7 @@ function em_admin_options_page() {
67
  }
68
  });
69
  $('input:radio[name=dbem_disable_title_rewrites]').trigger('change');
70
-
71
  });
72
  </script>
73
  <div class="wrap">
@@ -110,6 +128,9 @@ function em_admin_options_page() {
110
  $location_options[$EM_Location->id] = $EM_Location->name;
111
  }
112
  em_options_select ( __( 'Default Location' ), 'dbem_default_location', $location_options, __( 'This option allows you to select the default location when adding an event.','dbem' )." ".__('(not applicable with event ownership on presently, coming soon!)','dbem') );
 
 
 
113
 
114
  em_options_textarea ( __( 'Custom Placeholders', 'dbem' ), 'dbem_placeholders_custom', sprintf(__( "You can add custom placeholders here, one per line in this format <code>#_ATT{key}</code>. They will not appear on event pages unless you insert them into another template below, but you may want to store extra information about an event for other uses. <a href='%s'>More information on placeholders.</a>", 'dbem' ), 'wp-events-plugin.com/documentation/the-em-templates-syntax/') );
115
 
@@ -306,12 +327,27 @@ function em_admin_options_page() {
306
  </div> <!-- .postbox -->
307
 
308
  <div class="postbox " >
309
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'RSVP and bookings', 'dbem' ); ?> </span></h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  <div class="inside">
311
  <table class='form-table'>
312
  <?php
313
  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' ) );
314
- em_options_radio_binary ( __( 'Approval Required?', 'dbem' ), 'dbem_bookings_approval', __( 'Bookings will not be confirmed until the event administrator approves it.', 'dbem' ) );
315
  em_options_input_text ( __( 'Email events admin?', 'dbem' ), 'dbem_bookings_notify_admin', __( "If you would like every event booking confirmation email sent to an administrator write their email here (leave blank to not send an email).", 'dbem' ) );
316
  em_options_radio_binary ( __( 'Email contact person?', 'dbem' ), 'dbem_bookings_contact_email', __( 'Check this option if you want the event contact to receive an email when someone books places. An email will be sent when a booking is first made (regardless if confirmed or pending)', 'dbem' ) );
317
  ?>
@@ -390,44 +426,57 @@ function em_admin_options_page() {
390
  </div> <!-- .postbox -->
391
 
392
  <div class="postbox " >
393
- <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Management Permission Options', 'dbem' ); ?> (Beta)</span></h3>
394
  <div class="inside">
395
  <table class="form-table">
396
  <tr><td colspan="2">
397
  <strong><?php _e('Warning: Changing these values may result in exposing previously hidden information to all users.')?></strong><br />
398
- <em><?php _e('Note that currently "users" are considered as wordpress contributor users upwards, as they can create and manage events (we\'re working on that). Wordpress administrators can control all events/locations/categories/etc. on Events Manager.','dbem'); ?></em>
399
  </td></tr>
400
- <tr><th colspan="2"><strong><?php _e('Event Permissions','dbem'); ?></strong></th></tr>
401
  <?php
402
- $location_privacy_options = array(
403
- '0' => __('Every user can create and manage their own events. Users can\'t view or modify each others\' events and booking data','dbem'),
404
- '1' => __('Every user can create/edit/delete any event on this site. (not recommended)','dbem')
405
- );
406
- em_options_radio ( 'dbem_permissions_events', $location_privacy_options );
407
- ?>
408
- <tr><th colspan="2"><strong><?php _e('Location Permissions','dbem'); ?></strong></th></tr>
409
- <?php
410
- $location_privacy_options = array(
411
- '0' => __('Every user can create and manage their own location.','dbem')." ".__('In future releases of Events Manager, sharing locations with more than one user will be possible in this option, as well as connecting different user defined locations to prevent duplicate listings.','dbem'),
412
- '1' => __('Only event administrators can create and edit locations. User must choose from these available locations.','dbem'),
413
- '2' => __('Everyone can create/edit/delete all locations on this site. (not recommended)','dbem')
414
- );
415
- em_options_radio ( 'dbem_permissions_locations', $location_privacy_options );
416
- ?>
417
- <tr><th colspan="2"><strong><?php _e('Category Permissions','dbem'); ?></strong></th></tr>
418
- <?php
419
- $category_privacy_options = array(
420
- '0' => __('Every user can create and manage their own category.','dbem'),
421
- '1' => __('Only event administrators can create and edit categories. User must choose from these available categories.','dbem'),
422
- '2' => __('Everyone can create/edit/delete all categories on the system. (not recommended)','dbem')
423
- );
424
- em_options_radio ( 'dbem_permissions_categories', $category_privacy_options );
425
- ?>
426
  </table>
427
-
428
  </div> <!-- . inside -->
429
  </div> <!-- .postbox -->
430
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  <p class="submit">
432
  <input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
433
  <input type="hidden" name="em-submitted" value="1" />
18
  }
19
  }
20
  }
21
+ //set capabilities
22
+ if( !empty($_POST['em_capabilities']) && is_array($_POST['em_capabilities']) ){
23
+ global $em_capabilities_array, $wp_roles;
24
+ foreach( $wp_roles->role_objects as $role_name => $role ){
25
+ foreach( array_keys($em_capabilities_array) as $capability){
26
+ if( !empty($_POST['em_capabilities'][$role_name][$capability]) ){
27
+ $role->add_cap($capability);
28
+ }else{
29
+
30
+ $role->remove_cap($capability);
31
+ }
32
+ }
33
+ }
34
+ }
35
+ do_action('em_options_save');
36
  function em_options_saved_notice(){
37
  ?>
38
  <div class="updated"><p><strong><?php _e('Changes saved.'); ?></strong></p></div>
39
  <?php
40
  }
41
  add_action ( 'admin_notices', 'em_options_saved_notice' );
42
+ if( get_option('dbem_debug') ){
43
+ include_once( WP_PLUGIN_DIR.'/events-manager/em-debug.php');
44
+ }
45
  }
46
  }
47
  add_action('admin_head', 'em_options_save');
85
  }
86
  });
87
  $('input:radio[name=dbem_disable_title_rewrites]').trigger('change');
88
+ $(".postbox").addClass('closed'); //Let's start off closing everything for now.
89
  });
90
  </script>
91
  <div class="wrap">
128
  $location_options[$EM_Location->id] = $EM_Location->name;
129
  }
130
  em_options_select ( __( 'Default Location' ), 'dbem_default_location', $location_options, __( 'This option allows you to select the default location when adding an event.','dbem' )." ".__('(not applicable with event ownership on presently, coming soon!)','dbem') );
131
+
132
+ /*default location country*/
133
+ em_options_select ( __( 'Default Location Country' ), 'dbem_location_default_country', em_get_countries(__('no default country', 'dbem')), __('If you select a default country, that will be pre-selected when creating a new location.','dbem') );
134
 
135
  em_options_textarea ( __( 'Custom Placeholders', 'dbem' ), 'dbem_placeholders_custom', sprintf(__( "You can add custom placeholders here, one per line in this format <code>#_ATT{key}</code>. They will not appear on event pages unless you insert them into another template below, but you may want to store extra information about an event for other uses. <a href='%s'>More information on placeholders.</a>", 'dbem' ), 'wp-events-plugin.com/documentation/the-em-templates-syntax/') );
136
 
327
  </div> <!-- .postbox -->
328
 
329
  <div class="postbox " >
330
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Booking and Ticketing Options', 'dbem' ); ?> </span></h3>
331
+ <div class="inside">
332
+ <table class='form-table'>
333
+ <?php
334
+ em_options_radio_binary ( __( 'Approval Required?', 'dbem' ), 'dbem_bookings_approval', __( 'Bookings will not be confirmed until the event administrator approves it.', 'dbem' ) );
335
+ em_options_radio_binary ( __( 'Show unavailable tickets?', 'dbem' ), 'dbem_bookings_tickets_show_unavailable', __( 'You can choose whether or not to show unavailable tickets to visitors.', 'dbem' ) );
336
+ em_options_radio_binary ( __( 'Reserved unconfirmed spaces?', 'dbem' ), 'dbem_bookings_approval_reserved', __( 'By default, event spaces become unavailable once there are enough CONFIRMED bookings. To reserve spaces even if unnapproved, choose yes.', 'dbem' ) );
337
+ em_options_radio_binary ( __( 'Show multiple tickets if logged out?', 'dbem' ), 'dbem_bookings_tickets_show_loggedout', __( 'If logged out, a user will be asked to register in order to book. However, we can show available tickets if you have more than one ticket.', 'dbem' ) );
338
+ em_options_radio_binary ( __( 'Allow overbooking when approving?', 'dbem' ), 'dbem_bookings_approval_overbooking', __( 'If you get a lot of pending bookings and you decide to allow more bookings than spaces allow, setting this to yes will allow you to override the event space limit when manually approving.', 'dbem' ) );
339
+ echo $save_button;
340
+ ?>
341
+ </table>
342
+ </div> <!-- . inside -->
343
+ </div> <!-- .postbox -->
344
+
345
+ <div class="postbox " >
346
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Booking Email Templates', 'dbem' ); ?> </span></h3>
347
  <div class="inside">
348
  <table class='form-table'>
349
  <?php
350
  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' ) );
 
351
  em_options_input_text ( __( 'Email events admin?', 'dbem' ), 'dbem_bookings_notify_admin', __( "If you would like every event booking confirmation email sent to an administrator write their email here (leave blank to not send an email).", 'dbem' ) );
352
  em_options_radio_binary ( __( 'Email contact person?', 'dbem' ), 'dbem_bookings_contact_email', __( 'Check this option if you want the event contact to receive an email when someone books places. An email will be sent when a booking is first made (regardless if confirmed or pending)', 'dbem' ) );
353
  ?>
426
  </div> <!-- .postbox -->
427
 
428
  <div class="postbox " >
429
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'User Capabilities', 'dbem' ); ?> (Beta)</span></h3>
430
  <div class="inside">
431
  <table class="form-table">
432
  <tr><td colspan="2">
433
  <strong><?php _e('Warning: Changing these values may result in exposing previously hidden information to all users.')?></strong><br />
 
434
  </td></tr>
 
435
  <?php
436
+ global $wp_roles;
437
+ global $em_capabilities_array;
438
+ ?>
439
+ <tr><td colspan="2">
440
+ <p><em><?php _e('You can now give fine grained control with regards to what your users can do with events. Each user role can have perform different sets of actions.','dbem'); ?></em></p>
441
+ <table class="form-table" style="width:auto;">
442
+ <?php foreach($wp_roles->role_objects as $role): ?>
443
+ <tr>
444
+ <th><?php echo $role->name; ?></th>
445
+ <td>
446
+ <table>
447
+ <?php foreach(array_keys($em_capabilities_array) as $capability): ?>
448
+ <tr>
449
+ <td><?php echo $capability; ?></td>
450
+ <td><input type="checkbox" name="em_capabilities[<?php echo $role->name; ?>][<?php echo $capability ?>]" value="1" <?php echo $role->has_cap($capability) ? 'checked="checked"':''; ?> /></td>
451
+ </tr>
452
+ <?php endforeach; ?>
453
+ </table>
454
+ </td>
455
+ </tr>
456
+ <?php endforeach; ?>
457
+ </table>
458
+ </td></tr>
459
+ <?php echo $save_button; ?>
460
  </table>
 
461
  </div> <!-- . inside -->
462
  </div> <!-- .postbox -->
463
+
464
+ <?php /*
465
+ <div class="postbox " >
466
+ <div class="handlediv" title="<?php __('Click to toggle'); ?>"><br /></div><h3 class='hndle'><span><?php _e ( 'Debug Modes', 'dbem' ); ?> </span></h3>
467
+ <div class="inside">
468
+ <table class='form-table'>
469
+ <?php
470
+ em_options_radio_binary ( __( 'EM Debug Mode?', 'dbem' ), 'dbem_debug', __( 'Setting this to yes will display different content to admins for event pages and emails so you can see all the available placeholders and their values.', 'dbem' ) );
471
+ em_options_radio_binary ( __( 'WP Debug Mode?', 'dbem' ), 'dbem_wp_debug', __( 'This will turn WP_DEBUG mode on. Useful if you want to troubleshoot php errors without looking at your logs.', 'dbem' ) );
472
+ ?>
473
+ </table>
474
+ </div> <!-- . inside -->
475
+ </div> <!-- .postbox -->
476
+ */ ?>
477
+
478
+ <?php do_action('em_options_page_footer'); ?>
479
+
480
  <p class="submit">
481
  <input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
482
  <input type="hidden" name="em-submitted" value="1" />
admin/em-people.php CHANGED
@@ -1,125 +1,10 @@
1
  <?php
2
- /**
3
- * Check for flags to save personal data
4
- */
5
- function em_person_actions(){
6
- global $EM_Person;
7
- if( !empty($_REQUEST['action']) && is_object($EM_Person) ){
8
- if( $_REQUEST['action'] == 'edit_person' ){
9
- $validation = $EM_Person->get_post();
10
- if ( $validation ) { //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
11
- //Save
12
- if( $EM_Person->save() ) {
13
- function em_person_save_notification(){
14
- global $EM_Person;
15
- ?><div class="updated"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
16
- }
17
- }else{
18
- function em_person_save_notification(){
19
- global $EM_Person;
20
- ?><div class="error"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
21
- }
22
- }
23
- }else{
24
- //TODO make errors clearer when saving person
25
- function em_person_save_notification(){
26
- global $EM_Person;
27
- ?><div class="error"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
28
- }
29
- }
30
- add_action ( 'admin_notices', 'em_person_save_notification' );
31
- }
32
- if( $_REQUEST['action'] == 'person_delete' ){
33
- if( $EM_Person->delete() ){
34
- //TODO delete person needs confirmation
35
- wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-bookings');
36
- exit();
37
- }else{
38
- function em_person_delete_notification(){
39
- global $EM_Person;
40
- ?><div class="error"><p><strong><?php echo $EM_Person->feedback_message; ?></strong></p></div><?php
41
- }
42
- }
43
- add_action ( 'admin_notices', 'em_person_delete_notification' );
44
- }
45
- }
46
- }
47
- add_action('admin_init','em_person_actions');
48
-
49
- /**
50
- * Generate an edit form for person details.
51
- */
52
- function em_person_edit_form(){
53
- global $EM_Person;
54
- ?>
55
- <form action="" method="post" id="em-person-form">
56
- <table>
57
- <tr><td><strong><?php _e('Name','dbem'); ?></strong></td><td><input type="text" name="person_name" size="60" value="<?php echo $EM_Person->name; ?>" /></td></tr>
58
- <tr><td><strong><?php _e('Phone','dbem'); ?></strong></td><td><input type="text" name="person_phone" size="60" value="<?php echo $EM_Person->phone; ?>" /></td></tr>
59
- <tr><td><strong><?php _e('E-mail','dbem'); ?></strong></td><td><input type="text" name="person_email" size="60" value="<?php echo $EM_Person->email; ?>" /></td></tr>
60
- </table>
61
- <p class="submit">
62
- <input type="submit" name="events_update" value="<?php _e ( 'Save' ); ?> &raquo;" />
63
- </p>
64
- <input type="hidden" name="action" value="person_edit" />
65
- <input type="hidden" name="person_id" value="<?php echo $EM_Person->id; ?>" />
66
- </form>
67
- <?php
68
- }
69
-
70
- /**
71
- * Depreciated page... for now at least.
72
- */
73
- function em_admin_people_page() {
74
- ?>
75
- <div class='wrap'>
76
- <div id="icon-users" class="icon32"><br/></div>
77
- <h2>People</h2>
78
- <?php
79
- $EM_People = EM_People::get();
80
- if (count($EM_People) < 1 ) {
81
- _e("No people have responded to your events yet!", 'dbem');
82
- } else {
83
- ?>
84
- <p><?php _e('This table collects the data about the people who responded to your events', 'dbem') ?></p>
85
- <table id='dbem-people-table' class='widefat post fixed'>
86
- <thead>
87
- <tr>
88
- <th class='manage-column column-cb check-column' scope='col'>&nbsp;</th>
89
- <th class='manage-column ' scope='col'>Name</th>
90
- <th scope='col'>E-mail</th>
91
- <th scope='col'>Phone number</th>
92
- </tr>
93
- </thead>
94
- <tfoot>
95
- <tr>
96
- <th class='manage-column column-cb check-column' scope='col'>&nbsp;</th>
97
- <th class='manage-column ' scope='col'>Name</th>
98
- <th scope='col'>E-mail</th>
99
- <th scope='col'>Phone number</th>
100
- </tr>
101
- </tfoot>
102
- <?php foreach ($EM_People as $EM_Person): ?>
103
- <tr>
104
- <td>&nbsp;</td>
105
- <td><?php echo $EM_Person->name ?></td>
106
- <td><?php echo $EM_Person->email ?></td>
107
- <td><?php echo $EM_Person->phone ?></td>
108
- </tr>
109
- <?php endforeach; ?>
110
- </table>
111
- <?php
112
- }
113
- ?>
114
- </div>
115
- <?php
116
- }
117
 
118
  function em_printable_booking_report() {
119
  global $EM_Event;
120
  //check that user can access this page
121
  if( isset($_GET['page']) && $_GET['page']=='events-manager-bookings' && isset($_GET['action']) && $_GET['action'] == 'bookings_report' && is_object($EM_Event)){
122
- if( is_object($EM_Event) && !$EM_Event->can_manage() ){
123
  ?>
124
  <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
125
  <?php
@@ -145,28 +30,28 @@ function em_printable_booking_report() {
145
  <th scope='col'><?php _e('Name', 'dbem')?></th>
146
  <th scope='col'><?php _e('E-mail', 'dbem')?></th>
147
  <th scope='col'><?php _e('Phone number', 'dbem')?></th>
148
- <th scope='col'><?php _e('Seats', 'dbem')?></th>
149
  <th scope='col'><?php _e('Comment', 'dbem')?></th>
150
  </tr>
151
  <?php foreach($EM_Event->get_bookings()->bookings as $EM_Booking) { ?>
152
  <tr>
153
 
154
- <td><?php echo $EM_Booking->person->name ?></td>
155
- <td><?php echo $EM_Booking->person->email ?></td>
156
  <td><?php echo $EM_Booking->person->phone ?></td>
157
- <td class='seats-number'><?php echo $EM_Booking->seats ?></td>
158
  <td><?php echo $EM_Booking->comment ?></td>
159
  </tr>
160
  <?php } ?>
161
- <tr id='booked-seats'>
162
  <td colspan='3'>&nbsp;</td>
163
  <td class='total-label'><?php _e('Booked', 'dbem')?>:</td>
164
- <td class='seats-number'><?php echo $EM_Event->get_bookings()->get_booked_seats(); ?></td>
165
  </tr>
166
- <tr id='available-seats'>
167
  <td colspan='3'>&nbsp;</td>
168
  <td class='total-label'><?php _e('Available', 'dbem')?>:</td>
169
- <td class='seats-number'><?php echo $EM_Event->get_bookings()->get_available_seats(); ?></td>
170
  </tr>
171
  </table>
172
  </div>
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  function em_printable_booking_report() {
4
  global $EM_Event;
5
  //check that user can access this page
6
  if( isset($_GET['page']) && $_GET['page']=='events-manager-bookings' && isset($_GET['action']) && $_GET['action'] == 'bookings_report' && is_object($EM_Event)){
7
+ if( is_object($EM_Event) && !$EM_Event->can_manage('edit_events','edit_others_events') ){
8
  ?>
9
  <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
10
  <?php
30
  <th scope='col'><?php _e('Name', 'dbem')?></th>
31
  <th scope='col'><?php _e('E-mail', 'dbem')?></th>
32
  <th scope='col'><?php _e('Phone number', 'dbem')?></th>
33
+ <th scope='col'><?php _e('Spaces', 'dbem')?></th>
34
  <th scope='col'><?php _e('Comment', 'dbem')?></th>
35
  </tr>
36
  <?php foreach($EM_Event->get_bookings()->bookings as $EM_Booking) { ?>
37
  <tr>
38
 
39
+ <td><?php echo $EM_Booking->person->display_name ?></td>
40
+ <td><?php echo $EM_Booking->person->user_email ?></td>
41
  <td><?php echo $EM_Booking->person->phone ?></td>
42
+ <td class='spaces-number'><?php echo $EM_Booking->get_spaces() ?></td>
43
  <td><?php echo $EM_Booking->comment ?></td>
44
  </tr>
45
  <?php } ?>
46
+ <tr id='booked-spaces'>
47
  <td colspan='3'>&nbsp;</td>
48
  <td class='total-label'><?php _e('Booked', 'dbem')?>:</td>
49
+ <td class='spaces-number'><?php echo $EM_Event->get_bookings()->get_booked_spaces(); ?></td>
50
  </tr>
51
+ <tr id='available-spaces'>
52
  <td colspan='3'>&nbsp;</td>
53
  <td class='total-label'><?php _e('Available', 'dbem')?>:</td>
54
+ <td class='spaces-number'><?php echo $EM_Event->get_bookings()->get_available_spaces(); ?></td>
55
  </tr>
56
  </table>
57
  </div>
buddypress/bp-em-activity.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * bp_em_record_activity()
4
+ *
5
+ * If the activity stream component is installed, this function will record activity items for your
6
+ * component.
7
+ *
8
+ * You must pass the function an associated array of arguments:
9
+ *
10
+ * $args = array(
11
+ * REQUIRED PARAMS
12
+ * 'action' => For em: "Andy high-fived John", "Andy posted a new update".
13
+ * 'type' => The type of action being carried out, for em 'new_friendship', 'joined_group'. This should be unique within your component.
14
+ *
15
+ * OPTIONAL PARAMS
16
+ * 'id' => The ID of an existing activity item that you want to update.
17
+ * 'content' => The content of your activity, if it has any, for em a photo, update content or blog post excerpt.
18
+ * 'component' => The slug of the component.
19
+ * 'primary_link' => The link for the title of the item when appearing in RSS feeds (defaults to the activity permalink)
20
+ * 'item_id' => The ID of the main piece of data being recorded, for em a group_id, user_id, forum_post_id - useful for filtering and deleting later on.
21
+ * 'user_id' => The ID of the user that this activity is being recorded for. Pass false if it's not for a user.
22
+ * 'recorded_time' => (optional) The time you want to set as when the activity was carried out (defaults to now)
23
+ * 'hide_sitewide' => Should this activity item appear on the site wide stream?
24
+ * 'secondary_item_id' => (optional) If the activity is more complex you may need a second ID. For em a group forum post may need the group_id AND the forum_post_id.
25
+ * )
26
+ *
27
+ * Events usage would be:
28
+ *
29
+ * bp_em_record_activity( array( 'type' => 'new_highfive', 'action' => 'Andy high-fived John', 'user_id' => $bp->loggedin_user->id, 'item_id' => $bp->displayed_user->id ) );
30
+ *
31
+ */
32
+ function bp_em_record_activity( $args = '' ) {
33
+ if ( !function_exists( 'bp_activity_add' ) )
34
+ return false;
35
+
36
+ $defaults = array(
37
+ 'id' => false,
38
+ 'user_id' => '',
39
+ 'action' => '',
40
+ 'content' => '',
41
+ 'primary_link' => '',
42
+ 'component' => 'events-manager',
43
+ 'type' => false,
44
+ 'item_id' => false,
45
+ 'secondary_item_id' => false,
46
+ 'recorded_time' => gmdate( "Y-m-d H:i:s" ),
47
+ 'hide_sitewide' => false
48
+ );
49
+
50
+ $r = wp_parse_args( $args, $defaults );
51
+ extract( $r );
52
+
53
+ return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
54
+ }
55
+
56
+ /**
57
+ * Records new events to the activity stream.
58
+ * @param unknown_type $result
59
+ * @param unknown_type $EM_Event
60
+ * @return unknown
61
+ */
62
+ function bp_em_record_activity_event_save( $result, $EM_Event ){
63
+ if( $result && $EM_Event->status == 1 && ($EM_Event->previous_status == 0 || !empty($EM_Event->is_new)) ){
64
+ $user = get_userdata($EM_Event->owner);
65
+ bp_em_record_activity( array(
66
+ 'user_id' => $user->ID,
67
+ 'action' => sprintf(__('%s added a the event %s','dbem'), "<a href='".get_bloginfo('wpurl').'/'.BP_MEMBERS_SLUG.'/'.$user->user_login."/'>".$user->display_name."</a>", $EM_Event->output('#_EVENTLINK') ),
68
+ 'primary_link' => $EM_Event->output('#_EVENTURL'),
69
+ 'type' => 'new_event',
70
+ 'item_id' => $EM_Event->id,
71
+ ));
72
+ }
73
+ return $result;
74
+ }
75
+ add_filter('em_event_save','bp_em_record_activity_event_save', 10, 2);
76
+
77
+ /**
78
+ * @param boolean $result
79
+ * @param EM_Booking $EM_Booking
80
+ * @return boolean
81
+ */
82
+ function bp_em_record_activity_booking_save( $result, $EM_Booking ){
83
+ if( $result ){
84
+ $user = $EM_Booking->person;
85
+ $user_link = "<a href='".get_bloginfo('wpurl').'/'.BP_MEMBERS_SLUG.'/'.$user->user_login."/'>".$user->display_name."</a>";
86
+ $event_link = $EM_Booking->get_event()->output('#_EVENTLINK');
87
+ $status = $EM_Booking->status;
88
+ if( $status == 1 || (!get_option('dbem_bookings_approval') && $status < 2) ){
89
+ $action = sprintf(__('%s is attending %s.','dbem'), $user_link, $event_link );
90
+ }elseif( ($EM_Booking->previous_status == 1 || (!get_option('dbem_bookings_approval') && $EM_Booking->previous_status < 2)) && $status > 1 ){
91
+ $action = sprintf(__('%s will not be attending %s anymore.','dbem'), $user_link, $event_link );
92
+ }
93
+ if( !empty($action) ){
94
+ bp_em_record_activity( array(
95
+ 'user_id' => $EM_Booking->person->ID,
96
+ 'action' => $action,
97
+ 'primary_link' => $EM_Booking->get_event()->output('#_EVENTURL'),
98
+ 'type' => 'new_booking',
99
+ 'item_id' => $EM_Event->id,
100
+ 'secondary_item_id' => $EM_Booking->id
101
+ ));
102
+ }
103
+ }
104
+ return $result;
105
+ }
106
+ add_filter('em_booking_save','bp_em_record_activity_booking_save', 10, 2);
buddypress/bp-em-admin.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /***
4
+ * This file is used to add site administration menus to the WordPress backend.
5
+ *
6
+ * If you need to provide configuration options for your component that can only
7
+ * be modified by a site administrator, this is the best place to do it.
8
+ *
9
+ * However, if your component has settings that need to be configured on a user
10
+ * by user basis - it's best to hook into the front end "Settings" menu.
11
+ */
12
+
13
+ /**
14
+ * bp_em_admin()
15
+ *
16
+ * Checks for form submission, saves component settings and outputs admin screen HTML.
17
+ */
18
+ function bp_em_admin() {
19
+ global $bp;
20
+
21
+ /* If the form has been submitted and the admin referrer checks out, save the settings */
22
+ if ( isset( $_POST['submit'] ) && check_admin_referer('em-settings') ) {
23
+ update_option( 'em-setting-one', $_POST['em-setting-one'] );
24
+ update_option( 'em-setting-two', $_POST['em-setting-two'] );
25
+
26
+ $updated = true;
27
+ }
28
+
29
+ $setting_one = get_option( 'em-setting-one' );
30
+ $setting_two = get_option( 'em-setting-two' );
31
+ ?>
32
+ <div class="wrap">
33
+ <h2><?php _e( 'Events Admin', 'bp-em' ) ?></h2>
34
+ <br />
35
+
36
+ <?php if ( isset($updated) ) : ?><?php echo "<div id='message' class='updated fade'><p>" . __( 'Settings Updated.', 'bp-em' ) . "</p></div>" ?><?php endif; ?>
37
+
38
+ <form action="<?php echo site_url() . '/wp-admin/admin.php?page=bp-em-settings' ?>" name="em-settings-form" id="em-settings-form" method="post">
39
+
40
+ <table class="form-table">
41
+ <tr valign="top">
42
+ <th scope="row"><label for="target_uri"><?php _e( 'Option One', 'bp-em' ) ?></label></th>
43
+ <td>
44
+ <input name="em-setting-one" type="text" id="em-setting-one" value="<?php echo attribute_escape( $setting_one ); ?>" size="60" />
45
+ </td>
46
+ </tr>
47
+ <th scope="row"><label for="target_uri"><?php _e( 'Option Two', 'bp-em' ) ?></label></th>
48
+ <td>
49
+ <input name="em-setting-two" type="text" id="em-setting-two" value="<?php echo attribute_escape( $setting_two ); ?>" size="60" />
50
+ </td>
51
+ </tr>
52
+ </table>
53
+ <p class="submit">
54
+ <input type="submit" name="submit" value="<?php _e( 'Save Settings', 'bp-em' ) ?>"/>
55
+ </p>
56
+
57
+ <?php
58
+ /* This is very important, don't leave it out. */
59
+ wp_nonce_field( 'em-settings' );
60
+ ?>
61
+ </form>
62
+ </div>
63
+ <?php
64
+ }
65
+ ?>
buddypress/bp-em-core.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Define a slug constant that will be used to view this components pages
3
+ if ( !defined( 'BP_EM_SLUG' ) )
4
+ define ( 'BP_EM_SLUG', 'events' );
5
+
6
+ //Include component files
7
+ require ( dirname( __FILE__ ) . '/bp-em-activity.php' ); /* The notifications file should contain functions to send email notifications on specific user actions */
8
+ require ( dirname( __FILE__ ) . '/bp-em-templatetags.php' ); /* The templatetags file should contain classes and functions designed for use in template files */
9
+ require ( dirname( __FILE__ ) . '/bp-em-notifications.php' ); /* The notifications file should contain functions to send email notifications on specific user actions */
10
+ //Screens
11
+ include( dirname( __FILE__ ). '/screens/settings.php');
12
+ include( dirname( __FILE__ ). '/screens/profile.php');
13
+ include( dirname( __FILE__ ). '/screens/my-events.php');
14
+ include( dirname( __FILE__ ). '/screens/my-locations.php');
15
+ include( dirname( __FILE__ ). '/screens/attending.php');
16
+
17
+
18
+ /**
19
+ * bp_em_setup_globals()
20
+ *
21
+ * Sets up global variables for your component.
22
+ */
23
+ function bp_em_setup_globals() {
24
+ global $bp, $wpdb;
25
+ $bp->events = new stdClass();
26
+ $bp->events->id = 'events';
27
+ //$bp->events->table_name = $wpdb->base_prefix . 'bp_em';
28
+ $bp->events->format_notification_function = 'bp_em_format_notifications';
29
+ $bp->events->slug = BP_EM_SLUG;
30
+ /* Register this in the active components array */
31
+ $bp->active_components[$bp->events->slug] = $bp->events->id;
32
+ //quick link shortcut
33
+ $bp->events->link = trailingslashit($bp->loggedin_user->domain).'events/';
34
+ }
35
+ add_action( 'wp', 'bp_em_setup_globals', 2 );
36
+ //add_action( 'admin_menu', 'bp_em_setup_globals', 2 );
37
+
38
+ /**
39
+ * bp_em_setup_nav()
40
+ *
41
+ * Sets up the user profile navigation items for the component. This adds the top level nav
42
+ * item and all the sub level nav items to the navigation array. This is then
43
+ * rendered in the template.
44
+ */
45
+ function bp_em_setup_nav() {
46
+ global $bp;
47
+
48
+ /* Add 'Events' to the main user profile navigation */
49
+ bp_core_new_nav_item( array(
50
+ 'name' => __( 'Events', 'bp-em' ),
51
+ 'slug' => $bp->events->slug,
52
+ 'position' => 80,
53
+ 'screen_function' => bp_is_my_profile() ? 'bp_em_my_events':'bp_em_events',
54
+ 'default_subnav_slug' => bp_is_my_profile() ? 'my-events':''
55
+ ) );
56
+
57
+ $em_link = $bp->loggedin_user->domain . $bp->events->slug . '/';
58
+
59
+ if( bp_is_my_profile() ){
60
+ /* Create two sub nav items for this component */
61
+ bp_core_new_subnav_item( array(
62
+ 'name' => __( 'My Profile', 'dbem' ),
63
+ 'slug' => 'profile',
64
+ 'parent_slug' => $bp->events->slug,
65
+ 'parent_url' => $em_link,
66
+ 'screen_function' => 'bp_em_events',
67
+ 'position' => 10
68
+ ) );
69
+ }
70
+
71
+ bp_core_new_subnav_item( array(
72
+ 'name' => __( 'Events I\'m Attending', 'dbem' ),
73
+ 'slug' => 'attending',
74
+ 'parent_slug' => $bp->events->slug,
75
+ 'parent_url' => $em_link,
76
+ 'screen_function' => 'bp_em_attending',
77
+ 'position' => 20,
78
+ 'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
79
+ ) );
80
+
81
+ bp_core_new_subnav_item( array(
82
+ 'name' => __( 'My Events', 'dbem' ),
83
+ 'slug' => 'my-events',
84
+ 'parent_slug' => $bp->events->slug,
85
+ 'parent_url' => $em_link,
86
+ 'screen_function' => 'bp_em_my_events',
87
+ 'position' => 30,
88
+ 'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
89
+ ) );
90
+
91
+ bp_core_new_subnav_item( array(
92
+ 'name' => __( 'My Locations', 'dbem' ),
93
+ 'slug' => 'my-locations',
94
+ 'parent_slug' => $bp->events->slug,
95
+ 'parent_url' => $em_link,
96
+ 'screen_function' => 'bp_em_my_locations',
97
+ 'position' => 40,
98
+ 'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
99
+ ) );
100
+
101
+ /* Add a nav item for this component under the settings nav item. */
102
+ bp_core_new_subnav_item( array(
103
+ 'name' => __( 'Events', 'dbem' ),
104
+ 'slug' => 'events-settings',
105
+ 'parent_slug' => $bp->settings->slug,
106
+ 'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/',
107
+ 'screen_function' => 'bp_em_screen_settings_menu',
108
+ 'position' => 40,
109
+ 'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile
110
+ ) );
111
+ }
112
+
113
+ /***
114
+ * In versions of BuddyPress 1.2.2 and newer you will be able to use:
115
+ * add_action( 'bp_setup_nav', 'bp_example_setup_nav' );
116
+ */
117
+ add_action( 'wp', 'bp_em_setup_nav', 2 );
118
+ add_action( 'admin_menu', 'bp_em_setup_nav', 2 );
119
+
120
+ /**
121
+ * bp_em_load_template_filter()
122
+ *
123
+ * You can define a custom load template filter for your component. This will allow
124
+ * you to store and load template files from your plugin directory.
125
+ *
126
+ * This will also allow users to override these templates in their active theme and
127
+ * replace the ones that are stored in the plugin directory.
128
+ *
129
+ * If you're not interested in using template files, then you don't need this function.
130
+ *
131
+ * This will become clearer in the function bp_em_screen_one() when you want to load
132
+ * a template file.
133
+ */
134
+ function bp_em_load_template_filter( $found_template, $templates ) {
135
+ global $bp;
136
+
137
+ /**
138
+ * Only filter the template location when we're on the em component pages.
139
+ */
140
+ if ( $bp->current_component != $bp->events->slug )
141
+ return $found_template;
142
+
143
+ foreach ( (array) $templates as $template ) {
144
+ if ( file_exists( STYLESHEETPATH . '/' . $template ) )
145
+ $filtered_templates[] = STYLESHEETPATH . '/' . $template;
146
+ else
147
+ $filtered_templates[] = dirname( __FILE__ ) . '/templates/' . $template;
148
+ }
149
+
150
+ $found_template = $filtered_templates[0];
151
+
152
+ return apply_filters( 'bp_em_load_template_filter', $found_template );
153
+ }
154
+ add_filter( 'bp_located_template', 'bp_em_load_template_filter', 10, 2 );
155
+
156
+ /**
157
+ * Remove a screen notification for a user.
158
+ */
159
+ function bp_em_remove_screen_notifications() {
160
+ global $bp;
161
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->events->slug, 'attending' );
162
+ }
163
+ add_action( 'bp_em_my_events', 'bp_em_remove_screen_notifications' );
164
+ add_action( 'xprofile_screen_display_profile', 'bp_em_remove_screen_notifications' );
165
+
166
+ /**
167
+ * Delete events when you delete a user.
168
+ */
169
+ function bp_em_remove_data( $user_id ) {
170
+ $EM_Events = EM_Events::get(array('scope'=>'all','owner'=>$user_id, 'status'=>false));
171
+ EM_Events::delete($EM_Events);
172
+ }
173
+ add_action( 'wpmu_delete_user', 'bp_em_remove_data', 1 );
174
+ add_action( 'delete_user', 'bp_em_remove_data', 1 );
175
+ ?>
buddypress/bp-em-notifications.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Notification functions are used to send email notifications to users on specific events
5
+ * They will check to see the users notification settings first, if the user has the notifications
6
+ * turned on, they will be sent a formatted email notification.
7
+ *
8
+ * You should use your own custom actions to determine when an email notification should be sent.
9
+ */
10
+
11
+ function bp_em_send_high_five_notification( $to_user_id, $from_user_id ) {
12
+ global $bp;
13
+
14
+ /* Let's grab both user's names to use in the email. */
15
+ $sender_name = bp_core_get_user_displayname( $from_user_id, false );
16
+ $reciever_name = bp_core_get_user_displayname( $to_user_id, false );
17
+
18
+ /* We need to check to see if the recipient has opted not to recieve high-five emails */
19
+ if ( 'no' == get_usermeta( (int)$to_user_id, 'notification_em_new_high_five' ) )
20
+ return false;
21
+
22
+ /* Get the userdata for the reciever and sender, this will include usernames and emails that we need. */
23
+ $reciever_ud = get_userdata( $to_user_id );
24
+ $sender_ud = get_userdata( $from_user_id );
25
+
26
+ /* Now we need to construct the URL's that we are going to use in the email */
27
+ $sender_profile_link = site_url( BP_MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->profile->slug );
28
+ $sender_highfive_link = site_url( BP_MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->events->slug . '/screen-one' );
29
+ $reciever_settings_link = site_url( BP_MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/settings/notifications' );
30
+
31
+ /* Set up and send the message */
32
+ $to = $reciever_ud->user_email;
33
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( '%s high-fived you!', 'bp-em' ), stripslashes($sender_name) );
34
+
35
+ $message = sprintf( __(
36
+ '%s sent you a high-five! Why not send one back?
37
+
38
+ To see %s\'s profile: %s
39
+
40
+ To send %s a high five: %s
41
+
42
+ ---------------------
43
+ ', 'bp-em' ), $sender_name, $sender_name, $sender_profile_link, $sender_name, $sender_highfive_link );
44
+
45
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'bp-em' ), $reciever_settings_link );
46
+
47
+ // Send it!
48
+ wp_mail( $to, $subject, $message );
49
+ }
50
+ add_action( 'bp_em_send_high_five', 'bp_em_send_high_five_notification', 10, 2 );
51
+
52
+
53
+ /********************************************************************************
54
+ * Activity & Notification Functions
55
+ *
56
+ * These functions handle the recording, deleting and formatting of activity and
57
+ * notifications for the user and for this specific component.
58
+ */
59
+
60
+
61
+ /**
62
+ * bp_em_screen_notification_settings()
63
+ *
64
+ * Adds notification settings for the component, so that a user can turn off email
65
+ * notifications set on specific component actions.
66
+ */
67
+ function bp_em_screen_notification_settings() {
68
+ global $current_user;
69
+
70
+ /**
71
+ * Under Settings > Notifications within a users profile page they will see
72
+ * settings to turn off notifications for each component.
73
+ *
74
+ * You can plug your custom notification settings into this page, so that when your
75
+ * component is active, the user will see options to turn off notifications that are
76
+ * specific to your component.
77
+ */
78
+
79
+ /**
80
+ * Each option is stored in a posted array notifications[SETTING_NAME]
81
+ * When saved, the SETTING_NAME is stored as usermeta for that user.
82
+ *
83
+ * For em, notifications[notification_friends_friendship_accepted] could be
84
+ * used like this:
85
+ *
86
+ * if ( 'no' == get_usermeta( $bp['loggedin_userid], 'notification_friends_friendship_accepted' ) )
87
+ * // don't send the email notification
88
+ * else
89
+ * // send the email notification.
90
+ */
91
+
92
+ ?>
93
+ <table class="notification-settings" id="bp-em-notification-settings">
94
+ <tr>
95
+ <th class="icon"></th>
96
+ <th class="title"><?php _e( 'Events', 'bp-em' ) ?></th>
97
+ <th class="yes"><?php _e( 'Yes', 'bp-em' ) ?></th>
98
+ <th class="no"><?php _e( 'No', 'bp-em' )?></th>
99
+ </tr>
100
+ <tr>
101
+ <td></td>
102
+ <td><?php _e( 'Action One', 'bp-em' ) ?></td>
103
+ <td class="yes"><input type="radio" name="notifications[notification_em_action_one]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_em_action_one') || 'yes' == get_usermeta( $current_user->id,'notification_em_action_one') ) { ?>checked="checked" <?php } ?>/></td>
104
+ <td class="no"><input type="radio" name="notifications[notification_em_action_one]" value="no" <?php if ( get_usermeta( $current_user->id,'notification_em_action_one') == 'no' ) { ?>checked="checked" <?php } ?>/></td>
105
+ </tr>
106
+ <tr>
107
+ <td></td>
108
+ <td><?php _e( 'Action Two', 'bp-em' ) ?></td>
109
+ <td class="yes"><input type="radio" name="notifications[notification_em_action_two]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_em_action_two') || 'yes' == get_usermeta( $current_user->id,'notification_em_action_two') ) { ?>checked="checked" <?php } ?>/></td>
110
+ <td class="no"><input type="radio" name="notifications[notification_em_action_two]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id,'notification_em_action_two') ) { ?>checked="checked" <?php } ?>/></td>
111
+ </tr>
112
+
113
+ <?php do_action( 'bp_em_notification_settings' ); ?>
114
+ </table>
115
+ <?php
116
+ }
117
+ add_action( 'bp_notification_settings', 'bp_em_screen_notification_settings' );
118
+
119
+ /**
120
+ * bp_em_format_notifications()
121
+ *
122
+ * The format notification function will take DB entries for notifications and format them
123
+ * so that they can be displayed and read on the screen.
124
+ *
125
+ * Notifications are "screen" notifications, that is, they appear on the notifications menu
126
+ * in the site wide navigation bar. They are not for email notifications.
127
+ *
128
+ *
129
+ * The recording is done by using bp_core_add_notification() which you can search for in this file for
130
+ * ems of usage.
131
+ */
132
+ function bp_em_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
133
+ global $bp;
134
+
135
+ switch ( $action ) {
136
+ case 'new_high_five':
137
+ /* In this case, $item_id is the user ID of the user who sent the high five. */
138
+
139
+ /***
140
+ * We don't want a whole list of similar notifications in a users list, so we group them.
141
+ * If the user has more than one action from the same component, they are counted and the
142
+ * notification is rendered differently.
143
+ */
144
+ if ( (int)$total_items > 1 ) {
145
+ return apply_filters( 'bp_em_multiple_new_high_five_notification', '<a href="' . $bp->loggedin_user->domain . $bp->events->slug . '/screen-one/" title="' . __( 'Multiple high-fives', 'bp-em' ) . '">' . sprintf( __( '%d new high-fives, multi-five!', 'bp-em' ), (int)$total_items ) . '</a>', $total_items );
146
+ } else {
147
+ $user_fullname = bp_core_get_user_displayname( $item_id, false );
148
+ $user_url = bp_core_get_userurl( $item_id );
149
+ return apply_filters( 'bp_em_single_new_high_five_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s sent you a high-five!', 'bp-em' ), $user_fullname ) . '</a>', $user_fullname );
150
+ }
151
+ break;
152
+ }
153
+
154
+ do_action( 'bp_em_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
155
+
156
+ return false;
157
+ }
buddypress/bp-em-templatetags.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * In this file you should define template tag functions that end users can add to their template files.
5
+ * Each template tag function should echo the final data so that it will output the required information
6
+ * just by calling the function name.
7
+ */
buddypress/screens/attending.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * bp_em_screen_two()
4
+ *
5
+ * Sets up and displays the screen output for the sub nav item "em/screen-two"
6
+ */
7
+ function bp_em_attending() {
8
+ global $bp;
9
+ /**
10
+ * If the user has not Accepted or Rejected anything, then the code above will not run,
11
+ * we can continue and load the template.
12
+ */
13
+ do_action( 'bp_em_attending' );
14
+
15
+ add_action( 'bp_template_title', 'bp_em_attending_title' );
16
+ add_action( 'bp_template_content', 'bp_em_attending_content' );
17
+
18
+ /* Finally load the plugin template file. */
19
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
20
+ }
21
+
22
+ function bp_em_attending_title() {
23
+ _e( 'Attending', 'bp-em' );
24
+ }
25
+
26
+ function bp_em_attending_content() {
27
+ global $bp;
28
+ $EM_Person = new EM_Person($bp->displayed_user->id);
29
+ $events = $EM_Person->get_events();
30
+ $args = array(
31
+ 'format_header' => get_option('dbem_bp_events_list_format_header'),
32
+ 'format' => get_option('dbem_bp_events_list_format'),
33
+ 'format_footer' => get_option('dbem_bp_events_list_format_footer')
34
+ );
35
+ if( count($events) > 0 ){
36
+ echo EM_Events::output($events, $args);
37
+ }else{
38
+ echo get_option('dbem_bp_events_list_none_format');
39
+ }
40
+ }
buddypress/screens/my-events.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Controller for the event views in BP (using mvc terms here)
4
+ */
5
+ function bp_em_my_events() {
6
+ global $bp, $EM_Event;
7
+ if( !is_object($EM_Event) && !empty($_REQUEST['event_id']) ){
8
+ $EM_Event = new EM_Event($_REQUEST['event_id']);
9
+ }
10
+
11
+ do_action( 'bp_em_my_events' );
12
+
13
+ //plug into EM admin code (at least for now)
14
+ include_once(EM_DIR.'/admin/em-admin.php');
15
+ em_admin_load_scripts();
16
+ add_action('wp_head','em_admin_general_script');
17
+
18
+ $template_title = 'bp_em_my_events_title';
19
+ $template_content = 'bp_em_my_events_content';
20
+
21
+ if( count($bp->action_variables) > 0 ){
22
+ if( is_object($EM_Event) && !$EM_Event->can_manage('edit_events','edit_others_events') ) return false;
23
+ if( !empty($bp->action_variables[0]) ){
24
+ switch($bp->action_variables[0]){
25
+ case 'edit':
26
+ $template_title = 'bp_em_my_events_editor_title';
27
+ $template_content = 'bp_em_my_events_editor';
28
+ break;
29
+ }
30
+ }
31
+ }
32
+
33
+ add_action( 'bp_template_title', $template_title );
34
+ add_action( 'bp_template_content', $template_content );
35
+
36
+ /* Finally load the plugin template file. */
37
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
38
+ }
39
+
40
+ function bp_em_my_events_title() {
41
+ _e( 'My Events', 'dbem' );
42
+ }
43
+
44
+ /**
45
+ * Determines whether to show event page or events page, and saves any updates to the event or events
46
+ * @return null
47
+ */
48
+ function bp_em_my_events_content() {
49
+ em_locate_template('buddypress/events/my-events.php', true);
50
+ }
51
+
52
+ function bp_em_my_events_editor_title() {
53
+ global $EM_Event;
54
+ if( is_object($EM_Event) ){
55
+ _e( 'Edit Event', 'dbem' );
56
+ }else{
57
+ _e( 'Add Event', 'dbem' );
58
+ }
59
+ }
60
+
61
+ function bp_em_my_events_editor(){
62
+ em_locate_template('forms/events/editor.php', true);
63
+ }
64
+
65
+ ?>
buddypress/screens/my-locations.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Controller for the location views in BP (using mvc terms here)
4
+ */
5
+ function bp_em_my_locations() {
6
+ global $bp, $EM_Location;
7
+ if( !is_object($EM_Location) && !empty($_REQUEST['location_id']) ){
8
+ $EM_Location = new EM_Location($_REQUEST['location_id']);
9
+ }
10
+
11
+ do_action( 'bp_em_my_locations' );
12
+
13
+ //plug into EM admin code (at least for now)
14
+ include_once(EM_DIR.'/admin/em-admin.php');
15
+ em_admin_load_scripts();
16
+ add_action('wp_head','em_admin_general_script');
17
+
18
+ $template_title = 'bp_em_my_locations_title';
19
+ $template_content = 'bp_em_my_locations_content';
20
+
21
+ if( count($bp->action_variables) > 0 ){
22
+ if( is_object($EM_Location) && !$EM_Location->can_manage('edit_locations','edit_others_locations') ) return false;
23
+ if( !empty($bp->action_variables[0]) ){
24
+ switch($bp->action_variables[0]){
25
+ case 'edit':
26
+ $template_title = 'bp_em_my_locations_editor_title';
27
+ $template_content = 'bp_em_my_locations_editor_content';
28
+ break;
29
+ default :
30
+ $template_title = 'bp_em_my_locations_title';
31
+ $template_content = 'bp_em_my_locations_content';
32
+ break;
33
+ }
34
+ }else{
35
+ $template_title = 'bp_em_my_locations_title';
36
+ $template_content = 'bp_em_my_locations_content';
37
+ }
38
+ }
39
+
40
+ add_action( 'bp_template_title', $template_title );
41
+ add_action( 'bp_template_content', $template_content );
42
+
43
+ /* Finally load the plugin template file. */
44
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
45
+ }
46
+
47
+ function bp_em_my_locations_title() {
48
+ _e( 'My Locations', 'dbem' );
49
+ }
50
+
51
+ /**
52
+ * Determines whether to show location page or locations page, and saves any updates to the location or locations
53
+ * @return null
54
+ */
55
+ function bp_em_my_locations_content() {
56
+ em_locate_template('buddypress/locations/my-locations.php', true);
57
+ }
58
+
59
+ function bp_em_my_locations_editor_title() {
60
+ global $EM_Location;
61
+ if( is_object($EM_Location) ){
62
+ _e( 'Edit Location', 'dbem' );
63
+ }else{
64
+ _e( 'Add Location', 'dbem' );
65
+ }
66
+ }
67
+
68
+ function bp_em_my_locations_editor_content(){
69
+ em_locate_template('forms/locations/editor.php', true);
70
+ }
71
+
72
+ ?>
buddypress/screens/profile.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * bp_em_screen_one()
4
+ *
5
+ * Sets up and displays the screen output for the sub nav item "em/screen-one"
6
+ */
7
+ function bp_em_events() {
8
+ global $bp, $EM_Notices;
9
+
10
+ if( bp_is_my_profile() ){
11
+ $EM_Notices->add_info( __('You are currently viewing your public page, this is what other users will see.', 'dbem') );
12
+ }
13
+
14
+ /* Add a do action here, so your component can be extended by others. */
15
+ do_action( 'bp_em_events' );
16
+
17
+ add_action( 'bp_template_title', 'bp_em_events_title' );
18
+ add_action( 'bp_template_content', 'bp_em_events_content' );
19
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
20
+ //bp_core_load_template( apply_filters( 'bp_em_template_screen_one', 'em/screen-one' ) );
21
+ }
22
+ /***
23
+ * The second argument of each of the above add_action() calls is a function that will
24
+ * display the corresponding information. The functions are presented below:
25
+ */
26
+ function bp_em_events_title() {
27
+ _e( 'Events', 'bp-em' );
28
+ }
29
+
30
+ function bp_em_events_content() {
31
+ global $bp, $EM_Notices;
32
+ echo $EM_Notices;
33
+ ?>
34
+ <h4><?php _e('My Events', 'dbem'); ?></h4>
35
+ <?php
36
+ $events = EM_Events::get(array('owner'=>$bp->displayed_user->id));
37
+ if( count($events) > 0 ){
38
+ $args = array(
39
+ 'format_header' => get_option('dbem_bp_events_list_format_header'),
40
+ 'format' => get_option('dbem_bp_events_list_format'),
41
+ 'format_footer' => get_option('dbem_bp_events_list_format_footer'),
42
+ 'owner' => $bp->displayed_user->id
43
+ );
44
+ echo EM_Events::output($events, $args);
45
+ }else{
46
+ ?>
47
+ <p><?php _e('No Events', 'dbem'); ?></p>
48
+ <?php
49
+ }
50
+ ?>
51
+ <h4><?php _e("Events I'm Attending", 'dbem'); ?></h4>
52
+ <?php
53
+ bp_em_attending_content();
54
+ }
buddypress/screens/settings.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function bp_em_settings() {
3
+ global $bp, $current_user, $bp_settings_updated, $pass_error;
4
+
5
+ if ( isset( $_POST['submit'] ) ) {
6
+ /* Check the nonce */
7
+ check_admin_referer('bp-em-admin');
8
+
9
+ $bp_settings_updated = true;
10
+
11
+ /**
12
+ * This is when the user has hit the save button on their settings.
13
+ * The best place to store these settings is in wp_usermeta.
14
+ */
15
+ update_usermeta( $bp->loggedin_user->id, 'bp-em-option-one', attribute_escape( $_POST['bp-em-option-one'] ) );
16
+ }
17
+
18
+ add_action( 'bp_template_content_header', 'bp_em_screen_settings_menu_header' );
19
+ add_action( 'bp_template_title', 'bp_em_screen_settings_menu_title' );
20
+ add_action( 'bp_template_content', 'bp_em_screen_settings_menu_content' );
21
+
22
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
23
+ }
24
+
25
+ function bp_em_screen_settings_menu_header() {
26
+ _e( 'Events Settings Header', 'bp-em' );
27
+ }
28
+
29
+ function bp_em_screen_settings_menu_title() {
30
+ _e( 'Events Settings', 'bp-em' );
31
+ }
32
+
33
+ function bp_em_screen_settings_menu_content() {
34
+ global $bp, $bp_settings_updated; ?>
35
+
36
+ <?php if ( $bp_settings_updated ) { ?>
37
+ <div id="message" class="updated fade">
38
+ <p><?php _e( 'Changes Saved.', 'bp-em' ) ?></p>
39
+ </div>
40
+ <?php } ?>
41
+
42
+ <form action="<?php echo $bp->loggedin_user->domain . 'settings/events'; ?>" name="bp-em-admin-form" id="account-delete-form" class="bp-em-admin-form" method="post">
43
+
44
+ <input type="checkbox" name="bp-em-option-one" id="bp-em-option-one" value="1"<?php if ( '1' == get_usermeta( $bp->loggedin_user->id, 'bp-em-option-one' ) ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Do you love clicking checkboxes?', 'bp-em' ); ?>
45
+ <p class="submit">
46
+ <input type="submit" value="<?php _e( 'Save Settings', 'bp-em' ) ?> &raquo;" id="submit" name="submit" />
47
+ </p>
48
+
49
+ <?php
50
+ /* This is very important, don't leave it out. */
51
+ wp_nonce_field( 'bp-em-admin' );
52
+ ?>
53
+
54
+ </form>
55
+ <?php
56
+ }
classes/em-booking.php CHANGED
@@ -4,7 +4,8 @@ class EM_Booking extends EM_Object{
4
  var $id;
5
  var $event_id;
6
  var $person_id;
7
- var $seats;
 
8
  var $comment;
9
  var $status = 0;
10
  var $notes = array();
@@ -12,26 +13,44 @@ class EM_Booking extends EM_Object{
12
  'booking_id' => array('name'=>'id','type'=>'%d'),
13
  'event_id' => array('name'=>'event_id','type'=>'%d'),
14
  'person_id' => array('name'=>'person_id','type'=>'%d'),
15
- 'booking_seats' => array('name'=>'seats','type'=>'%d'),
 
16
  'booking_comment' => array('name'=>'comment','type'=>'%s'),
17
  'booking_status' => array('name'=>'status','type'=>'%d')
18
  );
19
  //Other Vars
20
  var $timestamp;
21
  var $person;
22
- var $required_fields = array('booking_id', 'event_id', 'person_id', 'booking_seats');
23
  var $feedback_message = "";
24
  var $errors = array();
 
 
 
 
 
25
  /**
26
  * If saved in this instance, you can see what previous approval status was.
27
  * @var int
28
  */
29
- var $previous_status = false;
30
  /**
31
  * The booking approval status number corresponds to a state in this array.
32
  * @var unknown_type
33
  */
34
  var $status_array = array();
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  /**
37
  * Creates booking object and retreives booking data (default is a blank booking object). Accepts either array of booking data (from db) or a booking id.
@@ -39,26 +58,19 @@ class EM_Booking extends EM_Object{
39
  * @return null
40
  */
41
  function EM_Booking( $booking_data = false ){
42
- if( !get_option('dbem_bookings_approval') ){
43
- $this->status = 1;
44
- }
45
- if( $booking_data !== false ){
46
  //Load booking data
47
  $booking = array();
48
  if( is_array($booking_data) ){
49
  $booking = $booking_data;
50
- //Also create a person out of this...
51
- $this->person = new EM_Person($booking_data);
52
- if( !empty($booking['person_id']) && $booking['person_id'] != $this->person->id){
53
- $this->person = new EM_Person($booking['booking_id']);
54
- }
55
  }elseif( is_numeric($booking_data) ){
56
  //Retreiving from the database
57
  global $wpdb;
58
- $sql = "SELECT * FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." WHERE booking_id ='$booking_data'";
59
- $booking = $wpdb->get_row($sql, ARRAY_A);
60
- //Get the person for this booking
61
- $this->person = new EM_Person($booking['person_id']);
62
  //Booking notes
63
  $notes = $wpdb->get_results("SELECT * FROM ". $wpdb->prefix . EM_META_TABLE ." WHERE meta_key='booking-note' AND object_id ='$booking_data'", ARRAY_A);
64
  foreach($notes as $note){
@@ -67,8 +79,11 @@ class EM_Booking extends EM_Object{
67
  }
68
  //Save into the object
69
  $this->to_object($booking);
70
- if( !empty($booking['booking_date']) ){
71
- $this->timestamp = strtotime($booking['booking_date']);
 
 
 
72
  }
73
  }
74
  //Do it here so things appear in the po file.
@@ -76,8 +91,10 @@ class EM_Booking extends EM_Object{
76
  0 => __('Pending','dbem'),
77
  1 => __('Approved','dbem'),
78
  2 => __('Rejected','dbem'),
79
- 3 => __('Cacncelled','dbem')
 
80
  );
 
81
  }
82
 
83
  /**
@@ -88,23 +105,17 @@ class EM_Booking extends EM_Object{
88
  global $wpdb;
89
  $table = $wpdb->prefix.EM_BOOKINGS_TABLE;
90
  do_action('em_booking_save_pre',$this);
91
- //First the person
92
  if($this->validate()){
93
- //Does this person exist?
94
- $person_result = $this->person->save();
95
- if( $person_result === false ){
96
- $this->errors = array_merge($this->errors, $this->person->errors);
97
- return false;
98
- }
99
- $this->person_id = $this->person->id;
100
-
101
- //Now we save the booking
102
  $data = $this->to_array();
103
  if($this->id != ''){
 
104
  $where = array( 'booking_id' => $this->id );
105
  $result = $wpdb->update($table, $data, $where, $this->get_types($data));
106
- $this->feedback_message = __('Changes saved');
107
  }else{
 
108
  $result = $wpdb->insert($table, $data, $this->get_types($data));
109
  $this->id = $wpdb->insert_id;
110
  $this->feedback_message = __('Your booking has been recorded','dbem');
@@ -112,14 +123,23 @@ class EM_Booking extends EM_Object{
112
  if( $result === false ){
113
  $this->feedback_message = __('There was a problem saving the booking.', 'dbem');
114
  $this->errors[] = __('There was a problem saving the booking.', 'dbem');
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
  return apply_filters('em_booking_save', ( count($this->errors) == 0 ), $this);
117
  }else{
118
  $this->feedback_message = __('There was a problem saving the booking.', 'dbem');
119
- $this->errors[] = __('There was a problem saving the booking.', 'dbem');
120
- return apply_filters('em_booking_save', false, $this);
121
  }
122
- return true;
123
  }
124
 
125
  /**
@@ -141,6 +161,7 @@ class EM_Booking extends EM_Object{
141
  $result = $wpdb->get_row($sql, ARRAY_A);
142
  if($result){
143
  $this->to_object($result);
 
144
  return true;
145
  }else{
146
  return false;
@@ -152,33 +173,160 @@ class EM_Booking extends EM_Object{
152
  * @return boolean
153
  */
154
  function get_post(){
155
- //Currently, only editing allowed, so here we are.
156
- $this->comment = (!empty($_REQUEST['booking_comment'])) ? $_REQUEST['booking_comment']:'';
157
- $this->seats = (!empty($_REQUEST['booking_seats'])) ? $_REQUEST['booking_seats']:'';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  return apply_filters('em_booking_get_post',$this->validate(),$this);
159
  }
160
 
161
  function validate(){
162
- return (
 
163
  (empty($this->event_id) || is_numeric($this->event_id)) &&
164
  (empty($this->person_id) || is_numeric($this->person_id)) &&
165
- is_numeric($this->seats)
 
166
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
 
169
  /**
170
- * Smart event locator, saves a database read if possible.
 
171
  */
172
  function get_event(){
173
  global $EM_Event;
174
- if( !empty($this->event) && is_object($this->event) && get_class($this->event)=='EM_Event' && $this->event->id == $this->event_id ){
175
  return $this->event;
176
- }elseif( is_object($EM_Event) && $EM_Event->id == $this->event_id ){
177
  $this->event = $EM_Event;
178
  }else{
179
  $this->event = new EM_Event($this->event_id);
180
  }
181
- return $this->event;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
 
184
  /**
@@ -188,14 +336,22 @@ class EM_Booking extends EM_Object{
188
  function get_status(){
189
  return $this->status_array[$this->status];
190
  }
 
191
  /**
192
  * I wonder what this does....
193
  * @return boolean
194
  */
195
  function delete(){
196
  global $wpdb;
 
197
  $sql = $wpdb->prepare("DELETE FROM ". $wpdb->prefix.EM_BOOKINGS_TABLE . " WHERE booking_id=%d", $this->id);
198
  $result = $wpdb->query( $sql );
 
 
 
 
 
 
199
  return ( $result !== false );
200
  }
201
 
@@ -228,28 +384,36 @@ class EM_Booking extends EM_Object{
228
  /**
229
  * Change the status of the booking. This will save to the Database too.
230
  * @param unknown_type $status
231
- * @return string|string|string
232
  */
233
- function set_status($status){
 
 
 
 
 
 
 
 
234
  $this->previous_status = $this->status;
235
  $this->status = $status;
236
  $result = $this->save();
237
- $action_string = strtolower($this->status_array[$status]);
238
  if($result){
239
  $this->feedback_message = sprintf(__('Booking %s.','dbem'), $action_string);
240
- if( $this->email() ){
241
- $this->feedback_message .= " ".__('Mail Sent.','dbem');
242
- }elseif( $this->previous_status == 0 ){
243
- //extra errors may be logged by email() in EM_Object
244
- $this->feedback_message .= ' <span style="color:red">'.__('ERROR : Mail Not Sent.','dbem').'</span>';
245
- return false;
 
 
246
  }
247
- return true;
248
  }else{
249
  //errors should be logged by save()
250
  $this->feedback_message = sprintf(__('Booking could not be %s.','dbem'), $action_string);
251
- return false;
252
  }
 
253
  }
254
 
255
  /**
@@ -275,15 +439,16 @@ class EM_Booking extends EM_Object{
275
  */
276
  function email(){
277
  global $EM_Mailer;
 
278
  $EM_Event = $this->get_event(); //We NEED event details here.
279
  //Make sure event matches booking, and that booking used to be approved.
280
- if( $this->previous_status == 0 || $this->status == 3 ){
281
- $contact_id = ( $EM_Event->contactperson_id != "") ? $EM_Event->contactperson_id : get_option('dbem_default_contact_person');
282
 
283
  $contact_subject = get_option('dbem_bookings_contact_email_subject');
284
  $contact_body = get_option('dbem_bookings_contact_email_body');
285
 
286
- if( (get_option('dbem_bookings_approval') == 0 && $this->previous_status === false) || $this->status == 1 ){
287
  $booker_subject = get_option('dbem_bookings_email_confirmed_subject');
288
  $booker_body = get_option('dbem_bookings_email_confirmed_body');
289
  }elseif( $this->status == 0 ){
@@ -306,10 +471,10 @@ class EM_Booking extends EM_Object{
306
  '#_RESPPHONE' => '#_BOOKINGPHONE',//Depreciated
307
  '#_COMMENT' => '#_BOOKINGCOMMENT',//Depreciated
308
  '#_RESERVEDSPACES' => '#_BOOKEDSPACES',//Depreciated
309
- '#_BOOKINGNAME' => $this->person->name,
310
- '#_BOOKINGEMAIL' => $this->person->email,
311
  '#_BOOKINGPHONE' => $this->person->phone,
312
- '#_BOOKINGSPACES' => $this->seats,
313
  '#_BOOKINGCOMMENT' => $this->comment,
314
  );
315
  foreach($placeholders as $key => $value) {
@@ -323,12 +488,12 @@ class EM_Booking extends EM_Object{
323
  $booker_body = $EM_Event->output($booker_body, 'email');
324
 
325
  //Send to the person booking
326
- if( !$this->email_send( $booker_subject,$booker_body, $this->person->email) ){
327
  return false;
328
  }
329
 
330
- //Send admin emails
331
- if( (get_option('dbem_bookings_approval') == 0 || $this->status == 0) && (get_option('dbem_bookings_contact_email') == 1 || get_option('dbem_bookings_notify_admin') != '') ){
332
  //Only gets sent if this is a pending booking, unless approvals are disabled.
333
  $contact_subject = $EM_Event->output($contact_subject, 'email');
334
  $contact_body = $EM_Event->output($contact_body, 'email');
@@ -357,7 +522,7 @@ class EM_Booking extends EM_Object{
357
  * Can the user manage this event?
358
  */
359
  function can_manage(){
360
- return ( get_option('dbem_permissions_events') || $this->get_event()->author == get_current_user_id() || em_verify_admin() );
361
  }
362
 
363
  /**
4
  var $id;
5
  var $event_id;
6
  var $person_id;
7
+ var $price;
8
+ var $spaces;
9
  var $comment;
10
  var $status = 0;
11
  var $notes = array();
13
  'booking_id' => array('name'=>'id','type'=>'%d'),
14
  'event_id' => array('name'=>'event_id','type'=>'%d'),
15
  'person_id' => array('name'=>'person_id','type'=>'%d'),
16
+ 'booking_price' => array('name'=>'price','type'=>'%d'),
17
+ 'booking_spaces' => array('name'=>'spaces','type'=>'%d'),
18
  'booking_comment' => array('name'=>'comment','type'=>'%s'),
19
  'booking_status' => array('name'=>'status','type'=>'%d')
20
  );
21
  //Other Vars
22
  var $timestamp;
23
  var $person;
24
+ var $required_fields = array('booking_id', 'event_id', 'person_id', 'booking_spaces');
25
  var $feedback_message = "";
26
  var $errors = array();
27
+ /**
28
+ * Contains an array of custom fields for a booking. This is loaded from em_meta, where the booking_custom name contains arrays of data.
29
+ * @var array
30
+ */
31
+ var $custom = array();
32
  /**
33
  * If saved in this instance, you can see what previous approval status was.
34
  * @var int
35
  */
36
+ var $previous_status;
37
  /**
38
  * The booking approval status number corresponds to a state in this array.
39
  * @var unknown_type
40
  */
41
  var $status_array = array();
42
+ /**
43
+ * @var EM_Tickets
44
+ */
45
+ var $tickets;
46
+ /**
47
+ * @var EM_Event
48
+ */
49
+ var $event;
50
+ /**
51
+ * @var EM_Tickets_Bookings
52
+ */
53
+ var $tickets_bookings;
54
 
55
  /**
56
  * Creates booking object and retreives booking data (default is a blank booking object). Accepts either array of booking data (from db) or a booking id.
58
  * @return null
59
  */
60
  function EM_Booking( $booking_data = false ){
61
+ //Get the person for this booking
62
+ if( $booking_data !== false ){
 
 
63
  //Load booking data
64
  $booking = array();
65
  if( is_array($booking_data) ){
66
  $booking = $booking_data;
 
 
 
 
 
67
  }elseif( is_numeric($booking_data) ){
68
  //Retreiving from the database
69
  global $wpdb;
70
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." LEFT JOIN ". $wpdb->prefix . EM_META_TABLE ." ON object_id=booking_id WHERE booking_id ='$booking_data'";
71
+ $booking = $wpdb->get_row($sql, ARRAY_A);
72
+ //Custom Fields
73
+ $custom = $wpdb->get_row("SELECT meta_key, meta_value FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." LEFT JOIN ". $wpdb->prefix . EM_META_TABLE ." ON object_id=booking_id WHERE booking_id ='$booking_data' AND meta_key='booking_custom'");
74
  //Booking notes
75
  $notes = $wpdb->get_results("SELECT * FROM ". $wpdb->prefix . EM_META_TABLE ." WHERE meta_key='booking-note' AND object_id ='$booking_data'", ARRAY_A);
76
  foreach($notes as $note){
79
  }
80
  //Save into the object
81
  $this->to_object($booking);
82
+ $this->get_person();
83
+ $this->timestamp = strtotime($booking['booking_date']);
84
+ //Add custom booking data
85
+ if( !empty($custom['meta_key']) && $custom['meta_key'] == 'booking_custom' && is_serialized($custom['meta_value']) ){
86
+ $this->custom = unserialize($custom['meta_value']);
87
  }
88
  }
89
  //Do it here so things appear in the po file.
91
  0 => __('Pending','dbem'),
92
  1 => __('Approved','dbem'),
93
  2 => __('Rejected','dbem'),
94
+ 3 => __('Cacncelled','dbem'),
95
+ 4 => __('Awaiting Online Payment','dbem')
96
  );
97
+ do_action('em_booking', $this, $booking_data);
98
  }
99
 
100
  /**
105
  global $wpdb;
106
  $table = $wpdb->prefix.EM_BOOKINGS_TABLE;
107
  do_action('em_booking_save_pre',$this);
 
108
  if($this->validate()){
109
+ $this->person_id = $this->get_person()->ID;
110
+ //Step 1. Save the booking
 
 
 
 
 
 
 
111
  $data = $this->to_array();
112
  if($this->id != ''){
113
+ $update = true;
114
  $where = array( 'booking_id' => $this->id );
115
  $result = $wpdb->update($table, $data, $where, $this->get_types($data));
116
+ $this->feedback_message = __('Changes saved','dbem');
117
  }else{
118
+ $update = false;
119
  $result = $wpdb->insert($table, $data, $this->get_types($data));
120
  $this->id = $wpdb->insert_id;
121
  $this->feedback_message = __('Your booking has been recorded','dbem');
123
  if( $result === false ){
124
  $this->feedback_message = __('There was a problem saving the booking.', 'dbem');
125
  $this->errors[] = __('There was a problem saving the booking.', 'dbem');
126
+ }else{
127
+ //Step 2. Insert ticket bookings for this booking id
128
+ $tickets_bookings_result = $this->get_tickets_bookings()->save();
129
+ if( !$tickets_bookings_result ){
130
+ if( !$update ){
131
+ //delete the booking and tickets, instead of a transaction
132
+ $this->delete();
133
+ }
134
+ $this->errors[] = __('There was a problem saving the booking.', 'dbem');
135
+ $this->add_errors( $this->get_tickets_bookings()->get_errors() );
136
+ }
137
  }
138
  return apply_filters('em_booking_save', ( count($this->errors) == 0 ), $this);
139
  }else{
140
  $this->feedback_message = __('There was a problem saving the booking.', 'dbem');
 
 
141
  }
142
+ return apply_filters('em_booking_save', false, $this);
143
  }
144
 
145
  /**
161
  $result = $wpdb->get_row($sql, ARRAY_A);
162
  if($result){
163
  $this->to_object($result);
164
+ $this->person = new EM_Person($this->person_id);
165
  return true;
166
  }else{
167
  return false;
173
  * @return boolean
174
  */
175
  function get_post(){
176
+ $this->tickets_bookings = new EM_Tickets_Bookings($this->id);
177
+ $result = array();
178
+ $this->event_id = $this->get_event()->id;
179
+ if( !empty($_POST['em_tickets']) && is_array($_POST['em_tickets']) ){
180
+ foreach( $_POST['em_tickets'] as $ticket_id => $values){
181
+ //make sure ticket exists
182
+ if( !empty($values['spaces']) ){
183
+ $args = array('ticket_id'=>$ticket_id, 'ticket_booking_spaces'=>$values['spaces'], 'booking_id'=>$this->id);
184
+ if($this->get_event()->get_bookings()->ticket_exists($ticket_id)){
185
+ $EM_Ticket_Booking = new EM_Ticket_Booking($args);
186
+ $EM_Ticket_Booking->booking = $this;
187
+ $this->tickets_bookings->add( $EM_Ticket_Booking );
188
+ }else{
189
+ $this->errors[]=__('You are trying to book a non-existent ticket for this event.','dbem');
190
+ }
191
+ }
192
+ }
193
+ $this->comment = (!empty($_REQUEST['booking_comment'])) ? $_REQUEST['booking_comment']:'';
194
+ $this->get_spaces();
195
+ $this->get_price();
196
+ $this->get_person();
197
+ }
198
  return apply_filters('em_booking_get_post',$this->validate(),$this);
199
  }
200
 
201
  function validate(){
202
+ //step 1, basic info
203
+ $basic = (
204
  (empty($this->event_id) || is_numeric($this->event_id)) &&
205
  (empty($this->person_id) || is_numeric($this->person_id)) &&
206
+ is_numeric($this->spaces) && $this->spaces > 0 &&
207
+ is_user_logged_in()
208
  );
209
+ //give some errors in step 1
210
+ if( $this->spaces == 0 ){
211
+ $this->add_error(__('You must request at least one space to book an event.','dbem'));
212
+ }
213
+ //step 2, tickets bookings info
214
+ if( count($this->get_tickets_bookings()) > 0 ){
215
+ $ticket_validation = array();
216
+ foreach($this->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking){
217
+ if ( !$EM_Ticket_Booking->validate() ){
218
+ $ticket_validation[] = false;
219
+ }
220
+ $this->errors = array_merge($this->errors, $EM_Ticket_Booking->get_errors());
221
+ }
222
+ $result = $basic && !in_array(false,$ticket_validation);
223
+ }else{
224
+ $result = false;
225
+ }
226
+
227
+ return apply_filters('em_booking_validate',$result,$this);
228
+ }
229
+
230
+ /**
231
+ * Get the total number of spaces booked in THIS booking. Seting $force_refresh to true will recheck spaces, even if previously done so.
232
+ * @param unknown_type $force_refresh
233
+ * @return mixed
234
+ */
235
+ function get_spaces( $force_refresh=false ){
236
+ if($this->spaces == 0 || $force_refresh == true ){
237
+ $this->spaces = $this->get_tickets_bookings()->get_spaces($force_refresh);
238
+ }
239
+ return apply_filters('em_booking_get_spaces',$this->spaces,$this);
240
+ }
241
+
242
+ /**
243
+ * Gets the total price for this whole booking. Seting $force_reset to true will recheck spaces, even if previously done so.
244
+ * @param boolean $force_refresh
245
+ * @return float
246
+ */
247
+ function get_price( $force_refresh=false ){
248
+ if($force_refresh || $this->price == 0){
249
+ $this->price = $this->get_tickets_bookings()->get_price($force_refresh);
250
+ }
251
+ return apply_filters('em_booking_get_prices',$this->price,$this);
252
  }
253
 
254
  /**
255
+ * Gets the event this booking belongs to and saves a refernece in the event property
256
+ * @return EM_Event
257
  */
258
  function get_event(){
259
  global $EM_Event;
260
+ if( is_object($this->event) && get_class($this->event)=='EM_Event' && $this->event->id == $this->event_id ){
261
  return $this->event;
262
+ }elseif( is_object($EM_Event) && ( (is_object($this->event) &&$this->event->id == $this->event_id) || empty($this->id)) ){
263
  $this->event = $EM_Event;
264
  }else{
265
  $this->event = new EM_Event($this->event_id);
266
  }
267
+ return apply_filters('em_booking_get_event',$this->event);
268
+ }
269
+
270
+ /**
271
+ * Get custom fields for this booking.
272
+ * @return array
273
+ */
274
+ function get_custom(){
275
+ global $wpdb;
276
+ if( count($this->custom) == 0 ){
277
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_META_TABLE ." WHERE object_id ='{$this->id}' AND (meta_key='booking_custom' OR meta_key IS NULL)";
278
+ $booking = $wpdb->get_row($sql, ARRAY_A);
279
+ //Add custom booking data
280
+ if( !empty($booking['meta_key']) && $booking['meta_key'] == 'booking_custom' && is_serialized($booking['meta_value']) ){
281
+ $this->custom = unserialize($booking['meta_value']);
282
+ }
283
+ }
284
+ return $this->custom;
285
+ }
286
+
287
+ /**
288
+ * Gets the ticket object this booking belongs to, saves a reference in ticket property
289
+ * @return EM_Ticket
290
+ */
291
+ function get_tickets(){
292
+ global $EM_Ticket;
293
+ if( is_object($this->tickets) && get_class($this->tickets)=='EM_Ticket' && $this->tickets->id == $this->ticket_id ){
294
+ return apply_filters('em_booking_get_tickets', $this->tickets, $this);
295
+ }elseif( is_object($EM_Ticket) && $EM_Ticket->id == $this->ticket_id ){
296
+ $this->tickets = $EM_Ticket;
297
+ }else{
298
+ $this->tickets = new EM_Tickets($this->ticket_id);
299
+ }
300
+ return apply_filters('em_booking_get_tickets', $this->tickets, $this);
301
+ }
302
+
303
+ /**
304
+ * Gets the ticket object this booking belongs to, saves a reference in ticket property
305
+ * @return EM_Tickets_Bookings
306
+ */
307
+ function get_tickets_bookings(){
308
+ global $wpdb;
309
+ if( !is_object($this->tickets_bookings) && get_class($this->tickets_bookings)!='EM_Tickets_Bookings'){
310
+ $this->tickets_bookings = new EM_Tickets_Bookings($this);
311
+ }
312
+ return apply_filters('em_booking_get_tickets_bookings', $this->tickets_bookings, $this);
313
+ }
314
+
315
+ function get_person(){
316
+ global $EM_Person;
317
+ if( is_object($this->person) && get_class($this->person)=='EM_Person' && ($this->person->ID == $this->person_id || empty($this->person_id) ) ){
318
+ return apply_filters('em_booking_get_person', $this->person, $this);
319
+ }elseif( is_object($EM_Person) && $EM_Person->ID == $this->person_id ){
320
+ $this->person = $EM_Person;
321
+ }else{
322
+ if( !empty($this->person_id) ){
323
+ $this->person = new EM_Person($this->person_id);
324
+ }elseif( is_user_logged_in() ){
325
+ //get current logged in user
326
+ $this->person = new EM_Person(get_current_user_id());
327
+ }
328
+ }
329
+ return apply_filters('em_booking_get_person', $this->person, $this);
330
  }
331
 
332
  /**
336
  function get_status(){
337
  return $this->status_array[$this->status];
338
  }
339
+
340
  /**
341
  * I wonder what this does....
342
  * @return boolean
343
  */
344
  function delete(){
345
  global $wpdb;
346
+ //FIXME ticket logic needed
347
  $sql = $wpdb->prepare("DELETE FROM ". $wpdb->prefix.EM_BOOKINGS_TABLE . " WHERE booking_id=%d", $this->id);
348
  $result = $wpdb->query( $sql );
349
+ if( $result !== false ){
350
+ //delete the tickets too
351
+ $this->get_tickets_bookings()->delete();
352
+ $this->previous_status = $this->status;
353
+ $this->status = false;
354
+ }
355
  return ( $result !== false );
356
  }
357
 
384
  /**
385
  * Change the status of the booking. This will save to the Database too.
386
  * @param unknown_type $status
387
+ * @return string
388
  */
389
+ function set_status($status){
390
+ $action_string = strtolower($this->status_array[$status]);
391
+ //if we're approving we can't approve a booking if spaces are full, so check before it's approved.
392
+ if($status == 1){
393
+ if( $this->get_event()->get_bookings()->get_available_spaces() < $this->get_spaces() && !get_option('dbem_bookings_approval_overbooking') ){
394
+ $this->feedback_message = sprintf(__('Not approved, spaces full.','dbem'), $action_string);
395
+ return apply_filters('em_booking_set_status', false, $this);
396
+ }
397
+ }
398
  $this->previous_status = $this->status;
399
  $this->status = $status;
400
  $result = $this->save();
 
401
  if($result){
402
  $this->feedback_message = sprintf(__('Booking %s.','dbem'), $action_string);
403
+ if( !($this->status == 0 && $this->previous_status > 0) ){
404
+ if( $this->email() ){
405
+ $this->feedback_message .= " ".__('Mail Sent.','dbem');
406
+ }elseif( $this->previous_status == 0 ){
407
+ //extra errors may be logged by email() in EM_Object
408
+ $this->feedback_message .= ' <span style="color:red">'.__('ERROR : Mail Not Sent.','dbem').'</span>';
409
+ $result = false;
410
+ }
411
  }
 
412
  }else{
413
  //errors should be logged by save()
414
  $this->feedback_message = sprintf(__('Booking could not be %s.','dbem'), $action_string);
 
415
  }
416
+ return apply_filters('em_booking_set_status', $result, $this);
417
  }
418
 
419
  /**
439
  */
440
  function email(){
441
  global $EM_Mailer;
442
+ //FIXME ticket logic needed
443
  $EM_Event = $this->get_event(); //We NEED event details here.
444
  //Make sure event matches booking, and that booking used to be approved.
445
+ if( !($this->status == 0 && $this->previous_status > 0) ){
446
+ $contact_id = ( $EM_Event->owner != "") ? $EM_Event->owner : get_option('dbem_default_contact_person');
447
 
448
  $contact_subject = get_option('dbem_bookings_contact_email_subject');
449
  $contact_body = get_option('dbem_bookings_contact_email_body');
450
 
451
+ if( get_option('dbem_bookings_approval') == 0 && $this->status < 2 || $this->status == 1 ){
452
  $booker_subject = get_option('dbem_bookings_email_confirmed_subject');
453
  $booker_body = get_option('dbem_bookings_email_confirmed_body');
454
  }elseif( $this->status == 0 ){
471
  '#_RESPPHONE' => '#_BOOKINGPHONE',//Depreciated
472
  '#_COMMENT' => '#_BOOKINGCOMMENT',//Depreciated
473
  '#_RESERVEDSPACES' => '#_BOOKEDSPACES',//Depreciated
474
+ '#_BOOKINGNAME' => $this->person->display_name,
475
+ '#_BOOKINGEMAIL' => $this->person->user_email,
476
  '#_BOOKINGPHONE' => $this->person->phone,
477
+ '#_BOOKINGSPACES' => $this->get_spaces(),
478
  '#_BOOKINGCOMMENT' => $this->comment,
479
  );
480
  foreach($placeholders as $key => $value) {
488
  $booker_body = $EM_Event->output($booker_body, 'email');
489
 
490
  //Send to the person booking
491
+ if( !$this->email_send( $booker_subject,$booker_body, $this->person->user_email) ){
492
  return false;
493
  }
494
 
495
+ //Send admin/contact emails
496
+ if( (get_option('dbem_bookings_approval') == 0 || $this->status == 0 || $this->status == 3) && (get_option('dbem_bookings_contact_email') == 1 || get_option('dbem_bookings_notify_admin') != '') ){
497
  //Only gets sent if this is a pending booking, unless approvals are disabled.
498
  $contact_subject = $EM_Event->output($contact_subject, 'email');
499
  $contact_body = $EM_Event->output($contact_body, 'email');
522
  * Can the user manage this event?
523
  */
524
  function can_manage(){
525
+ return $this->get_event()->can_manage('manage_bookings','manage_others_bookings');
526
  }
527
 
528
  /**
classes/em-bookings.php CHANGED
@@ -4,7 +4,7 @@
4
  * @author marcus
5
  *
6
  */
7
- class EM_Bookings extends EM_Object{
8
 
9
  /**
10
  * Array of EM_Booking objects for a specific event
@@ -12,73 +12,63 @@ class EM_Bookings extends EM_Object{
12
  */
13
  var $bookings = array();
14
  /**
15
- * Event ID
16
- * @var int
 
 
 
17
  */
18
- var $event_id;
19
  /**
20
- * Number of seats for this event
21
  * @var int
22
  */
23
- var $seats;
24
 
25
  var $feedback_message = "";
26
  var $errors = array();
27
 
28
  /**
29
- * Creates an EM_Bookings instance,
30
  * @param EM_Event $event
31
  * @return null
32
  */
33
- function EM_Bookings( $event = false ){
34
- if( is_object($event) && get_class($event) == "EM_Event" ){ //Creates a blank bookings object if needed
35
  global $wpdb;
36
- $this->event_id = $event->id;
37
- $this->seats = $event->seats;
38
- $sql = "SELECT * FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." b, ". $wpdb->prefix . EM_PEOPLE_TABLE ." p WHERE event_id ='{$this->event_id}' AND p.person_id=b.person_id";
39
  $bookings = $wpdb->get_results($sql, ARRAY_A);
40
  foreach ($bookings as $booking){
41
  $this->bookings[] = new EM_Booking($booking);
42
  }
 
 
 
 
 
 
 
 
43
  }
44
  }
45
 
46
  /**
47
- * Add a booking into this event (or add seats if person already booked this), checking that there's enough space for the event
48
  * @param $EM_Booking
49
  * @return boolean
50
  */
51
  function add( $EM_Booking ){
52
  global $wpdb,$EM_Mailer;
53
- if ( $this->get_available_seats() >= $EM_Booking->seats ) {
54
- $EM_Booking->event_id = $this->event_id;
55
- // checking whether the booker has already booked places
56
- $previous_booking = $this->find_previous_booking( $EM_Booking );
57
  $email = false;
58
- if ( is_object($previous_booking) ) {
59
- //Previously booked, so we add these seats to the booking
60
- $new_seats = $EM_Booking->seats;
61
- $EM_Booking = $previous_booking;
62
- $EM_Booking->seats += $new_seats;
63
- $result = $EM_Booking->save();
64
- if($result){
65
- //remove old booking
66
- foreach($this->bookings as $key=>$booking){
67
- if($booking->id == $EM_Booking->id){ unset($this->bookings[$key]); }
68
- }
69
- $this->bookings[] = $EM_Booking;
70
- $email = $EM_Booking->email();
71
- }
72
- } else {
73
- //New booking, so let's save the booking
74
- $result = $EM_Booking->save();
75
- if($result){
76
- $this->bookings[] = $EM_Booking;
77
- $email = $EM_Booking->email();
78
- }
79
- }
80
  if($result){
81
  //Success
 
 
82
  if( get_option('dbem_bookings_approval') == 1 ){
83
  $this->feedback_message = __('Booking successful, pending confirmation (you will also receive an email once confirmed).', 'dbem');
84
  }else{
@@ -87,8 +77,8 @@ class EM_Bookings extends EM_Object{
87
  if(!$email){
88
  $this->feedback_message .= ' '.__('However, there were some problems whilst sending confirmation emails to you and/or the event contact person. You may want to contact them directly and letting them know of this error.', 'dbem');
89
  if( current_user_can('activate_plugins') ){
90
- if( is_array($this->errors) && count($this->errors) > 0 ){
91
- $this->feedback_message .= '<br/><strong>Errors:</strong> (only admins see this message)<br/><ul><li>'. implode('</li><li>', $EM_Mailer->errors).'</li></ul>';
92
  }else{
93
  $this->feedback_message .= '<br/><strong>No errors returned by mailer</strong> (only admins see this message)';
94
  }
@@ -100,19 +90,112 @@ class EM_Bookings extends EM_Object{
100
  $this->errors[] = "<strong>".__('Booking could not be created','dbem').":</strong><br />". implode('<br />', $EM_Booking->errors);
101
  }
102
  } else {
103
- $this->errors[] = __('Booking cannot be made, not enough seats available!', 'dbem');
104
  return false;
105
  }
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  /**
109
  * Delete bookings on this id
110
  * @return boolean
111
  */
112
  function delete(){
113
  global $wpdb;
114
- $result = $wpdb->query("DELETE FROM ".$wpdb->prefix.EM_BOOKINGS_TABLE." WHERE event_id='{$this->event_id}'");
115
- return ($result);
 
 
 
 
 
 
 
 
116
  }
117
 
118
 
@@ -150,13 +233,18 @@ class EM_Bookings extends EM_Object{
150
  * @return bool
151
  */
152
  function set_status($status, $booking_ids){
 
153
  //FIXME there is a vulnerability where any user can approve/reject bookings if they know the ID
154
- if( EM_Object::array_is_numeric($booking_ids) ){
155
  //Get all the bookings
156
  $results = array();
157
  $mails = array();
158
  foreach( $booking_ids as $booking_id ){
159
  $EM_Booking = new EM_Booking($booking_id);
 
 
 
 
160
  $results[] = $EM_Booking->set_status($status);
161
  }
162
  if( !in_array('false',$results) ){
@@ -176,53 +264,67 @@ class EM_Bookings extends EM_Object{
176
  return false;
177
  }
178
 
 
179
  /**
180
- * Returns number of available seats for this event. If approval of bookings is on, will include pending bookings depending on em option.
 
181
  * @return int
182
  */
183
- function get_available_seats(){
184
- $booked_seats = 0;
 
 
 
 
 
 
 
 
 
 
 
185
  if( get_option('dbem_bookings_approval_reserved') == 1 ){
186
- return $this->seats - $this->get_booked_seats() - $this->get_pending_seats();
187
- }else{
188
- return $this->seats - $this->get_booked_seats();
189
  }
 
190
  }
191
 
192
  /**
193
- * Returns number of booked seats for this event. If approval of bookings is on, will return number of booked confirmed seats.
194
  * @return int
195
  */
196
- function get_booked_seats(){
197
- $booked_seats = 0;
198
- foreach ( $this->bookings as $booking ){
199
- if( $booking->status != 3 && (get_option('dbem_bookings_approval') == 0 || $booking->status == 1) ){
200
- $booked_seats += $booking->seats;
201
- }
202
  }
203
- return $booked_seats;
204
  }
205
 
206
  /**
207
- * Gets number of pending seats awaiting approval. Will return 0 if booking approval is not enabled.
208
  * @return int
209
  */
210
- function get_pending_seats(){
211
  if( get_option('dbem_bookings_approval') == 0 ){
212
  return 0;
213
  }
214
  $pending = 0;
215
  foreach ( $this->bookings as $booking ){
216
  if($booking->status == 0){
217
- $pending += $booking->seats;
218
  }
219
  }
220
  return $pending;
221
  }
222
 
223
  /**
224
- * Gets number of bookings (not seats). If booking approval is enabled, only the number of approved bookings will be shown.
225
- * @return array EM_Booking
226
  */
227
  function get_bookings(){
228
  $confirmed = array();
@@ -231,12 +333,13 @@ class EM_Bookings extends EM_Object{
231
  $confirmed[] = $booking;
232
  }
233
  }
234
- return $confirmed;
 
235
  }
236
 
237
  /**
238
  * Get pending bookings. If booking approval is disabled, will return no bookings.
239
- * @return array EM_Booking
240
  */
241
  function get_pending_bookings(){
242
  if( get_option('dbem_bookings_approval') == 0 ){
@@ -248,21 +351,23 @@ class EM_Bookings extends EM_Object{
248
  $pending[] = $booking;
249
  }
250
  }
251
- return $pending;
 
252
  }
253
 
254
  /**
255
- * Get rejected bookings.
256
- * @return array EM_Booking
257
  */
258
  function get_rejected_bookings(){
259
- $pending = array();
260
  foreach ( $this->bookings as $booking ){
261
  if($booking->status == 2){
262
- $pending[] = $booking;
263
  }
264
  }
265
- return $pending;
 
266
  }
267
 
268
  /**
@@ -270,13 +375,14 @@ class EM_Bookings extends EM_Object{
270
  * @return array EM_Booking
271
  */
272
  function get_cancelled_bookings(){
273
- $pending = array();
274
  foreach ( $this->bookings as $booking ){
275
  if($booking->status == 3){
276
- $pending[] = $booking;
277
  }
278
  }
279
- return $pending;
 
280
  }
281
 
282
  /**
@@ -288,10 +394,10 @@ class EM_Bookings extends EM_Object{
288
  //First see if we have a similar person on record that's making this booking
289
  $EM_Booking->person->load_similar();
290
  //If person exists on record, see if they've booked this event before, if so return the booking.
291
- if( is_numeric($EM_Booking->person->id) && $EM_Booking->person->id > 0 ){
292
- $EM_Booking->person_id = $EM_Booking->person->id;
293
  foreach ($this->bookings as $booking){
294
- if( $booking->person_id == $EM_Booking->person->id ){
295
  return $booking;
296
  }
297
  }
@@ -299,29 +405,15 @@ class EM_Bookings extends EM_Object{
299
  return false;
300
  }
301
 
302
-
303
  /**
304
- * Get all pending bookings for this event
305
- */
306
- function get_pending(){
307
- $pending = array();
308
- foreach($this->bookings as $booking){
309
- if($booking->status == 0){
310
- $pending[] = $booking;
311
- }
312
- }
313
- return $pending;
314
- }
315
-
316
- /**
317
- * Gets the pending number of bookings as a raw associative array.
318
  * @return array
 
319
  */
320
  function get( $args = array() ){
321
  global $wpdb,$current_user;
322
  $bookings_table = $wpdb->prefix . EM_BOOKINGS_TABLE;
323
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
324
- $people_table = $wpdb->prefix . EM_PEOPLE_TABLE;
325
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
326
 
327
  //Quick version, we can accept an array of IDs, which is easy to retrieve
@@ -330,14 +422,13 @@ class EM_Bookings extends EM_Object{
330
  $sql = "
331
  SELECT * FROM $bookings_table b
332
  LEFT JOIN $events_table e ON e.event_id=b.event_id
333
- LEFT JOIN $people_table p ON p.person_id=b.person_id
334
  WHERE booking_id".implode(" OR booking_id=", $args);
335
  $results = $wpdb->get_results(apply_filters('em_bookings_get_sql',$sql),ARRAY_A);
336
  $bookings = array();
337
  foreach($results as $result){
338
- $bookings[$result['event_id']] = new EM_Event($result);
339
  }
340
- return $bookings; //We return all the events matched as an EM_Event array.
341
  }
342
 
343
  //We assume it's either an empty array or array of search arguments to merge with defaults
@@ -361,7 +452,6 @@ class EM_Bookings extends EM_Object{
361
  $sql = "
362
  SELECT * FROM $bookings_table
363
  LEFT JOIN $events_table ON {$events_table}.event_id={$bookings_table}.event_id
364
- LEFT JOIN $people_table ON {$people_table}.person_id={$bookings_table}.person_id
365
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
366
  $where
367
  $orderby_sql
@@ -381,16 +471,16 @@ class EM_Bookings extends EM_Object{
381
  foreach ( $results as $booking ){
382
  $bookings[] = new EM_Booking($booking);
383
  }
384
-
385
- return apply_filters('em_bookings_get', $bookings);
386
  }
387
 
388
 
389
  //List of patients in the patient database, that a user can choose and go on to edit any previous treatment data, or add a new admission.
390
  function export_csv() {
391
  global $EM_Event;
392
- if($EM_Event->id != $this->event_id ){
393
- $event = new EM_Event($this->event_id);
394
  $event_name = $event->name;
395
  }else{
396
  $event_name = $EM_Event->name;
@@ -413,17 +503,17 @@ class EM_Bookings extends EM_Object{
413
  'Comment'
414
  );
415
  $file = sprintf(__('Booking details for "%s" as of %s','dbem'),$event_name, date_i18n('D d M Y h:i', current_time('timestamp'))) . "\n";
416
- $file = '"'. strtolower(implode('","', $labels)). '"' . "\n";
417
 
418
  //Rows
419
  foreach( $this->bookings as $EM_Booking ) {
420
  $row = array(
421
  $EM_Booking->id,
422
- $EM_Booking->person->name,
423
- $EM_Booking->person->email,
424
  $EM_Booking->person->phone,
425
  date('Y-m-d h:i', $EM_Booking->timestamp),
426
- $EM_Booking->seats,
427
  $EM_Booking->get_status(),
428
  $EM_Booking->comment
429
  );
@@ -472,17 +562,35 @@ class EM_Bookings extends EM_Object{
472
  );
473
  if( true || is_admin() ){
474
  //figure out default owning permissions
475
- switch( get_option('dbem_permissions_events') ){
476
- case 0:
477
- $defaults['owner'] = get_current_user_id();
478
- break;
479
- case 1:
480
- $defaults['owner'] = false;
481
- break;
482
  }
483
- $defaults['owner'] = ( em_verify_admin() ) ? false:$defaults['owner'];
484
  }
485
  return apply_filters('em_bookings_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
486
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  }
488
  ?>
4
  * @author marcus
5
  *
6
  */
7
+ class EM_Bookings extends EM_Object implements Iterator{
8
 
9
  /**
10
  * Array of EM_Booking objects for a specific event
12
  */
13
  var $bookings = array();
14
  /**
15
+ * @var EM_Tickets
16
+ */
17
+ var $tickets;
18
+ /**
19
+ * @var EM_Event
20
  */
21
+ var $event;
22
  /**
23
+ * How many spaces this event has
24
  * @var int
25
  */
26
+ var $spaces;
27
 
28
  var $feedback_message = "";
29
  var $errors = array();
30
 
31
  /**
32
+ * Creates an EM_Bookings instance, currently accepts an EM_Event object (gets all bookings for that event) or array of any EM_Booking objects, which can be manipulated in bulk with helper functions.
33
  * @param EM_Event $event
34
  * @return null
35
  */
36
+ function EM_Bookings( $data = false ){
37
+ if( is_object($data) && get_class($data) == "EM_Event" ){ //Creates a blank bookings object if needed
38
  global $wpdb;
39
+ $this->event = $data;
40
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." WHERE event_id ='{$this->event->id}'";
 
41
  $bookings = $wpdb->get_results($sql, ARRAY_A);
42
  foreach ($bookings as $booking){
43
  $this->bookings[] = new EM_Booking($booking);
44
  }
45
+ $this->spaces = $this->get_spaces();
46
+ }elseif( is_array($data) ){
47
+ foreach( $data as $EM_Booking ){
48
+ if( get_class($EM_Booking) == 'EM_Booking'){
49
+ $this->bookings[] = $EM_Booking;
50
+ }
51
+ }
52
+ $this->get_event();
53
  }
54
  }
55
 
56
  /**
57
+ * Add a booking into this event (or add spaces if person already booked this), checking that there's enough space for the event
58
  * @param $EM_Booking
59
  * @return boolean
60
  */
61
  function add( $EM_Booking ){
62
  global $wpdb,$EM_Mailer;
63
+ $EM_Booking->get_spaces(true);
64
+ if ( $this->get_available_spaces() >= $EM_Booking->get_spaces() ) {
65
+ //Save the booking
 
66
  $email = false;
67
+ $result = $EM_Booking->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  if($result){
69
  //Success
70
+ $this->bookings[] = $EM_Booking;
71
+ $email = $EM_Booking->email();
72
  if( get_option('dbem_bookings_approval') == 1 ){
73
  $this->feedback_message = __('Booking successful, pending confirmation (you will also receive an email once confirmed).', 'dbem');
74
  }else{
77
  if(!$email){
78
  $this->feedback_message .= ' '.__('However, there were some problems whilst sending confirmation emails to you and/or the event contact person. You may want to contact them directly and letting them know of this error.', 'dbem');
79
  if( current_user_can('activate_plugins') ){
80
+ if( count($EM_Booking->get_errors()) > 0 ){
81
+ $this->feedback_message .= '<br/><strong>Errors:</strong> (only admins see this message)<br/><ul><li>'. implode('</li><li>', $EM_Booking->get_errors()).'</li></ul>';
82
  }else{
83
  $this->feedback_message .= '<br/><strong>No errors returned by mailer</strong> (only admins see this message)';
84
  }
90
  $this->errors[] = "<strong>".__('Booking could not be created','dbem').":</strong><br />". implode('<br />', $EM_Booking->errors);
91
  }
92
  } else {
93
+ $this->add_error(__('Booking cannot be made, not enough spaces available!', 'dbem'));
94
  return false;
95
  }
96
  }
97
 
98
+ /**
99
+ * get POST data and create a booking for each ticket requested:
100
+ * @return bool
101
+ */
102
+ function add_from_post(){
103
+ $EM_Booking = new EM_booking();
104
+ $result = $EM_Booking->get_post();
105
+ if($result){
106
+ $result = $this->add($EM_Booking);
107
+ }else{
108
+ $this->errors = array_merge($this->errors, $EM_Booking->errors);
109
+ }
110
+ return apply_filters('em_bookings_add_from_post',$result,$EM_Booking,$this);
111
+ }
112
+
113
+ /**
114
+ * Smart event locator, saves a database read if possible. Note that if an event doesn't exist, a blank object will be created to prevent duplicates.
115
+ */
116
+ function get_event(){
117
+ if( is_object($this->event) && get_class($this->event) == 'EM_Event' ){
118
+ return $this->event;
119
+ }elseif( count($this->bookings) > 0 ){
120
+ foreach($this->bookings as $EM_Booking){
121
+ $this->event = $EM_Booking->get_event();
122
+ return $this->event;
123
+ }
124
+ }else{
125
+ $this->event = new EM_Event();
126
+ return $this->event;
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Retrieve and save the bookings belonging to instance. If called again will return cached version, set $force_reload to true to create a new EM_Tickets object.
132
+ * @param boolean $force_reload
133
+ * @return EM_Tickets
134
+ */
135
+ function get_tickets( $force_reload = false ){
136
+ if( !is_object($this->tickets) || $force_reload ){
137
+ $this->tickets = new EM_Tickets($this->get_event());
138
+ }
139
+ return apply_filters('em_bookings_get_tickets', $this->tickets, $this);
140
+ }
141
+
142
+ /**
143
+ * Returns EM_Tickets object with available tickets
144
+ * @return EM_Tickets
145
+ */
146
+ function get_available_tickets(){
147
+ $tickets = array();
148
+ $timesamp = current_time('timestamp');
149
+ foreach ($this->get_tickets() as $EM_Ticket){
150
+ if( $EM_Ticket->is_available() ){
151
+ //within time range
152
+ if( $EM_Ticket->get_available_spaces() > 0 ){
153
+ $tickets[] = $EM_Ticket;
154
+ }
155
+ }
156
+ }
157
+ $EM_Tickets = new EM_Tickets($tickets);
158
+ return apply_filters('em_bookings_get_tickets', $EM_Tickets, $this);
159
+ }
160
+
161
+ function get_user_list(){
162
+ $users = array();
163
+ foreach( $this->get_bookings()->bookings as $EM_Booking ){
164
+ $users[$EM_Booking->person->ID] = $EM_Booking->person;
165
+ }
166
+ return $users;
167
+ }
168
+
169
+ /**
170
+ * does this ticket exist?
171
+ * @return bool
172
+ */
173
+ function ticket_exists($ticket_id){
174
+ $EM_Tickets = $this->get_tickets();
175
+ foreach( $EM_Tickets->tickets as $EM_Ticket){
176
+ if($EM_Ticket->id == $ticket_id){
177
+ return apply_filters('em_bookings_ticket_exists',true, $EM_Ticket, $this);
178
+ }
179
+ }
180
+ return apply_filters('em_bookings_ticket_exists',false, $EM_Ticket,$this);
181
+ }
182
+
183
  /**
184
  * Delete bookings on this id
185
  * @return boolean
186
  */
187
  function delete(){
188
  global $wpdb;
189
+ $booking_ids = array();
190
+ if( is_object($this->event) ){
191
+ $result = $wpdb->query("DELETE FROM ".$wpdb->prefix.EM_BOOKINGS_TABLE." WHERE event_id='{$this->event_id}'");
192
+ }else{
193
+ foreach( $this->bookings as $EM_Booking ){
194
+ $booking_ids[] = $EM_Booking->id;
195
+ }
196
+ $result = $wpdb->query("DELETE FROM ".$wpdb->prefix.EM_BOOKINGS_TABLE." WHERE event_id IN (".implode(',',$booking_ids).")");
197
+ }
198
+ return ($result !== false);
199
  }
200
 
201
 
233
  * @return bool
234
  */
235
  function set_status($status, $booking_ids){
236
+ //FIXME status should work with instantiated object
237
  //FIXME there is a vulnerability where any user can approve/reject bookings if they know the ID
238
+ if( $this->array_is_numeric($booking_ids) ){
239
  //Get all the bookings
240
  $results = array();
241
  $mails = array();
242
  foreach( $booking_ids as $booking_id ){
243
  $EM_Booking = new EM_Booking($booking_id);
244
+ if( !$EM_Booking->can_manage() ){
245
+ $this->feedback_message = __('Bookings %s. Mails Sent.', 'dbem');
246
+ return false;
247
+ }
248
  $results[] = $EM_Booking->set_status($status);
249
  }
250
  if( !in_array('false',$results) ){
264
  return false;
265
  }
266
 
267
+
268
  /**
269
+ * Get the total number of spaces this event has. This will show the lower value of event global spaces limit or total ticket spaces. Setting $force_refresh to true will recheck spaces, even if previously done so.
270
+ * @param boolean $force_refresh
271
  * @return int
272
  */
273
+ function get_spaces( $force_refresh=false ){
274
+ if($force_refresh || $this->spaces == 0){
275
+ $this->spaces = $this->get_tickets()->get_spaces();
276
+ }
277
+ return apply_filters('em_booking_get_spaces',$this->spaces,$this);
278
+ }
279
+
280
+ /**
281
+ * Returns number of available spaces for this event. If approval of bookings is on, will include pending bookings depending on em option.
282
+ * @return int
283
+ */
284
+ function get_available_spaces(){
285
+ $available_spaces = 0;
286
  if( get_option('dbem_bookings_approval_reserved') == 1 ){
287
+ $available_spaces = $this->get_spaces() - $this->get_booked_spaces() - $this->get_pending_spaces();
288
+ }else{
289
+ $available_spaces = $this->get_spaces() - $this->get_booked_spaces();
290
  }
291
+ return apply_filters('get_available_spaces', $available_spaces, $this);
292
  }
293
 
294
  /**
295
+ * Returns number of booked spaces for this event. If approval of bookings is on, will return number of booked confirmed spaces.
296
  * @return int
297
  */
298
+ function get_booked_spaces(){
299
+ $booked_spaces = 0;
300
+ $EM_Bookings = $this->get_bookings(); //get bookings, automatically filtering approvals etc.
301
+ foreach ( $EM_Bookings->bookings as $EM_Booking ){
302
+ //never show cancelled status, nor pending if approvals required
303
+ $booked_spaces += $EM_Booking->get_spaces();
304
  }
305
+ return $booked_spaces;
306
  }
307
 
308
  /**
309
+ * Gets number of pending spaces awaiting approval. Will return 0 if booking approval is not enabled.
310
  * @return int
311
  */
312
+ function get_pending_spaces(){
313
  if( get_option('dbem_bookings_approval') == 0 ){
314
  return 0;
315
  }
316
  $pending = 0;
317
  foreach ( $this->bookings as $booking ){
318
  if($booking->status == 0){
319
+ $pending += $booking->get_spaces();
320
  }
321
  }
322
  return $pending;
323
  }
324
 
325
  /**
326
+ * Gets number of bookings (not spaces). If booking approval is enabled, only the number of approved bookings will be shown.
327
+ * @return EM_Bookings
328
  */
329
  function get_bookings(){
330
  $confirmed = array();
333
  $confirmed[] = $booking;
334
  }
335
  }
336
+ $EM_Bookings = new EM_Bookings($confirmed);
337
+ return $EM_Bookings;
338
  }
339
 
340
  /**
341
  * Get pending bookings. If booking approval is disabled, will return no bookings.
342
+ * @return EM_Bookings
343
  */
344
  function get_pending_bookings(){
345
  if( get_option('dbem_bookings_approval') == 0 ){
351
  $pending[] = $booking;
352
  }
353
  }
354
+ $EM_Bookings = new EM_Bookings($pending);
355
+ return $EM_Bookings;
356
  }
357
 
358
  /**
359
+ * Get rejected bookings. If booking approval is disabled, will return no bookings.
360
+ * @return array EM_Bookings
361
  */
362
  function get_rejected_bookings(){
363
+ $rejected = array();
364
  foreach ( $this->bookings as $booking ){
365
  if($booking->status == 2){
366
+ $rejected[] = $booking;
367
  }
368
  }
369
+ $EM_Bookings = new EM_Bookings($rejected);
370
+ return $EM_Bookings;
371
  }
372
 
373
  /**
375
  * @return array EM_Booking
376
  */
377
  function get_cancelled_bookings(){
378
+ $cancelled = array();
379
  foreach ( $this->bookings as $booking ){
380
  if($booking->status == 3){
381
+ $cancelled[] = $booking;
382
  }
383
  }
384
+ $EM_Bookings = new EM_Bookings($cancelled);
385
+ return $EM_Bookings;
386
  }
387
 
388
  /**
394
  //First see if we have a similar person on record that's making this booking
395
  $EM_Booking->person->load_similar();
396
  //If person exists on record, see if they've booked this event before, if so return the booking.
397
+ if( is_numeric($EM_Booking->person->ID) && $EM_Booking->person->ID > 0 ){
398
+ $EM_Booking->person_id = $EM_Booking->person->ID;
399
  foreach ($this->bookings as $booking){
400
+ if( $booking->person_id == $EM_Booking->person->ID ){
401
  return $booking;
402
  }
403
  }
405
  return false;
406
  }
407
 
 
408
  /**
409
+ * Get bookings that match the array of arguments passed.
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  * @return array
411
+ * @static
412
  */
413
  function get( $args = array() ){
414
  global $wpdb,$current_user;
415
  $bookings_table = $wpdb->prefix . EM_BOOKINGS_TABLE;
416
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
 
417
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
418
 
419
  //Quick version, we can accept an array of IDs, which is easy to retrieve
422
  $sql = "
423
  SELECT * FROM $bookings_table b
424
  LEFT JOIN $events_table e ON e.event_id=b.event_id
 
425
  WHERE booking_id".implode(" OR booking_id=", $args);
426
  $results = $wpdb->get_results(apply_filters('em_bookings_get_sql',$sql),ARRAY_A);
427
  $bookings = array();
428
  foreach($results as $result){
429
+ $bookings[] = new EM_Booking($result);
430
  }
431
+ return $bookings; //We return all the bookings matched as an EM_Booking array.
432
  }
433
 
434
  //We assume it's either an empty array or array of search arguments to merge with defaults
452
  $sql = "
453
  SELECT * FROM $bookings_table
454
  LEFT JOIN $events_table ON {$events_table}.event_id={$bookings_table}.event_id
 
455
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
456
  $where
457
  $orderby_sql
471
  foreach ( $results as $booking ){
472
  $bookings[] = new EM_Booking($booking);
473
  }
474
+ $EM_Bookings = new EM_Bookings($bookings);
475
+ return apply_filters('em_bookings_get', $EM_Bookings);
476
  }
477
 
478
 
479
  //List of patients in the patient database, that a user can choose and go on to edit any previous treatment data, or add a new admission.
480
  function export_csv() {
481
  global $EM_Event;
482
+ if($EM_Event->id != $this->event->id ){
483
+ $event = new EM_Event($this->event->id);
484
  $event_name = $event->name;
485
  }else{
486
  $event_name = $EM_Event->name;
503
  'Comment'
504
  );
505
  $file = sprintf(__('Booking details for "%s" as of %s','dbem'),$event_name, date_i18n('D d M Y h:i', current_time('timestamp'))) . "\n";
506
+ $file = '"'. implode('","', $labels). '"' . "\n";
507
 
508
  //Rows
509
  foreach( $this->bookings as $EM_Booking ) {
510
  $row = array(
511
  $EM_Booking->id,
512
+ $EM_Booking->person->display_name,
513
+ $EM_Booking->person->user_email,
514
  $EM_Booking->person->phone,
515
  date('Y-m-d h:i', $EM_Booking->timestamp),
516
+ $EM_Booking->get_spaces(),
517
  $EM_Booking->get_status(),
518
  $EM_Booking->comment
519
  );
562
  );
563
  if( true || is_admin() ){
564
  //figure out default owning permissions
565
+ if( !current_user_can('edit_others_events') ){
566
+ $defaults['owner'] = get_current_user_id();
567
+ }else{
568
+ $defaults['owner'] = false;
 
 
 
569
  }
 
570
  }
571
  return apply_filters('em_bookings_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
572
  }
573
+
574
+ //Iterator Implementation
575
+ public function rewind(){
576
+ reset($this->bookings);
577
+ }
578
+ public function current(){
579
+ $var = current($this->bookings);
580
+ return $var;
581
+ }
582
+ public function key(){
583
+ $var = key($this->bookings);
584
+ return $var;
585
+ }
586
+ public function next(){
587
+ $var = next($this->bookings);
588
+ return $var;
589
+ }
590
+ public function valid(){
591
+ $key = key($this->bookings);
592
+ $var = ($key !== NULL && $key !== FALSE);
593
+ return $var;
594
+ }
595
  }
596
  ?>
classes/em-calendar.php CHANGED
@@ -1,366 +1,368 @@
1
- <?php
2
- class EM_Calendar extends EM_Object {
3
-
4
- function init(){
5
- add_action('wp_head', array('EM_Calendar', 'insert_js'));
6
- }
7
-
8
- function output($args = array()) {
9
- global $wpdb;
10
-
11
- $args = self::get_default_search($args);
12
- $full = $args['full']; //For ZDE, don't delete pls
13
- $month = $args['month'];
14
- $year = $args['year'];
15
- $long_events = $args['long_events'];
16
-
17
- $week_starts_on_sunday = get_option('dbem_week_starts_sunday');
18
- $start_of_week = get_option('start_of_week');
19
-
20
- if( !(is_numeric($month) && $month <= 12 && $month > 0) ) {
21
- $month = date('m');
22
- }
23
- if( !( is_numeric($year) ) ){
24
- $year = date('Y');
25
- }
26
-
27
- // Get the first day of the month
28
- $month_start = mktime(0,0,0,$month, 1, $year);
29
- // Get friendly month name
30
- $month_name = date('M',$month_start);
31
- // Figure out which day of the week
32
- // the month starts on.
33
- $month_start_day = date('D', $month_start);
34
-
35
- switch($month_start_day){
36
- case "Sun": $offset = 0; break;
37
- case "Mon": $offset = 1; break;
38
- case "Tue": $offset = 2; break;
39
- case "Wed": $offset = 3; break;
40
- case "Thu": $offset = 4; break;
41
- case "Fri": $offset = 5; break;
42
- case "Sat": $offset = 6; break;
43
- }
44
- //We need to go back to the WP defined day when the week started, in case the event day is near the end
45
- $offset -= $start_of_week;
46
- if($offset<0)
47
- $offset += 7;
48
-
49
- // determine how many days are in the last month.
50
- $month_last = $month-1;
51
- $month_next = $month+1;
52
- $year_last = $year;
53
- $year_next = $year;
54
- if($month == 1) {
55
- $month_last = 12;
56
- $year_last = $year -1;
57
- }
58
- $num_days_last = self::days_in_month($month_last, $year_last);
59
-
60
- // determine how many days are in the current month.
61
- $num_days_current = self::days_in_month($month, $year);
62
- // Build an array for the current days
63
- // in the month
64
- for($i = 1; $i <= $num_days_current; $i++){
65
- $num_days_array[] = mktime(0,0,0,$month, $i, $year);
66
- }
67
- // Build an array for the number of days
68
- // in last month
69
- for($i = 1; $i <= $num_days_last; $i++){
70
- $num_days_last_array[] = mktime(0,0,0,$month_last, $i, $year_last);
71
- }
72
- // If the $offset from the starting day of the
73
- // week happens to be Sunday, $offset would be 0,
74
- // so don't need an offset correction.
75
-
76
- if($offset > 0){
77
- $offset_correction = array_slice($num_days_last_array, -$offset, $offset);
78
- $new_count = array_merge($offset_correction, $num_days_array);
79
- $offset_count = count($offset_correction);
80
- } else { // The else statement is to prevent building the $offset array.
81
- $offset_count = 0;
82
- $new_count = $num_days_array;
83
- }
84
- // count how many days we have with the two
85
- // previous arrays merged together
86
- $current_num = count($new_count);
87
-
88
- // Since we will have 5 HTML table rows (TR)
89
- // with 7 table data entries (TD)
90
- // we need to fill in 35 TDs
91
- // so, we will have to figure out
92
- // how many days to appened to the end
93
- // of the final array to make it 35 days.
94
-
95
-
96
- if($current_num > 35){
97
- $num_weeks = 6;
98
- $outset = (42 - $current_num);
99
- } elseif($current_num < 35){
100
- $num_weeks = 5;
101
- $outset = (35 - $current_num);
102
- }
103
- if($current_num == 35){
104
- $num_weeks = 5;
105
- $outset = 0;
106
- }
107
- // Outset Correction
108
- for($i = 1; $i <= $outset; $i++){
109
- $new_count[] = mktime(0,0,0,$month_next, $i, $year_next);
110
- }
111
- // Now let's "chunk" the $all_days array
112
- // into weeks. Each week has 7 days
113
- // so we will array_chunk it into 7 days.
114
- $weeks = array_chunk($new_count, 7);
115
-
116
-
117
-
118
- // Build Previous and Next Links
119
- $base_link = "?".$_SERVER['QUERY_STRING']."&amp;";
120
-
121
- $full ? $link_extra_class = "full-link" : $link_extra_class = '';
122
- //Get an array of arguments that don't include default valued args
123
- $link_args = self::get_link_args($args);
124
-
125
- //Get the previous link
126
- if($month == 1){
127
- $back_month = 12;
128
- $back_year = $year-1;
129
- } else {
130
- $back_month = $month -1;
131
- $back_year = $year;
132
- }
133
- $previous_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&amp;month={$back_month}&amp;year={$back_year}&amp;{$link_args}'>&lt;&lt;</a>";
134
-
135
- //Now the next
136
- if($month == 12){
137
- $next_month = 1;
138
- $next_year = $year+1;
139
- } else {
140
- $next_month = $month + 1;
141
- $next_year = $year;
142
- }
143
- $next_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&amp;month={$next_month}&amp;year={$next_year}&amp;{$link_args}'>&gt;&gt;</a>";
144
-
145
-
146
- $class = ($full) ? 'dbem-calendar-full' : 'dbem-calendar';
147
- $calendar="<div class='$class'><div style='display:none' class='month_n'>$month</div><div class='year_n' style='display:none' >$year</div>";
148
-
149
- $weekdays = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
150
- $n = 0 ;
151
- while( $n < $start_of_week ) {
152
- $last_day = array_shift($weekdays);
153
- $weekdays[]= $last_day;
154
- $n++;
155
- }
156
-
157
- $days_initials = "";
158
- foreach($weekdays as $weekday) {
159
- $days_initials .= "<td>".self::translate_and_trim($weekday)."</td>";
160
- }
161
- $full ? $fullclass = 'fullcalendar' : $fullclass='';
162
- // Build the heading portion of the calendar table
163
- $calendar .= "<table class='dbem-calendar-table $fullclass'>\n".
164
- "<thead>\n<tr>\n".
165
- "<td>$previous_link</td><td class='month_name' colspan='5'>". apply_filters('dbem_calendar_output_month', ucfirst(date_i18n('M', $month_start)), $month_start, $args)." $year</td><td>$next_link</td>\n".
166
- "</tr>\n</thead>\n".
167
- "<tr class='days-names'>\n".
168
- $days_initials.
169
- "</tr>\n";
170
-
171
- // Now we break each key of the array
172
- // into a week and create a new table row for each
173
- // week with the days of that week in the table data
174
-
175
- $i = 0;
176
- $current_date = date('Y-m-d', current_time('timestamp'));
177
- foreach ( $weeks as $week ) {
178
- $calendar .= "<tr>\n";
179
- foreach ( $week as $d ) {
180
- if ($i < $offset_count) { //if it is PREVIOUS month
181
- $calendar .= "<td class='eventless-pre'>" . date ( 'j', $d ) . "</td>\n";
182
- }
183
- if (($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)) { // if it is THIS month
184
- $day = date ( 'j', $d );
185
- if ( $current_date == date('Y-m-d', $d) ){
186
- $calendar .= "<td class='eventless-today'>$day</td>\n";
187
- } else {
188
- $calendar .= "<td class='eventless'>$day</td>\n";
189
- }
190
- } elseif (($outset > 0)) { //if it is NEXT month
191
- if (($i >= ($num_weeks * 7) - $outset)) {
192
- $calendar .= "<td class='eventless-post'>" . date ( 'j', $d ) . "</td>\n";
193
- }
194
- }
195
- $i ++;
196
- }
197
- $calendar .= "</tr>\n";
198
- }
199
-
200
- $calendar .= " </table>\n</div>";
201
-
202
- // query the database for events in this time span
203
- if ($month == 1) {
204
- $month_pre=12;
205
- $month_post=2;
206
- $year_pre=$year-1;
207
- $year_post=$year;
208
- } elseif($month == 12) {
209
- $month_pre=11;
210
- $month_post=1;
211
- $year_pre=$year;
212
- $year_post=$year+1;
213
- } else {
214
- $month_pre=$month-1;
215
- $month_post=$month+1;
216
- $year_pre=$year;
217
- $year_post=$year;
218
- }
219
- $args['year'] = array($year_pre, $year_post);
220
- $args['month'] = array($month_pre, $month_post);
221
- $events = EM_Events::get($args);
222
-
223
- $eventful_days= array();
224
- if($events){
225
- //Go through the events and slot them into the right d-m index
226
- foreach($events as $event) {
227
- $event = apply_filters('em_calendar_output_loop_start', $event);
228
- if( $long_events ){
229
- //If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day
230
- $event_start_date = mktime(0,0,0,$month_pre,1,$year_pre);
231
- $event_end_date = mktime(0,0,0,$month_post,date('t', $event_start_date),$year_post );
232
- if( $event_end_date == '' ) $event_end_date = $event_start_date;
233
- while( $event_start_date <= $event->end ){
234
- //Ensure date is within event dates, if so add to eventful days array
235
- if( $event_start_date > $event->start - (86400) ){ //subtract a day since start may be later in day
236
- $event_eventful_date = date('Y-m-d', $event_start_date);
237
- if( array_key_exists($event_eventful_date, $eventful_days) && is_array($eventful_days[$event_eventful_date]) ){
238
- $eventful_days[$event_eventful_date][] = $event;
239
- } else {
240
- $eventful_days[$event_eventful_date] = array($event);
241
- }
242
- }
243
- $event_start_date += (86400); //add a day
244
- }
245
- }else{
246
- //Only show events on the day that they start
247
- if( isset($eventful_days[$event->start_date]) && is_array($eventful_days[$event->start_date]) ){
248
- $eventful_days[$event->start_date][] = $event;
249
- } else {
250
- $eventful_days[$event->start_date] = array($event);
251
- }
252
- }
253
- $event = apply_filters('em_calendar_output_loop_end', $event);
254
- }
255
- }
256
-
257
- $event_format = get_option('dbem_full_calendar_event_format');
258
- $event_title_format = get_option('dbem_small_calendar_event_title_format');
259
- $event_title_separator_format = get_option('dbem_small_calendar_event_title_separator');
260
- $cells = array() ;
261
- foreach($eventful_days as $day_key => $events) {
262
- //Set the date into the key
263
- $event_start_date = explode('-', $day_key);
264
- $cells[$day_key]['day'] = ltrim($event_start_date[2],'0');
265
- $cells[$day_key]['month'] = $event_start_date[1];
266
- $cells[$day_key]['year'] = $event_start_date[0];
267
- $events_titles = array();
268
- foreach($events as $event) {
269
- $events_titles[] = $event->output($event_title_format);
270
- }
271
- $link_title = implode( $event_title_separator_format, $events_titles);
272
-
273
- $events_page_id = get_option('dbem_events_page');
274
- $event_page_link = get_permalink($events_page_id);
275
- if (stristr($event_page_link, "?"))
276
- $joiner = "&amp;";
277
- else
278
- $joiner = "?";
279
-
280
-
281
- $cells[$day_key]['cell'] = "<a title='$link_title' href='".$event_page_link.$joiner."calendar_day={$day_key}'>{$cells[$day_key]['day']}</a>";
282
- if ($full) {
283
- $cells[$day_key]['cell'] .= "<ul>";
284
-
285
- foreach($events as $event) {
286
- $cells[$day_key]['cell'] .= $event->output($event_format);
287
- }
288
- $cells[$day_key]['cell'] .= "</ul>";
289
- }
290
- }
291
-
292
- if($events){
293
- foreach($cells as $cell) {
294
- if ($cell['month'] == $month_pre && $cell['year'] == $year_pre) {
295
- $calendar = str_replace("<td class='eventless-pre'>".$cell['day']."</td>","<td class='eventful-pre'>".$cell['cell']."</td>",$calendar);
296
- } elseif($cell['month'] == $month_post && $cell['year'] == $year_post) {
297
- $calendar = str_replace("<td class='eventless-post'>".$cell['day']."</td>","<td class='eventful-post'>".$cell['cell']."</td>",$calendar);
298
- } elseif( date('Y-m-j', current_time('timestamp')) == $cell['year']."-".$cell['month']."-".$cell['day'] ) {
299
- $calendar = str_replace("<td class='eventless-today'>".$cell['day']."</td>","<td class='eventful-today'>".$cell['cell']."</td>",$calendar);
300
- } elseif( $cell['month'] == $month && $cell['year'] == $year){
301
- $calendar = str_replace("<td class='eventless'>".$cell['day']."</td>","<td class='eventful'>".$cell['cell']."</td>",$calendar);
302
- }
303
- }
304
- }
305
- return apply_filters('em_calendar_output', '<div id="em-calendar-'.rand(100,200).'" class="em-calendar-wrapper">'.$calendar.'</div>');
306
- }
307
-
308
- /**
309
- * Echoes the calendar external JS contents directly into the head of the document
310
- * @return unknown_type
311
- */
312
- function insert_js() {
313
- ?>
314
- <script type='text/javascript'>
315
- <?php include(WP_PLUGIN_DIR.'/events-manager/includes/js/em_calendar_ajax.js'); ?>
316
- </script>
317
- <?php
318
- }
319
-
320
-
321
- function days_in_month($month, $year) {
322
- return date('t', mktime(0,0,0,$month,1,$year));
323
- }
324
-
325
- function translate_and_trim($string, $length = 1) {
326
- return substr(__($string), 0, $length);
327
- }
328
-
329
- /**
330
- * Helper function to create a link querystring from array which contains arguments with only values that aren't defuaults.
331
- */
332
- function get_link_args($args = array(), $html_entities=true){
333
- unset($args['month']); unset($args['year']);
334
- $default_args = self::get_default_search(array());
335
- foreach($default_args as $arg_key => $arg_value){
336
- if( !isset($args[$arg_key]) || $args[$arg_key] == $arg_value ){
337
- unset($args[$arg_key]);
338
- }
339
- }
340
- $qs_array = array();
341
- foreach($args as $key => $value){
342
- if(is_array($value)){
343
- $value = implode(',',$value);
344
- }
345
- $qs_array[] = "$key=".urlencode($value);
346
- }
347
- return ($html_entities) ? implode('&amp;', $qs_array) : implode('&', $qs_array);
348
- }
349
-
350
-
351
- function get_default_search($array=array()){
352
- //These defaults aren't for db queries, but flags for what to display in calendar output
353
- $defaults = array(
354
- 'full' => 0, //Will display a full calendar with event names
355
- 'long_events' => 0, //Events that last longer than a day
356
- 'scope' => 'all',
357
- 'owner' => false
358
- );
359
- $atts = parent::get_default_search($defaults, $array);
360
- $atts['full'] = ($atts['full']==true) ? 1:0;
361
- $atts['long_events'] = ($atts['long_events']==true) ? 1:0;
362
- return apply_filters('em_calendar_get_default_search', $atts, $array, $defaults);
363
- }
364
- }
365
- add_action('init', array('EM_Calendar', 'init'));
 
 
366
  ?>
1
+ <?php
2
+ class EM_Calendar extends EM_Object {
3
+
4
+ function init(){
5
+ add_action('wp_head', array('EM_Calendar', 'insert_js'));
6
+ }
7
+
8
+ function output($args = array()) {
9
+ global $wpdb;
10
+
11
+ $args = self::get_default_search($args);
12
+ $full = $args['full']; //For ZDE, don't delete pls
13
+ $month = $args['month'];
14
+ $year = $args['year'];
15
+ $long_events = $args['long_events'];
16
+
17
+ $week_starts_on_sunday = get_option('dbem_week_starts_sunday');
18
+ $start_of_week = get_option('start_of_week');
19
+
20
+ if( !(is_numeric($month) && $month <= 12 && $month > 0) ) {
21
+ $month = date('m');
22
+ }
23
+ if( !( is_numeric($year) ) ){
24
+ $year = date('Y');
25
+ }
26
+
27
+ // Get the first day of the month
28
+ $month_start = mktime(0,0,0,$month, 1, $year);
29
+ // Get friendly month name
30
+ $month_name = date('M',$month_start);
31
+ // Figure out which day of the week
32
+ // the month starts on.
33
+ $month_start_day = date('D', $month_start);
34
+
35
+ switch($month_start_day){
36
+ case "Sun": $offset = 0; break;
37
+ case "Mon": $offset = 1; break;
38
+ case "Tue": $offset = 2; break;
39
+ case "Wed": $offset = 3; break;
40
+ case "Thu": $offset = 4; break;
41
+ case "Fri": $offset = 5; break;
42
+ case "Sat": $offset = 6; break;
43
+ }
44
+ //We need to go back to the WP defined day when the week started, in case the event day is near the end
45
+ $offset -= $start_of_week;
46
+ if($offset<0)
47
+ $offset += 7;
48
+
49
+ // determine how many days are in the last month.
50
+ $month_last = $month-1;
51
+ $month_next = $month+1;
52
+ $year_last = $year;
53
+ $year_next = $year;
54
+ if($month == 1) {
55
+ $month_last = 12;
56
+ $year_last = $year -1;
57
+ }
58
+ $num_days_last = self::days_in_month($month_last, $year_last);
59
+
60
+ // determine how many days are in the current month.
61
+ $num_days_current = self::days_in_month($month, $year);
62
+ // Build an array for the current days
63
+ // in the month
64
+ for($i = 1; $i <= $num_days_current; $i++){
65
+ $num_days_array[] = mktime(0,0,0,$month, $i, $year);
66
+ }
67
+ // Build an array for the number of days
68
+ // in last month
69
+ for($i = 1; $i <= $num_days_last; $i++){
70
+ $num_days_last_array[] = mktime(0,0,0,$month_last, $i, $year_last);
71
+ }
72
+ // If the $offset from the starting day of the
73
+ // week happens to be Sunday, $offset would be 0,
74
+ // so don't need an offset correction.
75
+
76
+ if($offset > 0){
77
+ $offset_correction = array_slice($num_days_last_array, -$offset, $offset);
78
+ $new_count = array_merge($offset_correction, $num_days_array);
79
+ $offset_count = count($offset_correction);
80
+ } else { // The else statement is to prevent building the $offset array.
81
+ $offset_count = 0;
82
+ $new_count = $num_days_array;
83
+ }
84
+ // count how many days we have with the two
85
+ // previous arrays merged together
86
+ $current_num = count($new_count);
87
+
88
+ // Since we will have 5 HTML table rows (TR)
89
+ // with 7 table data entries (TD)
90
+ // we need to fill in 35 TDs
91
+ // so, we will have to figure out
92
+ // how many days to appened to the end
93
+ // of the final array to make it 35 days.
94
+
95
+
96
+ if($current_num > 35){
97
+ $num_weeks = 6;
98
+ $outset = (42 - $current_num);
99
+ } elseif($current_num < 35){
100
+ $num_weeks = 5;
101
+ $outset = (35 - $current_num);
102
+ }
103
+ if($current_num == 35){
104
+ $num_weeks = 5;
105
+ $outset = 0;
106
+ }
107
+ // Outset Correction
108
+ for($i = 1; $i <= $outset; $i++){
109
+ $new_count[] = mktime(0,0,0,$month_next, $i, $year_next);
110
+ }
111
+ // Now let's "chunk" the $all_days array
112
+ // into weeks. Each week has 7 days
113
+ // so we will array_chunk it into 7 days.
114
+ $weeks = array_chunk($new_count, 7);
115
+
116
+
117
+
118
+ // Build Previous and Next Links
119
+ $base_link = "?".$_SERVER['QUERY_STRING']."&amp;";
120
+
121
+ $full ? $link_extra_class = "full-link" : $link_extra_class = '';
122
+ //Get an array of arguments that don't include default valued args
123
+ $link_args = self::get_link_args($args);
124
+
125
+ //Get the previous link
126
+ if($month == 1){
127
+ $back_month = 12;
128
+ $back_year = $year-1;
129
+ } else {
130
+ $back_month = $month -1;
131
+ $back_year = $year;
132
+ }
133
+ $previous_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&amp;month={$back_month}&amp;year={$back_year}&amp;{$link_args}'>&lt;&lt;</a>";
134
+
135
+ //Now the next
136
+ if($month == 12){
137
+ $next_month = 1;
138
+ $next_year = $year+1;
139
+ } else {
140
+ $next_month = $month + 1;
141
+ $next_year = $year;
142
+ }
143
+ $next_link = "<a class='em-calnav $link_extra_class' href='?ajaxCalendar=1&amp;month={$next_month}&amp;year={$next_year}&amp;{$link_args}'>&gt;&gt;</a>";
144
+
145
+
146
+ $class = ($full) ? 'dbem-calendar-full' : 'dbem-calendar';
147
+ $calendar="<div class='$class'><div style='display:none' class='month_n'>$month</div><div class='year_n' style='display:none' >$year</div>";
148
+
149
+ $weekdays = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
150
+ $n = 0 ;
151
+ while( $n < $start_of_week ) {
152
+ $last_day = array_shift($weekdays);
153
+ $weekdays[]= $last_day;
154
+ $n++;
155
+ }
156
+
157
+ $days_initials = "";
158
+ foreach($weekdays as $weekday) {
159
+ $days_initials .= "<td>".self::translate_and_trim($weekday)."</td>";
160
+ }
161
+ $full ? $fullclass = 'fullcalendar' : $fullclass='';
162
+ // Build the heading portion of the calendar table
163
+ $calendar .= "<table class='dbem-calendar-table $fullclass'>\n".
164
+ "<thead>\n<tr>\n".
165
+ "<td>$previous_link</td><td class='month_name' colspan='5'>". apply_filters('dbem_calendar_output_month', ucfirst(date_i18n('M', $month_start)), $month_start, $args)." $year</td><td>$next_link</td>\n".
166
+ "</tr>\n</thead>\n".
167
+ "<tr class='days-names'>\n".
168
+ $days_initials.
169
+ "</tr>\n";
170
+
171
+ // Now we break each key of the array
172
+ // into a week and create a new table row for each
173
+ // week with the days of that week in the table data
174
+
175
+ $i = 0;
176
+ $current_date = date('Y-m-d', current_time('timestamp'));
177
+ foreach ( $weeks as $week ) {
178
+ $calendar .= "<tr>\n";
179
+ foreach ( $week as $d ) {
180
+ if ($i < $offset_count) { //if it is PREVIOUS month
181
+ $calendar .= "<td class='eventless-pre'>" . date ( 'j', $d ) . "</td>\n";
182
+ }
183
+ if (($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)) { // if it is THIS month
184
+ $day = date ( 'j', $d );
185
+ if ( $current_date == date('Y-m-d', $d) ){
186
+ $calendar .= "<td class='eventless-today'>$day</td>\n";
187
+ } else {
188
+ $calendar .= "<td class='eventless'>$day</td>\n";
189
+ }
190
+ } elseif (($outset > 0)) { //if it is NEXT month
191
+ if (($i >= ($num_weeks * 7) - $outset)) {
192
+ $calendar .= "<td class='eventless-post'>" . date ( 'j', $d ) . "</td>\n";
193
+ }
194
+ }
195
+ $i ++;
196
+ }
197
+ $calendar .= "</tr>\n";
198
+ }
199
+
200
+ $calendar .= " </table>\n</div>";
201
+
202
+ // query the database for events in this time span
203
+ if ($month == 1) {
204
+ $month_pre=12;
205
+ $month_post=2;
206
+ $year_pre=$year-1;
207
+ $year_post=$year;
208
+ } elseif($month == 12) {
209
+ $month_pre=11;
210
+ $month_post=1;
211
+ $year_pre=$year;
212
+ $year_post=$year+1;
213
+ } else {
214
+ $month_pre=$month-1;
215
+ $month_post=$month+1;
216
+ $year_pre=$year;
217
+ $year_post=$year;
218
+ }
219
+ $args['year'] = array($year_pre, $year_post);
220
+ $args['month'] = array($month_pre, $month_post);
221
+ $events = EM_Events::get($args);
222
+
223
+ $eventful_days= array();
224
+ if($events){
225
+ //Go through the events and slot them into the right d-m index
226
+ foreach($events as $event) {
227
+ $event = apply_filters('em_calendar_output_loop_start', $event);
228
+ if( $long_events ){
229
+ //If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day
230
+ $event_start_date = mktime(0,0,0,$month_pre,1,$year_pre);
231
+ $event_end_date = mktime(0,0,0,$month_post,date('t', $event_start_date),$year_post );
232
+ if( $event_end_date == '' ) $event_end_date = $event_start_date;
233
+ while( $event_start_date <= $event->end ){
234
+ //Ensure date is within event dates, if so add to eventful days array
235
+ if( $event_start_date > $event->start - (86400) ){ //subtract a day since start may be later in day
236
+ $event_eventful_date = date('Y-m-d', $event_start_date);
237
+ if( array_key_exists($event_eventful_date, $eventful_days) && is_array($eventful_days[$event_eventful_date]) ){
238
+ $eventful_days[$event_eventful_date][] = $event;
239
+ } else {
240
+ $eventful_days[$event_eventful_date] = array($event);
241
+ }
242
+ }
243
+ $event_start_date += (86400); //add a day
244
+ }
245
+ }else{
246
+ //Only show events on the day that they start
247
+ if( isset($eventful_days[$event->start_date]) && is_array($eventful_days[$event->start_date]) ){
248
+ $eventful_days[$event->start_date][] = $event;
249
+ } else {
250
+ $eventful_days[$event->start_date] = array($event);
251
+ }
252
+ }
253
+ $event = apply_filters('em_calendar_output_loop_end', $event);
254
+ }
255
+ }
256
+
257
+ $event_format = get_option('dbem_full_calendar_event_format');
258
+ $event_title_format = get_option('dbem_small_calendar_event_title_format');
259
+ $event_title_separator_format = get_option('dbem_small_calendar_event_title_separator');
260
+ $cells = array() ;
261
+ foreach($eventful_days as $day_key => $events) {
262
+ //Set the date into the key
263
+ $event_start_date = explode('-', $day_key);
264
+ $cells[$day_key]['day'] = ltrim($event_start_date[2],'0');
265
+ $cells[$day_key]['month'] = $event_start_date[1];
266
+ $cells[$day_key]['year'] = $event_start_date[0];
267
+ $events_titles = array();
268
+ foreach($events as $event) {
269
+ $events_titles[] = $event->output($event_title_format);
270
+ }
271
+ $link_title = implode( $event_title_separator_format, $events_titles);
272
+
273
+ global $wp_rewrite;
274
+ $event_page_link = get_permalink(get_option('dbem_events_page')); //don't use EM_URI here, since ajax calls this before EM_URI is defined.
275
+ if( $wp_rewrite->using_permalinks() ){
276
+ $cells[$day_key]['cell'] = "<a title='$link_title' href='".$event_page_link."{$day_key}/'>{$cells[$day_key]['day']}</a>";
277
+ }else{
278
+ if (stristr($event_page_link, "?"))
279
+ $joiner = "&amp;";
280
+ else
281
+ $joiner = "?";
282
+ $cells[$day_key]['cell'] = "<a title='$link_title' href='".$event_page_link.$joiner."calendar_day={$day_key}'>{$cells[$day_key]['day']}</a>";
283
+ }
284
+ if ($full) {
285
+ $cells[$day_key]['cell'] .= "<ul>";
286
+
287
+ foreach($events as $event) {
288
+ $cells[$day_key]['cell'] .= $event->output($event_format);
289
+ }
290
+ $cells[$day_key]['cell'] .= "</ul>";
291
+ }
292
+ }
293
+
294
+ if($events){
295
+ foreach($cells as $cell) {
296
+ if ($cell['month'] == $month_pre && $cell['year'] == $year_pre) {
297
+ $calendar = str_replace("<td class='eventless-pre'>".$cell['day']."</td>","<td class='eventful-pre'>".$cell['cell']."</td>",$calendar);
298
+ } elseif($cell['month'] == $month_post && $cell['year'] == $year_post) {
299
+ $calendar = str_replace("<td class='eventless-post'>".$cell['day']."</td>","<td class='eventful-post'>".$cell['cell']."</td>",$calendar);
300
+ } elseif( date('Y-m-j', current_time('timestamp')) == $cell['year']."-".$cell['month']."-".$cell['day'] ) {
301
+ $calendar = str_replace("<td class='eventless-today'>".$cell['day']."</td>","<td class='eventful-today'>".$cell['cell']."</td>",$calendar);
302
+ } elseif( $cell['month'] == $month && $cell['year'] == $year){
303
+ $calendar = str_replace("<td class='eventless'>".$cell['day']."</td>","<td class='eventful'>".$cell['cell']."</td>",$calendar);
304
+ }
305
+ }
306
+ }
307
+ return apply_filters('em_calendar_output', '<div id="em-calendar-'.rand(100,200).'" class="em-calendar-wrapper">'.$calendar.'</div>');
308
+ }
309
+
310
+ /**
311
+ * Echoes the calendar external JS contents directly into the head of the document
312
+ * @return unknown_type
313
+ */
314
+ function insert_js() {
315
+ ?>
316
+ <script type='text/javascript'>
317
+ <?php include(WP_PLUGIN_DIR.'/events-manager/includes/js/em_calendar_ajax.js'); ?>
318
+ </script>
319
+ <?php
320
+ }
321
+
322
+
323
+ function days_in_month($month, $year) {
324
+ return date('t', mktime(0,0,0,$month,1,$year));
325
+ }
326
+
327
+ function translate_and_trim($string, $length = 1) {
328
+ return substr(__($string), 0, $length);
329
+ }
330
+
331
+ /**
332
+ * Helper function to create a link querystring from array which contains arguments with only values that aren't defuaults.
333
+ */
334
+ function get_link_args($args = array(), $html_entities=true){
335
+ unset($args['month']); unset($args['year']);
336
+ $default_args = self::get_default_search(array());
337
+ foreach($default_args as $arg_key => $arg_value){
338
+ if( !isset($args[$arg_key]) || $args[$arg_key] == $arg_value ){
339
+ unset($args[$arg_key]);
340
+ }
341
+ }
342
+ $qs_array = array();
343
+ foreach($args as $key => $value){
344
+ if(is_array($value)){
345
+ $value = implode(',',$value);
346
+ }
347
+ $qs_array[] = "$key=".urlencode($value);
348
+ }
349
+ return ($html_entities) ? implode('&amp;', $qs_array) : implode('&', $qs_array);
350
+ }
351
+
352
+
353
+ function get_default_search($array=array()){
354
+ //These defaults aren't for db queries, but flags for what to display in calendar output
355
+ $defaults = array(
356
+ 'full' => 0, //Will display a full calendar with event names
357
+ 'long_events' => 0, //Events that last longer than a day
358
+ 'scope' => 'future',
359
+ 'owner' => false
360
+ );
361
+ $atts = parent::get_default_search($defaults, $array);
362
+ $atts['full'] = ($atts['full']==true) ? 1:0;
363
+ $atts['long_events'] = ($atts['long_events']==true) ? 1:0;
364
+ return apply_filters('em_calendar_get_default_search', $atts, $array, $defaults);
365
+ }
366
+ }
367
+ add_action('init', array('EM_Calendar', 'init'));
368
  ?>
classes/em-categories.php CHANGED
@@ -133,25 +133,26 @@ class EM_Categories extends EM_Object {
133
  'eventless' => false, //cats WITHOUT events, eventful takes precedence
134
  );
135
  if( is_admin() ){
136
- //by default, we only get categories the owner can manage
137
- switch( get_option('dbem_permissions_categories') ){
138
- case 0:
139
- $defaults['owner'] = get_current_user_id();
140
- break;
141
- case 1:
142
- $wp_user_search = new WP_User_Search(null, null, 'administrator');
143
- $users = $wp_user_search->get_results();
144
- $users[] = get_current_user_id();
145
- $users[] = 0;
146
- $defaults['owner'] = implode(',', $users);
147
- break;
148
- case 2:
149
- $defaults['owner'] = false;
150
- break;
151
- }
152
- $defaults['owner'] = ( em_verify_admin() ) ? false:$defaults['owner'];
153
  }
154
  return apply_filters('em_categories_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
155
  }
156
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
133
  'eventless' => false, //cats WITHOUT events, eventful takes precedence
134
  );
135
  if( is_admin() ){
136
+ //$defaults['owner'] = self::get_default_search_owner();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
  return apply_filters('em_categories_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
139
  }
140
+
141
+ /**
142
+ * will return the default search parameter to use according to permission settings
143
+ * @return string
144
+ */
145
+ function get_default_search_owner(){
146
+ //by default, we only get categories the owner can manage
147
+ $defaults = array('owner'=>false);
148
+ //by default, we only get categories the owner can manage
149
+ if( !current_user_can('edit_categories') ){
150
+ $defaults['owner'] = get_current_user_id();
151
+ break;
152
+ }else{
153
+ $defaults['owner'] = false;
154
+ break;
155
+ }
156
+ return $defaults['owner'];
157
+ }
158
  }
classes/em-category.php CHANGED
@@ -3,11 +3,13 @@
3
  class EM_Category extends EM_Object {
4
  //DB Fields
5
  var $id = '';
 
6
  var $owner = '';
7
  var $name = '';
8
  //Other Vars
9
  var $fields = array(
10
  'category_id' => array('name'=>'id','type'=>'%d'),
 
11
  'category_owner' => array('name'=>'owner','type'=>'%d'),
12
  'category_name' => array('name'=>'name','type'=>'%s')
13
  );
@@ -21,22 +23,26 @@ class EM_Category extends EM_Object {
21
  * @return null
22
  */
23
  function EM_Category( $category_data = false ) {
 
24
  //Initialize
25
  $this->required_fields = array("category_name" => __('The category name', 'dbem'));
26
  $category = array();
27
- if( $category_data != false ){
28
  //Load location data
29
  if( is_array($category_data) && isset($category_data['category_name']) ){
30
  $category = $category_data;
31
  }elseif( is_numeric($category_data) ){
32
  //Retreiving from the database
33
- global $wpdb;
34
  $sql = "SELECT * FROM ". $wpdb->prefix.EM_CATEGORIES_TABLE ." WHERE category_id ='{$category_data}'";
35
  $category = $wpdb->get_row($sql, ARRAY_A);
 
 
 
36
  }
37
  //Save into the object
38
  $this->to_object($category);
39
  }
 
40
  }
41
 
42
  function get_post(){
@@ -51,26 +57,55 @@ class EM_Category extends EM_Object {
51
 
52
  function save(){
53
  global $wpdb;
54
- do_action('em_category_save_pre', $this);
55
- $table = $wpdb->prefix.EM_CATEGORIES_TABLE;
56
- $data = $this->to_array();
57
- unset($data['category_id']);
58
- if($this->id != ''){
59
- $where = array( 'category_id' => $this->id );
60
- $wpdb->update($table, $data, $where, $this->get_types($data));
61
- }else{
62
- $wpdb->insert($table, $data, $this->get_types($data));
63
- $this->id = $wpdb->insert_id;
 
 
 
 
64
  }
65
- return apply_filters('em_category_save', ( $this->id > 0 && $image_upload ), $this, $image_upload);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  function delete(){
69
- global $wpdb;
70
- do_action('em_category_delete_pre', $this);
71
- $table_name = $wpdb->prefix.EM_CATEGORIES_TABLE;
72
- $sql = "DELETE FROM $table_name WHERE category_id = '{$this->id}';";
73
- $result = $wpdb->query($sql);
 
 
 
74
  return apply_filters('em_category_delete', $result, $this);
75
  }
76
 
@@ -134,19 +169,8 @@ class EM_Category extends EM_Object {
134
  return apply_filters('em_category_output', $category_string, $this, $format, $target);
135
  }
136
 
137
- function can_manage(){
138
- return ( get_option('dbem_permissions_categories') == 2 || $this->owner == get_current_user_id() || empty($this->id) || em_verify_admin() );
139
- }
140
-
141
- function can_use(){
142
- switch( get_option('dbem_permissions_locations') ){
143
- case 0:
144
- return $this->owner == get_current_user_id();
145
- case 1:
146
- return em_verify_admin($this->owner);
147
- case 2:
148
- return true;
149
- }
150
  }
151
  }
152
  ?>
3
  class EM_Category extends EM_Object {
4
  //DB Fields
5
  var $id = '';
6
+ var $slug = '';
7
  var $owner = '';
8
  var $name = '';
9
  //Other Vars
10
  var $fields = array(
11
  'category_id' => array('name'=>'id','type'=>'%d'),
12
+ 'category_slug' => array('name'=>'slug','type'=>'%s'),
13
  'category_owner' => array('name'=>'owner','type'=>'%d'),
14
  'category_name' => array('name'=>'name','type'=>'%s')
15
  );
23
  * @return null
24
  */
25
  function EM_Category( $category_data = false ) {
26
+ global $wpdb;
27
  //Initialize
28
  $this->required_fields = array("category_name" => __('The category name', 'dbem'));
29
  $category = array();
30
+ if( !empty($category_data) ){
31
  //Load location data
32
  if( is_array($category_data) && isset($category_data['category_name']) ){
33
  $category = $category_data;
34
  }elseif( is_numeric($category_data) ){
35
  //Retreiving from the database
 
36
  $sql = "SELECT * FROM ". $wpdb->prefix.EM_CATEGORIES_TABLE ." WHERE category_id ='{$category_data}'";
37
  $category = $wpdb->get_row($sql, ARRAY_A);
38
+ }else{
39
+ $sql = "SELECT * FROM ". $wpdb->prefix.EM_CATEGORIES_TABLE ." WHERE category_slug ='{$category_data}'";
40
+ $category = $wpdb->get_row($sql, ARRAY_A);
41
  }
42
  //Save into the object
43
  $this->to_object($category);
44
  }
45
+ do_action('em_category',$this, $category_data);
46
  }
47
 
48
  function get_post(){
57
 
58
  function save(){
59
  global $wpdb;
60
+ $result = false;
61
+ if( $this->can_manage('edit_categories') ){
62
+ do_action('em_category_save_pre', $this);
63
+ $table = $wpdb->prefix.EM_CATEGORIES_TABLE;
64
+ $this->slug = $this->sanitize_title();
65
+ $data = $this->to_array();
66
+ unset($data['category_id']);
67
+ if($this->id != ''){
68
+ $where = array( 'category_id' => $this->id );
69
+ $result = $wpdb->update($table, $data, $where, $this->get_types($data));
70
+ }else{
71
+ $wpdb->insert($table, $data, $this->get_types($data));
72
+ $result = $this->id = $wpdb->insert_id;
73
+ }
74
  }
75
+ return apply_filters('em_category_save', ($result !== false), $this);
76
+ }
77
+
78
+ /**
79
+ * Takes the title and gives either a unique slug or returns the currently used slug if this record already has it.
80
+ * @param unknown_type $title
81
+ */
82
+ function sanitize_title($iteration = 1){
83
+ global $wpdb;
84
+ //Generate the slug. If this is a new event, create the slug automatically, if not, verify it is still unique and if not rewrite
85
+ if( empty($this->slug) ){
86
+ $this->slug = sanitize_title($this->name);
87
+ }
88
+ $slug = $this->slug;
89
+ $slug_matches = $wpdb->get_results('SELECT category_id FROM '.$wpdb->prefix.EM_LOCATIONS_TABLE." WHERE category_slug='{$slug}'", ARRAY_A);
90
+ if( count($slug_matches) > 0 ){ //we will check that the slug is unique
91
+ if( $slug_matches[0]['category_id'] != $this->id || count($slug_matches) > 1 ){
92
+ //we have a conflict, so try another alternative
93
+ $this->slug = preg_replace('/\-[0-9]+$/', '', $slug).'-'.($iteration+1);
94
+ $this->sanitize_title($iteration+1);
95
+ }
96
+ }
97
+ return apply_filters('em_location_sanitize_title', $this->slug, $this);
98
  }
99
 
100
  function delete(){
101
+ global $wpdb;
102
+ $result = false;
103
+ if( $this->can_manage('edit_categories') ){
104
+ do_action('em_category_delete_pre', $this);
105
+ $table_name = $wpdb->prefix.EM_CATEGORIES_TABLE;
106
+ $sql = "DELETE FROM $table_name WHERE category_id = '{$this->id}';";
107
+ $result = $wpdb->query($sql);
108
+ }
109
  return apply_filters('em_category_delete', $result, $this);
110
  }
111
 
169
  return apply_filters('em_category_output', $category_string, $this, $format, $target);
170
  }
171
 
172
+ function can_manage( $capability_owner = 'edit_categories', $capability_admin = false ){
173
+ return current_user_can($capability_owner);
 
 
 
 
 
 
 
 
 
 
 
174
  }
175
  }
176
  ?>
classes/em-event.php CHANGED
@@ -18,7 +18,8 @@ class EM_Event extends EM_Object{
18
  */
19
  var $fields = array(
20
  'event_id' => array( 'name'=>'id', 'type'=>'%d' ),
21
- 'event_author' => array( 'name'=>'author', 'type'=>'%d' ),
 
22
  'event_name' => array( 'name'=>'name', 'type'=>'%s' ),
23
  'event_start_time' => array( 'name'=>'start_time', 'type'=>'%s' ),
24
  'event_end_time' => array( 'name'=>'end_time', 'type'=>'%s' ),
@@ -26,8 +27,7 @@ class EM_Event extends EM_Object{
26
  'event_end_date' => array( 'name'=>'end_date', 'type'=>'%s' ),
27
  'event_notes' => array( 'name'=>'notes', 'type'=>'%s' ),
28
  'event_rsvp' => array( 'name'=>'rsvp', 'type'=>'%d' ),
29
- 'event_seats' => array( 'name'=>'seats', 'type'=>'%d' ),
30
- 'event_contactperson_id' => array( 'name'=>'contactperson_id', 'type'=>'%d' ),
31
  'location_id' => array( 'name'=>'location_id', 'type'=>'%d' ),
32
  'recurrence_id' => array( 'name'=>'recurrence_id', 'type'=>'%d' ),
33
  'event_category_id' => array( 'name'=>'category_id', 'type'=>'%d' ),
@@ -36,11 +36,13 @@ class EM_Event extends EM_Object{
36
  'recurrence_interval' => array( 'name'=>'interval', 'type'=>'%d' ), //every x day(s)/week(s)/month(s)
37
  'recurrence_freq' => array( 'name'=>'freq', 'type'=>'%s' ), //daily,weekly,monthly?
38
  'recurrence_byday' => array( 'name'=>'byday', 'type'=>'%s' ), //if weekly or monthly, what days of the week?
39
- 'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d' ) //if monthly which week (-1 is last)
 
40
  );
41
  /* Field Names - see above for matching DB field names and other field meta data */
42
  var $id;
43
- var $author;
 
44
  var $name;
45
  var $start_time;
46
  var $end_time;
@@ -48,8 +50,7 @@ class EM_Event extends EM_Object{
48
  var $end_date;
49
  var $notes;
50
  var $rsvp;
51
- var $seats;
52
- var $contactperson_id;
53
  var $location_id;
54
  var $recurrence_id;
55
  var $category_id;
@@ -59,6 +60,7 @@ class EM_Event extends EM_Object{
59
  var $freq;
60
  var $byday;
61
  var $byweekno;
 
62
 
63
  /**
64
  * Timestamp of start date/time
@@ -109,6 +111,11 @@ class EM_Event extends EM_Object{
109
  * @var string
110
  */
111
  var $feedback_message;
 
 
 
 
 
112
  /**
113
  * Array of dbem_event field names required to create an event
114
  * @var array
@@ -118,10 +125,9 @@ class EM_Event extends EM_Object{
118
  /**
119
  * Initialize an event. You can provide event data in an associative array (using database table field names), an id number, or false (default) to create empty event.
120
  * @param mixed $event_data
121
- * @param boolean $recurrent
122
  * @return null
123
  */
124
- function EM_Event($event_data = false, $recurrent = false) {
125
  global $wpdb, $EM_Recurrences;
126
  //TODO Change the way we deal with time, maybe revert to timestamps for manipulation, and worry about output in html and db writes?
127
  if( $event_data !== false ){
@@ -129,9 +135,16 @@ class EM_Event extends EM_Object{
129
  if( is_array($event_data) ){
130
  //Accepts a raw array that'll just be imported directly into the object with no DB lookups (same for event and recurrence)
131
  $event = $event_data;
132
- $this->location = new EM_Location( $event );
 
 
133
  $this->category = new EM_Category( $event );
134
- }elseif( is_numeric($event_data) && $event_data > 0 ){
 
 
 
 
 
135
  //Retreiving from the database
136
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
137
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
@@ -140,7 +153,7 @@ class EM_Event extends EM_Object{
140
  SELECT * FROM $events_table
141
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
142
  LEFT JOIN $categories_table ON {$categories_table}.category_id={$events_table}.event_category_id
143
- WHERE event_id = $event_data
144
  "; //We get event and location data here to avoid extra queries
145
  $event = $wpdb->get_row ( $sql, ARRAY_A );
146
  //Sort Location
@@ -154,36 +167,48 @@ class EM_Event extends EM_Object{
154
  }
155
  $event['event_attributes'] = (!is_array($event['event_attributes'])) ? array() : $event['event_attributes'] ;
156
  }
157
- $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
158
  $this->to_object($event, true);
159
 
160
  //Start/End times should be available as timestamp
161
  $this->start = strtotime($this->start_date." ".$this->start_time);
162
  $this->end = strtotime($this->end_date." ".$this->end_time);
163
- $this->modified = strtotime($event['event_date_modified']);
164
- $this->created = strtotime($event['event_date_created']);
165
 
166
- //Add Contact Person
167
- if($this->contactperson_id){
168
- if($this->contactperson_id > 0){
169
- $this->contact = get_userdata($this->contactperson_id);
170
- }
171
  }
172
  if( !is_object($this->contact) ){
173
- $this->contactperson_id = get_option('dbem_default_contact_person');
174
- $this->contact = get_userdata($this->contactperson_id);
175
  }
176
  if( is_object($this->contact) ){
177
  $this->contact->phone = get_metadata('user', $this->contact->ID, 'dbem_phone', true);
178
  }
179
  //Now, if this is a recurrence, get the recurring for caching to the $EM_Recurrences
180
- if( $this->is_recurrence() && !array_key_exists($this->recurrence_id, $EM_Recurrences) ){
181
  $EM_Recurrences[$this->recurrence_id] = new EM_Event($this->recurrence_id);
182
  }
183
  }else{
184
  $this->location = new EM_Location(); //blank location
185
  $this->category = new EM_Category(); //blank category
186
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  }
188
 
189
  /**
@@ -197,7 +222,7 @@ class EM_Event extends EM_Object{
197
  $this->start_date = ( !empty($_POST['event_start_date']) ) ? $_POST['event_start_date'] : '';
198
  $this->end_date = ( !empty($_POST['event_end_date']) ) ? $_POST['event_end_date'] : $this->start_date;
199
  $this->rsvp = ( !empty($_POST['event_rsvp']) ) ? 1:0;
200
- $this->seats = ( !empty($_POST['event_seats']) && is_numeric($_POST['event_seats']) ) ? $_POST['event_seats']:0;
201
  $this->notes = ( !empty($_POST['content']) ) ? stripslashes($_POST['content']) : ''; //WP TinyMCE field
202
  //Sort out time
203
  //TODO make time handling less painful
@@ -225,22 +250,27 @@ class EM_Event extends EM_Object{
225
  //Start/End times should be available as timestamp
226
  $this->start = strtotime($this->start_date." ".$this->start_time);
227
  $this->end = strtotime($this->end_date." ".$this->end_time);
228
- //Contact Person
229
- if ( !empty($_POST['event_contactperson_id']) && is_numeric($_POST['event_contactperson_id']) ) {
230
- //TODO contactperson choices needs limiting depending on role
231
- $this->contactperson_id = $_POST['event_contactperson_id'];
232
  }
 
233
  //category
234
  if( !empty($_POST['event_category_id']) && is_numeric($_POST['event_category_id']) ){
235
  $this->category_id = $_POST['event_category_id'];
236
  }
237
  //Attributes
238
  $event_attributes = array();
239
- for($i=1 ; !empty($_POST["mtm_{$i}_ref"]) && trim($_POST["mtm_{$i}_ref"]) != '' ; $i++ ){
240
- if( !empty($_POST["mtm_{$i}_name"]) && trim($_POST["mtm_{$i}_name"]) != '' ){
241
- $event_attributes[$_POST["mtm_{$i}_ref"]] = stripslashes($_POST["mtm_{$i}_name"]);
242
- }
243
- }
 
 
 
 
244
  $this->attributes = $event_attributes;
245
  //Recurrence data
246
  $this->recurrence_id = ( !empty($_POST['recurrence_id']) && is_numeric($_POST['recurrence_id']) ) ? $_POST['recurrence_id'] : 0 ;
@@ -257,12 +287,18 @@ class EM_Event extends EM_Object{
257
  }
258
 
259
  //Add location information, or just link to previous location, this is a requirement...
260
- if( !empty($_POST['location-select-id']) ) {
261
- $this->location = new EM_Location($_POST['location-select-id']);
 
 
262
  } else {
263
- $this->location = new EM_Location($_POST);
264
  $this->location->load_similar($_POST);
265
  }
 
 
 
 
266
  return apply_filters('em_event_get_post', $this->validate(), $this);
267
  }
268
 
@@ -274,36 +310,53 @@ class EM_Event extends EM_Object{
274
  function save(){
275
  //FIXME Event doesn't save title when inserting first time
276
  global $wpdb, $current_user;
277
- if( !$this->can_manage(true) ){
278
  return apply_filters('em_event_save', false, $this);
279
  }
280
  do_action('em_event_save_pre', $this);
281
  get_currentuserinfo();
282
  $events_table = $wpdb->prefix.EM_EVENTS_TABLE;
 
283
  //First let's save the location, no location no event!
284
- if ( !$this->location->id && !$this->location->save() ){ //shouldn't try to save if location exists
285
  $this->errors[] = __ ( 'There was a problem saving the location so event was not saved.', 'dbem' );
286
  return apply_filters('em_event_save', false, $this);
287
  }
288
  $this->location_id = $this->location->id;
289
- //Contact person can be anyone the admin wants, but the creator if not.
290
- if( em_verify_admin() ){
291
- $this->contactperson_id = ( $this->contactperson_id > 0 ) ? $this->contactperson_id:0;
292
  }else{
293
  //force
294
- $this->contactperson_id = get_current_user_id();
295
  }
 
 
 
 
 
 
 
 
 
 
296
  //Now save the event
297
  if ( !$this->id ) {
298
  // Insert New Event
299
- $this->author = $current_user->ID; //Record creator of event
300
- $event = $this->to_array(false, true);
301
  $event['event_attributes'] = serialize($this->attributes);
302
  $event['recurrence_id'] = ( is_numeric($this->recurrence_id) ) ? $this->recurrence_id : 0;
303
  $event = apply_filters('em_event_save_pre',$event,$this);
304
  $result = $wpdb->insert ( $events_table, $event, $this->get_types($event) );
305
  if($result !== false){
306
  $this->id = $wpdb->insert_id;
 
 
 
 
 
 
307
  //Deal with recurrences
308
  if ( $this->is_recurring() ) {
309
  //Recurrence master event saved, now Save Events & check errors
@@ -326,7 +379,7 @@ class EM_Event extends EM_Object{
326
  } else {
327
  // Update Event
328
  //TODO event privacy protection, only authors and authorized users can edit events
329
- //$this->author = $current_user->ID; //Record creator of event
330
  //FIXME Saving recurrence and disabling recurrence doesn't work
331
  $this->recurrence_id = 0; // If it's saved here, it becomes individual
332
  $event = $this->to_array();
@@ -334,6 +387,11 @@ class EM_Event extends EM_Object{
334
  $event = apply_filters('em_event_save_pre',$event,$this);
335
  $result = $wpdb->update ( $events_table, $event, array('event_id' => $this->id), $this->get_types($event) );
336
  if($result !== false){ //Can't just do $result since if you don't make an actual record details change, it'll return 0 for no changes made
 
 
 
 
 
337
  //Deal with recurrences
338
  if ( $this->is_recurring() ) {
339
  if( !$this->save_events() ){
@@ -357,6 +415,28 @@ class EM_Event extends EM_Object{
357
  }
358
  }
359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  /**
361
  * Delete whole event, including recurrence and recurring data
362
  * @param $recurrence_id
@@ -366,7 +446,7 @@ class EM_Event extends EM_Object{
366
  global $wpdb;
367
  do_action('em_event_delete_pre', $this);
368
  $result = false;
369
- if( $this->can_manage(true) ){
370
  if( $this->is_recurring() ){
371
  //Delete the recurrences then this recurrence event
372
  $this->delete_events();
@@ -376,7 +456,35 @@ class EM_Event extends EM_Object{
376
  $result = $this->get_bookings()->delete();
377
  }
378
  }
379
- return apply_filters('em_event_delete', $result, $this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  }
381
 
382
  /**
@@ -386,15 +494,17 @@ class EM_Event extends EM_Object{
386
  function duplicate(){
387
  global $wpdb, $EZSQL_ERROR;
388
  //First, duplicate.
389
- if( $this->can_manage(true) ){
390
  $event_table_name = $wpdb->prefix . EM_EVENTS_TABLE;
391
- $eventArray = $this->to_array(true);
392
  unset($eventArray['event_id']);
393
  $EM_Event = new EM_Event( $eventArray );
394
  if( $EM_Event->save() ){
395
- $EM_Event->feedback_message = __("You are now viewing the duplicated event", 'dbem');
396
  return apply_filters('em_event_duplicate', $EM_Event, $this);
397
  }
 
 
398
  }
399
  //TODO add error notifications for duplication failures.
400
  return apply_filters('em_event_duplicate', false, $this);;
@@ -427,7 +537,7 @@ class EM_Event extends EM_Object{
427
  }else{
428
  $this->errors[] = __('Dates must have correct formatting. Please use the date picker provided.','dbem');
429
  }
430
- if( !$this->location->validate() ){
431
  $this->errors = array_merge($this->errors, $this->location->errors);
432
  }
433
  //TODO validate recurrence during event validate
@@ -448,13 +558,28 @@ class EM_Event extends EM_Object{
448
  }else{
449
  $this->category = new EM_Category($this->category_id);
450
  }
451
- return $this->event;
452
  global $wpdb;
453
  $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."'";
454
  $category = $wpdb->get_row($sql, ARRAY_A);
455
  return apply_filters('em_event_get_category', $category, $this);
456
  }
457
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  /**
459
  * Shortcut function for $this->get_bookings()->delete(), because using the EM_Bookings requires loading previous bookings, which isn't neceesary.
460
  */
@@ -462,7 +587,7 @@ class EM_Event extends EM_Object{
462
  global $wpdb;
463
  do_action('em_event_delete_bookings_pre', $this);
464
  $result = false;
465
- if( $this->can_manage(true) ){
466
  $result = $wpdb->query( $wpdb->prepare("DELETE FROM ".$wpdb->prefix.EM_BOOKINGS_TABLE." WHERE event_id=%d", $this->id) );
467
  }
468
  return apply_filters('em_event_delete_bookings', $result, $this);
@@ -482,6 +607,15 @@ class EM_Event extends EM_Object{
482
  return apply_filters('em_event_get_bookings', $this->bookings, $this);
483
  }
484
 
 
 
 
 
 
 
 
 
 
485
  /**
486
  * Will output a single event format of this event.
487
  * Equivalent of calling EM_Event::output( get_option ( 'dbem_single_event_format' ) )
@@ -558,7 +692,7 @@ class EM_Event extends EM_Object{
558
  }
559
  break;
560
  case '#_EDITEVENTLINK':
561
- if( $this->can_manage() ){
562
  //TODO user should have permission to edit the event
563
  $replace = "<a href='".get_bloginfo('wpurl')."/wp-admin/admin.php?page=events-manager-event&amp;event_id={$this->id}'>".__('Edit').' '.__('Event', 'dbem')."</a>";
564
  }
@@ -569,16 +703,16 @@ class EM_Event extends EM_Object{
569
  case '#_BOOKINGFORM':
570
  if ($this->rsvp && get_option('dbem_rsvp_enabled')){
571
  if($result == '#_BOOKINGFORM'){
572
- $replace = em_add_booking_form().em_delete_booking_form();
573
  }else{
574
- $replace = ($result == '#_ADDBOOKINGFORM') ? em_add_booking_form():em_delete_booking_form();
575
  }
576
  }
577
  break;
578
  case '#_AVAILABLESEATS': //Depreciated
579
  case '#_AVAILABLESPACES':
580
  if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
581
- $replace = $this->get_bookings()->get_available_seats();
582
  } else {
583
  $replace = "0";
584
  }
@@ -586,14 +720,21 @@ class EM_Event extends EM_Object{
586
  case '#_BOOKEDSEATS': //Depreciated
587
  case '#_BOOKEDSPACES':
588
  if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
589
- $replace = $this->get_bookings()->get_booked_seats();
 
 
 
 
 
 
 
590
  } else {
591
  $replace = "0";
592
  }
593
  break;
594
  case '#_SEATS': //Depreciated
595
  case '#_SPACES':
596
- $replace = $this->seats;
597
  break;
598
  //Contact Person
599
  case '#_CONTACTNAME':
@@ -625,6 +766,23 @@ class EM_Event extends EM_Object{
625
  }
626
  }
627
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  default:
629
  $replace = $result;
630
  break;
@@ -666,7 +824,7 @@ class EM_Event extends EM_Object{
666
  $event_string = str_replace($result,$replace,$event_string );
667
  }
668
  //This is for the custom attributes
669
- preg_match_all('/#_ATT\{.+?\}(\{(.+)\})?/', $format, $results);
670
  foreach($results[0] as $resultKey => $result) {
671
  //Strip string of placeholder and just leave the reference
672
  $attRef = substr( substr($result, 0, strpos($result, '}')), 6 );
@@ -696,7 +854,7 @@ class EM_Event extends EM_Object{
696
  * @return boolean
697
  */
698
  function save_events() {
699
- if( $this->is_recurring() && $this->can_manage() ){
700
  do_action('em_event_save_events_pre', $this); //actions/filters only run if event is recurring
701
  global $wpdb;
702
  $event_saves = array();
@@ -717,8 +875,7 @@ class EM_Event extends EM_Object{
717
  $event['event_start_date'] = date("Y-m-d", $day);
718
  $event['event_end_date'] = $event['event_start_date'];
719
  $event_saves[] = $wpdb->insert($wpdb->prefix.EM_EVENTS_TABLE, $event, $this->get_types($event));
720
- //TODO should be EM_DEBUG, and do we really need it?
721
- if( DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
722
  }
723
  return apply_filters('em_event_save_events', !in_array(false, $event_saves), $this);
724
  }
@@ -735,7 +892,7 @@ class EM_Event extends EM_Object{
735
  do_action('em_event_delete_events_pre', $this);
736
  //So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer
737
  $result = false;
738
- if( $this->can_manage(true) ){
739
  $EM_Events = EM_Events::get( array('recurrence_id'=>$this->id) );
740
  $event_ids = array();
741
  foreach($EM_Events as $EM_Event){
@@ -774,14 +931,10 @@ class EM_Event extends EM_Object{
774
  }
775
 
776
  /**
777
- * Can the user manage this event?
778
  */
779
- function can_manage( $error_msg = false ){
780
- $can_manage = ( get_option('dbem_permissions_events') || $this->author == get_current_user_id() || empty($this->id) || em_verify_admin() );
781
- if($error_msg && !$can_manage){
782
- $this->errors[] = __('You do not have permission to manage this event.','dbem');
783
- }
784
- return apply_filters('em_event_can_manage', $can_manage, $this);
785
  }
786
 
787
  /**
@@ -890,15 +1043,25 @@ class EM_Event extends EM_Object{
890
  }
891
  }
892
 
 
 
 
 
 
 
 
 
 
 
 
 
893
  /**
894
  * Returns a string representation of this recurrence. Will return false if not a recurrence
895
  * @return string
896
  */
897
  function get_recurrence_description() {
898
- //FIXME Recurrence description not working for recurrence
899
- global $EM_Recurrences;
900
  if( $this->is_individual() ) return false;
901
- $recurrence = $EM_Recurrences[$this->recurrence_id]->to_array();
902
  $weekdays_name = array(__('Sunday'),__('Monday'),__('Tuesday'),__('Wednesday'),__('Thursday'),__('Friday'),__('Saturday'));
903
  $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'));
904
  $output = sprintf (__('From %1$s to %2$s', 'dbem'), $recurrence['event_start_date'], $recurrence['event_end_date']).", ";
@@ -907,8 +1070,7 @@ class EM_Event extends EM_Object{
907
  if ($recurrence['recurrence_interval'] > 1 ) {
908
  $freq_desc = sprintf (__("every %s days", 'dbem'), $recurrence['recurrence_interval']);
909
  }
910
- }
911
- if ($recurrence['recurrence_freq'] == 'weekly') {
912
  $weekday_array = explode(",", $recurrence['recurrence_byday']);
913
  $natural_days = array();
914
  foreach($weekday_array as $day){
@@ -920,8 +1082,7 @@ class EM_Event extends EM_Object{
920
  $freq_desc = ", ".sprintf (__("every %s weeks", 'dbem'), $recurrence['recurrence_interval']);
921
  }
922
 
923
- }
924
- if ($recurrence['recurrence_freq'] == 'monthly') {
925
  $weekday_array = explode(",", $recurrence['recurrence_byday']);
926
  $natural_days = array();
927
  foreach($weekday_array as $day){
@@ -931,7 +1092,8 @@ class EM_Event extends EM_Object{
931
  if ($recurrence['recurrence_interval'] > 1 ) {
932
  $freq_desc .= ", ".sprintf (__("every %s months",'dbem'), $recurrence['recurrence_interval']);
933
  }
934
-
 
935
  }
936
  $output .= $freq_desc;
937
  return $output;
@@ -943,24 +1105,18 @@ class EM_Event extends EM_Object{
943
 
944
  /**
945
  * Returns this object in the form of an array, useful for saving directly into the wp_dbem_events table.
946
- * @param boolean $location
947
  * @param boolean $for_database
948
  * @return array
949
  */
950
- function to_array($location = false, $for_database = false){
951
  $event = array();
952
  //Core Event Data
953
  foreach ( $this->fields as $key => $val ) {
954
  //TODO does it matter if it's for db or not... shouldn't it just not include blanks?
955
- if( !$for_database || $for_database && $this->$val['name'] ){
956
  $event[$key] = $this->$val['name'];
957
  }
958
  }
959
- //Location Data
960
- if($location && is_object($this->location)){
961
- $location = $this->location->to_array();
962
- $event = array_merge($event, $location);
963
- }
964
  return $event;
965
  }
966
  }
18
  */
19
  var $fields = array(
20
  'event_id' => array( 'name'=>'id', 'type'=>'%d' ),
21
+ 'event_slug' => array( 'name'=>'slug', 'type'=>'%s' ),
22
+ 'event_owner' => array( 'name'=>'owner', 'type'=>'%d' ),
23
  'event_name' => array( 'name'=>'name', 'type'=>'%s' ),
24
  'event_start_time' => array( 'name'=>'start_time', 'type'=>'%s' ),
25
  'event_end_time' => array( 'name'=>'end_time', 'type'=>'%s' ),
27
  'event_end_date' => array( 'name'=>'end_date', 'type'=>'%s' ),
28
  'event_notes' => array( 'name'=>'notes', 'type'=>'%s' ),
29
  'event_rsvp' => array( 'name'=>'rsvp', 'type'=>'%d' ),
30
+ //'event_spaces' => array( 'name'=>'spaces', 'type'=>'%d' ),
 
31
  'location_id' => array( 'name'=>'location_id', 'type'=>'%d' ),
32
  'recurrence_id' => array( 'name'=>'recurrence_id', 'type'=>'%d' ),
33
  'event_category_id' => array( 'name'=>'category_id', 'type'=>'%d' ),
36
  'recurrence_interval' => array( 'name'=>'interval', 'type'=>'%d' ), //every x day(s)/week(s)/month(s)
37
  'recurrence_freq' => array( 'name'=>'freq', 'type'=>'%s' ), //daily,weekly,monthly?
38
  'recurrence_byday' => array( 'name'=>'byday', 'type'=>'%s' ), //if weekly or monthly, what days of the week?
39
+ 'recurrence_byweekno' => array( 'name'=>'byweekno', 'type'=>'%d' ), //if monthly which week (-1 is last)
40
+ 'event_status' => array( 'name'=>'status', 'type'=>'%d' ) //if monthly which week (-1 is last)
41
  );
42
  /* Field Names - see above for matching DB field names and other field meta data */
43
  var $id;
44
+ var $slug;
45
+ var $owner;
46
  var $name;
47
  var $start_time;
48
  var $end_time;
50
  var $end_date;
51
  var $notes;
52
  var $rsvp;
53
+ //var $spaces;
 
54
  var $location_id;
55
  var $recurrence_id;
56
  var $category_id;
60
  var $freq;
61
  var $byday;
62
  var $byweekno;
63
+ var $status;
64
 
65
  /**
66
  * Timestamp of start date/time
111
  * @var string
112
  */
113
  var $feedback_message;
114
+ /**
115
+ * Any warnings about an event (e.g. bad data, recurring/recurrence, etc.)
116
+ * @var string
117
+ */
118
+ var $warnings;
119
  /**
120
  * Array of dbem_event field names required to create an event
121
  * @var array
125
  /**
126
  * Initialize an event. You can provide event data in an associative array (using database table field names), an id number, or false (default) to create empty event.
127
  * @param mixed $event_data
 
128
  * @return null
129
  */
130
+ function EM_Event($event_data = false) {
131
  global $wpdb, $EM_Recurrences;
132
  //TODO Change the way we deal with time, maybe revert to timestamps for manipulation, and worry about output in html and db writes?
133
  if( $event_data !== false ){
135
  if( is_array($event_data) ){
136
  //Accepts a raw array that'll just be imported directly into the object with no DB lookups (same for event and recurrence)
137
  $event = $event_data;
138
+ if($event['location_name']){
139
+ $this->location = new EM_Location( $event );
140
+ }
141
  $this->category = new EM_Category( $event );
142
+ }elseif( !empty($event_data) ) {
143
+ if( is_numeric($event_data) && $event_data > 0 ){
144
+ $cond = "event_id = $event_data";
145
+ }else{
146
+ $cond = "event_slug = '".$wpdb->escape($event_data)."'";
147
+ }
148
  //Retreiving from the database
149
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
150
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
153
  SELECT * FROM $events_table
154
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
155
  LEFT JOIN $categories_table ON {$categories_table}.category_id={$events_table}.event_category_id
156
+ WHERE $cond
157
  "; //We get event and location data here to avoid extra queries
158
  $event = $wpdb->get_row ( $sql, ARRAY_A );
159
  //Sort Location
167
  }
168
  $event['event_attributes'] = (!is_array($event['event_attributes'])) ? array() : $event['event_attributes'] ;
169
  }
170
+ $event['recurrence_byday'] = ( empty($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
171
  $this->to_object($event, true);
172
 
173
  //Start/End times should be available as timestamp
174
  $this->start = strtotime($this->start_date." ".$this->start_time);
175
  $this->end = strtotime($this->end_date." ".$this->end_time);
176
+ $this->modified = ( !empty($event['event_date_modified']) ) ? strtotime($event['event_date_modified']):time();
177
+ $this->created = ( !empty($event['event_date_created']) ) ? strtotime($event['event_date_created']):time();
178
 
179
+ //Add Owner as Contact Person
180
+ if($this->owner && $this->owner > 0){
181
+ $this->contact = get_userdata($this->owner);
 
 
182
  }
183
  if( !is_object($this->contact) ){
184
+ $this->owner = get_option('dbem_default_contact_person');
185
+ $this->contact = get_userdata($this->owner);
186
  }
187
  if( is_object($this->contact) ){
188
  $this->contact->phone = get_metadata('user', $this->contact->ID, 'dbem_phone', true);
189
  }
190
  //Now, if this is a recurrence, get the recurring for caching to the $EM_Recurrences
191
+ if( $this->is_recurrence() && is_array($EM_Recurrences) && !array_key_exists($this->recurrence_id, $EM_Recurrences) ){
192
  $EM_Recurrences[$this->recurrence_id] = new EM_Event($this->recurrence_id);
193
  }
194
  }else{
195
  $this->location = new EM_Location(); //blank location
196
  $this->category = new EM_Category(); //blank category
197
  }
198
+ $this->get_location();
199
+ //Do it here so things appear in the po file.
200
+ $this->status_array = array(
201
+ 0 => __('Pending','dbem'),
202
+ 1 => __('Approved','dbem')
203
+ );
204
+
205
+ //Set up some warning meta
206
+ if ( $this->is_recurring() ) {
207
+ $this->warnings['recurring'] = __( 'WARNING: This is a recurring event.', 'dbem' )."<br />". __( 'Modifications to this event will cause all recurrences of this event to be deleted and recreated and previous bookings will be deleted! You can edit individual recurrences and disassociate them with this recurring event.', 'dbem' );
208
+ } elseif ( $this->is_recurrence() ) {
209
+ $this->warnings['recurrence'] = __('WARNING: This is a recurrence in a set of recurring events.', 'dbem')."<br />". __('If you update this event data and save, it will become an independent event, and will not be deleted or modified automatically if you reschedule the original recurring event details.', 'dbem' );
210
+ }
211
+ do_action('em_event', $this, $event_data);
212
  }
213
 
214
  /**
222
  $this->start_date = ( !empty($_POST['event_start_date']) ) ? $_POST['event_start_date'] : '';
223
  $this->end_date = ( !empty($_POST['event_end_date']) ) ? $_POST['event_end_date'] : $this->start_date;
224
  $this->rsvp = ( !empty($_POST['event_rsvp']) ) ? 1:0;
225
+ //$this->spaces = ( !empty($_POST['event_spaces']) && is_numeric($_POST['event_spaces']) ) ? $_POST['event_spaces']:0;
226
  $this->notes = ( !empty($_POST['content']) ) ? stripslashes($_POST['content']) : ''; //WP TinyMCE field
227
  //Sort out time
228
  //TODO make time handling less painful
250
  //Start/End times should be available as timestamp
251
  $this->start = strtotime($this->start_date." ".$this->start_time);
252
  $this->end = strtotime($this->end_date." ".$this->end_time);
253
+
254
+ //owner
255
+ if( !empty($_REQUEST['event_owner']) && is_numeric($_REQUEST['event_owner']) ){
256
+ $this->owner = current_user_can('edit_others_events') ? $_REQUEST['event_owner']:get_current_user_id();
257
  }
258
+
259
  //category
260
  if( !empty($_POST['event_category_id']) && is_numeric($_POST['event_category_id']) ){
261
  $this->category_id = $_POST['event_category_id'];
262
  }
263
  //Attributes
264
  $event_attributes = array();
265
+ $post = $_POST;
266
+ $event_available_attributes = em_get_attributes();
267
+ if( !empty($_POST['em_attributes']) && is_array($_POST['em_attributes']) ){
268
+ foreach($_POST['em_attributes'] as $att_key => $att_value ){
269
+ if( (in_array($att_key, $event_available_attributes) || array_key_exists($att_key, $this->attributes) ) && trim($att_value) != '' ){
270
+ $event_attributes[$att_key] = $att_value;
271
+ }
272
+ }
273
+ }
274
  $this->attributes = $event_attributes;
275
  //Recurrence data
276
  $this->recurrence_id = ( !empty($_POST['recurrence_id']) && is_numeric($_POST['recurrence_id']) ) ? $_POST['recurrence_id'] : 0 ;
287
  }
288
 
289
  //Add location information, or just link to previous location, this is a requirement...
290
+ if( !empty($_POST['location_id']) && is_numeric($_POST['location_id'])) {
291
+ $this->location_id = $_POST['location_id'];
292
+ $this->location = new EM_Location($_POST['location_id']);
293
+
294
  } else {
295
+ $this->location = new EM_Location($_POST);
296
  $this->location->load_similar($_POST);
297
  }
298
+ if( !$this->get_bookings()->get_tickets()->get_post() ){
299
+ $EM_Tickets = $this->get_bookings()->get_tickets();
300
+ array_merge($this->errors, $this->get_bookings()->get_tickets()->errors);
301
+ }
302
  return apply_filters('em_event_get_post', $this->validate(), $this);
303
  }
304
 
310
  function save(){
311
  //FIXME Event doesn't save title when inserting first time
312
  global $wpdb, $current_user;
313
+ if( !$this->can_manage('edit_events', 'edit_others_events')){
314
  return apply_filters('em_event_save', false, $this);
315
  }
316
  do_action('em_event_save_pre', $this);
317
  get_currentuserinfo();
318
  $events_table = $wpdb->prefix.EM_EVENTS_TABLE;
319
+ $request = $_REQUEST;
320
  //First let's save the location, no location no event!
321
+ if ( !$this->get_location()->id && !$this->location->save() ){ //shouldn't try to save if location exists
322
  $this->errors[] = __ ( 'There was a problem saving the location so event was not saved.', 'dbem' );
323
  return apply_filters('em_event_save', false, $this);
324
  }
325
  $this->location_id = $this->location->id;
326
+ //owner person can be anyone the admin wants, but the creator if not.
327
+ if( current_user_can('edit_others_events') ){
328
+ $this->owner = ( $this->owner > 0 ) ? $this->owner:0;
329
  }else{
330
  //force
331
+ $this->owner = get_current_user_id();
332
  }
333
+ //Set status of this event, depending on user type
334
+ if( current_user_can('publish_events') ){
335
+ //top level can edit and publish any events
336
+ $this->status = 1;
337
+ }else{
338
+ //any updates or additions put the event into pending status
339
+ $this->status = 0;
340
+ }
341
+ $this->slug = $this->sanitize_title();
342
+
343
  //Now save the event
344
  if ( !$this->id ) {
345
  // Insert New Event
346
+ $this->owner = $current_user->ID; //Record creator of event
347
+ $event = $this->to_array(true);
348
  $event['event_attributes'] = serialize($this->attributes);
349
  $event['recurrence_id'] = ( is_numeric($this->recurrence_id) ) ? $this->recurrence_id : 0;
350
  $event = apply_filters('em_event_save_pre',$event,$this);
351
  $result = $wpdb->insert ( $events_table, $event, $this->get_types($event) );
352
  if($result !== false){
353
  $this->id = $wpdb->insert_id;
354
+ $this->is_new = true;
355
+ //Add Tickets
356
+ if( !$this->get_bookings()->get_tickets()->save() ){
357
+ $this->errors[] = __( 'Something went wrong with creating tickets.', 'dbem' );
358
+ return apply_filters('em_event_save', false, $this);
359
+ }
360
  //Deal with recurrences
361
  if ( $this->is_recurring() ) {
362
  //Recurrence master event saved, now Save Events & check errors
379
  } else {
380
  // Update Event
381
  //TODO event privacy protection, only authors and authorized users can edit events
382
+ //$this->owner = $current_user->ID; //Record creator of event
383
  //FIXME Saving recurrence and disabling recurrence doesn't work
384
  $this->recurrence_id = 0; // If it's saved here, it becomes individual
385
  $event = $this->to_array();
387
  $event = apply_filters('em_event_save_pre',$event,$this);
388
  $result = $wpdb->update ( $events_table, $event, array('event_id' => $this->id), $this->get_types($event) );
389
  if($result !== false){ //Can't just do $result since if you don't make an actual record details change, it'll return 0 for no changes made
390
+ //Add Tickets
391
+ if( !$this->get_bookings()->get_tickets()->save() ){
392
+ $this->errors[] = __( 'Something went wrong with creating tickets.', 'dbem' );
393
+ return apply_filters('em_event_save', false, $this);
394
+ }
395
  //Deal with recurrences
396
  if ( $this->is_recurring() ) {
397
  if( !$this->save_events() ){
415
  }
416
  }
417
 
418
+ /**
419
+ * Takes the title and gives either a unique slug or returns the currently used slug if this record already has it.
420
+ * @param unknown_type $title
421
+ */
422
+ function sanitize_title($iteration = 1){
423
+ global $wpdb;
424
+ //Generate the slug. If this is a new event, create the slug automatically, if not, verify it is still unique and if not rewrite
425
+ if( empty($this->slug) ){
426
+ $this->slug = sanitize_title($this->name);
427
+ }
428
+ $slug = $this->slug;
429
+ $slug_matches = $wpdb->get_results('SELECT event_id FROM '.$wpdb->prefix.EM_EVENTS_TABLE." WHERE event_slug='{$slug}'", ARRAY_A);
430
+ if( count($slug_matches) > 0 ){ //we will check that the slug is unique
431
+ if( $slug_matches[0]['event_id'] != $this->id || count($slug_matches) > 1 ){
432
+ //we have a conflict, so try another alternative
433
+ $this->slug = preg_replace('/\-[0-9]+$/', '', $slug).'-'.($iteration+1);
434
+ $this->sanitize_title($iteration+1);
435
+ }
436
+ }
437
+ return apply_filters('em_event_sanitize_title', $this->slug, $this);
438
+ }
439
+
440
  /**
441
  * Delete whole event, including recurrence and recurring data
442
  * @param $recurrence_id
446
  global $wpdb;
447
  do_action('em_event_delete_pre', $this);
448
  $result = false;
449
+ if( $this->can_manage( 'delete_events','delete_others_events' ) ){
450
  if( $this->is_recurring() ){
451
  //Delete the recurrences then this recurrence event
452
  $this->delete_events();
456
  $result = $this->get_bookings()->delete();
457
  }
458
  }
459
+ return apply_filters('em_event_delete', $result !== false, $this);
460
+ }
461
+
462
+ /**
463
+ * approve a booking.
464
+ * @return bool
465
+ */
466
+ function approve(){
467
+ return $this->set_status(1);
468
+ }
469
+
470
+ /**
471
+ * Change the status of the event. This will save to the Database too.
472
+ * @param unknown_type $status
473
+ * @return string
474
+ */
475
+ function set_status($status){
476
+ $action_string = strtolower($this->status_array[$status]);
477
+ $this->previous_status = $this->status;
478
+ $this->status = $status;
479
+ $result = $this->save();
480
+ if($result){
481
+ $this->feedback_message = sprintf(__('Event %s.','dbem'), $action_string);
482
+ return true;
483
+ }else{
484
+ //errors should be logged by save()
485
+ $this->feedback_message = sprintf(__('Booking could not be %s.','dbem'), $action_string);
486
+ return false;
487
+ }
488
  }
489
 
490
  /**
494
  function duplicate(){
495
  global $wpdb, $EZSQL_ERROR;
496
  //First, duplicate.
497
+ if( $this->can_manage('edit_events','edit_others_events') ){
498
  $event_table_name = $wpdb->prefix . EM_EVENTS_TABLE;
499
+ $eventArray = $this->to_array();
500
  unset($eventArray['event_id']);
501
  $EM_Event = new EM_Event( $eventArray );
502
  if( $EM_Event->save() ){
503
+ $EM_Event->feedback_message = sprintf(__("%s successfully duplicated.", 'dbem'), __('Event','dbem'));
504
  return apply_filters('em_event_duplicate', $EM_Event, $this);
505
  }
506
+ }else{
507
+ $EM_Event->add_error( sprintf(__('You are not allowed to manage this %s.'), __('event','dbem')) );
508
  }
509
  //TODO add error notifications for duplication failures.
510
  return apply_filters('em_event_duplicate', false, $this);;
537
  }else{
538
  $this->errors[] = __('Dates must have correct formatting. Please use the date picker provided.','dbem');
539
  }
540
+ if( $this->get_location()->id == '' && !$this->get_location()->validate() ){
541
  $this->errors = array_merge($this->errors, $this->location->errors);
542
  }
543
  //TODO validate recurrence during event validate
558
  }else{
559
  $this->category = new EM_Category($this->category_id);
560
  }
 
561
  global $wpdb;
562
  $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."'";
563
  $category = $wpdb->get_row($sql, ARRAY_A);
564
  return apply_filters('em_event_get_category', $category, $this);
565
  }
566
 
567
+ /**
568
+ * Returns the location object this event belongs to.
569
+ * @return EM_Location
570
+ */
571
+ function get_location() {
572
+ global $EM_location;
573
+ if( is_object($this->location) && get_class($this->location)=='EM_location' && ($this->location_id == $this->location->id || empty($this->id)) ){
574
+ return $this->location;
575
+ }elseif( is_object($EM_location) && $EM_location->id == $this->location_id ){
576
+ $this->location = $EM_location;
577
+ }else{
578
+ $this->location = new EM_location($this->location_id);
579
+ }
580
+ return apply_filters('em_event_get_location', $this->location, $this);
581
+ }
582
+
583
  /**
584
  * Shortcut function for $this->get_bookings()->delete(), because using the EM_Bookings requires loading previous bookings, which isn't neceesary.
585
  */
587
  global $wpdb;
588
  do_action('em_event_delete_bookings_pre', $this);
589
  $result = false;
590
+ if( $this->can_manage('manage_bookings','manage_others_bookings') ){
591
  $result = $wpdb->query( $wpdb->prepare("DELETE FROM ".$wpdb->prefix.EM_BOOKINGS_TABLE." WHERE event_id=%d", $this->id) );
592
  }
593
  return apply_filters('em_event_delete_bookings', $result, $this);
607
  return apply_filters('em_event_get_bookings', $this->bookings, $this);
608
  }
609
 
610
+ /**
611
+ * Gets number of spaces in this event, dependent on ticket spaces or hard limit, whichever is smaller.
612
+ * @param boolean $force_refresh
613
+ * @return int
614
+ */
615
+ function get_spaces($force_refresh=false){
616
+ return $this->get_bookings()->get_spaces($force_refresh);
617
+ }
618
+
619
  /**
620
  * Will output a single event format of this event.
621
  * Equivalent of calling EM_Event::output( get_option ( 'dbem_single_event_format' ) )
692
  }
693
  break;
694
  case '#_EDITEVENTLINK':
695
+ if( $this->can_manage('edit_event','edit_others_events') ){
696
  //TODO user should have permission to edit the event
697
  $replace = "<a href='".get_bloginfo('wpurl')."/wp-admin/admin.php?page=events-manager-event&amp;event_id={$this->id}'>".__('Edit').' '.__('Event', 'dbem')."</a>";
698
  }
703
  case '#_BOOKINGFORM':
704
  if ($this->rsvp && get_option('dbem_rsvp_enabled')){
705
  if($result == '#_BOOKINGFORM'){
706
+ $replace = EM_Bookings_Form::create().EM_Bookings_Form::cancel();
707
  }else{
708
+ $replace = ($result == '#_ADDBOOKINGFORM') ? EM_Bookings_Form::create():EM_Bookings_Form::cancel();
709
  }
710
  }
711
  break;
712
  case '#_AVAILABLESEATS': //Depreciated
713
  case '#_AVAILABLESPACES':
714
  if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
715
+ $replace = $this->get_bookings()->get_available_spaces();
716
  } else {
717
  $replace = "0";
718
  }
720
  case '#_BOOKEDSEATS': //Depreciated
721
  case '#_BOOKEDSPACES':
722
  if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
723
+ $replace = $this->get_bookings()->get_booked_spaces();
724
+ } else {
725
+ $replace = "0";
726
+ }
727
+ break;
728
+ case '#_PENDINGSPACES':
729
+ if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
730
+ $replace = $this->get_bookings()->get_pending_spaces();
731
  } else {
732
  $replace = "0";
733
  }
734
  break;
735
  case '#_SEATS': //Depreciated
736
  case '#_SPACES':
737
+ $replace = $this->get_spaces();
738
  break;
739
  //Contact Person
740
  case '#_CONTACTNAME':
766
  }
767
  }
768
  break;
769
+ case '#_CONTACTPROFILELINK':
770
+ case '#_CONTACTPROFILEURL':
771
+ if( function_exists('bp_core_get_user_domain') ){
772
+ $replace = bp_core_get_user_domain($this->contact->ID);
773
+ if( $result == '#_CONTACTPROFILELINK' ){
774
+ $replace = '<a href="'.$replace.'">'.__('Profile').'</a>';
775
+ }
776
+ }
777
+ break;
778
+ case '#_ATTENDEES':
779
+ $template = em_locate_template('placeholders/attendees.php');
780
+ if( $template ){
781
+ ob_start();
782
+ include($template);
783
+ $replace = ob_get_clean();
784
+ }
785
+ break;
786
  default:
787
  $replace = $result;
788
  break;
824
  $event_string = str_replace($result,$replace,$event_string );
825
  }
826
  //This is for the custom attributes
827
+ preg_match_all('/#_ATT\{.+?\}(\{.+?\})?/', $format, $results);
828
  foreach($results[0] as $resultKey => $result) {
829
  //Strip string of placeholder and just leave the reference
830
  $attRef = substr( substr($result, 0, strpos($result, '}')), 6 );
854
  * @return boolean
855
  */
856
  function save_events() {
857
+ if( $this->is_recurring() && $this->can_manage('edit_events','edit_others_events') ){
858
  do_action('em_event_save_events_pre', $this); //actions/filters only run if event is recurring
859
  global $wpdb;
860
  $event_saves = array();
875
  $event['event_start_date'] = date("Y-m-d", $day);
876
  $event['event_end_date'] = $event['event_start_date'];
877
  $event_saves[] = $wpdb->insert($wpdb->prefix.EM_EVENTS_TABLE, $event, $this->get_types($event));
878
+ if( EM_DEBUG ){ echo "Entering recurrence " . date("D d M Y", $day)."<br/>"; }
 
879
  }
880
  return apply_filters('em_event_save_events', !in_array(false, $event_saves), $this);
881
  }
892
  do_action('em_event_delete_events_pre', $this);
893
  //So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer
894
  $result = false;
895
+ if( $this->can_manage('delete_events', 'delete_others_events') ){
896
  $EM_Events = EM_Events::get( array('recurrence_id'=>$this->id) );
897
  $event_ids = array();
898
  foreach($EM_Events as $EM_Event){
931
  }
932
 
933
  /**
934
+ * Can the user manage this?
935
  */
936
+ function can_manage( $owner_capability = false, $admin_capability = false ){
937
+ return apply_filters('em_event_can_manage', parent::can_manage($owner_capability, $admin_capability), $this);
 
 
 
 
938
  }
939
 
940
  /**
1043
  }
1044
  }
1045
 
1046
+ function get_recurrence(){
1047
+ global $EM_Recurrences;
1048
+ if( is_array($EM_Recurrences) && array_key_exists($this->recurrence_id, $EM_Recurrences) && is_object($EM_Recurrences[$this->recurrence_id]) && get_class($EM_Recurrences[$this->recurrence_id]) == 'EM_Event' ){
1049
+ $recurrence = $EM_Recurrences[$this->recurrence_id];
1050
+ }else{
1051
+ //get this recurrence
1052
+ $recurrence = new EM_Event($this->recurrence_id);
1053
+ $EM_Recurrences[$this->recurrence_id] = $recurrence;
1054
+ }
1055
+ return $recurrence;
1056
+ }
1057
+
1058
  /**
1059
  * Returns a string representation of this recurrence. Will return false if not a recurrence
1060
  * @return string
1061
  */
1062
  function get_recurrence_description() {
 
 
1063
  if( $this->is_individual() ) return false;
1064
+ $recurrence = $this->get_recurrence()->to_array();
1065
  $weekdays_name = array(__('Sunday'),__('Monday'),__('Tuesday'),__('Wednesday'),__('Thursday'),__('Friday'),__('Saturday'));
1066
  $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'));
1067
  $output = sprintf (__('From %1$s to %2$s', 'dbem'), $recurrence['event_start_date'], $recurrence['event_end_date']).", ";
1070
  if ($recurrence['recurrence_interval'] > 1 ) {
1071
  $freq_desc = sprintf (__("every %s days", 'dbem'), $recurrence['recurrence_interval']);
1072
  }
1073
+ }elseif ($recurrence['recurrence_freq'] == 'weekly') {
 
1074
  $weekday_array = explode(",", $recurrence['recurrence_byday']);
1075
  $natural_days = array();
1076
  foreach($weekday_array as $day){
1082
  $freq_desc = ", ".sprintf (__("every %s weeks", 'dbem'), $recurrence['recurrence_interval']);
1083
  }
1084
 
1085
+ }elseif ($recurrence['recurrence_freq'] == 'monthly') {
 
1086
  $weekday_array = explode(",", $recurrence['recurrence_byday']);
1087
  $natural_days = array();
1088
  foreach($weekday_array as $day){
1092
  if ($recurrence['recurrence_interval'] > 1 ) {
1093
  $freq_desc .= ", ".sprintf (__("every %s months",'dbem'), $recurrence['recurrence_interval']);
1094
  }
1095
+ }else{
1096
+ $freq_desc = "[ERROR: corrupted database record]";
1097
  }
1098
  $output .= $freq_desc;
1099
  return $output;
1105
 
1106
  /**
1107
  * Returns this object in the form of an array, useful for saving directly into the wp_dbem_events table.
 
1108
  * @param boolean $for_database
1109
  * @return array
1110
  */
1111
+ function to_array($for_database = false){
1112
  $event = array();
1113
  //Core Event Data
1114
  foreach ( $this->fields as $key => $val ) {
1115
  //TODO does it matter if it's for db or not... shouldn't it just not include blanks?
1116
+ if( !$for_database || $for_database && $this->$val['name'] != '' ){
1117
  $event[$key] = $this->$val['name'];
1118
  }
1119
  }
 
 
 
 
 
1120
  return $event;
1121
  }
1122
  }
classes/em-events.php CHANGED
@@ -1,10 +1,15 @@
1
  <?php
 
2
  /**
3
  * Use this class to query and manipulate sets of events. If dealing with more than one event, you probably want to use this class in some way.
4
  *
5
  */
6
- class EM_Events extends EM_Object {
7
-
 
 
 
 
8
  /**
9
  * Returns an array of EM_Events that match the given specs in the argument, or returns a list of future evetnts in future
10
  * (see EM_Events::get_default_search() ) for explanation of possible search array values. You can also supply a numeric array
@@ -13,7 +18,7 @@ class EM_Events extends EM_Object {
13
  * @param array $args
14
  * @return EM_Event array()
15
  */
16
- function get( $args = array() ) {
17
  global $wpdb;
18
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
19
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
@@ -54,15 +59,19 @@ class EM_Events extends EM_Object {
54
  $orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
55
 
56
  //Create the SQL statement and execute
 
57
  $sql = "
58
- SELECT * FROM $events_table
59
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
60
  LEFT JOIN $categories_table ON {$categories_table}.category_id={$events_table}.event_category_id
61
  $where
62
  $orderby_sql
63
  $limit $offset
64
  ";
65
-
 
 
 
66
  $results = $wpdb->get_results( apply_filters('em_events_get_sql',$sql, $args), ARRAY_A);
67
 
68
  //If we want results directly in an array, why not have a shortcut here?
@@ -92,11 +101,16 @@ class EM_Events extends EM_Object {
92
  return apply_filters('em_events_count_date', $wpdb->get_var($sql));
93
  }
94
 
 
 
 
 
95
  /**
96
  * Will delete given an array of event_ids or EM_Event objects
97
  * @param unknown_type $id_array
98
  */
99
  function delete( $array ){
 
100
  global $wpdb;
101
  //Detect array type and generate SQL for event IDs
102
  $event_ids = array();
@@ -174,12 +188,13 @@ class EM_Events extends EM_Object {
174
  }
175
  //Add headers and footers to output
176
  if( $format == get_option ( 'dbem_event_list_item_format' ) ){
177
- $single_event_format_header = get_option ( 'dbem_event_list_item_format_header' );
178
- $single_event_format_header = ( $single_event_format_header != '' ) ? $single_event_format_header : "<ul class='dbem_events_list'>";
179
- $single_event_format_footer = get_option ( 'dbem_event_list_item_format_footer' );
180
- $single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
181
- $output = $single_event_format_header . $output . $single_event_format_footer;
182
  }
 
183
  //Pagination (if needed/requested)
184
  if( !empty($args['pagination']) && !empty($limit) && $events_count > $limit ){
185
  //Show the pagination links (unless there's less than $limit events)
@@ -198,13 +213,13 @@ class EM_Events extends EM_Object {
198
 
199
  function can_manage($event_ids){
200
  global $wpdb;
201
- if( em_verify_admin() ){
202
  return apply_filters('em_events_can_manage', true, $event_ids);
203
  }
204
  if( EM_Object::array_is_numeric($event_ids) ){
205
  $condition = implode(" OR event_id=", $event_ids);
206
  //Delete all the bookings
207
- $results = $wpdb->query("SELECT event_author FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." WHERE author_id != '". get_current_user_id() ."' event_id=$condition;");
208
  return apply_filters('em_events_can_manage', (count($results) > 0), $event_ids);
209
  }
210
  return apply_filters('em_events_can_manage', false, $event_ids);
@@ -214,7 +229,15 @@ class EM_Events extends EM_Object {
214
  * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
215
  */
216
  function build_sql_conditions( $args = array() ){
217
- return apply_filters( 'em_events_build_sql_conditions', parent::build_sql_conditions($args), $args );
 
 
 
 
 
 
 
 
218
  }
219
 
220
  /* Overrides EM_Object method to apply a filter to result
@@ -234,21 +257,45 @@ class EM_Events extends EM_Object {
234
  $defaults = array(
235
  'orderby' => get_option('dbem_events_default_orderby'),
236
  'order' => get_option('dbem_events_default_order'),
237
- 'rsvp' => false //if set to true, only events with bookings enabled are returned
 
 
 
238
  );
239
  if( is_admin() ){
240
  //figure out default owning permissions
241
- switch( get_option('dbem_permissions_events') ){
242
- case 0:
243
- $defaults['owner'] = get_current_user_id();
244
- break;
245
- case 1:
246
- $defaults['owner'] = false;
247
- break;
248
  }
249
- $defaults['owner'] = ( em_verify_admin() ) ? false:$defaults['owner'];
250
  }
251
  return apply_filters('em_events_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
252
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  }
254
  ?>
1
  <?php
2
+ //TODO EM_Events is currently static, better we make this non-static so we can loop sets of events, and standardize with other objects.
3
  /**
4
  * Use this class to query and manipulate sets of events. If dealing with more than one event, you probably want to use this class in some way.
5
  *
6
  */
7
+ class EM_Events extends EM_Object implements Iterator {
8
+ /**
9
+ * Array of EM_Event objects
10
+ * @var array EM_Event
11
+ */
12
+ var $events = array();
13
  /**
14
  * Returns an array of EM_Events that match the given specs in the argument, or returns a list of future evetnts in future
15
  * (see EM_Events::get_default_search() ) for explanation of possible search array values. You can also supply a numeric array
18
  * @param array $args
19
  * @return EM_Event array()
20
  */
21
+ function get( $args = array(), $count=false ) {
22
  global $wpdb;
23
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
24
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
59
  $orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
60
 
61
  //Create the SQL statement and execute
62
+ $selectors = ( $count ) ? 'COUNT(*)':'*';
63
  $sql = "
64
+ SELECT $selectors FROM $events_table
65
  LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
66
  LEFT JOIN $categories_table ON {$categories_table}.category_id={$events_table}.event_category_id
67
  $where
68
  $orderby_sql
69
  $limit $offset
70
  ";
71
+ //If we're only counting results, return the number of results
72
+ if( $count ){
73
+ return $wpdb->get_var($sql);
74
+ }
75
  $results = $wpdb->get_results( apply_filters('em_events_get_sql',$sql, $args), ARRAY_A);
76
 
77
  //If we want results directly in an array, why not have a shortcut here?
101
  return apply_filters('em_events_count_date', $wpdb->get_var($sql));
102
  }
103
 
104
+ function count( $args = array() ){
105
+ return apply_filters('em_events_count', self::get($args, true), $args);
106
+ }
107
+
108
  /**
109
  * Will delete given an array of event_ids or EM_Event objects
110
  * @param unknown_type $id_array
111
  */
112
  function delete( $array ){
113
+ //TODO add better cap checks in bulk actions
114
  global $wpdb;
115
  //Detect array type and generate SQL for event IDs
116
  $event_ids = array();
188
  }
189
  //Add headers and footers to output
190
  if( $format == get_option ( 'dbem_event_list_item_format' ) ){
191
+ $format_header = ( get_option( 'dbem_event_list_item_format_header') == '' ) ? '':get_option ( 'dbem_event_list_item_format_header' );
192
+ $format_footer = ( get_option ( 'dbem_event_list_item_format_footer' ) == '' ) ? '':get_option ( 'dbem_event_list_item_format_footer' );
193
+ }else{
194
+ $format_header = ( !empty($args['format_header']) ) ? $args['format_header']:'';
195
+ $format_footer = ( !empty($args['format_footer']) ) ? $args['format_footer']:'';
196
  }
197
+ $output = $format_header . $output . $format_footer;
198
  //Pagination (if needed/requested)
199
  if( !empty($args['pagination']) && !empty($limit) && $events_count > $limit ){
200
  //Show the pagination links (unless there's less than $limit events)
213
 
214
  function can_manage($event_ids){
215
  global $wpdb;
216
+ if( current_user_can('edit_others_events') ){
217
  return apply_filters('em_events_can_manage', true, $event_ids);
218
  }
219
  if( EM_Object::array_is_numeric($event_ids) ){
220
  $condition = implode(" OR event_id=", $event_ids);
221
  //Delete all the bookings
222
+ $results = $wpdb->query("SELECT event_owner FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." WHERE author_id != '". get_current_user_id() ."' event_id=$condition;");
223
  return apply_filters('em_events_can_manage', (count($results) > 0), $event_ids);
224
  }
225
  return apply_filters('em_events_can_manage', false, $event_ids);
229
  * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
230
  */
231
  function build_sql_conditions( $args = array() ){
232
+ $conditions = parent::build_sql_conditions($args);
233
+ if( !empty($args['search']) ){
234
+ $like_search = array('event_name','event_notes');
235
+ $conditions['search'] = "(".implode(" LIKE '%{$args['search']}%' OR ", $like_search). " LIKE '%{$args['search']}%')";
236
+ }
237
+ if( array_key_exists('status',$args) && is_numeric($args['status']) ){
238
+ $conditions['status'] = "(`event_status`={$args['status']})";
239
+ }
240
+ return apply_filters( 'em_events_build_sql_conditions', $conditions, $args );
241
  }
242
 
243
  /* Overrides EM_Object method to apply a filter to result
257
  $defaults = array(
258
  'orderby' => get_option('dbem_events_default_orderby'),
259
  'order' => get_option('dbem_events_default_order'),
260
+ 'rsvp' => false, //if set to true, only events with bookings enabled are returned
261
+ 'status' => 1, //approved events only
262
+ 'format_header' => '', //events can have custom html above the list
263
+ 'format_footer' => '', //events can have custom html below the list
264
  );
265
  if( is_admin() ){
266
  //figure out default owning permissions
267
+ $defaults['owner'] = !current_user_can('edit_others_events') ? get_current_user_id() : false;
268
+ if( !array_key_exists('status', $array) && current_user_can('edit_others_events') ){
269
+ $defaults['status'] = false; //by default, admins see pending and live events
 
 
 
 
270
  }
 
271
  }
272
  return apply_filters('em_events_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
273
  }
274
+
275
+ //TODO Implement object and interators for handling groups of events.
276
+ public function rewind(){
277
+ reset($this->events);
278
+ }
279
+
280
+ public function current(){
281
+ $var = current($this->events);
282
+ return $var;
283
+ }
284
+
285
+ public function key(){
286
+ $var = key($this->events);
287
+ return $var;
288
+ }
289
+
290
+ public function next(){
291
+ $var = next($this->events);
292
+ return $var;
293
+ }
294
+
295
+ public function valid(){
296
+ $key = key($this->events);
297
+ $var = ($key !== NULL && $key !== FALSE);
298
+ return $var;
299
+ }
300
  }
301
  ?>
classes/em-location.php CHANGED
@@ -6,9 +6,13 @@
6
  class EM_Location extends EM_Object {
7
  //DB Fields
8
  var $id = '';
 
9
  var $name = '';
10
  var $address = '';
11
  var $town = '';
 
 
 
12
  var $latitude = '';
13
  var $longitude = '';
14
  var $description = '';
@@ -17,16 +21,19 @@ class EM_Location extends EM_Object {
17
  //Other Vars
18
  var $fields = array(
19
  'location_id' => array('name'=>'id','type'=>'%d'),
 
20
  'location_name' => array('name'=>'name','type'=>'%s'),
21
  'location_address' => array('name'=>'address','type'=>'%s'),
22
  'location_town' => array('name'=>'town','type'=>'%s'),
23
- //Not Used - 'location_province' => array('name'=>'province','type'=>'%s'),
 
 
24
  'location_latitude' => array('name'=>'latitude','type'=>'%f'),
25
  'location_longitude' => array('name'=>'longitude','type'=>'%f'),
26
  'location_description' => array('name'=>'description','type'=>'%s'),
27
  'location_owner' => array('name'=>'owner','type'=>'%d')
28
  );
29
- var $required_fields;
30
  var $feedback_message = "";
31
  var $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
32
  var $errors = array();
@@ -38,16 +45,21 @@ class EM_Location extends EM_Object {
38
  */
39
  function EM_Location( $location_data = 0 ) {
40
  //Initialize
41
- $this->required_fields = array("name" => __('The location name', 'dbem'), "address" => __('The location address', 'dbem'), "town" => __('The location town', 'dbem'));
42
- if( $location_data != 0 ){
43
  //Load location data
44
  if( is_array($location_data) && isset($location_data['location_name']) ){
45
  $location = $location_data;
46
- }elseif( $location_data > 0 ){
47
  //Retreiving from the database
48
  global $wpdb;
49
- $sql = "SELECT * FROM ". $wpdb->prefix.EM_LOCATIONS_TABLE ." WHERE location_id ='{$location_data}'";
50
- $location = $wpdb->get_row($sql, ARRAY_A);
 
 
 
 
 
51
  }
52
  //If gmap is turned off, values may not be returned and set, so we set it here
53
  if(empty($location['location_latitude'])) {
@@ -58,6 +70,7 @@ class EM_Location extends EM_Object {
58
  $this->to_object($location, true);
59
  $this->get_image_url();
60
  }
 
61
  }
62
 
63
  function get_post(){
@@ -68,6 +81,9 @@ class EM_Location extends EM_Object {
68
  $location['location_name'] = ( !empty($_POST['location_name']) ) ? stripslashes($_POST['location_name']):'';
69
  $location['location_address'] = ( !empty($_POST['location_address']) ) ? stripslashes($_POST['location_address']):'';
70
  $location['location_town'] = ( !empty($_POST['location_town']) ) ? stripslashes($_POST['location_town']):'';
 
 
 
71
  $location['location_latitude'] = ( !empty($_POST['location_latitude']) ) ? $_POST['location_latitude']:'';
72
  $location['location_longitude'] = ( !empty($_POST['location_longitude']) ) ? $_POST['location_longitude']:'';
73
  $location['location_description'] = ( !empty($_POST['content']) ) ? stripslashes($_POST['content']):'';
@@ -76,32 +92,78 @@ class EM_Location extends EM_Object {
76
 
77
  function save(){
78
  global $wpdb, $current_user;
79
- get_currentuserinfo();
80
- do_action('em_location_save_pre', $this);
81
- $table = $wpdb->prefix.EM_LOCATIONS_TABLE;
82
- $data = $this->to_array();
83
- unset($data['location_id']);
84
- unset($data['location_image_url']);
85
- if($this->id != ''){
86
- $where = array( 'location_id' => $this->id );
87
- $wpdb->update($table, $data, $where, $this->get_types($data));
88
- }else{
89
- $this->owner = $current_user->ID; //Record creator of event
90
- $data['location_owner'] = $this->owner;
91
- $wpdb->insert($table, $data, $this->get_types($data));
92
- $this->id = $wpdb->insert_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
- $image_upload = $this->image_upload();
95
- return apply_filters('em_location_save', ( $this->id > 0 && $image_upload ), $this, $image_upload);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
 
98
  function delete(){
99
  global $wpdb;
100
- do_action('em_location_delete_pre', $this);
101
- $table_name = $wpdb->prefix.EM_LOCATIONS_TABLE;
102
- $sql = "DELETE FROM $table_name WHERE location_id = '{$this->id}';";
103
- $result = $wpdb->query($sql);
104
- $result = $this->image_delete() && $result;
 
 
 
 
 
 
 
 
 
 
105
  return apply_filters('em_location_delete', $result, $this);
106
  }
107
 
@@ -119,11 +181,15 @@ class EM_Location extends EM_Object {
119
  }
120
 
121
  function image_delete() {
122
- $file_name= ABSPATH.EM_IMAGE_UPLOAD_DIR."/location-".$this->id;
123
- $result = false;
124
- foreach($this->mime_types as $type) {
125
- if (file_exists($file_name.".".$type))
126
- $result = unlink($file_name.".".$type);
 
 
 
 
127
  }
128
  return apply_filters('em_location_image_delete', $result, $this);
129
  }
@@ -153,7 +219,7 @@ class EM_Location extends EM_Object {
153
  global $wpdb;
154
  if( !empty($criteria['location_name']) && !empty($criteria['location_name']) && !empty($criteria['location_name']) ){
155
  $locations_table = $wpdb->prefix.EM_LOCATIONS_TABLE;
156
- $prepared_sql = $wpdb->prepare("SELECT * FROM $locations_table WHERE location_name = %s AND location_address = %s AND location_town = %s", stripcslashes($criteria['location_name']), stripcslashes($criteria['location_address']), stripcslashes($criteria['location_town']) );
157
  //$wpdb->show_errors(true);
158
  $location = $wpdb->get_row($prepared_sql, ARRAY_A);
159
  if( is_array($location) ){
@@ -169,11 +235,16 @@ class EM_Location extends EM_Object {
169
  * @return boolean
170
  */
171
  function validate(){
 
172
  foreach ( $this->required_fields as $field => $description) {
173
- if ( $this->$field == "" ) {
174
- $this->errors[] = $description.__(" is missing!", "dbem");
175
- }
 
 
 
176
  }
 
177
  if ( !empty($_FILES['location_image']) && $_FILES['location_image']['size'] > 0 ) {
178
  if (is_uploaded_file($_FILES['location_image']['tmp_name'])) {
179
  $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
@@ -203,19 +274,11 @@ class EM_Location extends EM_Object {
203
  return apply_filters('em_location_has_events', (count($affected_events) > 0), $this);
204
  }
205
 
206
- function can_manage(){
207
- return ( get_option('dbem_permissions_locations') == 2 || $this->owner == get_current_user_id() || empty($this->id) || em_verify_admin() );
208
- }
209
-
210
- function can_use(){
211
- switch( get_option('dbem_permissions_locations') ){
212
- case 0:
213
- return $this->owner == get_current_user_id();
214
- case 1:
215
- return em_verify_admin($this->owner);
216
- case 2:
217
- return true;
218
- }
219
  }
220
 
221
  function output_single($target = 'html'){
@@ -230,6 +293,30 @@ class EM_Location extends EM_Object {
230
  $match = true;
231
  $replace = '';
232
  switch( $result ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  case '#_MAP': //Depreciated
234
  case '#_LOCATIONMAP':
235
  $replace = EM_Map::get_single( array('location' => $this) );
@@ -244,6 +331,12 @@ class EM_Location extends EM_Object {
244
  $replace = $matches[0];
245
  }
246
  break;
 
 
 
 
 
 
247
  case '#_LOCATIONURL':
248
  case '#_LOCATIONLINK':
249
  case '#_LOCATIONPAGEURL': //Depreciated
@@ -269,27 +362,6 @@ class EM_Location extends EM_Object {
269
  $replace = get_option('dbem_location_no_events_message');
270
  }
271
  break;
272
- case '#_IMAGE': //Depreciated
273
- case '#_LOCATIONIMAGE':
274
- if($this->image_url != ''){
275
- $replace = "<img src='".$this->image_url."' alt='".$this->name."'/>";
276
- }
277
- break;
278
- case '#_NAME': //Depreciated
279
- case '#_LOCATIONNAME':
280
- $replace = $this->name;
281
- break;
282
- case '#_ADDRESS': //Depreciated
283
- case '#_LOCATIONADDRESS':
284
- $replace = $this->address;
285
- break;
286
- case '#_TOWN': //Depreciated
287
- case '#_LOCATIONTOWN':
288
- $replace = $this->town;
289
- break;
290
- case '#_LOCATIONID':
291
- $replace = $this->id;
292
- break;
293
  default:
294
  $match = false;
295
  break;
@@ -304,4 +376,13 @@ class EM_Location extends EM_Object {
304
  $location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name) , $location_string ); //Depreciated
305
  return apply_filters('em_location_output', $location_string, $this, $format, $target);
306
  }
 
 
 
 
 
 
 
 
 
307
  }
6
  class EM_Location extends EM_Object {
7
  //DB Fields
8
  var $id = '';
9
+ var $slug = '';
10
  var $name = '';
11
  var $address = '';
12
  var $town = '';
13
+ var $state = '';
14
+ var $postcode = '';
15
+ var $country = '';
16
  var $latitude = '';
17
  var $longitude = '';
18
  var $description = '';
21
  //Other Vars
22
  var $fields = array(
23
  'location_id' => array('name'=>'id','type'=>'%d'),
24
+ 'location_slug' => array('name'=>'slug','type'=>'%s'),
25
  'location_name' => array('name'=>'name','type'=>'%s'),
26
  'location_address' => array('name'=>'address','type'=>'%s'),
27
  'location_town' => array('name'=>'town','type'=>'%s'),
28
+ 'location_state' => array('name'=>'state','type'=>'%s'),
29
+ 'location_postcode' => array('name'=>'postcode','type'=>'%s'),
30
+ 'location_country' => array('name'=>'country','type'=>'%s'),
31
  'location_latitude' => array('name'=>'latitude','type'=>'%f'),
32
  'location_longitude' => array('name'=>'longitude','type'=>'%f'),
33
  'location_description' => array('name'=>'description','type'=>'%s'),
34
  'location_owner' => array('name'=>'owner','type'=>'%d')
35
  );
36
+ var $required_fields = array();
37
  var $feedback_message = "";
38
  var $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
39
  var $errors = array();
45
  */
46
  function EM_Location( $location_data = 0 ) {
47
  //Initialize
48
+ $this->required_fields = array("name" => __('The location name', 'dbem'), "address" => __('The location address', 'dbem'), "town" => __('The location town', 'dbem'), "country" => __('The country', 'dbem'),);
49
+ if( !empty($location_data) ){
50
  //Load location data
51
  if( is_array($location_data) && isset($location_data['location_name']) ){
52
  $location = $location_data;
53
+ }elseif( !empty($location_data) ){
54
  //Retreiving from the database
55
  global $wpdb;
56
+ if( is_numeric($location_data) ){
57
+ $sql = "SELECT * FROM ". $wpdb->prefix.EM_LOCATIONS_TABLE ." WHERE location_id ='{$location_data}'";
58
+ $location = $wpdb->get_row($sql, ARRAY_A);
59
+ }else{
60
+ $sql = "SELECT * FROM ". $wpdb->prefix.EM_LOCATIONS_TABLE ." WHERE location_slug ='{$location_data}'";
61
+ $location = $wpdb->get_row($sql, ARRAY_A);
62
+ }
63
  }
64
  //If gmap is turned off, values may not be returned and set, so we set it here
65
  if(empty($location['location_latitude'])) {
70
  $this->to_object($location, true);
71
  $this->get_image_url();
72
  }
73
+ do_action('em_location', $this, $location_data);
74
  }
75
 
76
  function get_post(){
81
  $location['location_name'] = ( !empty($_POST['location_name']) ) ? stripslashes($_POST['location_name']):'';
82
  $location['location_address'] = ( !empty($_POST['location_address']) ) ? stripslashes($_POST['location_address']):'';
83
  $location['location_town'] = ( !empty($_POST['location_town']) ) ? stripslashes($_POST['location_town']):'';
84
+ $location['location_state'] = ( !empty($_POST['location_state']) ) ? stripslashes($_POST['location_state']):'';
85
+ $location['location_postcode'] = ( !empty($_POST['location_postcode']) ) ? stripslashes($_POST['location_postcode']):'';
86
+ $location['location_country'] = ( !empty($_POST['location_country']) ) ? stripslashes($_POST['location_country']):'';
87
  $location['location_latitude'] = ( !empty($_POST['location_latitude']) ) ? $_POST['location_latitude']:'';
88
  $location['location_longitude'] = ( !empty($_POST['location_longitude']) ) ? $_POST['location_longitude']:'';
89
  $location['location_description'] = ( !empty($_POST['content']) ) ? stripslashes($_POST['content']):'';
92
 
93
  function save(){
94
  global $wpdb, $current_user;
95
+ if( $this->validate() ){
96
+ if( current_user_can('edit_locations') ){
97
+ get_currentuserinfo();
98
+ do_action('em_location_save_pre', $this);
99
+ $table = $wpdb->prefix.EM_LOCATIONS_TABLE;
100
+ $this->slug = $this->sanitize_title();
101
+ $data = $this->to_array();
102
+ unset($data['location_id']);
103
+ unset($data['location_image_url']);
104
+ if($this->id != ''){
105
+ $where = array( 'location_id' => $this->id );
106
+ $result = $wpdb->update($table, $data, $where, $this->get_types($data));
107
+ if( $result ){
108
+ $this->feedback_message = sprintf(__('%s successfully updated.', 'dbem'), __('Location','dbem'));
109
+ }
110
+ }else{
111
+ $this->owner = $current_user->ID; //Record creator of event
112
+ $data['location_owner'] = $this->owner;
113
+ $result = $wpdb->insert($table, $data, $this->get_types($data));
114
+ $this->id = $wpdb->insert_id;
115
+ if( $result ){
116
+ $this->feedback_message = sprintf(__('%s successfully added.', 'dbem'), __('Location','dbem'));
117
+ }
118
+ }
119
+ $image_upload = $this->image_upload();
120
+ return apply_filters('em_location_save', ( $this->id > 0 && $image_upload ), $this, $image_upload);
121
+ }else{
122
+ $this->add_error( sprintf(__('You do not have permission to create/edit %s.','dbem'), __('locations','dbem')) );
123
+ }
124
  }
125
+ return apply_filters('em_location_save', false, $this, false);
126
+ }
127
+
128
+ /**
129
+ * Takes the title and gives either a unique slug or returns the currently used slug if this record already has it.
130
+ * @param unknown_type $title
131
+ */
132
+ function sanitize_title($iteration = 1){
133
+ global $wpdb;
134
+ //Generate the slug. If this is a new event, create the slug automatically, if not, verify it is still unique and if not rewrite
135
+ if( empty($this->slug) ){
136
+ $this->slug = sanitize_title($this->name);
137
+ }
138
+ $slug = $this->slug;
139
+ $slug_matches = $wpdb->get_results('SELECT location_id FROM '.$wpdb->prefix.EM_LOCATIONS_TABLE." WHERE location_slug='{$slug}'", ARRAY_A);
140
+ if( count($slug_matches) > 0 ){ //we will check that the slug is unique
141
+ if( $slug_matches[0]['location_id'] != $this->id || count($slug_matches) > 1 ){
142
+ //we have a conflict, so try another alternative
143
+ $this->slug = preg_replace('/\-[0-9]+$/', '', $slug).'-'.($iteration+1);
144
+ $this->sanitize_title($iteration+1);
145
+ }
146
+ }
147
+ return apply_filters('em_location_sanitize_title', $this->slug, $this);
148
  }
149
 
150
  function delete(){
151
  global $wpdb;
152
+ if( current_user_can('delete_locations') ){
153
+ do_action('em_location_delete_pre', $this);
154
+ $table_name = $wpdb->prefix.EM_LOCATIONS_TABLE;
155
+ $sql = "DELETE FROM $table_name WHERE location_id = '{$this->id}';";
156
+ $result = $wpdb->query($sql);
157
+ $result = $this->image_delete() && $result;
158
+ if( $result ){
159
+ $this->feedback_message = sprintf(__('%s successfully deleted.', 'dbem'), __('Location','dbem')) ;
160
+ }else{
161
+ $this->add_error( sprintf(__('%s could not be deleted.', 'dbem'), __('Location','dbem')) );
162
+ }
163
+ }else{
164
+ $this->add_error( sprintf(__('You do not have permission to delete %s.','dbem'), __('locations','dbem')) );
165
+ $result = false;
166
+ }
167
  return apply_filters('em_location_delete', $result, $this);
168
  }
169
 
181
  }
182
 
183
  function image_delete() {
184
+ if( $this->image_url == '' ){
185
+ $result = true;
186
+ }else{
187
+ $file_name= ABSPATH.EM_IMAGE_UPLOAD_DIR."/location-".$this->id;
188
+ $result = false;
189
+ foreach($this->mime_types as $type) {
190
+ if (file_exists($file_name.".".$type))
191
+ $result = unlink($file_name.".".$type);
192
+ }
193
  }
194
  return apply_filters('em_location_image_delete', $result, $this);
195
  }
219
  global $wpdb;
220
  if( !empty($criteria['location_name']) && !empty($criteria['location_name']) && !empty($criteria['location_name']) ){
221
  $locations_table = $wpdb->prefix.EM_LOCATIONS_TABLE;
222
+ $prepared_sql = $wpdb->prepare("SELECT * FROM $locations_table WHERE location_name = %s AND location_address = %s AND location_town = %s AND location_state = %s AND location_postcode = %s AND location_country = %s", stripcslashes($criteria['location_name']), stripcslashes($criteria['location_address']), stripcslashes($criteria['location_town']), stripcslashes($criteria['location_state']), stripcslashes($criteria['location_postcode']), stripcslashes($criteria['location_country']) );
223
  //$wpdb->show_errors(true);
224
  $location = $wpdb->get_row($prepared_sql, ARRAY_A);
225
  if( is_array($location) ){
235
  * @return boolean
236
  */
237
  function validate(){
238
+ //check required fields
239
  foreach ( $this->required_fields as $field => $description) {
240
+ if( $field == 'country' && !array_key_exists($this->country, em_get_countries()) ){
241
+ //country specific checking
242
+ $this->errors[] = $this->required_fields['country'].__(" is required.", "dbem");
243
+ }elseif ( $this->$field == "" ) {
244
+ $this->errors[] = $description.__(" is required.", "dbem");
245
+ }
246
  }
247
+ //Srt out the image
248
  if ( !empty($_FILES['location_image']) && $_FILES['location_image']['size'] > 0 ) {
249
  if (is_uploaded_file($_FILES['location_image']['tmp_name'])) {
250
  $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
274
  return apply_filters('em_location_has_events', (count($affected_events) > 0), $this);
275
  }
276
 
277
+ /**
278
+ * Can the user manage this location?
279
+ */
280
+ function can_manage( $owner_capability = false, $admin_capability = false ){
281
+ return apply_filters('em_location_can_manage', parent::can_manage($owner_capability, $admin_capability), $this);
 
 
 
 
 
 
 
 
282
  }
283
 
284
  function output_single($target = 'html'){
293
  $match = true;
294
  $replace = '';
295
  switch( $result ){
296
+ case '#_LOCATIONID':
297
+ $replace = $this->id;
298
+ break;
299
+ case '#_NAME': //Depreciated
300
+ case '#_LOCATIONNAME':
301
+ $replace = $this->name;
302
+ break;
303
+ case '#_ADDRESS': //Depreciated
304
+ case '#_LOCATIONADDRESS':
305
+ $replace = $this->address;
306
+ break;
307
+ case '#_TOWN': //Depreciated
308
+ case '#_LOCATIONTOWN':
309
+ $replace = $this->town;
310
+ break;
311
+ case '#_LOCATIONSTATE':
312
+ $replace = $this->id;
313
+ break;
314
+ case '#_LOCATIONPOSTCODE':
315
+ $replace = $this->id;
316
+ break;
317
+ case '#_LOCATIONCOUNTRY':
318
+ $replace = $this->id;
319
+ break;
320
  case '#_MAP': //Depreciated
321
  case '#_LOCATIONMAP':
322
  $replace = EM_Map::get_single( array('location' => $this) );
331
  $replace = $matches[0];
332
  }
333
  break;
334
+ case '#_IMAGE': //Depreciated
335
+ case '#_LOCATIONIMAGE':
336
+ if($this->image_url != ''){
337
+ $replace = "<img src='".$this->image_url."' alt='".$this->name."'/>";
338
+ }
339
+ break;
340
  case '#_LOCATIONURL':
341
  case '#_LOCATIONLINK':
342
  case '#_LOCATIONPAGEURL': //Depreciated
362
  $replace = get_option('dbem_location_no_events_message');
363
  }
364
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  default:
366
  $match = false;
367
  break;
376
  $location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name) , $location_string ); //Depreciated
377
  return apply_filters('em_location_output', $location_string, $this, $format, $target);
378
  }
379
+
380
+ function get_country(){
381
+ $countries = em_get_countries();
382
+ if( !empty($countries[$this->country]) ){
383
+ return apply_filters('em_location_get_country', $countries[$this->country], $this);
384
+ }
385
+ return apply_filters('em_location_get_country', false, $this);
386
+
387
+ }
388
  }
classes/em-locations.php CHANGED
@@ -11,13 +11,13 @@ class EM_Locations extends EM_Object {
11
  * @param boolean $return_objects
12
  * @return array
13
  */
14
- function get( $args = array() ){
15
  global $wpdb;
16
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
17
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
18
 
19
  //Quick version, we can accept an array of IDs, which is easy to retrieve
20
- if( self::array_is_numeric($args) && count() ){ //Array of numbers, assume they are event IDs to retreive
21
  //We can just get all the events here and return them
22
  $sql = "SELECT * FROM $locations_table WHERE location_id=".implode(" OR location_id=", $args);
23
  $results = $wpdb->get_results($sql,ARRAY_A);
@@ -26,8 +26,12 @@ class EM_Locations extends EM_Object {
26
  $locations[$result['location_id']] = new EM_Location($result);
27
  }
28
  return $locations; //We return all the events matched as an EM_Event array.
29
- }
30
-
 
 
 
 
31
 
32
  //We assume it's either an empty array or array of search arguments to merge with defaults
33
  $args = self::get_default_search($args);
@@ -50,17 +54,23 @@ class EM_Locations extends EM_Object {
50
  //Now, build orderby sql
51
  $orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
52
 
53
-
 
 
54
  //Create the SQL statement and execute
55
  $sql = "
56
  SELECT $fields FROM $locations_table
57
  LEFT JOIN $events_table ON {$locations_table}.location_id={$events_table}.location_id
58
  $where
59
- GROUP BY location_id
60
  $orderby_sql
61
  $limit $offset
62
  ";
63
 
 
 
 
 
64
  $results = $wpdb->get_results($sql, ARRAY_A);
65
 
66
  //If we want results directly in an array, why not have a shortcut here?
@@ -75,6 +85,10 @@ class EM_Locations extends EM_Object {
75
  return apply_filters('em_locations_get', $locations, $args);
76
  }
77
 
 
 
 
 
78
  /**
79
  * Output a set of matched of events
80
  * @param array $args
@@ -141,6 +155,19 @@ class EM_Locations extends EM_Object {
141
  return apply_filters('em_locations_output', $output, $locations, $args);
142
  }
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  /**
145
  * Builds an array of SQL query conditions based on regularly used arguments
146
  * @param array $args
@@ -160,9 +187,7 @@ class EM_Locations extends EM_Object {
160
  }
161
  //owner lookup
162
  if( !empty($args['owner']) ){
163
- if ( get_option('dbem_permissions_locations') < 1 && !em_verify_admin() ){
164
- $conditions['owner'] = "location_owner=".get_current_user_id();
165
- }
166
  }
167
  return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
168
  }
@@ -188,26 +213,9 @@ class EM_Locations extends EM_Object {
188
  $array['eventful'] = ( !empty($array['eventful']) && $array['eventful'] == true );
189
  $array['eventless'] = ( !empty($array['eventless']) && $array['eventless'] == true );
190
  if( is_admin() ){
191
- //by default, we only get categories the owner can manage
192
- switch( get_option('dbem_permissions_locations') ){
193
- case 0:
194
- $defaults['owner'] = get_current_user_id();
195
- break;
196
- case 1:
197
- $wp_user_search = new WP_User_Search(null, null, 'administrator');
198
- $users = $wp_user_search->get_results();
199
- $users[] = get_current_user_id();
200
- $users[] = 0;
201
- $defaults['owner'] = implode(',', $users);
202
- break;
203
- case 2:
204
- $defaults['owner'] = false;
205
- break;
206
- }
207
- $defaults['owner'] = ( em_verify_admin() ) ? false:$defaults['owner'];
208
  }
209
  return apply_filters('em_locations_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults);
210
  }
211
- //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.
212
  }
213
  ?>
11
  * @param boolean $return_objects
12
  * @return array
13
  */
14
+ function get( $args = array(), $count=false ){
15
  global $wpdb;
16
  $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
17
  $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
18
 
19
  //Quick version, we can accept an array of IDs, which is easy to retrieve
20
+ if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
21
  //We can just get all the events here and return them
22
  $sql = "SELECT * FROM $locations_table WHERE location_id=".implode(" OR location_id=", $args);
23
  $results = $wpdb->get_results($sql,ARRAY_A);
26
  $locations[$result['location_id']] = new EM_Location($result);
27
  }
28
  return $locations; //We return all the events matched as an EM_Event array.
29
+ }elseif( is_numeric($args) ){
30
+ //return an event in the usual array format
31
+ return apply_filters('em_locations_get', array(new EM_Event($args)), $args);
32
+ }elseif( is_array($args) && is_object(current($args)) && get_class((current($args))) == 'EM_Location' ){
33
+ return apply_filters('em_locations_get', $args, $args);
34
+ }
35
 
36
  //We assume it's either an empty array or array of search arguments to merge with defaults
37
  $args = self::get_default_search($args);
54
  //Now, build orderby sql
55
  $orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
56
 
57
+ if( $count ){
58
+ $fields = $locations_table.'.location_id';
59
+ }
60
  //Create the SQL statement and execute
61
  $sql = "
62
  SELECT $fields FROM $locations_table
63
  LEFT JOIN $events_table ON {$locations_table}.location_id={$events_table}.location_id
64
  $where
65
+ GROUP BY {$locations_table}.location_id
66
  $orderby_sql
67
  $limit $offset
68
  ";
69
 
70
+ //If we're only counting results, return the number of results
71
+ if( $count ){
72
+ return count($wpdb->get_results($sql));
73
+ }
74
  $results = $wpdb->get_results($sql, ARRAY_A);
75
 
76
  //If we want results directly in an array, why not have a shortcut here?
85
  return apply_filters('em_locations_get', $locations, $args);
86
  }
87
 
88
+ function count( $args = array() ){
89
+ return apply_filters('em_locations_count', self::get($args, true), $args);
90
+ }
91
+
92
  /**
93
  * Output a set of matched of events
94
  * @param array $args
155
  return apply_filters('em_locations_output', $output, $locations, $args);
156
  }
157
 
158
+ function delete( $args = array() ){
159
+ if( !is_object(current($args)) && get_class((current($args))) != 'EM_Location' ){
160
+ $locations = self::get($args);
161
+ }else{
162
+ $locations = $args;
163
+ }
164
+ $results = array();
165
+ foreach ( $locations as $EM_Location ){
166
+ $results[] = $EM_Location->delete();
167
+ }
168
+ return apply_filters('em_locations_delete', in_array(false, $results), $locations);
169
+ }
170
+
171
  /**
172
  * Builds an array of SQL query conditions based on regularly used arguments
173
  * @param array $args
187
  }
188
  //owner lookup
189
  if( !empty($args['owner']) ){
190
+ $conditions['owner'] = "location_owner=".$args['owner'];
 
 
191
  }
192
  return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
193
  }
213
  $array['eventful'] = ( !empty($array['eventful']) && $array['eventful'] == true );
214
  $array['eventless'] = ( !empty($array['eventless']) && $array['eventless'] == true );
215
  if( is_admin() ){
216
+ $defaults['owner'] = !current_user_can('read_others_locations') ? get_current_user_id():false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
  return apply_filters('em_locations_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults);
219
  }
 
220
  }
221
  ?>
classes/em-notices.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author marcus
5
+ *
6
+ */
7
+ class EM_Notices implements Iterator {
8
+ var $notices = array('errors'=>array(), 'infos'=>array(), 'alerts'=>array(), 'confirms'=>array());
9
+
10
+ function __construct(){
11
+ //Grab from session
12
+ if( !empty($_SESSION['events']['notices']) && is_serialized($_SESSION['events']['notices']) ){
13
+ $this->notices = unserialize($_SESSION['events']['notices']);
14
+ }
15
+ //Flush notices that weren't made to stay cross-requests, we can do this if initialized immediately.
16
+ foreach($this->notices as $notice_type => $notices){
17
+ foreach ($notices as $key => $notice){
18
+ if( empty($notice['static']) ){
19
+ unset($this->notices[$notice_type][$key]);
20
+ }else{
21
+ unset($this->notices[$notice_type][$key]['static']); //so it gets removed next request
22
+ }
23
+ }
24
+ }
25
+ add_action('shutdown', array(&$this,'flush_notices'));
26
+ }
27
+
28
+ function flush_notices(){
29
+ $_SESSION['events']['notices'] = serialize($this->notices);
30
+ }
31
+
32
+ function __toString(){
33
+ $string = false;
34
+ if(count($this->notices['errors']) > 0){
35
+ $string .= "<div class='em-warning em-warning-errors error'>{$this->get_errors()}</div>";
36
+ }
37
+ if(count($this->notices['alerts']) > 0){
38
+ $string .= "<div class='em-warning em-warning-alerts updated'>{$this->get_alerts()}</div>";
39
+ }
40
+ if(count($this->notices['infos']) > 0){
41
+ $string .= "<div class='em-warning em-warning-infos updated'>{$this->get_infos()}</div>";
42
+ }
43
+ if(count($this->notices['confirms']) > 0){
44
+ $string .= "<div class='em-warning em-warning-confirms updated'>{$this->get_confirms()}</div>";
45
+ }
46
+ return ($string !== false) ? "<div class='statusnotice'>".$string."</div>" : '';
47
+ }
48
+
49
+ /* General */
50
+ function add($string, $type, $static = false){
51
+ if( is_array($string) ){
52
+ $result = true;
53
+ foreach($string as $string_item){
54
+ if( $this->add($string_item, $type, $static) === false ){ $result = false; }
55
+ }
56
+ return $result;
57
+ }
58
+ if($string != ''){
59
+ if( isset($this->notices[$type]) ){
60
+ foreach( $this->notices[$type] as $notice_key => $notice ){
61
+ if($string == $notice['string']){
62
+ return $notice_key;
63
+ }
64
+ }
65
+ $i = key($this->notices[$type])+1;
66
+ $this->notices[$type][$i]['string'] = $string;
67
+ if( $static ){
68
+ $this->notices[$type][$i]['static'] = true;
69
+ }
70
+ return $i;
71
+ }else{
72
+ return false;
73
+ }
74
+ }else{
75
+ return false;
76
+ }
77
+ }
78
+ function remove($key, $type){
79
+ if( isset($this->notices[$type]) ){
80
+ unset($this->notices[$type][$key]);
81
+ return true;
82
+ }else{
83
+ return false;
84
+ }
85
+ }
86
+ function get($type){
87
+ if( isset($this->notices[$type]) ){
88
+ foreach ($this->notices[$type] as $key => $error){
89
+ $class = substr($type, 0, (strlen($type)-1));
90
+ $string .= "<p>{$error['string']}</p>";
91
+ if($error['static'] !== true){
92
+ $this->remove($key, $type);
93
+ }
94
+ }
95
+ return $string;
96
+ }else{
97
+ return false;
98
+ }
99
+ }
100
+
101
+ /* Errors */
102
+ function add_error($string, $static=false){
103
+ return $this->add($string, 'errors', $static);
104
+ }
105
+ function remove_error($key){
106
+ return $this->remove($key, 'errors');
107
+ }
108
+ function get_errors(){
109
+ return $this->get('errors');
110
+ }
111
+
112
+ /* Alerts */
113
+ function add_alert($string, $static=false){
114
+ return $this->add($string, 'alerts', $static);
115
+ }
116
+ function remove_alert($key){
117
+ return $this->remove($key, 'alerts');
118
+ }
119
+ function get_alerts(){
120
+ return $this->get('alerts');
121
+ }
122
+
123
+ /* Info */
124
+ function add_info($string, $static=false){
125
+ return $this->add($string, 'infos', $static);
126
+ }
127
+ function remove_info($key){
128
+ return $this->remove($key, 'infos');
129
+ }
130
+ function get_infos(){
131
+ return $this->get('infos');
132
+ }
133
+
134
+ /* Confirms */
135
+ function add_confirm($string, $static=false){
136
+ return $this->add($string, 'confirms', $static);
137
+ }
138
+ function remove_confirm($key){
139
+ return $this->remove($key, 'confirms');
140
+ }
141
+ function get_confirms(){
142
+ return $this->get('confirms');
143
+ }
144
+
145
+ //Iterator Implementation
146
+ function rewind(){
147
+ reset($this->bookings);
148
+ }
149
+ function current(){
150
+ $var = current($this->bookings);
151
+ return $var;
152
+ }
153
+ function key(){
154
+ $var = key($this->bookings);
155
+ return $var;
156
+ }
157
+ function next(){
158
+ $var = next($this->bookings);
159
+ return $var;
160
+ }
161
+ function valid(){
162
+ $key = key($this->bookings);
163
+ $var = ($key !== NULL && $key !== FALSE);
164
+ return $var;
165
+ }
166
+
167
+ }
168
+ global $EM_Notices;
169
+ $EM_Notices = new EM_Notices();
170
+ ?>
classes/em-object.php CHANGED
@@ -4,8 +4,10 @@
4
  *
5
  */
6
  class EM_Object {
7
-
8
  var $fields = array();
 
 
 
9
 
10
  /**
11
  * Takes the array and provides a clean array of search parameters, along with details
@@ -14,6 +16,7 @@ class EM_Object {
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(
@@ -34,7 +37,8 @@ class EM_Object {
34
  'pagination'=>false,
35
  'array'=>false,
36
  'owner'=>false,
37
- 'rsvp'=>false
 
38
  );
39
  //Return default if nothing passed
40
  if( empty($defaults) && empty($array) ){
@@ -97,6 +101,7 @@ class EM_Object {
97
  $defaults['offset'] = (is_numeric($defaults['offset'])) ? $defaults['offset']:$super_defaults['offset'];
98
  $defaults['recurring'] = ($defaults['recurring'] == true);
99
  $defaults['owner'] = (is_numeric($defaults['owner'])) ? $defaults['owner']:$super_defaults['owner'];
 
100
  //Calculate offset in event page is set
101
  if($defaults['page'] > 1){
102
  $defaults['offset'] = $defaults['limit'] * ($defaults['page']-1);
@@ -224,7 +229,7 @@ class EM_Object {
224
  }
225
  //Default ownership belongs to an event, child objects can just overwrite this if needed.
226
  if( is_numeric($owner) ){
227
- $conditions['owner'] = 'event_author='.$owner;
228
  }
229
  return apply_filters('em_object_build_sql_conditions', $conditions);
230
  }
@@ -266,6 +271,34 @@ class EM_Object {
266
  }
267
  return apply_filters('em_object_build_sql_orderby', $orderby);
268
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
 
270
  /**
271
  * Save an array into this class.
@@ -292,10 +325,16 @@ class EM_Object {
292
  * Returns this object in the form of an array, useful for saving directly into a database table.
293
  * @return array
294
  */
295
- function to_array(){
296
  $array = array();
297
  foreach ( $this->fields as $key => $val ) {
298
- $array[$key] = $this->$val['name'];
 
 
 
 
 
 
299
  }
300
  return apply_filters('em_to_array', $array);
301
  }
@@ -392,8 +431,12 @@ class EM_Object {
392
  function email_send($subject, $body, $email){
393
  global $EM_Mailer;
394
  if( !$EM_Mailer->send($subject,$body,$email) ){
395
- foreach($EM_Mailer->errors as $error){
396
- $this->errors[] = $error;
 
 
 
 
397
  }
398
  return false;
399
  }
@@ -413,6 +456,31 @@ class EM_Object {
413
  }
414
  }
415
  return (!in_array(false, $results) && count($results) > 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  }
417
 
418
  /**
@@ -426,11 +494,11 @@ class EM_Object {
426
  }else{
427
  $return = self::array_to_json($array);
428
  }
429
- if( isset($_GET['callback']) ){
430
- $return = $_GET['callback']."($return)";
431
  }
432
  return apply_filters('em_object_json_encode', $return, $array);
433
- }
434
 
435
  /**
436
  * Compatible json encoder function for PHP4
4
  *
5
  */
6
  class EM_Object {
 
7
  var $fields = array();
8
+ var $required_fields = array();
9
+ var $feedback_message = "";
10
+ var $errors = array();
11
 
12
  /**
13
  * Takes the array and provides a clean array of search parameters, along with details
16
  * @return array
17
  */
18
  function get_default_search($defaults=array(), $array = array()){
19
+ global $wpdb;
20
  //TODO accept all objects as search options as well as ids (e.g. location vs. location_id, person vs. person_id)
21
  //Create minimal defaults array, merge it with supplied defaults array
22
  $super_defaults = array(
37
  'pagination'=>false,
38
  'array'=>false,
39
  'owner'=>false,
40
+ 'rsvp'=>false,
41
+ 'search'=>false
42
  );
43
  //Return default if nothing passed
44
  if( empty($defaults) && empty($array) ){
101
  $defaults['offset'] = (is_numeric($defaults['offset'])) ? $defaults['offset']:$super_defaults['offset'];
102
  $defaults['recurring'] = ($defaults['recurring'] == true);
103
  $defaults['owner'] = (is_numeric($defaults['owner'])) ? $defaults['owner']:$super_defaults['owner'];
104
+ $defaults['search'] = ($defaults['search']) ? $wpdb->escape(like_escape($defaults['search'])):false;
105
  //Calculate offset in event page is set
106
  if($defaults['page'] > 1){
107
  $defaults['offset'] = $defaults['limit'] * ($defaults['page']-1);
229
  }
230
  //Default ownership belongs to an event, child objects can just overwrite this if needed.
231
  if( is_numeric($owner) ){
232
+ $conditions['owner'] = 'event_owner='.$owner;
233
  }
234
  return apply_filters('em_object_build_sql_conditions', $conditions);
235
  }
271
  }
272
  return apply_filters('em_object_build_sql_orderby', $orderby);
273
  }
274
+
275
+ /**
276
+ * Used by "single" objects, e.g. bookings, events, locations to verify if they have the capability to edit this or someone else's object. Relies on the fact that the object has an owner property with id of user (or admin capability must pass).
277
+ * @param string $owner_capability If the object has an owner property and the user id matches that, this capability will be checked for.
278
+ * @param string $admin_capability If the user isn't the owner of the object, this capability will be checked for.
279
+ * @return boolean
280
+ */
281
+ function can_manage( $owner_capability = false, $admin_capability = false ){
282
+ global $em_capabilities_array;
283
+ //do they own this?
284
+ $is_owner = ( $this->owner == get_current_user_id() || empty($this->id) );
285
+ //now check capability
286
+ $can_manage = false;
287
+ if( $is_owner && current_user_can($owner_capability) ){
288
+ $can_manage = true;
289
+ }elseif( $is_owner && array_key_exists($owner_capability, $em_capabilities_array) ){
290
+ $error_msg = $em_capabilities_array[$owner_capability];
291
+ }
292
+ if( !$is_owner && current_user_can($admin_capability) ){
293
+ $can_manage = true;
294
+ }elseif( !$is_owner && array_key_exists($admin_capability, $em_capabilities_array) ){
295
+ $error_msg = $em_capabilities_array[$admin_capability];
296
+ }
297
+ if( !$can_manage ){
298
+ $this->add_error($error_msg);
299
+ }
300
+ return $can_manage;
301
+ }
302
 
303
  /**
304
  * Save an array into this class.
325
  * Returns this object in the form of an array, useful for saving directly into a database table.
326
  * @return array
327
  */
328
+ function to_array($db = false){
329
  $array = array();
330
  foreach ( $this->fields as $key => $val ) {
331
+ if($db){
332
+ if( !empty($this->$val['name']) || empty($val['null']) ){
333
+ $array[$key] = $this->$val['name'];
334
+ }
335
+ }else{
336
+ $array[$key] = $this->$val['name'];
337
+ }
338
  }
339
  return apply_filters('em_to_array', $array);
340
  }
431
  function email_send($subject, $body, $email){
432
  global $EM_Mailer;
433
  if( !$EM_Mailer->send($subject,$body,$email) ){
434
+ if( is_array($EM_Mailer->errors) ){
435
+ foreach($EM_Mailer->errors as $error){
436
+ $this->errors[] = $error;
437
+ }
438
+ }else{
439
+ $this->errors[] = $EM_Mailer->errors;
440
  }
441
  return false;
442
  }
456
  }
457
  }
458
  return (!in_array(false, $results) && count($results) > 0);
459
+ }
460
+
461
+ /**
462
+ * Returns an array of errors in this object
463
+ * @return array
464
+ */
465
+ function get_errors(){
466
+ if(is_array($this->errors)){
467
+ return $this->errors;
468
+ }else{
469
+ return array();
470
+ }
471
+ }
472
+
473
+ /**
474
+ * Adds an error to the object
475
+ */
476
+ function add_error($error){
477
+ if(is_array($this->errors)){
478
+ if( !in_array($error, $this->errors) ){
479
+ $this->errors[] = $error;
480
+ }
481
+ }else{
482
+ $this->errors = array($error);
483
+ }
484
  }
485
 
486
  /**
494
  }else{
495
  $return = self::array_to_json($array);
496
  }
497
+ if( isset($_REQUEST['callback']) ){
498
+ $return = $_REQUEST['callback']."($return)";
499
  }
500
  return apply_filters('em_object_json_encode', $return, $array);
501
+ }
502
 
503
  /**
504
  * Compatible json encoder function for PHP4
classes/em-people.php CHANGED
@@ -21,65 +21,6 @@ class EM_People extends EM_Object {
21
  return $result;
22
  }
23
 
24
- function get_new( $args = array() ) {
25
- global $wpdb;
26
- $people_table = $wpdb->prefix.EM_PEOPLE_TABLE;
27
- $bookings_table = $wpdb->prefix.EM_BOOKINGS_TABLE;
28
-
29
- //Quick version, we can accept an array of IDs, which is easy to retrieve
30
- if( self::array_is_numeric($args) ){ //Array of numbers, assume they are event IDs to retreive
31
- //We can just get all the events here and return them
32
- $sql = "SELECT * FROM $people_table WHERE person_id=".implode(" OR person_id=", $args);
33
- $results = $wpdb->get_results(apply_filters('em_people_get_sql',$sql),ARRAY_A);
34
- $people = array();
35
- foreach($results as $result){
36
- $people[$result['person_id']] = new EM_Person($result);
37
- }
38
- return $people; //We return all the people matched as an EM_Event array.
39
- }
40
-
41
- //We assume it's either an empty array or array of search arguments to merge with defaults
42
- $args = self::get_default_search($args);
43
- $limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';
44
- $offset = ( $limit != "" && is_numeric($args['offset']) ) ? "OFFSET {$args['offset']}" : '';
45
-
46
- //Get the default conditions
47
- $conditions = self::build_sql_conditions($args);
48
- //Put it all together
49
- $where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
50
-
51
- //Get ordering instructions
52
- $EM_Person = new EM_Person();
53
- $accepted_fields = $EM_Person->get_fields(true);
54
- $orderby = self::build_sql_orderby($args, $accepted_fields, get_option('dbem_people_default_order'));
55
- //Now, build orderby sql
56
- $orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
57
-
58
- //Create the SQL statement and execute
59
- $sql = "
60
- SELECT * FROM $people_table
61
- LEFT JOIN $bookings_table ON {$bookings_table}.person_id={$people_table}.person_id
62
- $where
63
- GROUP BY person_id
64
- $orderby_sql
65
- $limit $offset
66
- ";
67
- $results = $wpdb->get_results( apply_filters('em_people_get_sql',$sql, $args), ARRAY_A);
68
- //If we want results directly in an array, why not have a shortcut here?
69
- if( $args['array'] == true ){
70
- return $results;
71
- }
72
-
73
- //Make returned results EM_Event objects
74
- $results = (is_array($results)) ? $results:array();
75
- $people = array();
76
- foreach ( $results as $person_array ){
77
- $people[$person_array['person_id']] = new EM_Person($person_array);
78
- }
79
-
80
- return apply_filters('em_people_get', $people);
81
- }
82
-
83
  /* Overrides EM_Object method to apply a filter to result
84
  * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
85
  */
@@ -88,6 +29,15 @@ class EM_People extends EM_Object {
88
  //FIXME EM_People doesn't build sql conditions in EM_Object
89
  $conditions = array();
90
 
 
 
 
 
 
 
 
 
 
91
  return apply_filters( 'em_people_build_sql_conditions', $conditions, $args );
92
  }
93
 
@@ -110,18 +60,6 @@ class EM_People extends EM_Object {
110
  'eventful' => false, //cats that have an event (scope will also play a part here
111
  'eventless' => false, //cats WITHOUT events, eventful takes precedence
112
  );
113
- //figure out default owning permissions, but since public is for viewing events, only impose limitations in admin area
114
- if( is_admin() ){
115
- switch( get_option('dbem_permissions_events') ){
116
- case 0:
117
- $defaults['owner'] = get_current_user_id();
118
- break;
119
- case 1:
120
- $defaults['owner'] = false;
121
- break;
122
- }
123
- $defaults['owner'] = ( em_verify_admin() ) ? false:$defaults['owner'];
124
- }
125
  return apply_filters('em_people_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
126
  }
127
 
21
  return $result;
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  /* Overrides EM_Object method to apply a filter to result
25
  * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
26
  */
29
  //FIXME EM_People doesn't build sql conditions in EM_Object
30
  $conditions = array();
31
 
32
+ //owner lookup
33
+ //FIXME permissions need tweaking for people, not owned by event owner, but site.
34
+ /*
35
+ if( is_numeric($args['owner']) ){
36
+ $conditions['owner'] = "person_owner=".get_current_user_id();
37
+ }elseif( preg_match('/^([0-9],?)+$/', $args['owner']) ){
38
+ $conditions['owner'] = "person_owner IN (".explode(',', $args['owner']).")";
39
+ }
40
+ */
41
  return apply_filters( 'em_people_build_sql_conditions', $conditions, $args );
42
  }
43
 
60
  'eventful' => false, //cats that have an event (scope will also play a part here
61
  'eventless' => false, //cats WITHOUT events, eventful takes precedence
62
  );
 
 
 
 
 
 
 
 
 
 
 
 
63
  return apply_filters('em_people_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
64
  }
65
 
classes/em-permalinks.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( !class_exists('EM_Permalinks') ){
4
+ class EM_Permalinks {
5
+
6
+ static $em_queryvars = array(
7
+ 'event_id', 'event_slug',
8
+ 'location_id', 'location_slug',
9
+ 'person_id',
10
+ 'booking_id',
11
+ 'category_id', 'category_slug',
12
+ 'ticket_id',
13
+ 'calendar_day',
14
+ 'book',
15
+ 'rss','ical', 'scope', 'page'
16
+ );
17
+ static $scopes = 'today|tomorrow|this\-month|next\-month|past|all|future';
18
+
19
+ function init(){
20
+ add_filter('pre_update_option_dbem_events_page', array('EM_Permalinks','option_update'));
21
+ add_filter('init', array('EM_Permalinks','flush'));
22
+ add_filter('rewrite_rules_array',array('EM_Permalinks','rewrite_rules_array'));
23
+ add_filter('query_vars',array('EM_Permalinks','query_vars'));
24
+ add_action('template_redirect',array('EM_Permalinks','init_objects'));
25
+ add_action('template_redirect',array('EM_Permalinks','redirection'));
26
+ //Add filters to rewrite the URLs
27
+ add_filter('em_event_output_placeholder',array('EM_Permalinks','rewrite_urls'),1,3);
28
+ add_filter('em_location_output_placeholder',array('EM_Permalinks','rewrite_urls'),1,3);
29
+ }
30
+
31
+ function flush(){
32
+ global $wp_rewrite;
33
+ if( get_option('dbem_flush_needed') ){
34
+ $wp_rewrite->flush_rules();
35
+ delete_option('dbem_flush_needed');
36
+ }
37
+ }
38
+
39
+ function rewrite_urls($replace, $object, $result){
40
+ global $wp_query, $wp_rewrite;
41
+ if( $wp_rewrite->using_permalinks() ){
42
+ switch( $result ){
43
+ case '#_EVENTPAGEURL': //Depreciated
44
+ case '#_LINKEDNAME': //Depreciated
45
+ case '#_EVENTURL': //Just the URL
46
+ case '#_EVENTLINK': //HTML Link
47
+ if( is_object($object) && get_class($object)=='EM_Event' ){
48
+ $event_link = trailingslashit(trailingslashit(EM_URI).'event/'.$object->slug);
49
+ if($result == '#_LINKEDNAME' || $result == '#_EVENTLINK'){
50
+ $replace = "<a href='{$event_link}' title='{$object->name}'>{$object->name}</a>";
51
+ }else{
52
+ $replace = $event_link;
53
+ }
54
+ }
55
+ break;
56
+ case '#_LOCATIONURL':
57
+ case '#_LOCATIONLINK':
58
+ case '#_LOCATIONPAGEURL': //Depreciated
59
+ if( is_object($object) && get_class($object)=='EM_Location' ){
60
+ $link = trailingslashit(trailingslashit(EM_URI).'location/'.$object->slug);
61
+ $replace = ($result == '#_LOCATIONURL' || $result == '#_LOCATIONPAGEURL') ? $link : '<a href="'.$link.'">'.$object->name.'</a>';
62
+ }
63
+ break;
64
+ }
65
+ }
66
+ return $replace;
67
+ }
68
+
69
+ /**
70
+ * will redirect old links to new link structures.
71
+ * @return mixed
72
+ */
73
+ function redirection(){
74
+ global $wp_rewrite, $post, $wp_query;
75
+ if( $wp_rewrite->using_permalinks() && !is_admin() ){
76
+ //is this a querystring url?
77
+ $events_page_id = get_option ( 'dbem_events_page' );
78
+ if ( is_object($post) && $post->ID == $events_page_id && $events_page_id != 0 ) {
79
+ $page = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : '';
80
+ if ( !empty($_GET['calendar_day']) ) {
81
+ //Events for a specific day
82
+ wp_redirect( self::url($_GET['calendar_day'],$page), 301);
83
+ exit();
84
+ } elseif ( !empty($_GET['location_id']) && is_numeric($_GET['location_id']) ) {
85
+ //Just a single location
86
+ wp_redirect( self::url('location', $_GET['location_id'],$page), 301);
87
+ exit();
88
+ } elseif ( !empty($_GET['location_slug']) ) {
89
+ //Just a single location with slug
90
+ wp_redirect( self::url('location', $_GET['location_slug'],$page), 301);
91
+ exit();
92
+ } elseif ( !empty($_GET['book']) && !empty($_GET['event_id']) ) {
93
+ //bookings page
94
+ wp_redirect( self::url('book', $_GET['event_id']), 301);
95
+ exit();
96
+ } elseif ( !empty($_GET['event_id']) && is_numeric($_GET['event_id']) ) {
97
+ //single event page
98
+ wp_redirect( self::url('event', $_GET['event_id']), 301);
99
+ exit();
100
+ } elseif ( !empty($_GET['event_slug']) ) {
101
+ //single event page with slug
102
+ wp_redirect( self::url('event', $_GET['event_slug']), 301);
103
+ exit();
104
+ } elseif ( !empty($_GET['category_id']) && is_numeric($_GET['category_id']) ){
105
+ //category page
106
+ wp_redirect( self::url('category', $_GET['category_id'], $page), 301);
107
+ exit();
108
+ } elseif ( !empty($_GET['category_slug']) ){
109
+ //category page with slug
110
+ wp_redirect( self::url('category', $_GET['category_slug'], $page), 301);
111
+ exit();
112
+ } elseif( !empty($_GET['scope']) ) {
113
+ // Multiple events page
114
+ wp_redirect( self::url($_GET['scope'], $page), 301);
115
+ exit();
116
+ }
117
+ }elseif( !empty($_GET['dbem_rss']) ){
118
+ //RSS page
119
+ wp_redirect( self::url('rss'), 301);
120
+ exit();
121
+ }
122
+ }
123
+ }
124
+ // Adding a new rule
125
+ function rewrite_rules_array($rules){
126
+ //get the slug of the event page
127
+ $events_page_id = get_option ( 'dbem_events_page' );
128
+ $events_page = get_post($events_page_id);
129
+ $em_rules = array();
130
+ if( is_object($events_page) ){
131
+ $events_slug = $events_page->post_name;
132
+ $em_rules[$events_slug.'/('.self::$scopes.')$'] = 'index.php?pagename='.$events_slug.'&scope=$matches[1]'; //events with scope
133
+ $em_rules[$events_slug.'/(\d{4}-\d{2}-\d{2})$'] = 'index.php?pagename='.$events_slug.'&calendar_day=$matches[1]'; //event calendar date search
134
+ $em_rules[$events_slug.'/event/(\d*)$'] = 'index.php?pagename='.$events_slug.'&event_id=$matches[1]'; //single event page with id
135
+ $em_rules[$events_slug.'/event/book/(\d*)$'] = 'index.php?pagename='.$events_slug.'&event_id=$matches[1]&book=1'; //single event booking form with id
136
+ $em_rules[$events_slug.'/event/book/(.+)$'] = 'index.php?pagename='.$events_slug.'&event_slug=$matches[1]&book=1'; //single event booking form with slug
137
+ $em_rules[$events_slug.'/event/(.+)$'] = 'index.php?pagename='.$events_slug.'&event_slug=$matches[1]'; //single event page with slug
138
+ $em_rules[$events_slug.'/location/(\d*)$'] = 'index.php?pagename='.$events_slug.'&location_id=$matches[1]'; //location page with id
139
+ $em_rules[$events_slug.'/location/(.+)$'] = 'index.php?pagename='.$events_slug.'&location_slug=$matches[1]'; //location page with slug
140
+ $em_rules[$events_slug.'/category/(.+)$'] = 'index.php?pagename='.$events_slug.'&category_id=$matches[1]'; //category page with id
141
+ $em_rules[$events_slug.'/category/(.+)$'] = 'index.php?pagename='.$events_slug.'&category_slug=$matches[1]'; //category page with slug
142
+ $em_rules[$events_slug.'/rss$'] = 'index.php?pagename='.$events_slug.'&rss=1'; //rss page
143
+ $em_rules[$events_slug.'/ical$'] = 'index.php?pagename='.$events_slug.'&ical=1'; //ical page
144
+ $em_rules[$events_slug.'/(\d+)$'] = 'index.php?pagename='.$events_slug.'&page=$matches[1]'; //event pageno
145
+ }
146
+ return $em_rules + $rules;
147
+ }
148
+
149
+ /**
150
+ * Generate a URL. Pass each section of a link as a parameter, e.g. EM_Permalinks::url('event',$event_id); will create an event link.
151
+ * @param mixed
152
+ */
153
+ function url(){
154
+ $args = func_get_args();
155
+ $em_uri = ( !defined('EM_URI') ) ? get_permalink(get_option("dbem_events_page")):EM_URI; //PAGE URI OF EM
156
+ $event_link = trailingslashit(trailingslashit($em_uri). implode('/',$args));
157
+ return $event_link;
158
+ }
159
+
160
+ /**
161
+ * checks if the events page has changed, and sets a flag to flush wp_rewrite.
162
+ * @param mixed $val
163
+ * @return mixed
164
+ */
165
+ function option_update( $val ){
166
+ if( get_option('dbem_events_page') != $val ){
167
+ update_option('dbem_flush_needed',1);
168
+ }
169
+ return $val;
170
+ }
171
+
172
+ // Adding the id var so that WP recognizes it
173
+ function query_vars($vars){
174
+ foreach(self::$em_queryvars as $em_queryvar){
175
+ array_push($vars, $em_queryvar);
176
+ }
177
+ return $vars;
178
+ }
179
+
180
+ /**
181
+ * Not the "WP way" but for now this'll do!
182
+ */
183
+ function init_objects(){
184
+ //Build permalinks here
185
+ global $wp_query, $wp_rewrite;
186
+ if ( $wp_rewrite->using_permalinks() ) {
187
+ foreach(self::$em_queryvars as $em_queryvar){
188
+ if( $wp_query->get($em_queryvar) ) {
189
+ $_REQUEST[$em_queryvar] = $wp_query->get($em_queryvar);
190
+ }
191
+ }
192
+ }
193
+ //dirty rss condition
194
+ if( !empty($_REQUEST['rss']) ){
195
+ $_REQUEST['rss_main'] = 'main';
196
+ }
197
+ }
198
+ }
199
+ EM_Permalinks::init();
200
+ }
classes/em-person.php CHANGED
@@ -1,110 +1,30 @@
1
  <?php
2
  // TODO make person details more secure and integrate with WP user data
3
- class EM_Person extends EM_Object{
4
- //DB Fields
5
- var $id = '';
6
- var $owner = '';
7
- var $name = '';
8
- var $email = '';
9
- var $phone = '';
10
- //Other Vars
11
- var $fields = array(
12
- 'person_id' => array('name'=>'id','type'=>'%d'),
13
- 'person_name' => array('name'=>'name','type'=>'%s'),
14
- 'person_email' => array('name'=>'email','type'=>'%s'),
15
- 'person_phone' => array('name'=>'phone','type'=>'%s')
16
- );
17
- var $required_fields = array('person_id', 'person_name', 'person_email', 'person_phone');
18
- var $feedback_message = "";
19
- var $errors = array();
20
 
21
- function EM_Person( $person_data = false ){
22
- if( $person_data != 0 ){
23
- //Load person data
24
- $person = array();
25
- if( is_array($person_data) ){
26
- $person = $person_data;
27
- }elseif( is_numeric($person_data) ){
28
- //Retreiving from the database
29
- global $wpdb;
30
- $sql = "SELECT * FROM ". $wpdb->prefix . EM_PEOPLE_TABLE ." WHERE person_id ='$person_data'";
31
- $person = $wpdb->get_row($sql, ARRAY_A);
32
- }
33
- //Save into the object
34
- $this->to_object($person);
35
- }
36
- }
37
-
38
- /**
39
- * Load an record into this object by passing an associative array of table criterie to search for.
40
- * Returns boolean depending on whether a record is found or not.
41
- * @param $search
42
- * @return boolean
43
- */
44
- function get($search) {
45
- global $wpdb;
46
- $conds = array();
47
- foreach($search as $key => $value) {
48
- if( array_key_exists($key, $this->fields) ){
49
- $conds[] = "`$key`='$value'";
50
- }
51
- }
52
- $sql = "SELECT * FROM ". $wpdb->prefix.EM_PEOPLE_TABLE ." WHERE " . implode(' AND ', $conds) ;
53
- $result = $wpdb->get_row($sql, ARRAY_A);
54
- if($result){
55
- $this->to_object($result);
56
- return true;
57
- }else{
58
- return false;
59
- }
60
- }
61
-
62
- function get_post(){
63
- $this->name = ( !empty($_REQUEST['person_name']) ) ? stripslashes($_REQUEST['person_name']) : '' ;
64
- $this->email = ( !empty($_REQUEST['person_email']) ) ? $_REQUEST['person_email'] : '';
65
- $this->phone = ( !empty($_REQUEST['person_phone']) ) ? $_REQUEST['person_phone'] : '';
66
- return apply_filters('em_person_get_post', $this->validate(), $this);
67
- }
68
-
69
- function save(){
70
- global $wpdb;
71
- do_action('em_person_save_pre',$this);
72
- if($this->validate()){
73
- //Does this person already exist?
74
- $this->load_similar();
75
- $table = $wpdb->prefix.EM_PEOPLE_TABLE;
76
- $data = $this->to_array();
77
- unset($data['person_id']);
78
- if($this->id != ''){
79
- $where = array( 'person_id' => $this->id );
80
- $result = $wpdb->update($table, $data, $where);
81
  }else{
82
- $result = $wpdb->insert($table, $data);
83
- $this->id = $wpdb->insert_id;
84
  }
85
- $this->feedback_message = ($result) ? __('Changes saved.'): __('Could not edit person details.','dbem');
86
- return apply_filters('em_save_delete', $result, $this);
87
- }else{
88
- $this->feedback_message = __('Could not edit person details.','dbem');
89
- return apply_filters('em_save_delete', false, $this);
90
  }
91
- }
92
-
93
- function delete(){
94
- global $wpdb;
95
- do_action('em_person_delete_pre', $this);
96
- $results = array();
97
- $results[] = $wpdb->query ( $wpdb->prepare("DELETE FROM ". $wpdb->prefix . EM_PEOPLE_TABLE ." WHERE person_id=%d", $this->id) );
98
- $results[] = $wpdb->query ( $wpdb->prepare("DELETE FROM ". $wpdb->prefix . EM_BOOKINGS_TABLE ." WHERE person_id=%d", $this->id) );
99
- return apply_filters('em_event_delete', !in_array(false,$results), $this);
100
- }
101
-
102
- function validate(){
103
- if( !preg_match('/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/', $this->email) ){
104
- $this->errors[] = __('Please provide a valid email address.', 'dbem');
105
- return false;
106
  }
107
- return true;
 
108
  }
109
 
110
  function get_bookings(){
@@ -114,41 +34,36 @@ class EM_Person extends EM_Object{
114
  foreach($results as $booking_data){
115
  $bookings[] = new EM_Booking($booking_data);
116
  }
117
- return $bookings;
118
  }
119
-
120
  /**
121
- * Checks agains the database to see if this user exists already
122
- * @return boolean|int
123
  */
124
- function find_similar(){
125
  global $wpdb;
126
- $sql = "SELECT * FROM ". $wpdb->prefix.EM_PEOPLE_TABLE ." WHERE person_name='%s' AND person_email='%s' AND person_phone='%s'";
127
- $row = $wpdb->get_row( $wpdb->prepare($sql, array($this->name, $this->email, $this->phone)), ARRAY_A );
128
- if( is_array($row) ){
129
- return $row['person_id'];
130
  }
131
- return false;
132
  }
133
 
134
- /**
135
- * Checks if a similar record exists (same name, email and phone) and if so it loads
136
- * @return boolean
137
- */
138
- function load_similar(){
139
- $return = $this->find_similar();
140
- if( is_numeric($return) ){
141
- $this->id = $return;
142
- return true;
143
- }
144
- return false;
145
- }
146
-
147
- /**
148
- * Can the user manage this event?
149
- */
150
- function can_manage(){
151
- return ( get_option('dbem_permissions_events') || $this->owner == get_current_user_id() || em_verify_admin() );
152
  }
153
  }
154
  ?>
1
  <?php
2
  // TODO make person details more secure and integrate with WP user data
3
+ class EM_Person extends WP_User{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ function EM_Person( $person_id = false, $username = false ){
6
+ if( is_array($person_id) ){
7
+ if( array_key_exists('person_id',$person_id) ){
8
+ $person_id = $person_id['person_id'];
9
+ }elseif ( array_key_exists('user_id',$person_id) ){
10
+ $person_id = $person_id['user_id'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }else{
12
+ $person_id = $person_id['ID'];
 
13
  }
14
+ }elseif( is_object($person_id) && get_class($person_id) == 'WP_User'){
15
+ $person_id = $person_id->ID; //create new object if passed a wp_user
 
 
 
16
  }
17
+ if($username){
18
+ parent::WP_User($person_id, $username);
19
+ }elseif($person_id === 0){
20
+ $this->ID = 0;
21
+ $this->display_name = 'Unregistered Booking';
22
+ $this->user_email = 'n/a';
23
+ }else{
24
+ parent::WP_User($person_id);
 
 
 
 
 
 
 
25
  }
26
+ $this->phone = get_metadata('user', $this->ID, 'dbem_phone', true); //extra field for EM
27
+ do_action('em_person',$this, $person_id, $username);
28
  }
29
 
30
  function get_bookings(){
34
  foreach($results as $booking_data){
35
  $bookings[] = new EM_Booking($booking_data);
36
  }
37
+ return new EM_Bookings($bookings);
38
  }
39
+
40
  /**
41
+ * @return EM_Events
 
42
  */
43
+ function get_events(){
44
  global $wpdb;
45
+ $events = array();
46
+ foreach( $this->get_bookings()->get_bookings() as $EM_Booking ){
47
+ $events[$EM_Booking->event_id] = $EM_Booking->get_event();
 
48
  }
49
+ return $events;
50
  }
51
 
52
+ function display_summary(){
53
+ ob_start();
54
+ ?>
55
+ <table>
56
+ <tr>
57
+ <td><?php echo get_avatar($this->ID); ?></td>
58
+ <td style="padding-left:10px; vertical-align: top;">
59
+ <strong>Name</strong> : <?php echo $this->display_name; ?><br /><br />
60
+ <strong>Email</strong> : <?php echo $this->user_email; ?><br /><br />
61
+ <strong>Phone</strong> : <?php echo $this->phone; ?>
62
+ </td>
63
+ </tr>
64
+ </table>
65
+ <?php
66
+ return ob_get_clean();
 
 
 
67
  }
68
  }
69
  ?>
classes/em-recurrence.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * Object that holds event recurrence info
4
- * The EM_Event objects will handle adding / editing / deleting recurrences, this just holds the recurring info
5
- * and provides extra functions to obtain related events.
6
- * @author marcus
7
- */
8
- class EM_Recurrence extends EM_Object{
9
- //TODO We NEED to add an author and rsvp to this recurrence.....
10
- var $fields = array(
11
- 'recurrence_id' => 'id',
12
- 'recurrence_author' => 'author',
13
- 'recurrence_name' => 'name',
14
- 'recurrence_start_time' => 'start_time',
15
- 'recurrence_end_time' => 'end_time',
16
- 'recurrence_start_date' => 'start_date',
17
- 'recurrence_end_date' => 'end_date',
18
- 'recurrence_notes' => 'notes',
19
- 'recurrence_rsvp' => 'rsvp',
20
- 'recurrence_seats' => 'seats',
21
- 'recurrence_contactperson_id' => 'contactperson_id',
22
- 'location_id' => 'location_id',
23
- 'recurrence_id' => 'recurrence_id',
24
- 'recurrence_category_id' => 'category_id',
25
- 'recurrence_attributes' => 'attributes',
26
- 'recurrence_interval' => 'interval',
27
- 'recurrence_freq' => 'freq',
28
- 'recurrence_byday' => 'byday',
29
- 'recurrence_byweekno' => 'byweekno',
30
- );
31
- /**
32
- * Array of EM_Event objects
33
- * @var array
34
- */
35
- var $events = array();
36
-
37
- /**
38
- * Initialize object. You can provide event data in an associative array (using database table field names), an id number, or false (default) to create empty event.
39
- * If you provide an event array or object, it will convert it into a recurrence (useful if you want to change event data into recurrence).
40
- * @param mixed $event_data
41
- * @return null
42
- */
43
- function EM_Recurrence($event_data = false) {
44
- global $wpdb;
45
- if( $event_data !== false ){
46
- $recurrence = array();
47
- if( is_array($event_data) && isset($event_data['recurrence_name']) ){
48
- //Directly inserting array of recurrence data
49
- $recurrence = $event_data;
50
- }elseif( is_numeric($event_data) || isset($event_data['recurrence_id']) ){
51
- //$event_data is recurrence_id - Retreiving from the database
52
- $recurrence_id = (is_array($event_data)) ? $event_data['recurrence_id']:$event_data;
53
- $sql = "SELECT * FROM ". $wpdb->prefix . EM_RECURRENCE_TABLE ." WHERE recurrence_id = $recurrence_id";
54
- $result = $wpdb->get_row( $sql, ARRAY_A );
55
- if($result){
56
- $this->location = new EM_Location ( $recurrence ['location_id'] );
57
- $recurrence = $result;
58
- }
59
- }
60
- $this->to_object($recurrence);
61
- }
62
- }
63
-
64
- /**
65
- * Removes recurrence record.
66
- * @param $recurrence_id
67
- * @return null
68
- */
69
- function delete() {
70
- global $wpdb;
71
- $sql = "DELETE FROM ".$wpdb->prefix.EM_RECURRENCE_TABLE." WHERE recurrence_id = '{$this->id}';";
72
- $wpdb->query($sql);
73
- }
74
-
75
- /**
76
- * Save an array into this class
77
- * @param $array
78
- * @return null
79
- */
80
- function to_object( $array = array() ){
81
- //Save event core data
82
- parent::to_object($array);
83
- //Save location info
84
- $this->location = new EM_Location($array['location_id']);
85
- //Save contact person info
86
- }
87
-
88
- }
89
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/em-ticket-booking.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EM_Ticket_Booking extends EM_Object{
3
+ //DB Fields
4
+ var $id;
5
+ var $booking_id;
6
+ var $ticket_id;
7
+ var $price;
8
+ var $spaces;
9
+ var $fields = array(
10
+ 'ticket_booking_id' => array('name'=>'id','type'=>'%d'),
11
+ 'ticket_id' => array('name'=>'ticket_id','type'=>'%d'),
12
+ 'booking_id' => array('name'=>'booking_id','type'=>'%d'),
13
+ 'ticket_booking_price' => array('name'=>'price','type'=>'%f'),
14
+ 'ticket_booking_spaces' => array('name'=>'spaces','type'=>'%d')
15
+ );
16
+ //Other Vars
17
+ /**
18
+ * Contains ticket object
19
+ * @var EM_Ticket
20
+ */
21
+ var $ticket;
22
+ /**
23
+ * Contains the booking object of this
24
+ * @var EM_Booking
25
+ */
26
+ var $booking;
27
+ var $required_fields = array( 'ticket_id', 'ticket_booking_spaces');
28
+
29
+ /**
30
+ * Creates ticket object and retreives ticket data (default is a blank ticket object). Accepts either array of ticket data (from db) or a ticket id.
31
+ * @param mixed $ticket_data
32
+ * @return null
33
+ */
34
+ function EM_Ticket_Booking( $ticket_data = false ){
35
+ if( $ticket_data !== false ){
36
+ //Load ticket data
37
+ $ticket = array();
38
+ if( is_array($ticket_data) ){
39
+ $ticket = $ticket_data;
40
+ }elseif( is_numeric($ticket_data) ){
41
+ //Retreiving from the database
42
+ global $wpdb;
43
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_TICKETS_BOOKINGS_TABLE ." WHERE ticket_booking_id ='$ticket_data'";
44
+ $ticket = $wpdb->get_row($sql, ARRAY_A);
45
+ }
46
+ //Save into the object
47
+ $this->to_object($ticket);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Saves the ticket into the database, whether a new or existing ticket
53
+ * @return boolean
54
+ */
55
+ function save(){
56
+ global $wpdb;
57
+ $table = $wpdb->prefix. EM_TICKETS_BOOKINGS_TABLE;
58
+ do_action('em_ticket_booking_save_pre',$this);
59
+ //First the person
60
+ if($this->validate()){
61
+ //Now we save the ticket
62
+ $this->booking_id = $this->get_booking()->id; //event wouldn't exist before save, so refresh id
63
+ $data = $this->to_array(true); //add the true to remove the nulls
64
+ if($this->id != ''){
65
+ $where = array( 'ticket_booking_id' => $this->id );
66
+ $result = $wpdb->update($table, $data, $where, $this->get_types($data));
67
+ $this->feedback_message = __('Changes saved','dbem');
68
+ }else{
69
+ //TODO better error handling
70
+ $result = $wpdb->insert($table, $data, $this->get_types($data));
71
+ $this->id = $wpdb->insert_id;
72
+ $this->feedback_message = __('Ticket booking created','dbem');
73
+ }
74
+ if( $result === false ){
75
+ $this->feedback_message = __('There was a problem saving the ticket booking.', 'dbem');
76
+ $this->errors[] = __('There was a problem saving the ticket booking.', 'dbem');
77
+ }
78
+ return apply_filters('em_ticket_booking_save', ( count($this->errors) == 0 ), $this);
79
+ }else{
80
+ $this->feedback_message = __('There was a problem saving the ticket booking.', 'dbem');
81
+ $this->errors[] = __('There was a problem saving the ticket booking.', 'dbem');
82
+ return apply_filters('em_ticket_booking_save', false, $this);
83
+ }
84
+ return true;
85
+ }
86
+
87
+
88
+ /**
89
+ * Validates the ticket for saving. Should be run during any form submission or saving operation.
90
+ * @return boolean
91
+ */
92
+ function validate(){
93
+ $missing_fields = Array ();
94
+ foreach ( $this->required_fields as $field ) {
95
+ $true_field = $this->fields[$field]['name'];
96
+ if ( $this->$true_field == "") {
97
+ $missing_fields[] = $field;
98
+ }
99
+ }
100
+ if ( count($missing_fields) > 0){
101
+ // TODO Create friendly equivelant names for missing fields notice in validation
102
+ $this->errors[] = __ ( 'Missing fields: ' ) . implode ( ", ", $missing_fields ) . ". ";
103
+ }
104
+ return apply_filters('em_event_validate', count($this->errors) == 0, $this );
105
+ }
106
+
107
+ /**
108
+ * Get the total number of spaces booked for this ticket within this booking.
109
+ * @return int
110
+ */
111
+ function get_spaces(){
112
+ return apply_filters('em_booking_get_spaces',$this->spaces,$this);
113
+ }
114
+
115
+ /**
116
+ * Gets the total price for this whole booking. Seting $force_reset to true will recheck spaces, even if previously done so.
117
+ * @param boolean $force_refresh
118
+ * @return float
119
+ */
120
+ function get_price( $force_refresh=false ){
121
+ if( $force_refresh || $this->price == 0 ){
122
+ //get the ticket, clculate price on spaces
123
+ $this->price = $this->get_ticket()->get_price() * $this->spaces;
124
+ }
125
+ return apply_filters('em_booking_get_prices',$this->price,$this);
126
+ }
127
+
128
+ /**
129
+ * Smart event locator, saves a database read if possible.
130
+ */
131
+ function get_booking(){
132
+ global $EM_Booking;
133
+ if( is_object($this->booking) && get_class($this->booking)=='EM_Booking' && ($this->booking->id == $this->booking_id || (empty($this->id) && empty($this->booking_id))) ){
134
+ return $this->booking;
135
+ }elseif( is_object($EM_Booking) && $EM_Booking->id == $this->booking_id ){
136
+ $this->booking = $EM_Booking;
137
+ }else{
138
+ if(is_numeric($this->booking_id)){
139
+ $this->booking = new EM_Booking($this->booking_id);
140
+ }else{
141
+ $this->booking = new EM_Booking();
142
+ }
143
+ }
144
+ return apply_filters('em_ticket_booking_get_booking', $this->booking, $this);;
145
+ }
146
+
147
+ /**
148
+ * Gets the ticket object this booking belongs to, saves a reference in ticket property
149
+ * @return EM_Ticket
150
+ */
151
+ function get_ticket(){
152
+ global $EM_Ticket;
153
+ if( is_object($this->ticket) && get_class($this->ticket)=='EM_Ticket' && $this->ticket->id == $this->ticket_id ){
154
+ return $this->ticket;
155
+ }elseif( is_object($EM_Ticket) && $EM_Ticket->id == $this->ticket_id ){
156
+ $this->ticket = $EM_Ticket;
157
+ }else{
158
+ $this->ticket = new EM_Ticket($this->ticket_id);
159
+ }
160
+ return $this->ticket;
161
+ }
162
+
163
+ /**
164
+ * I wonder what this does....
165
+ * @return boolean
166
+ */
167
+ function delete(){
168
+ global $wpdb;
169
+ $sql = $wpdb->prepare("DELETE FROM ". $wpdb->prefix.EM_TICKETS_BOOKINGS_TABLE . " WHERE ticket_booking_id=%d", $this->id);
170
+ $result = $wpdb->query( $sql );
171
+ return apply_filters('em_ticket_booking_delete', ($result !== false ), $this);
172
+ }
173
+
174
+
175
+ /**
176
+ * Get the html options for quantities to go within a <select> container
177
+ * @return string
178
+ */
179
+ function get_spaces_options($zero_value = true){
180
+ $available_spaces = $this->get_available_spaces();
181
+ if( $available_spaces >= $this->min || ( empty($this->min) && $available_spaces > 0) ) {
182
+ ob_start();
183
+ ?>
184
+ <select name="em_tickets[<?php echo $this->id ?>][spaces]">
185
+ <?php
186
+ $min = ($this->min > 0) ? $this->min:1;
187
+ $max = ($this->max > 0) ? $this->max:get_option('dbem_bookings_form_max');
188
+ ?>
189
+ <?php if($zero_value) : ?><option>0</option><?php endif; ?>
190
+ <?php for( $i=$min; $i<=$max; $i++ ): ?>
191
+ <option><?php echo $i ?></option>
192
+ <?php endfor; ?>
193
+ </select>
194
+ <?php
195
+ return ob_get_clean();
196
+ }else{
197
+ return false;
198
+ }
199
+
200
+ }
201
+
202
+ /**
203
+ * Can the user manage this event?
204
+ */
205
+ function can_manage(){
206
+ return ( $this->get_booking()->can_manage() );
207
+ }
208
+ }
209
+ ?>
classes/em-ticket.php ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EM_Ticket extends EM_Object{
3
+ //DB Fields
4
+ var $id;
5
+ var $event_id;
6
+ var $name;
7
+ var $description;
8
+ var $price;
9
+ var $start;
10
+ var $end;
11
+ var $min;
12
+ var $max;
13
+ var $spaces;
14
+ var $fields = array(
15
+ 'ticket_id' => array('name'=>'id','type'=>'%d'),
16
+ 'event_id' => array('name'=>'event_id','type'=>'%d'),
17
+ 'ticket_name' => array('name'=>'name','type'=>'%s'),
18
+ 'ticket_description' => array('name'=>'description','type'=>'%s','null'=>1),
19
+ 'ticket_price' => array('name'=>'price','type'=>'%f','null'=>1),
20
+ 'ticket_start' => array('name'=>'start','type'=>'%s','null'=>1),
21
+ 'ticket_end' => array('name'=>'end','type'=>'%s','null'=>1),
22
+ 'ticket_min' => array('name'=>'min','type'=>'%s','null'=>1),
23
+ 'ticket_max' => array('name'=>'max','type'=>'%s','null'=>1),
24
+ 'ticket_spaces' => array('name'=>'spaces','type'=>'%s','null'=>1)
25
+ );
26
+ //Other Vars
27
+ /**
28
+ * @var EM_Event
29
+ */
30
+ var $event;
31
+ /**
32
+ * Contains only bookings belonging to this ticket.
33
+ * @var EM_Booking
34
+ */
35
+ var $bookings = array();
36
+ var $required_fields = array('ticket_name');
37
+ var $start_timestamp;
38
+ var $end_timestamp;
39
+ /**
40
+ * is this ticket limited by spaces allotted to this ticket? false if no limit (i.e. the events general limit of seats)
41
+ * @var unknown_type
42
+ */
43
+ var $spaces_limit = true;
44
+
45
+ /**
46
+ * Creates ticket object and retreives ticket data (default is a blank ticket object). Accepts either array of ticket data (from db) or a ticket id.
47
+ * @param mixed $ticket_data
48
+ * @return null
49
+ */
50
+ function EM_Ticket( $ticket_data = false ){
51
+ if( $ticket_data !== false ){
52
+ //Load ticket data
53
+ $ticket = array();
54
+ if( is_array($ticket_data) ){
55
+ $ticket = $ticket_data;
56
+ }elseif( is_numeric($ticket_data) ){
57
+ //Retreiving from the database
58
+ global $wpdb;
59
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_TICKETS_TABLE ." WHERE ticket_id ='$ticket_data'";
60
+ $ticket = $wpdb->get_row($sql, ARRAY_A);
61
+ //Ticket notes
62
+ $notes = $wpdb->get_results("SELECT * FROM ". $wpdb->prefix . EM_META_TABLE ." WHERE meta_key='ticket-note' AND object_id ='$ticket_data'", ARRAY_A);
63
+ foreach($notes as $note){
64
+ $this->notes[] = unserialize($note['meta_value']);
65
+ }
66
+ }
67
+ //Save into the object
68
+ $this->to_object($ticket);
69
+ $this->start_timestamp = (!empty($ticket['ticket_start'])) ? strtotime($ticket['ticket_start']):false;
70
+ $this->end_timestamp = (!empty($ticket['ticket_end'])) ? strtotime($ticket['ticket_end']):false;
71
+ }
72
+ do_action('em_ticket',$this, $ticket_data);
73
+ }
74
+
75
+ /**
76
+ * Saves the ticket into the database, whether a new or existing ticket
77
+ * @return boolean
78
+ */
79
+ function save(){
80
+ global $wpdb;
81
+ $table = $wpdb->prefix.EM_TICKETS_TABLE;
82
+ do_action('em_ticket_save_pre',$this);
83
+ //First the person
84
+ if($this->validate() && $this->can_manage() ){
85
+ //Now we save the ticket
86
+ $this->event_id = $this->get_event()->id; //event wouldn't exist before save, so refresh id
87
+ $data = $this->to_array(true); //add the true to remove the nulls
88
+ if($this->id != ''){
89
+ //since currently wpdb calls don't accept null, let's build the sql ourselves.
90
+ $set_array = array();
91
+ foreach( $this->fields as $field_name => $field ){
92
+ if( empty($this->$field['name']) && $field['null'] ){
93
+ $set_array[] = "{$field_name}=NULL";
94
+ }else{
95
+ $set_array[] = "{$field_name}='".$wpdb->escape($this->$field['name'])."'";
96
+ }
97
+ }
98
+ $sql = "UPDATE $table SET ".implode(', ', $set_array)." WHERE ticket_id={$this->id}";
99
+ $result = $wpdb->query($sql);
100
+ $this->feedback_message = __('Changes saved','dbem');
101
+ }else{
102
+ //TODO better error handling
103
+ $result = $wpdb->insert($table, $data, $this->get_types($data));
104
+ $this->id = $wpdb->insert_id;
105
+ $this->feedback_message = __('Ticket created','dbem');
106
+ }
107
+ if( $result === false ){
108
+ $this->feedback_message = __('There was a problem saving the ticket.', 'dbem');
109
+ $this->errors[] = __('There was a problem saving the ticket.', 'dbem');
110
+ }
111
+ return apply_filters('em_ticket_save', ( count($this->errors) == 0 ), $this);
112
+ }else{
113
+ $this->feedback_message = __('There was a problem saving the ticket.', 'dbem');
114
+ $this->errors[] = __('There was a problem saving the ticket.', 'dbem');
115
+ return apply_filters('em_ticket_save', false, $this);
116
+ }
117
+ return true;
118
+ }
119
+
120
+ /**
121
+ * Get posted data and save it into the object (not db)
122
+ * @return boolean
123
+ */
124
+ function get_post(){
125
+ //We are getting the values via POST or GET
126
+ do_action('em_location_get_post_pre', $this);
127
+ $location = array();
128
+ $location['ticket_id'] = ( !empty($_POST['ticket_id']) ) ? $_POST['ticket_id']:'';
129
+ $location['event_id'] = ( !empty($_POST['event_id']) ) ? $_POST['event_id']:'';
130
+ $location['ticket_name'] = ( !empty($_POST['ticket_name']) ) ? stripslashes($_POST['ticket_name']):'';
131
+ $location['ticket_description'] = ( !empty($_POST['ticket_description']) ) ? stripslashes($_POST['ticket_description']):'';
132
+ $location['ticket_price'] = ( !empty($_POST['ticket_price']) ) ? $_POST['ticket_price']:'';
133
+ $location['ticket_start'] = ( !empty($_POST['ticket_start']) ) ? $_POST['ticket_start']:'';
134
+ $location['ticket_end'] = ( !empty($_POST['ticket_end']) ) ? $_POST['ticket_end']:'';
135
+ $this->start_timestamp = ( !empty($_POST['ticket_start']) ) ? strtotime($_POST['ticket_start']):'';
136
+ $this->end_timestamp = ( !empty($_POST['ticket_end']) ) ? strtotime($_POST['ticket_end']):'';
137
+ $location['ticket_min'] = ( !empty($_POST['ticket_min']) ) ? $_POST['ticket_min']:'';
138
+ $location['ticket_max'] = ( !empty($_POST['ticket_max']) ) ? $_POST['ticket_max']:'';
139
+ $location['ticket_spaces'] = ( !empty($_POST['ticket_spaces']) ) ? $_POST['ticket_spaces']:'';
140
+ $this->to_object( apply_filters('em_location_get_post', $location, $this) );
141
+ }
142
+
143
+
144
+ /**
145
+ * Validates the ticket for saving. Should be run during any form submission or saving operation.
146
+ * @return boolean
147
+ */
148
+ function validate(){
149
+ $missing_fields = Array ();
150
+ foreach ( $this->required_fields as $field ) {
151
+ $true_field = $this->fields[$field]['name'];
152
+ if ( $this->$true_field == "") {
153
+ $missing_fields[] = $field;
154
+ }
155
+ }
156
+ if ( count($missing_fields) > 0){
157
+ // TODO Create friendly equivelant names for missing fields notice in validation
158
+ $this->errors[] = __ ( 'Missing fields: ' ) . implode ( ", ", $missing_fields ) . ". ";
159
+ }
160
+ return apply_filters('em_event_validate', count($this->errors) == 0, $this );
161
+ }
162
+
163
+ function is_available(){
164
+ $timestamp = current_time('timestamp');
165
+ $available_spaces = $this->get_available_spaces();
166
+ $val = (empty($this->start) || $this->start_timestamp <= $timestamp);
167
+ $val2 = ($this->end_timestamp >= $timestamp || empty($this->end));
168
+ $val3 = $this->get_event()->end > current_time('timestamp');
169
+
170
+ if( (empty($this->start) || $this->start_timestamp <= $timestamp) && ($this->end_timestamp >= $timestamp || empty($this->end)) && $this->get_event()->end > current_time('timestamp') ){
171
+ //Time Constraints met, now quantities
172
+ if( $available_spaces > 0 && ($available_spaces >= $this->min || empty($this->min)) ){
173
+ return apply_filters('em_ticket_is_available',true,$this);
174
+ }
175
+ }
176
+ return apply_filters('em_ticket_is_available',false,$this);
177
+ }
178
+
179
+ /**
180
+ * Gets the total price for this ticket.
181
+ * @return float
182
+ */
183
+ function get_price(){
184
+ return apply_filters('em_ticket_get_prices',$this->price,$this);
185
+ }
186
+
187
+ /**
188
+ * Get the total number of tickets (spaces) available, bearing in mind event-wide maxiumums and ticket priority settings.
189
+ * @return int
190
+ */
191
+ function get_spaces(){
192
+ return apply_filters('em_ticket_get_spaces',$this->spaces,$this);
193
+ }
194
+
195
+ /**
196
+ * Returns the number of available spaces left in this ticket, bearing in mind event-wide restrictions, previous bookings, approvals and other tickets.
197
+ * @return int
198
+ */
199
+ function get_available_spaces(){
200
+ $event_available_spaces = $this->get_event()->get_bookings()->get_available_spaces();
201
+ $ticket_available_spaces = $this->get_spaces() - $this->get_booked_spaces();
202
+ $return = ($ticket_available_spaces <= $event_available_spaces) ? $ticket_available_spaces:$event_available_spaces;
203
+ return apply_filters('em_ticket_get_available_spaces', $return, $this);
204
+ }
205
+
206
+ /**
207
+ * Returns the number of available spaces left in this ticket, bearing in mind event-wide restrictions, previous bookings, approvals and other tickets.
208
+ * @return int
209
+ */
210
+ function get_booked_spaces($force_reload=false){
211
+ //get all bookings for this event
212
+ $spaces = 0;
213
+ if( is_object($this->bookings) && $force_reload ){
214
+ return $this->bookings;
215
+ }
216
+ foreach( $this->get_bookings()->get_bookings()->bookings as $EM_Booking ){ //get_bookings() is used twice so we get the confirmed (or all if confirmation disabled) bookings of this ticket's total bookings.
217
+ //foreach booking, get this ticket booking info if found
218
+ foreach($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking){
219
+ if( $EM_Ticket_Booking->ticket_id == $this->id ){
220
+ $spaces += $EM_Ticket_Booking->get_spaces();
221
+ }
222
+ }
223
+ }
224
+ return apply_filters('em_ticket_get_available_spaces', $spaces, $this);
225
+ }
226
+
227
+ /**
228
+ * Smart event locator, saves a database read if possible.
229
+ * @return EM_Event
230
+ */
231
+ function get_event(){
232
+ global $EM_Event;
233
+ if( is_object($this->event) && get_class($this->event)=='EM_Event' && ($this->event->id == $this->event_id || empty($this->event_id)) ){
234
+ return $this->event;
235
+ }elseif( is_object($EM_Event) && $EM_Event->id == $this->event_id ){
236
+ $this->event = $EM_Event;
237
+ }else{
238
+ $this->event = new EM_Event($this->event_id);
239
+ }
240
+ return $this->event;
241
+ }
242
+
243
+ /**
244
+ * returns array of EM_Booking objects that have this ticket
245
+ * @return EM_Bookings
246
+ */
247
+ function get_bookings(){
248
+ $bookings = array();
249
+ foreach( $this->get_event()->get_bookings()->bookings as $EM_Booking ){
250
+ foreach($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking){
251
+ if( $EM_Ticket_Booking->ticket_id == $this->id ){
252
+ $bookings[$EM_Booking->id] = $EM_Booking;
253
+ }
254
+ }
255
+ }
256
+ $this->bookings = new EM_Bookings($bookings);
257
+ return $this->bookings;
258
+ }
259
+
260
+ /**
261
+ * I wonder what this does....
262
+ * @return boolean
263
+ */
264
+ function delete(){
265
+ global $wpdb;
266
+ $result = false;
267
+ if( $this->can_manage() ){
268
+ if( count($this->get_bookings()->bookings) == 0 ){
269
+ $sql = $wpdb->prepare("DELETE FROM ". $wpdb->prefix.EM_TICKETS_TABLE . " WHERE ticket_id=%d", $this->id);
270
+ $result = $wpdb->query( $sql );
271
+ }else{
272
+ $this->feedback_message = __('You cannot delete a ticket that has a booking on it.','dbem');
273
+ return false;
274
+ }
275
+ }
276
+ return ( $result !== false );
277
+ }
278
+
279
+ /**
280
+ * Get the html options for quantities to go within a <select> container
281
+ * @return string
282
+ */
283
+ function get_spaces_options($zero_value = true){
284
+ $available_spaces = $this->get_available_spaces();
285
+ if( $this->is_available() ) {
286
+ ob_start();
287
+ ?>
288
+ <select name="em_tickets[<?php echo $this->id ?>][spaces]">
289
+ <?php
290
+ $min = ($this->min > 0) ? $this->min:1;
291
+ $max = ($this->max > 0) ? $this->max:get_option('dbem_bookings_form_max');
292
+ ?>
293
+ <?php if($zero_value) : ?><option>0</option><?php endif; ?>
294
+ <?php for( $i=$min; $i<=$available_spaces && $i<=$max; $i++ ): ?>
295
+ <option><?php echo $i ?></option>
296
+ <?php endfor; ?>
297
+ </select>
298
+ <?php
299
+ return ob_get_clean();
300
+ }else{
301
+ return false;
302
+ }
303
+
304
+ }
305
+
306
+ /**
307
+ * Can the user manage this event?
308
+ */
309
+ function can_manage(){
310
+ return $this->get_event()->can_manage('manage_bookings','manage_others_bookings');
311
+ }
312
+
313
+ /**
314
+ * Outputs properties with formatting
315
+ * @param string $property
316
+ * @return string
317
+ */
318
+ function output_property($property){
319
+ switch($property){
320
+ case 'start':
321
+ $value = date_i18n( get_option('date_format'), $this->start_timestamp );
322
+ break;
323
+ case 'end':
324
+ $value = date_i18n( get_option('date_format'), $this->end_timestamp );
325
+ break;
326
+ default:
327
+ $value = $this->$property;
328
+ break;
329
+ }
330
+ return apply_filters('em_ticket_output_property',$value,$this);
331
+ }
332
+ }
333
+ ?>
classes/em-tickets-bookings.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Deals with the each ticket booked in a single booking
4
+ * @author marcus
5
+ *
6
+ */
7
+ class EM_Tickets_Bookings extends EM_Object{
8
+
9
+ /**
10
+ * Array of EM_Ticket_Booking objects for a specific event
11
+ * @var array
12
+ */
13
+ var $tickets_bookings = array();
14
+ /**
15
+ * This object belongs to this booking object
16
+ * @var EM_Booking
17
+ */
18
+ var $booking;
19
+ /**
20
+ * This object belongs to this booking object
21
+ * @var EM_Ticket
22
+ */
23
+ var $ticket;
24
+ var $spaces;
25
+ var $price;
26
+
27
+ /**
28
+ * Creates an EM_Tickets instance,
29
+ * @param EM_Event $event
30
+ * @return null
31
+ */
32
+ function EM_Tickets_Bookings( $object = false ){
33
+ global $wpdb;
34
+ if($object){
35
+ if( is_object($object) && get_class($object) == "EM_Booking"){
36
+ $this->booking = $object;
37
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_TICKETS_BOOKINGS_TABLE ." bt LEFT JOIN ". $wpdb->prefix . EM_BOOKINGS_TABLE ." b ON bt.booking_id=b.booking_id WHERE b.booking_id ='{$this->booking->id}'";
38
+ }elseif( is_object($object) && get_class($object) == "EM_Ticket"){
39
+ $this->ticket = $object;
40
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_TICKETS_BOOKINGS_TABLE ." bt LEFT JOIN ". $wpdb->prefix . EM_TICKETS_TABLE ." t ON bt.ticket_id=t.ticket_id WHERE t.ticket_id ='{$this->ticket->id}'";
41
+ }elseif( is_numeric($object) ){
42
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_TICKETS_BOOKINGS_TABLE ." bt LEFT JOIN ". $wpdb->prefix . EM_BOOKINGS_TABLE ." t ON bt.booking_id=b.booking_id WHERE b.booking_id ='{$object}'";
43
+ }
44
+ $tickets_bookings = $wpdb->get_results($sql, ARRAY_A);
45
+ //Get tickets belonging to this tickets booking.
46
+ foreach ($tickets_bookings as $ticket_booking){
47
+ $EM_Ticket_Booking = new EM_Ticket_Booking($ticket_booking);
48
+ $EM_Ticket_Booking->booking = $this->booking; //save some calls
49
+ $this->tickets_bookings[] = $EM_Ticket_Booking;
50
+ }
51
+ }
52
+ do_action('em_tickets_bookings',$this, $object);
53
+ }
54
+
55
+ /**
56
+ * Saves the ticket bookings for this booking into the database, whether a new or existing booking
57
+ * @return boolean
58
+ */
59
+ function save(){
60
+ global $wpdb;
61
+ do_action('em_tickets_bookings_save_pre',$this);
62
+ foreach( $this->tickets_bookings as $EM_Ticket_Booking ){
63
+ $result = $EM_Ticket_Booking->save();
64
+ if(!$result){
65
+ $this->errors = array_merge($this->errors, $EM_Ticket_Booking->get_errors());
66
+ }
67
+ }
68
+ if( count($this->errors) > 0 ){
69
+ $this->feedback_message = __('There was a problem saving the booking.', 'dbem');
70
+ $this->errors[] = __('There was a problem saving the booking.', 'dbem');
71
+ return apply_filters('em_tickets_bookings_save', false, $this);
72
+ }
73
+ return apply_filters('em_tickets_bookings_save', true, $this);
74
+ }
75
+
76
+ /**
77
+ * Add a booking into this event object, checking that there's enough space for the event
78
+ * @param EM_Ticket_Booking $EM_Ticket_Booking
79
+ * @return boolean
80
+ */
81
+ function add( $EM_Ticket_Booking ){
82
+ global $wpdb,$EM_Mailer;
83
+ //Does the ticket we want to book have enough spaeces?
84
+ if( $EM_Ticket_Booking->get_spaces() > 0 ){
85
+ if ( $EM_Ticket_Booking->get_ticket()->get_available_spaces() >= $EM_Ticket_Booking->get_spaces() ) {
86
+ $this->tickets_bookings[] = $EM_Ticket_Booking;
87
+ $this->get_spaces(true);
88
+ $this->get_price(true);
89
+ return apply_filters('em_tickets_bookings_add',true,$this);
90
+ } else {
91
+ $this->errors[] = __('Booking cannot be made, not enough spaces available!', 'dbem');
92
+ return apply_filters('em_tickets_bookings_add',false,$this);
93
+ }
94
+ }
95
+ return apply_filters('em_tickets_bookings_add',false,$this);
96
+ }
97
+
98
+ /**
99
+ * Smart event locator, saves a database read if possible.
100
+ */
101
+ function get_booking(){
102
+ global $EM_Booking;
103
+ $booking_id = $this->get_booking_id();
104
+ if( is_object($this->booking) && get_class($this->booking)=='EM_Booking' && $this->booking->id == $booking_id ){
105
+ return $this->booking;
106
+ }elseif( is_object($EM_Booking) && $EM_Booking->id == $booking_id ){
107
+ $this->booking = $EM_Booking;
108
+ }else{
109
+ if(is_numeric($booking_id)){
110
+ $this->booking = new EM_Booking($booking_id);
111
+ }else{
112
+ $this->booking = new EM_Booking();
113
+ }
114
+ }
115
+ return apply_filters('em_tickets_bookings_get_booking', $this->booking, $this);;
116
+ }
117
+
118
+ function get_booking_id(){
119
+ if( count($this->tickets_bookings) > 0 ){
120
+ foreach($this->tickets_bookings as $EM_Booking_Ticket){ break; } //get first array item
121
+ return apply_filters('em_tickets_bookings_get_booking_id', $EM_Booking_Ticket->id, $this);
122
+ }
123
+ return apply_filters('em_tickets_bookings_get_booking_id', false, $this);
124
+ }
125
+
126
+ /**
127
+ * Delete all ticket bookings
128
+ * @return boolean
129
+ */
130
+ function delete(){
131
+ global $wpdb;
132
+ if( is_object($this->get_booking()) && $this->get_booking()->can_manage() ){
133
+ $result = $wpdb->query("DELETE FROM ".$wpdb->prefix.EM_TICKETS_BOOKINGS_TABLE." WHERE booking_id='{$this->booking->id}'");
134
+ }else{
135
+ //FIXME ticket bookings
136
+ $ticket_ids = array();
137
+ foreach( $this->tickets_bookings as $EM_Ticket_Booking ){
138
+ if( $EM_Ticket_Booking->can_manage() ){
139
+ $tickets_bookings_ids[] = $EM_Ticket_Booking->id;
140
+ }else{
141
+ $this->errors[] = sprintf(__('You do not have the rights to manage this %s.','dbem'),__('Booking','dbem'));
142
+ }
143
+ }
144
+ if(count($ticket_ids) > 0){
145
+ $result = $wpdb->query("DELETE FROM ".$wpdb->prefix.EM_TICKETS_BOOKINGS_TABLE." WHERE ticket_booking_id IN (".implode(',',$ticket_ids).")");
146
+ }
147
+ }
148
+ return apply_filters('em_tickets_bookings_get_booking_id', ($result == true), $this);
149
+ }
150
+
151
+ /**
152
+ * Retrieve multiple ticket info via POST
153
+ * @return boolean
154
+ */
155
+ function get_post(){
156
+ //Build Event Array
157
+ do_action('em_tickets_get_post_pre', $this);
158
+ $this->tickets = array(); //clean current tickets out
159
+ if( !empty($_POST['em_tickets']) && is_array($_POST['em_tickets']) ){
160
+ //get all ticket data and create objects
161
+ foreach($_POST['em_tickets'] as $ticket_data){
162
+ $EM_Ticket = new EM_Ticket($ticket_data);
163
+ $this->tickets[] = $EM_Ticket;
164
+ }
165
+ }elseif( is_object($this->booking) ){
166
+ //we create a blank standard ticket
167
+ $EM_Ticket = new EM_Ticket(array(
168
+ 'event_id' => $this->booking->id,
169
+ 'ticket_name' => __('Standard','dbem')
170
+ ));
171
+ $this->tickets[] = $EM_Ticket;
172
+ }
173
+ return apply_filters('em_tickets_bookings_get_post', $this->validate(), $this);
174
+ }
175
+
176
+ /**
177
+ * Go through the tickets in this object and validate them
178
+ */
179
+ function validate(){
180
+ $errors = array();
181
+ foreach($this->tickets_bookings as $EM_Ticket_Booking){
182
+ $errors[] = $EM_Ticket_Booking->validate();
183
+ }
184
+ return apply_filters('em_tickets_bookings_validate', !in_array(false, $errors), $this);
185
+ }
186
+
187
+ /**
188
+ * Get the total number of spaces booked in this booking. Seting $force_reset to true will recheck spaces, even if previously done so.
189
+ * @param unknown_type $force_refresh
190
+ * @return mixed
191
+ */
192
+ function get_spaces( $force_refresh=false ){
193
+ if($force_refresh || $this->spaces == 0){
194
+ $spaces = 0;
195
+ foreach($this->tickets_bookings as $EM_Ticket_Booking){
196
+ $spaces += $EM_Ticket_Booking->get_spaces();
197
+ }
198
+ $this->spaces = $spaces;
199
+ }
200
+ return apply_filters('em_booking_get_spaces',$this->spaces,$this);
201
+ }
202
+
203
+ /**
204
+ * Gets the total price for this whole booking by adding up subtotals of booked tickets. Seting $force_reset to true will recheck spaces, even if previously done so.
205
+ * @param boolean $force_refresh
206
+ * @return float
207
+ */
208
+ function get_price( $force_refresh=false ){
209
+ $price = 0;
210
+ if($force_refresh || $this->price == 0){
211
+ foreach($this->tickets_bookings as $EM_Ticket_Booking){
212
+ $price += $EM_Ticket_Booking->get_price();
213
+ }
214
+ $this->price = $price;
215
+ }
216
+ return apply_filters('em_booking_get_prices',$this->price,$this);
217
+ }
218
+
219
+ /**
220
+ * Goes through each ticket and populates it with the bookings made
221
+ */
222
+ function get_ticket_bookings(){
223
+ foreach( $this->tickets as $EM_Ticket ){
224
+ $EM_Ticket->get_bookings();
225
+ }
226
+ }
227
+
228
+ /* Overrides EM_Object method to apply a filter to result
229
+ * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
230
+ */
231
+ function build_sql_conditions( $args = array() ){
232
+ $conditions = apply_filters( 'em_tickets_build_sql_conditions', parent::build_sql_conditions($args), $args );
233
+ if( is_numeric($args['status']) ){
234
+ $conditions['status'] = 'ticket_status='.$args['status'];
235
+ }
236
+ return apply_filters('em_tickets_bookings_build_sql_conditions', $conditions, $args);
237
+ }
238
+
239
+ /* Overrides EM_Object method to apply a filter to result
240
+ * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
241
+ */
242
+ function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
243
+ return apply_filters( 'em_tickets_bookings_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order')), $args, $accepted_fields, $default_order );
244
+ }
245
+
246
+ /*
247
+ * Adds custom Events search defaults
248
+ * @param array $array
249
+ * @return array
250
+ * @uses EM_Object#get_default_search()
251
+ */
252
+ function get_default_search( $array = array() ){
253
+ $defaults = array(
254
+ 'status' => false,
255
+ 'person' => true //to add later, search by person's tickets...
256
+ );
257
+ $defaults['owner'] = !current_user_can('manage_others_bookings') ? get_current_user_id():false;
258
+ return apply_filters('em_tickets_bookings_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
259
+ }
260
+ }
261
+ ?>
classes/em-tickets.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Deals with the ticket info for an event
4
+ * @author marcus
5
+ *
6
+ */
7
+ class EM_Tickets extends EM_Object{
8
+
9
+ /**
10
+ * Array of EM_Ticket objects for a specific event
11
+ * @var array
12
+ */
13
+ var $tickets = array();
14
+ /**
15
+ * Event ID
16
+ * @var EM_Event
17
+ */
18
+ var $event;
19
+ /**
20
+ * @var EM_Booking
21
+ */
22
+ var $booking;
23
+ var $spaces;
24
+
25
+
26
+ /**
27
+ * Creates an EM_Tickets instance,
28
+ * @param EM_Event $event
29
+ * @return null
30
+ */
31
+ function EM_Tickets( $object = false ){
32
+ global $wpdb;
33
+ if( is_object($object) && get_class($object) == "EM_Event" ){ //Creates a blank tickets object if needed
34
+ $this->event = $object;
35
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_TICKETS_TABLE ." WHERE event_id ='{$this->event->id}'";
36
+ $tickets = $wpdb->get_results($sql, ARRAY_A);
37
+ foreach ($tickets as $ticket){
38
+ $EM_Ticket = new EM_Ticket($ticket);
39
+ $EM_Ticket->event = $this->event;
40
+ $this->tickets[] = $EM_Ticket;
41
+ }
42
+ }elseif( is_object($object) && get_class($object) == "EM_Booking"){
43
+ $this->booking = $object;
44
+ $this->event = $this->booking->get_event();
45
+ $sql = "SELECT * FROM ". $wpdb->prefix . EM_TICKETS_TABLE ." t LEFT JOIN ". $wpdb->prefix . EM_BOOKINGS_TICKETS_TABLE ." bt ON bt.ticket_id=t.ticket_id WHERE booking_id ='{$EM_Booking->id}'";
46
+ $tickets = $wpdb->get_results($sql, ARRAY_A);
47
+ foreach ($tickets as $ticket){
48
+ $EM_Ticket = new EM_Ticket($ticket);
49
+ $EM_Ticket->event = $this->event;
50
+ $this->tickets[] = $EM_Ticket;
51
+ }
52
+ }
53
+ do_action('em_tickets', $this, $object);
54
+ }
55
+
56
+ /**
57
+ * @return EM_Event
58
+ */
59
+ function get_event(){
60
+ return $this->event;
61
+ }
62
+
63
+ /**
64
+ * Get the first EM_Ticket object in this instance. Returns false if no tickets available.
65
+ * @return EM_Ticket
66
+ */
67
+ function get_first(){
68
+ if( count($this->tickets) > 0 ){
69
+ foreach($this->tickets as $EM_Ticket){
70
+ return $EM_Ticket;
71
+ }
72
+ }else{
73
+ return false;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Delete tickets on this id
79
+ * @return boolean
80
+ */
81
+ function delete(){
82
+ global $wpdb;
83
+ if( is_object($this->event) ){
84
+ $result = $wpdb->query("DELETE FROM ".$wpdb->prefix.EM_TICKETS_TABLE." WHERE event_id='{$this->event->id}'");
85
+ }else{
86
+ foreach( $this->tickets as $EM_Ticket ){
87
+ $ticket_ids[] = $EM_Ticket->id;
88
+ }
89
+ $result = $wpdb->query("DELETE FROM ".$wpdb->prefix.EM_TICKETS_TABLE." WHERE event_id IN (".implode(',',$ticket_ids).")");
90
+ }
91
+ return ($result == true);
92
+ }
93
+
94
+ /**
95
+ * Retrieve multiple ticket info via POST
96
+ * @return boolean
97
+ */
98
+ function get_post(){
99
+ //Build Event Array
100
+ do_action('em_tickets_get_post_pre', $this);
101
+ $this->tickets = array(); //clean current tickets out
102
+ if( !empty($_POST['em_tickets']) && is_array($_POST['em_tickets']) ){
103
+ //get all ticket data and create objects
104
+ foreach($_POST['em_tickets'] as $ticket_data){
105
+ $EM_Ticket = new EM_Ticket($ticket_data);
106
+ $this->tickets[] = $EM_Ticket;
107
+ }
108
+ }elseif( is_object($this->event) ){
109
+ //we create a blank standard ticket
110
+ $EM_Ticket = new EM_Ticket(array(
111
+ 'event_id' => $this->event->id,
112
+ 'ticket_name' => __('Standard','dbem')
113
+ ));
114
+ $this->tickets[] = $EM_Ticket;
115
+ }
116
+ return apply_filters('em_tickets_get_post', $this->validate(), $this);
117
+ }
118
+
119
+ /**
120
+ * Go through the tickets in this object and validate them
121
+ */
122
+ function validate(){
123
+ $errors = array();
124
+ foreach($this->tickets as $EM_Ticket){
125
+ $errors[] = $EM_Ticket->validate();
126
+ }
127
+ return apply_filters('em_tickets_validate', !in_array(false, $errors), $this);
128
+ }
129
+
130
+ /**
131
+ * Save tickets into DB
132
+ */
133
+ function save(){
134
+ $errors = array();
135
+ foreach( $this->tickets as $EM_Ticket ){
136
+ $EM_Ticket->event = $this->event; //pass on saved event_data
137
+ $errors[] = $EM_Ticket->save();
138
+ }
139
+ return apply_filters('em_tickets_save', !in_array(false, $errors), $this);
140
+ }
141
+
142
+ /**
143
+ * Goes through each ticket and populates it with the bookings made
144
+ */
145
+ function get_ticket_bookings(){
146
+ foreach( $this->tickets as $EM_Ticket ){
147
+ $EM_Ticket->get_bookings();
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Get the total number of spaces this event has. This will show the lower value of event global spaces limit or total ticket spaces. Setting $force_refresh to true will recheck spaces, even if previously done so.
153
+ * @param boolean $force_refresh
154
+ * @return int
155
+ */
156
+ function get_spaces( $force_refresh=false ){
157
+ $spaces = 0;
158
+ if($force_refresh || $this->spaces == 0){
159
+ foreach( $this->tickets as $EM_Ticket ){
160
+ /* @var $EM_Ticket EM_Ticket */
161
+ $spaces += $EM_Ticket->get_spaces();
162
+ }
163
+ $this->spaces = $spaces;
164
+ }
165
+ return apply_filters('em_booking_get_spaces',$this->spaces,$this);
166
+ }
167
+
168
+ /* Overrides EM_Object method to apply a filter to result
169
+ * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_conditions()
170
+ */
171
+ function build_sql_conditions( $args = array() ){
172
+ $conditions = apply_filters( 'em_tickets_build_sql_conditions', parent::build_sql_conditions($args), $args );
173
+ if( is_numeric($args['status']) ){
174
+ $conditions['status'] = 'ticket_status='.$args['status'];
175
+ }
176
+ return apply_filters('em_tickets_build_sql_conditions', $conditions, $args);
177
+ }
178
+
179
+ /* Overrides EM_Object method to apply a filter to result
180
+ * @see wp-content/plugins/events-manager/classes/EM_Object#build_sql_orderby()
181
+ */
182
+ function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
183
+ return apply_filters( 'em_tickets_build_sql_orderby', parent::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order')), $args, $accepted_fields, $default_order );
184
+ }
185
+
186
+ /*
187
+ * Adds custom Events search defaults
188
+ * @param array $array
189
+ * @return array
190
+ * @uses EM_Object#get_default_search()
191
+ */
192
+ function get_default_search( $array = array() ){
193
+ $defaults = array(
194
+ 'status' => false,
195
+ 'person' => true //to add later, search by person's tickets...
196
+ );
197
+ if( is_admin() ){
198
+ //figure out default owning permissions
199
+ $defaults['owner'] = !current_user_can('manage_others_bookings') ? get_current_user_id():false;
200
+ }
201
+ return apply_filters('em_tickets_get_default_search', parent::get_default_search($defaults,$array), $array, $defaults);
202
+ }
203
+ }
204
+ ?>
em-actions.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
4
+ */
5
+ function em_init_actions() {
6
+ //NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
7
+ //TODO Clean this up.... use a uniformed way of calling EM Ajax actions
8
+ if( !empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action']) ){
9
+ if(isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
10
+ if(isset($_REQUEST['id'])){
11
+ $EM_Location = new EM_Location($_REQUEST['id']);
12
+ $location_array = $EM_Location->to_array();
13
+ $location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
14
+ echo EM_Object::json_encode($location_array);
15
+ }
16
+ die();
17
+ }
18
+ if(isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
19
+ if(isset($_REQUEST['id'])){
20
+ $EM_Ticket = new EM_Ticket($_REQUEST['id']);
21
+ $result = $EM_Ticket->delete();
22
+ if($result){
23
+ $result = array('result'=>true);
24
+ }else{
25
+ $result = array('result'=>false, 'error'=>$EM_Ticket->feedback_message);
26
+ }
27
+ }else{
28
+ $result = array('result'=>false, 'error'=>__('No ticket id provided','dbem'));
29
+ }
30
+ echo EM_Object::json_encode($result);
31
+ die();
32
+ }
33
+ if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
34
+ $EM_Locations = EM_Locations::get( $_REQUEST );
35
+ $json_locations = array();
36
+ foreach($EM_Locations as $location_key => $EM_Location) {
37
+ $json_locations[$location_key] = $EM_Location->to_array();
38
+ $json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
39
+ }
40
+ echo EM_Object::json_encode($json_locations);
41
+ die();
42
+ }
43
+
44
+ if(isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
45
+ //FIXME if long events enabled originally, this won't show up on ajax call
46
+ echo EM_Calendar::output($_REQUEST);
47
+ die();
48
+ }
49
+
50
+ //EM Ajax requests require this flag.
51
+ if( is_admin() && is_user_logged_in() ){
52
+ //Admin operations
53
+ global $EM_Booking;
54
+ //TODO multiple deletion won't work in ajax
55
+ if( !empty($_REQUEST['action']) && (!empty($_REQUEST['bookings']) || !empty($_REQUEST['booking_id'])) ){
56
+ $allowed_actions = array('bookings_approve'=>'approve','bookings_reject'=>'reject','bookings_unapprove'=>'unapprove', 'bookings_delete'=>'delete');
57
+ if( array_key_exists($_REQUEST['action'], $allowed_actions) ){
58
+ $action = $allowed_actions[$_REQUEST['action']];
59
+ //Just do it here, since we may be deleting bookings of different events.
60
+ if( !empty($_REQUEST['bookings']) && EM_Object::array_is_numeric($_REQUEST['bookings'])){
61
+ $results = array();
62
+ foreach($_REQUEST['bookings'] as $booking_id){
63
+ $EM_Booking = new EM_Booking($booking_id);
64
+ $result = $EM_Booking->$action();
65
+ $results[] = $result;
66
+ if( !in_array(false, $results) || !$result ){
67
+ $feedback = $EM_Booking->feedback_message;
68
+ }
69
+ }
70
+ $result = !in_array(false,$results);
71
+ }elseif( !empty($_REQUEST['bookings']) && is_numeric($_REQUEST['bookings'])){
72
+ $EM_Booking = new EM_Booking($_REQUEST['bookings']);
73
+ $result = $EM_Booking->$action();
74
+ $feedback = $EM_Booking->feedback_message;
75
+ }elseif( is_object($EM_Booking) ){
76
+ $result = $EM_Booking->$action();
77
+ $feedback = $EM_Booking->feedback_message;
78
+ }
79
+ if( $result ){
80
+ echo $feedback;
81
+ }else{
82
+ echo '<span style="color:red">'.$feedback.'</span>';
83
+ }
84
+ die();
85
+ }
86
+ }
87
+ //Specific Oject Ajax
88
+ if( !empty($_REQUEST['em_obj']) ){
89
+ switch( $_REQUEST['em_obj'] ){
90
+ case 'em_bookings_events_table':
91
+ case 'em_bookings_pending_table':
92
+ case 'em_bookings_confirmed_table':
93
+ call_user_func($_REQUEST['em_obj']);
94
+ break;
95
+ }
96
+ die();
97
+ }
98
+ }
99
+ }
100
+ //Event Actions
101
+ if( !empty($_REQUEST['action']) && substr($_REQUEST['action'],0,5) == 'event' ){
102
+ global $EM_Event, $EM_Notices;
103
+ //Load the event object, with saved event if requested
104
+ if( !empty($_REQUEST['event_id']) ){
105
+ $EM_Event = new EM_Event($_REQUEST['event_id']);
106
+ }else{
107
+ $EM_Event = new EM_Event();
108
+ }
109
+ if( $_REQUEST['action'] == 'event_save' && current_user_can('edit_events') ){
110
+ //Check Nonces
111
+ if( is_admin() ){
112
+ if( !wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save') ) check_admin_referer('trigger_error');
113
+ }else{
114
+ if( !wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save') ) exit('Trying to perform an illegal action.');
115
+ }
116
+ //Grab and validate submitted data
117
+ if ( $EM_Event->get_post() && $EM_Event->save() ) { //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
118
+ $EM_Notices->add_confirm($EM_Event->feedback_message);
119
+ if( is_admin() ){
120
+ $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno']:'';
121
+ $scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope']:'';
122
+ //wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager&pno='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
123
+ }else{
124
+ $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
125
+ wp_redirect( $redirect );
126
+ }
127
+ $events_result = true;
128
+ }else{
129
+ foreach($EM_Event->get_errors() as $error){
130
+ $EM_Notices->add_error( $error );
131
+ }
132
+ $events_result = false;
133
+ }
134
+ }
135
+ if ( $_REQUEST['action'] == 'event_duplicate' ) {
136
+ global $EZSQL_ERROR;
137
+ $EM_Event = $EM_Event->duplicate();
138
+ if( $EM_Event === false ){
139
+ $EM_Notices->add_error($EM_Event->errors, true);
140
+ }else{
141
+ if( $EM_Event->id == $_REQUEST['event_id'] ){
142
+ $EM_Notices->add_confirm($EM_Event->feedback_message ." ". sprintf(__('You are now viewing the duplicated %s.', 'dbem'),__('event','dbem')), true);
143
+ }else{
144
+ $EM_Notices->add_confirm($EM_Event->feedback_message, true);
145
+ }
146
+ }
147
+ }
148
+ if ( $_REQUEST['action'] == 'event_delete' ) {
149
+ //DELETE action
150
+ $selectedEvents = !empty($_REQUEST['events']) ? $_REQUEST['events']:'';
151
+ if( EM_Object::array_is_numeric($selectedEvents) ){
152
+ $events_result = EM_Events::delete( $selectedEvents );
153
+ }elseif( is_object($EM_Event) ){
154
+ $events_result = $EM_Event->delete();
155
+ }
156
+ $plural = (count($selectedEvents) > 1) ? __('Events','dbem'):__('Event','dbem');
157
+ if($events_result){
158
+ $message = ( is_object($EM_Event) ) ? $EM_Event->feedback_message : sprintf(__('%s successfully deleted.','dbem'),$plural);
159
+ $EM_Notices->add_confirm( $message );
160
+ }else{
161
+ $message = ( is_object($EM_Event) ) ? $EM_Event->errors : sprintf(__('%s could not be deleted.','dbem'),$plural);
162
+ $EM_Notices->add_confirm( $message );
163
+ }
164
+ }elseif( $_REQUEST['action'] == 'event_approve' ){
165
+ //Approve Action
166
+ $events_result = $EM_Event->approve();
167
+ if($events_result){
168
+ $EM_Notices->add_confirm( $EM_Event->feedback_message );
169
+ }else{
170
+ $EM_Notices->add_error( $EM_Event->errors );
171
+ }
172
+ }
173
+
174
+ //AJAX Exit
175
+ if( isset($events_result) && !empty($_REQUEST['em_ajax']) ){
176
+ if( $events_result ){
177
+ $return = array('result'=>true, 'message'=>$EM_Event->feedback_message);
178
+ }else{
179
+ $return = array('result'=>false, 'message'=>$EM_Event->feedback_message, 'errors'=>$EM_Event->errors);
180
+ }
181
+ }
182
+ }
183
+
184
+ //Location Actions
185
+ if( !empty($_REQUEST['action']) && substr($_REQUEST['action'],0,8) == 'location' ){
186
+ global $EM_Location, $EM_Notices;
187
+ //Load the location object, with saved event if requested
188
+ if( !empty($_REQUEST['location_id']) ){
189
+ $EM_Location = new EM_Location($_REQUEST['location_id']);
190
+ }else{
191
+ $EM_Location = new EM_Location();
192
+ }
193
+ if( $_REQUEST['action'] == 'location_save' && current_user_can('edit_locations') ){
194
+ //Check Nonces
195
+ em_verify_nonce('location_save');
196
+ //Grab and validate submitted data
197
+ $EM_Location->get_post();
198
+ if ( $EM_Location->save() ) { //EM_location gets the location if submitted via POST and validates it (safer than to depend on JS)
199
+ $EM_Notices->add_confirm($EM_Location->feedback_message);
200
+ $result = true;
201
+ }else{
202
+ foreach($EM_Location->get_errors() as $error){
203
+ $EM_Notices->add_error( $error );
204
+ }
205
+ $result = false;
206
+ }
207
+ }elseif( !empty($_REQUEST['action']) && $_REQUEST['action'] == "location_delete" ){
208
+ //delete location
209
+ //get object or objects
210
+ if( !empty($_REQUEST['locations']) || !empty($_REQUEST['location_id']) ){
211
+ $args = !empty($_REQUEST['locations']) ? $_REQUEST['locations']:$_REQUEST['location_id'];
212
+ $locations = EM_Locations::get($args);
213
+ foreach($locations as $location) {
214
+ if( !$location->delete() ){
215
+ $EM_Notices->add_error($location->get_errors());
216
+ $errors = true;
217
+ }
218
+ }
219
+ if( empty($errors) ){
220
+ $result = true;
221
+ $location_term = ( count($locations) > 1 ) ?__('Locations', 'dbem') : __('Location', 'dbem');
222
+ $EM_Notices->add_confirm( sprintf(__('%s successfully deleted', 'dbem'), $location_term) );
223
+ }else{
224
+ $result = false;
225
+ }
226
+ }
227
+ }
228
+ if( isset($result) && $result && !empty($_REQUEST['em_ajax']) ){
229
+ $return = array('result'=>true, 'message'=>$EM_Location->feedback_message);
230
+ echo EM_Object::json_encode($return);
231
+ die();
232
+ }elseif( isset($result) && !$result && !empty($_REQUEST['em_ajax']) ){
233
+ $return = array('result'=>false, 'message'=>$EM_Location->feedback_message, 'errors'=>$EM_Notices->get_errors());
234
+ echo EM_Object::json_encode($return);
235
+ die();
236
+ }
237
+ }
238
+ }
239
+ add_action('init','em_init_actions');
240
+
241
+ ?>
em-ajax.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- //AJAX function
3
- function em_ajax_actions() {
4
- //TODO Clean this up.... use a uniformed way of calling EM Ajax actions
5
- if( !empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action']) ){
6
- if(isset($_REQUEST['dbem_ajax_action']) && $_REQUEST['dbem_ajax_action'] == 'booking_data') {
7
- if(isset($_REQUEST['id'])){
8
- $EM_Event = new EM_Event($_REQUEST['id']);
9
- echo "[{bookedSeats:".$EM_Event->get_bookings()->get_booked_seats().", availableSeats:".$EM_Event->get_bookings()->get_available_seats()."}]";
10
- }
11
- die();
12
- }
13
- if(isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
14
- if(isset($_REQUEST['id'])){
15
- $EM_Location = new EM_Location($_REQUEST['id']);
16
- $location_array = $EM_Location->to_array();
17
- $location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
18
- echo EM_Object::json_encode($location_array);
19
- }
20
- die();
21
- }
22
- if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
23
- $locations = EM_Locations::get( $_REQUEST );
24
- $json_locations = array();
25
- foreach($locations as $location_key => $location) {
26
- $json_locations[$location_key] = $location->to_array();
27
- $json_locations[$location_key]['location_balloon'] = $location->output(get_option('dbem_map_text_format'));
28
- }
29
- echo EM_Object::json_encode($json_locations);
30
- die();
31
- }
32
-
33
- if(isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
34
- //FIXME if long events enabled originally, this won't show up on ajax call
35
- echo EM_Calendar::output($_REQUEST);
36
- die();
37
- }
38
-
39
- //EM Ajax requests require this flag.
40
- if( is_admin() ){
41
- //Admin operations
42
- //Booking Actions
43
- global $EM_Booking;
44
- if( !empty($_REQUEST['bookings']) || is_object($EM_Booking) ){
45
- if( is_object($EM_Booking) ){
46
- $_REQUEST['bookings'] = $EM_Booking; //small hack to prevent unecessary db reads
47
- }
48
- $EM_Bookings = new EM_Bookings(); //Empty, not bound to event.
49
- if( $_REQUEST['action'] == 'bookings_approve' ){
50
- $EM_Bookings->approve($_REQUEST['bookings']);
51
- echo $EM_Bookings->feedback_message;
52
- die();
53
- }elseif($_REQUEST['action'] == 'bookings_reject'){
54
- $EM_Bookings->reject($_REQUEST['bookings']);
55
- echo $EM_Bookings->feedback_message;
56
- die();
57
- }elseif($_REQUEST['action'] == 'bookings_unapprove'){
58
- $EM_Bookings->unapprove($_REQUEST['bookings']);
59
- echo $EM_Bookings->feedback_message;
60
- die();
61
- }elseif($_REQUEST['action'] == 'bookings_delete'){
62
- //Just do it here, since we may be deleting bookings of different events.
63
- $result = false;
64
- if(EM_Object::array_is_numeric($_REQUEST['bookings'])){
65
- $results = array();
66
- foreach($_REQUEST['bookings'] as $booking_id){
67
- $EM_Booking = new EM_Booking($booking_id);
68
- $results[] = $EM_Booking->delete();
69
- }
70
- $result = !in_array(false,$results);
71
- }elseif( is_numeric($_REQUEST['bookings']) ){
72
- $EM_Booking = new EM_Booking($_REQUEST['bookings']);
73
- $result = $EM_Booking->delete();
74
- }elseif( is_object($EM_Booking) ){
75
- $result = $EM_Booking->delete();
76
- }
77
- if( $result ){
78
- echo __('Booking Deleted','dbem');
79
- }else{
80
- echo '<span style="color:red">'.__('Booking deletion unsuccessful','dbem').'</span>';
81
- }
82
- die();
83
- }
84
- }
85
- //Specific Oject Ajax
86
- if( !empty($_REQUEST['em_obj']) ){
87
- switch( $_REQUEST['em_obj'] ){
88
- case 'em_bookings_events_table':
89
- case 'em_bookings_pending_table':
90
- case 'em_bookings_confirmed_table':
91
- call_user_func($_REQUEST['em_obj']);
92
- break;
93
- }
94
- die();
95
- }
96
- }
97
- }
98
- }
99
- add_action('init','em_ajax_actions');
100
-
101
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
em-bookings.php CHANGED
@@ -1,163 +1,263 @@
1
  <?php
2
- /* Contains functions to handle save and delete requests on the front-end for bookings */
3
- global $dbem_form_messages_booking_delete;
4
- $dbem_form_messages_booking_delete = array();
5
- global $dbem_form_messages_booking_add;
6
- $dbem_form_messages_booking_add = array();
7
-
8
  /**
9
- * Check if there's any actions to take for bookings
10
- * @return null
 
 
 
11
  */
12
- function em_actions_bookings() {
13
- global $dbem_form_messages_booking_delete, $dbem_form_messages_booking_add;
14
- global $wpdb;
15
- global $EM_Event;
16
 
17
- if( @get_class($EM_Event) == 'EM_Event' ){
18
- //ADD/EDIT Booking
19
- if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'add_booking') {
20
- //$EM_Event->get_bookings();
21
- if( $EM_Event->get_bookings()->add( new EM_Booking($_POST) ) ){
22
- $dbem_form_messages_booking_add['success'] = $EM_Event->get_bookings()->feedback_message;
 
 
 
 
 
 
 
 
23
  }else{
24
- $dbem_form_messages_booking_add['error'] = implode('<br />', $EM_Event->get_bookings()->errors);
25
- }
26
- }
27
- //DELETE Booking
28
- if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'delete_booking') {
29
- $EM_Person = new EM_Person();
30
- if( $EM_Person->get(array('person_name' => $_POST['person_name'], 'person_email' => $_POST['person_email'])) ){
31
- $deleted = 0;
32
- foreach($EM_Event->get_bookings()->bookings as $EM_Booking){
33
- if($EM_Booking->person->id == $EM_Person->id ){
34
- $EM_Booking->cancel();
35
- $deleted++;
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
  }
39
- if($deleted > 0){
40
- $dbem_form_messages_booking_delete['success'] = __('Booking deleted', 'dbem');
41
- }else{
42
- $dbem_form_messages_booking_delete['error'] = __('There are no bookings associated to this name and e-mail', 'dbem');
43
  }
44
- }
45
- }
46
- }
47
- add_action('init','em_actions_bookings');
48
-
49
- /**
50
- * Returns the booking form for the front-end, displayed when using placeholder #_ADDBOOKINGFORM
51
- * @return string
52
- */
53
- function em_add_booking_form() {
54
- global $dbem_form_messages_booking_add, $EM_Event;
55
-
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();
63
- ?>
64
- <div id="dbem-rsvp">
65
- <a name="dbem-rsvp"></a>
66
- <h3><?php _e('Book now!','dbem') ?></h3>
67
-
68
- <?php if( !empty($dbem_form_messages_booking_add['success']) ) : ?>
69
- <div class='dbem-rsvp-message-success'><?php echo $dbem_form_messages_booking_add['success'] ?></div>
70
- <?php elseif( !empty($dbem_form_messages_booking_add['error']) ) : ?>
71
- <div class='dbem-rsvp-message-error'><?php echo $dbem_form_messages_booking_add['error'] ?></div>
72
- <?php elseif( !empty($dbem_form_messages_booking_add['message']) ) : ?>
73
- <div class='dbem-rsvp-message'><?php echo $dbem_form_messages_booking_add['message'] ?></div>
74
- <?php endif; ?>
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>
84
- <select name='booking_seats' >
85
- <?php
86
- foreach($booked_places_options as $option) {
87
- echo $option ."\n";
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  ?>
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;
97
- <input type='hidden' name='eventAction' value='add_booking'/>
98
- <input type='hidden' name='event_id' value='<?php echo $EM_Event->id; ?>'/>
99
- </p>
100
- </form>
101
- </div>
102
- <script type="text/javascript">
103
- jQuery(document).ready( function($){
104
- if( $('#dbem-booking-delete').size() > 0 ){
105
- var triggerText = '<?php ( !empty($_POST['eventAction']) && $_POST['eventAction'] == 'delete_booking') ? _e('Hide cancellation form', 'dbem') : _e('Cancel a booking', 'dbem'); ?>';
106
- $('#dbem-rsvp input[type=submit]').after(' <a href="#" id="dbem-booking-cancel">'+triggerText+'</a>');
107
- if( $('#dbem-booking-cancel').html() == '<?php _e('Cancel a booking', 'dbem'); ?>' ) { $('#dbem-booking-delete').hide(); }
108
- $('#dbem-booking-cancel').click( function(event){
109
- event.preventDefault();
110
- if( $('#dbem-booking-cancel').html() == '<?php _e('Cancel a booking', 'dbem'); ?>' ){
111
- $('#dbem-booking-cancel').html('<?php _e('Hide cancellation form', 'dbem'); ?>');
112
- $('#dbem-booking-delete').slideDown();
113
- }else{
114
- $('#dbem-booking-cancel').html('<?php _e('Cancel a booking', 'dbem'); ?>');
115
- $('#dbem-booking-delete').slideUp();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
- });
118
- }
119
- });
120
- </script>
121
- <?php
122
- return ob_get_clean();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
-
125
- /**
126
- * Booking removal in front end, called by placeholder #_REMOVEBOOKINGFORM
127
- * @return string
128
- */
129
- function em_delete_booking_form() {
130
- global $dbem_form_messages_booking_delete, $EM_Event;
131
- $destination = "?".$_SERVER['QUERY_STRING'];
132
- ob_start();
133
- ?>
134
- <div id="dbem-booking-delete">
135
- <a name="dbem-booking-delete"></a>
136
- <h3><?php _e('Cancel your booking', 'dbem') ?></h3>
137
-
138
- <?php if( !empty($dbem_form_messages_booking_delete['success']) ) : ?>
139
- <div class='dbem-rsvp-message-success'><?php echo $dbem_form_messages_booking_delete['success'] ?></div>
140
- <?php elseif( !empty($dbem_form_messages_booking_delete['error']) ) : ?>
141
- <div class='dbem-rsvp-message-error'><?php echo $dbem_form_messages_booking_delete['error'] ?></div>
142
- <?php elseif( !empty($dbem_form_messages_booking_delete['message']) ) : ?>
143
- <div class='dbem-rsvp-message'><?php echo $dbem_form_messages_booking_delete['message'] ?></div>
144
- <?php endif; ?>
145
 
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'/>
156
- <input type='hidden' name='event_id' value='<?php echo $EM_Event->id; ?>'/>
157
- <input type='submit' value='<?php _e('Cancel your booking', 'dbem') ?>'/>
158
- </form>
159
- </div>
160
- <?php
161
- return ob_get_clean();
162
  }
 
163
  ?>
1
  <?php
 
 
 
 
 
 
2
  /**
3
+ * This object is a parent of EM_Bookings_Form, which is extendable by creating a bookings form object and placing the
4
+ * php file in the wp-content/mu-plugins folder (see http://wpmututorials.com/plugins/basics/what-is-the-mu-plugins-folder/ for more info).
5
+ * Since mu-plugin files are executed before this, the EM_Bookings_Form will already be defined and won't be definied here.
6
+ * @author marcus
7
+ *
8
  */
9
+ class EM_Bookings_Form_Core extends EM_Object {
10
+ /* Contains functions to handle save and delete requests on the front-end for bookings */
11
+ static $em_form_messages_booking_cancel = array();
12
+ static $em_form_messages_booking_add = array();
13
 
14
+ function init(){
15
+ add_action('template_redirect', array('EM_Bookings_Form','actions'),100);
16
+ //catch the ajax call
17
+ add_action( 'wp_ajax_add_booking', array('EM_Bookings_Form','ajax_add_booking') );
18
+ }
19
+
20
+ function ajax_add_booking(){
21
+ /* Check the nonce */
22
+ check_admin_referer( 'add_booking', '_wpnonce_add_booking' );
23
+ if( !empty($_REQUEST['event_id']) && is_numeric($_REQUEST['event_id']) ){
24
+ $EM_Event = new EM_Event($_REQUEST['event_id']);
25
+ $result = $EM_Event->get_bookings()->add_from_post();
26
+ if($result){
27
+ $return = array('result'=>true, 'message'=>$EM_Event->get_bookings()->feedback_message);
28
  }else{
29
+ $return = array('result'=>false, 'message'=>implode('<br />', $EM_Event->get_bookings()->errors));
30
+ }
31
+ echo EM_Object::json_encode($return);
32
+ exit();
33
+ }else{
34
+ $return = array('result'=>false, 'message'=>'');
35
+ echo EM_Object::json_encode($return);
36
+ exit();
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Check if there's any actions to take for bookings
42
+ * @return null
43
+ */
44
+ function actions() {
45
+ global $wpdb;
46
+ global $EM_Event, $EM_Person;
47
+ if( @get_class($EM_Event) == 'EM_Event' ){
48
+ //ADD/EDIT Booking
49
+ if (isset($_POST['action']) && $_POST['action'] == 'add_booking') {
50
+ check_admin_referer( 'em_add_booking', '_wpnonce_em_add_booking' );
51
+ $EM_Event->get_bookings()->add_from_post();
52
+ }
53
+ //CANCEL Booking
54
+ if (isset($_POST['action']) && $_POST['action'] == 'cancel_booking') {
55
+ self::cancel_booking();
56
+ }
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Handles booking cancellations on the front end. makes a few extra checks.
62
+ */
63
+ function cancel_booking(){
64
+ global $EM_Event;
65
+ if( is_user_logged_in() ){
66
+ $canceled = 0;
67
+ foreach($EM_Event->get_bookings()->bookings as $EM_Booking){
68
+ if($EM_Booking->person->ID == $EM_Person->ID ){
69
+ $EM_Booking->cancel();
70
+ $canceled++;
71
  }
72
  }
73
+ if($canceled > 0){
74
+ self::$em_form_messages_booking_cancel['success'] = __('Booking cancelled', 'dbem');
 
 
75
  }
76
+ }else{
77
+ self::$em_form_messages_booking_cancel['error'] = __('You must log in to cancel your booking.', 'dbem');
78
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
+
81
+ /**
82
+ * Returns the booking form for the front-end, displayed when using placeholder #_ADDBOOKINGFORM
83
+ * @return string
84
+ */
85
+ function create() {
86
+ global $em_form_messages_booking_add, $EM_Event;
87
+
88
+ $booked_places_options = array();
89
+ for ( $i = 1; $i <= 10; $i++ ) {
90
+ $booking_spaces = (!empty($_POST['booking_spaces']) && $_POST['booking_spaces'] == $i) ? 'selected="selected"':'';
91
+ array_push($booked_places_options, "<option value='$i' $booking_spaces>$i</option>");
92
+ }
93
+ ob_start();
94
+ ?>
95
+ <div id="em-booking">
96
+ <a name="em-booking"></a>
97
+ <h3><?php _e('Book now!','dbem') ?></h3>
98
+
99
+ <?php if( !empty($EM_Event->get_bookings()->feedback_message) && count($EM_Event->get_bookings()->errors) == 0 ) : ?>
100
+ <div class='em-booking-message-success'><?php echo $EM_Event->get_bookings()->feedback_message; ?></div>
101
+ <?php elseif( count($EM_Event->get_bookings()->errors) > 1 ) : ?>
102
+ <div class='em-booking-message-error'><?php echo implode('<br />', $EM_Event->get_bookings()->errors); ?></div>
103
+ <?php elseif( !empty($EM_Event->get_bookings()->feedback_message) ) : ?>
104
+ <div class='em-booking-message'><?php echo $EM_Event->get_bookings()->feedback_message; ?></div>
105
+ <?php endif; ?>
106
+
107
+ <form id='em-booking-form' name='booking-form' method='post' action=''>
108
+ <?php do_action('em_booking_form_before_tickets'); ?>
109
+ <?php
110
+ $EM_Tickets = ( get_option('dbem_bookings_tickets_show_unavailable') ) ? $EM_Event->get_bookings()->get_tickets():$EM_Event->get_bookings()->get_tickets();
111
+ if( (count($EM_Tickets->tickets) > 1 || !empty($EM_Tickets->get_first()->price)) && (get_option('dbem_bookings_tickets_show_loggedout') || is_user_logged_in()) ): ?>
112
+ <table class="em-tickets" cellspacing="0" cellpadding="0">
113
+ <tr>
114
+ <td><?php _e('Ticket Type','dbem') ?></td>
115
+ <td><?php _e('Price','dbem') ?></td>
116
+ <td><?php _e('Spaces','dbem') ?></td>
117
+ </tr>
118
+ <?php foreach( $EM_Tickets->tickets as $EM_Ticket ): ?>
119
+ <?php if( $EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable') ): ?>
120
+ <tr>
121
+ <td><?php echo $EM_Ticket->output_property('name'); ?></td>
122
+ <td><?php echo $EM_Ticket->output_property('price'); ?></td>
123
+ <td>
124
+ <?php
125
+ $spaces_options = $EM_Ticket->get_spaces_options();
126
+ if( $spaces_options ){
127
+ echo $spaces_options;
128
+ }else{
129
+ echo "<strong>".__('N/A','dbem')."</strong>";
130
+ }
131
+ ?>
132
+ </td>
133
+ </tr>
134
+ <?php endif; ?>
135
+ <?php endforeach; ?>
136
+ </table>
137
+ <?php endif; ?>
138
+ <?php do_action('em_booking_form_after_tickets'); ?>
139
+ <?php if( is_user_logged_in() && count($EM_Tickets->tickets) > 0 ) : ?>
140
+ <?php $EM_Ticket = $EM_Tickets->get_first(); ?>
141
+ <table class='em-booking-form-details'>
142
+ <?php if( is_object($EM_Ticket) && (count($EM_Tickets->tickets) == 1 && empty($EM_Tickets->get_first()->price)) ): ?>
143
+ <tr>
144
+ <th scope='row'><?php _e('Spaces', 'dbem') ?>:</th>
145
+ <td>
146
+ <?php
147
+ $spaces_options = $EM_Ticket->get_spaces_options(false);
148
+ if( $spaces_options ){
149
+ echo $spaces_options;
150
+ }else{
151
+ echo "<strong>".__('N/A','dbem')."</strong>";
152
+ }
153
  ?>
154
+ </td>
155
+ </tr>
156
+ <?php endif; ?>
157
+ <?php do_action('em_booking_form_before_user_details'); ?>
158
+ <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>
159
+ <?php do_action('em_booking_form_footer'); ?>
160
+ </table>
161
+ <div class="em-booking-buttons">
162
+ <?php echo apply_filters('em_booking_form_buttons', '<input type="submit" class="em-booking-submit" value="'.__('Send your booking', 'dbem').'" />'); ?>
163
+ <input type='hidden' name='action' value='add_booking'/>
164
+ <input type='hidden' name='callback' value='em'/>
165
+ <input type='hidden' name='event_id' value='<?php echo $EM_Event->id; ?>'/>
166
+ <?php echo wp_nonce_field('add_booking','_wpnonce_add_booking'); ?>
167
+ </div>
168
+ <?php elseif( count($EM_Tickets->tickets) == 0 ): ?>
169
+ <div><?php _e('No more tickets available at this time.','dbem'); ?></div>
170
+ <?php else: ?>
171
+ <div><?php echo sprintf(__('You must <a href="%s">register</a> or <a href="%s">log in</a> in order to create and manage your bookings.','dbem'), site_url('wp-login.php?action=register', 'login_post'), site_url('wp-login.php', 'login_post')); ?></div>
172
+ <?php endif; ?>
173
+ </form>
174
+ </div>
175
+ <?php echo self::get_js(); ?>
176
+ <?php
177
+ return apply_filters('em_bookings_form_create', ob_get_clean());
178
+ }
179
+
180
+ function get_js(){
181
+ ob_start();
182
+ ?>
183
+ <script type="text/javascript">
184
+ jQuery(document).ready( function($){
185
+ $('#em-booking-form').ajaxForm({
186
+ url: EM.ajaxurl,
187
+ dataType: 'jsonp',
188
+ beforeSubmit: function(formData, jqForm, options) {
189
+ $('.em-booking-message').remove();
190
+ $('#em-booking-form').append('<div id="em-loading"></div>');
191
+ },
192
+ success : function(response, statusText, xhr, $form) {
193
+ $('#em-loading').remove();
194
+ if(response.result){
195
+ $('<div class="em-booking-message-success em-booking-message">'+response.message+'</div>').insertBefore('#em-booking-form');
196
+ }else{
197
+ $('<div class="em-booking-message-error em-booking-message">'+response.message+'</div>').insertBefore('#em-booking-form');
198
+
199
+ }
200
  }
201
+ });
202
+ });
203
+ </script>
204
+ <?php
205
+ return apply_filters('em_bookings_form_get_js', ob_get_clean());
206
+ }
207
+
208
+ /**
209
+ * Booking removal in front end, called by placeholder #_REMOVEBOOKINGFORM
210
+ * @return string
211
+ */
212
+ function cancel() {
213
+ global $em_form_messages_booking_cancel, $EM_Event;
214
+ $destination = "?".$_SERVER['QUERY_STRING'];
215
+ ob_start();
216
+ ?>
217
+ <div id="em-booking-delete">
218
+ <a name="em-booking-delete"></a>
219
+ <h3><?php _e('Cancel your booking', 'dbem') ?></h3>
220
+
221
+ <?php if( is_user_logged_in() ): ?>
222
+ <?php if( !empty(self::$em_form_messages_booking_cancel['success']) ) : ?>
223
+ <div class='em-booking-message-success'><?php echo self::$em_form_messages_booking_cancel['success'] ?></div>
224
+ <?php elseif( !empty(self::$em_form_messages_booking_cancel['error']) ) : ?>
225
+ <div class='em-booking-message-error'><?php echo self::$em_form_messages_booking_cancel['error'] ?></div>
226
+ <?php elseif( !empty(self::$em_form_messages_booking_cancel['message']) ) : ?>
227
+ <div class='em-booking-message'><?php echo self::$em_form_messages_booking_add['message'] ?></div>
228
+ <?php endif; ?>
229
+
230
+ <form name='booking-delete-form' method='post' action='<?php echo $destination ?>#em-booking-delete'>
231
+ <input type='hidden' name='em_action' value='delete_booking'/>
232
+ <input type='hidden' name='event_id' value='<?php echo $EM_Event->id; ?>'/>
233
+ <input type='submit' value='<?php _e('Cancel your booking', 'dbem') ?>'/>
234
+ </form>
235
+ <?php else: ?>
236
+ <p>Please <a href="<?php echo site_url('wp-login.php', 'login_post'); ?>">log in</a> to manage your bookings.</p>
237
+ <?php endif; ?>
238
+ </div>
239
+ <?php
240
+ return ob_get_clean();
241
+ }
242
+
243
+ /* AJAX update posting */
244
+ function bp_dtheme_post_update() {
245
+ global $bp;
246
+
247
+ /* Check the nonce */
248
+ check_admin_referer( 'post_update', '_wpnonce_post_update' );
249
+
250
+ if ( !is_user_logged_in() ) {
251
+ echo '-1';
252
+ return false;
253
+ }
254
+ add_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' );
255
+ }
256
  }
257
+ if( !class_exists('EM_Bookings_Form') ){
258
+ class EM_Bookings_Form extends EM_Bookings_Form_Core {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
 
260
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  }
262
+ EM_Bookings_Form::init();
263
  ?>
em-debug.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //set debug mode on.
3
+ function dbem_debug_option($option){
4
+ global $dbem_debug_options;
5
+ return $dbem_debug_options[$option];
6
+ }
7
+
8
+ global $dbem_debug_options;
9
+ $dbem_email_template = str_replace('"', "'", file_get_contents(WP_PLUGIN_DIR.'/events-manager/includes/sample-placeholders/booking-email.html'));
10
+ $dbem_event_format = str_replace('"', "'", file_get_contents(WP_PLUGIN_DIR.'/events-manager/includes/sample-placeholders/event-single.html'));
11
+ $dbem_debug_options = array(
12
+ //Event Formatting
13
+ 'dbem_event_list_item_format' => '<li>#j #M #Y - #H:#i<br/> #_EVENTLINK<br/>#_LOCATIONTOWN </li>',
14
+ 'dbem_single_event_format' => $dbem_event_format,
15
+ //Location Formatting
16
+ 'dbem_location_event_list_item_format' => "<li>#_LOCATIONNAME - #j #M #Y - #H:#i</li>",
17
+ 'dbem_location_list_item_format' => '#_LOCATIONLINK<ul><li>#_LOCATIONADDRESS</li><li>#_LOCATIONTOWN</li></ul>',
18
+ 'dbem_location_no_events_message' => __('<li>No events in this location</li>', 'dbem'),
19
+ 'dbem_single_location_format' => '<p>#_LOCATIONADDRESS</p><p>#_LOCATIONTOWN</p>',
20
+ //General Settings
21
+ //Emails
22
+ 'dbem_bookings_contact_email_subject' => "New booking [DEBUG MODE]",
23
+ 'dbem_bookings_contact_email_body' => $dbem_email_template,
24
+ 'dbem_contactperson_email_cancelled_subject' => "Booking Cancelled [DEBUG MODE]",
25
+ 'dbem_contactperson_email_cancelled_body' => $dbem_email_template,
26
+ 'dbem_bookings_email_pending_subject' => "Booking Pending [DEBUG MODE]",
27
+ 'dbem_bookings_email_pending_body' => $dbem_email_template,
28
+ 'dbem_bookings_email_rejected_subject' => "Booking Rejected [DEBUG MODE]",
29
+ 'dbem_bookings_email_rejected_body' => $dbem_email_template,
30
+ 'dbem_bookings_email_confirmed_subject' => 'Booking Confirmed [DEBUG MODE]',
31
+ 'dbem_bookings_email_confirmed_body' => $dbem_email_template,
32
+ 'dbem_bookings_email_cancelled_subject' => 'Booking Cancelled [DEBUG MODE]',
33
+ 'dbem_bookings_email_cancelled_body' => $dbem_email_template
34
+ );
35
+
36
+ if( get_option('dbem_debug') && !empty($_REQUEST['page']) && $_REQUEST['page'] != 'events-manager-options' ){
37
+ foreach($dbem_debug_options as $debug_option => $value){
38
+ if( !empty($dbem_debug_options[$debug_option]) ){
39
+ add_filter('pre_option_'.$debug_option, create_function('','return "'.$dbem_debug_options[$debug_option].'";'));
40
+ }
41
+ }
42
+ }
43
+ if( is_admin() && get_option('dbem_debug')){
44
+ function em_debug_notification(){ ?><div class="error"><p><strong><?php echo sprintf(__('You are in Events Manager debug mode. To turn debug mode off, go to the <a href="%s">settings</a> page.'), em_add_get_params($_SERVER['REQUEST_URI'], array('dbem_debug_off'=>1))) ?></strong></p></div><?php }
45
+ add_action ( 'admin_notices', 'em_debug_notification' );
46
+ }
em-events.php CHANGED
@@ -9,9 +9,22 @@
9
  * @return string
10
  */
11
  function em_content($content) {
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  $events_page_id = get_option ( 'dbem_events_page' );
13
  if ( get_the_ID() == $events_page_id && $events_page_id != 0 ) {
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
  //general defaults
@@ -24,7 +37,7 @@ function em_content($content) {
24
  if ( !empty($_REQUEST['calendar_day']) ) {
25
  //Events for a specific day
26
  $args['scope'] = $_REQUEST['calendar_day'];
27
- $page = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : 1;
28
  $events = EM_Events::get( apply_filters('em_content_calendar_day_args', $args) ); //Get events first, so we know how many there are in advance
29
  if ( count($events) > 1 || $page > 1 || get_option('dbem_display_calendar_day_single') == 1 ) {
30
  $args['limit'] = get_option('dbem_events_default_limit');
@@ -36,20 +49,23 @@ function em_content($content) {
36
  } else {
37
  $content = get_option('dbem_no_events_message');
38
  }
39
- } elseif ( !empty($_REQUEST['location_id']) && is_numeric($_REQUEST['location_id']) ) {
40
  //Just a single location
41
- $location = new EM_Location($_REQUEST['location_id']);
42
- $content = $location->output_single();
43
- } elseif ( !empty($_REQUEST['event_id']) && is_numeric($_REQUEST['event_id']) ) {
44
- // single event page
45
- $event = new EM_Event( $_REQUEST['event_id'] );
46
- $content = $event->output_single();
47
- } elseif ( !empty($_REQUEST['bookings_id']) ) {
48
  //bookings page
49
- }else {
 
 
 
 
 
 
 
 
50
  // Multiple events page
51
  $scope = ( !empty($_REQUEST['scope']) ) ? EM_Object::sanitize($_REQUEST['scope']) : "future";
52
- //If we have a $_GET['page'] var, use it to calculate the offset/limit ratios (safer than offset/limit get vars)
53
  $args['scope'] = $scope;
54
  if ( !empty($_REQUEST['category_id']) ) $args['category'] = $_REQUEST['category_id'];
55
  if (get_option ( 'dbem_display_calendar_in_events_page' )){
@@ -58,14 +74,12 @@ function em_content($content) {
58
  $content = EM_Calendar::output( apply_filters('em_content_calendar_args', $args) );
59
  }else{
60
  $args['limit'] = get_option('dbem_events_default_limit');
61
- $args['page'] = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : 1;
62
-
63
  /*calculate event list time range */
64
  $time_limit = get_option('dbem_events_page_time_limit');
65
- if ( is_numeric($time_limit) && $time_limit > 0 ){
66
  $args['scope'] = date('Y-m-d').",".date('Y-m-t', strtotime('+'.($time_limit-1).' month'));
67
  }
68
-
69
  $content = EM_Events::output( apply_filters('em_content_events_args', $args) );
70
  }
71
  }
@@ -110,9 +124,16 @@ function em_events_page_title($content) {
110
  }elseif (isset ( $_REQUEST ['location_id'] ) && $_REQUEST ['location_id'] |= '') {
111
  $location = new EM_Location( EM_Object::sanitize($_REQUEST ['location_id']) );
112
  $content = $location->output(get_option( 'dbem_location_page_title_format' ));;
113
- }elseif (isset ( $_REQUEST ['event_id'] ) && $_REQUEST ['event_id'] != '') {
 
 
 
114
  // single event page
115
- $content = $EM_Event->output ( get_option ( 'dbem_event_page_title_format' ) );
 
 
 
 
116
  }else{
117
  // Multiple events page
118
  $content = get_option ( 'dbem_events_page_title' );
9
  * @return string
10
  */
11
  function em_content($content) {
12
+ /*
13
+ echo "<h2>WP_REWRITE</h2>";
14
+ echo "<pre>";
15
+ global $wp_rewrite;
16
+ print_r($wp_rewrite);
17
+ echo "</pre>";
18
+ echo "<h2>WP_QUERY</h2>";
19
+ echo "<pre>";
20
+ global $wp_query;
21
+ print_r($wp_query);
22
+ echo "</pre>";
23
+ die();
24
+ */
25
  $events_page_id = get_option ( 'dbem_events_page' );
26
  if ( get_the_ID() == $events_page_id && $events_page_id != 0 ) {
27
+ global $wpdb, $EM_Event, $EM_Location, $EM_Category;
28
  //TODO FILTER - filter em page content before placeholder replacing
29
  //TODO any loop should put the current $EM_Event etc. into the global variable
30
  //general defaults
37
  if ( !empty($_REQUEST['calendar_day']) ) {
38
  //Events for a specific day
39
  $args['scope'] = $_REQUEST['calendar_day'];
40
+ $page = ( !empty($_REQUEST['page']) && is_numeric($_REQUEST['page']) )? $_REQUEST['page'] : 1;
41
  $events = EM_Events::get( apply_filters('em_content_calendar_day_args', $args) ); //Get events first, so we know how many there are in advance
42
  if ( count($events) > 1 || $page > 1 || get_option('dbem_display_calendar_day_single') == 1 ) {
43
  $args['limit'] = get_option('dbem_events_default_limit');
49
  } else {
50
  $content = get_option('dbem_no_events_message');
51
  }
52
+ } elseif ( is_object($EM_Location) ) {
53
  //Just a single location
54
+ $content = $EM_Location->output_single();
55
+ } elseif ( is_object($EM_Event) && !empty($_REQUEST['book']) ) {
 
 
 
 
 
56
  //bookings page
57
+ $content = $EM_Event->output( get_option('dbem_bookings_page') );
58
+ } elseif ( is_object($EM_Event) ) {
59
+ // single event page
60
+ if( $EM_Event->status == 1 ){
61
+ $content = $EM_Event->output_single();
62
+ }else{
63
+ $content = get_option('dbem_no_events_message');
64
+ }
65
+ } else {
66
  // Multiple events page
67
  $scope = ( !empty($_REQUEST['scope']) ) ? EM_Object::sanitize($_REQUEST['scope']) : "future";
68
+ //If we have a $_REQUEST['page'] var, use it to calculate the offset/limit ratios (safer than offset/limit get vars)
69
  $args['scope'] = $scope;
70
  if ( !empty($_REQUEST['category_id']) ) $args['category'] = $_REQUEST['category_id'];
71
  if (get_option ( 'dbem_display_calendar_in_events_page' )){
74
  $content = EM_Calendar::output( apply_filters('em_content_calendar_args', $args) );
75
  }else{
76
  $args['limit'] = get_option('dbem_events_default_limit');
77
+ $args['page'] = (!empty($_REQUEST['page']) && is_numeric($_REQUEST['page']) )? $_REQUEST['page'] : 1;
 
78
  /*calculate event list time range */
79
  $time_limit = get_option('dbem_events_page_time_limit');
80
+ if ( is_numeric($time_limit) && $time_limit > 0 && $scope == 'future'){
81
  $args['scope'] = date('Y-m-d').",".date('Y-m-t', strtotime('+'.($time_limit-1).' month'));
82
  }
 
83
  $content = EM_Events::output( apply_filters('em_content_events_args', $args) );
84
  }
85
  }
124
  }elseif (isset ( $_REQUEST ['location_id'] ) && $_REQUEST ['location_id'] |= '') {
125
  $location = new EM_Location( EM_Object::sanitize($_REQUEST ['location_id']) );
126
  $content = $location->output(get_option( 'dbem_location_page_title_format' ));;
127
+ }elseif ( is_object($EM_Event) && !empty($_REQUEST['book']) ) {
128
+ //bookings page
129
+ $content = $EM_Event->output( get_option('dbem_bookings_page_title') );
130
+ }elseif ( is_object($EM_Event) ) {
131
  // single event page
132
+ if( $EM_Event->status == 1 ){
133
+ $content = $EM_Event->output ( get_option ( 'dbem_event_page_title_format' ) );
134
+ }else{
135
+ $content = get_option('dbem_events_page_title');
136
+ }
137
  }else{
138
  // Multiple events page
139
  $content = get_option ( 'dbem_events_page_title' );
em-functions.php CHANGED
@@ -1,26 +1,4 @@
1
  <?php
2
- //simple backwards compatability for WP 2.x ... since it's only this function to get it down to 2.9.1
3
- if( !function_exists('get_current_user_id') ){
4
- function get_current_user_id() {
5
- $user = wp_get_current_user();
6
- return ( isset( $user->ID ) ? (int) $user->ID : 0 );
7
- }
8
- }
9
-
10
- /**
11
- * Currently, just is_super_admin() but allows scalability of permissions now.
12
- * @param int $user_id
13
- * @return boolean
14
- */
15
- function em_verify_admin( $user_id = false ){
16
- if(function_exists('is_super_admin')){
17
- return is_super_admin($user_id);
18
- }elseif( current_user_can('delete_posts') ){
19
- return true;
20
- }
21
- return false;
22
- }
23
-
24
 
25
  /**
26
  * Intro paragraph to new users.
@@ -91,10 +69,12 @@ function em_add_get_params($url, $params=array(), $html=true, $encode=true){
91
  $url_params_dirty = $url_parts[1];
92
  }
93
  //get the get params as an array
94
- if( strstr($url_params_dirty, '&amp;') !== false ){
95
- $url_params_dirty = explode('&amp;', $url_params_dirty);
96
- }else{
97
- $url_params_dirty = explode('&', $url_params_dirty);
 
 
98
  }
99
  //split further into associative array
100
  $url_params = array();
@@ -118,15 +98,37 @@ function em_add_get_params($url, $params=array(), $html=true, $encode=true){
118
  return $url;
119
  }
120
 
121
- function url_exists($url) {
122
- if ((strpos ( $url, "http" )) === false)
123
- $url = "http://" . $url;
124
- // FIXME ripristina la linea seguente e VEDI DI SISTEMARE!!!!
125
- // if (is_array(@get_headers($url))) {
126
- if (true)
127
- return true;
128
- else
129
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
131
 
132
  /**
@@ -143,6 +145,34 @@ function em_get_wp_users() {
143
  return $indexed_users;
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  /*
147
  * UI Helpers
148
  * previously dbem_UI_helpers.php functions
@@ -209,11 +239,16 @@ function em_options_textarea($title, $name, $description) {
209
  <?php
210
  }
211
 
212
- function em_options_radio($name, $options) {
213
  $option = get_option($name);
214
  ?>
215
  <tr valign="top" id='<?php echo $name;?>_row'>
216
- <td colspan="2">
 
 
 
 
 
217
  <table>
218
  <?php foreach($options as $value => $text): ?>
219
  <tr>
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
  * Intro paragraph to new users.
69
  $url_params_dirty = $url_parts[1];
70
  }
71
  //get the get params as an array
72
+ if( !is_array($url_params_dirty) ){
73
+ if( strstr($url_params_dirty, '&amp;') !== false ){
74
+ $url_params_dirty = explode('&amp;', $url_params_dirty);
75
+ }else{
76
+ $url_params_dirty = explode('&', $url_params_dirty);
77
+ }
78
  }
79
  //split further into associative array
80
  $url_params = array();
98
  return $url;
99
  }
100
 
101
+ /**
102
+ * Get a array of countries, translated. Keys are 2 character country iso codes. If you supply a string or array that will be the first value in the array (if array, the array key is the first key in the returned array)
103
+ * @param mixed $add_blank
104
+ * @return array
105
+ */
106
+ function em_get_countries($add_blank = false){
107
+ global $em_countries_array;
108
+ if( !is_array($em_countries_array) ){
109
+ $em_countries_array = array('AF' => 'Afghanistan', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AR' => 'Argentina', 'AU' => 'Australia', 'AT' => 'Austria', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BE' => 'Belgium', 'BJ' => 'Benin', 'BT' => 'Bhutan', 'BW' => 'Botswana', 'BR' => 'Brazil', 'BN' => 'Brunei', 'BG' => 'Bulgaria', 'BI' => 'Burundi', 'KH' => 'Cambodia', 'CA' => 'Canada', 'CF' => 'Central African Republic', 'TD' => 'Chad', 'CL' => 'Chile', 'CN' => 'China', 'CI' => 'C�te D\'ivoire', 'HR' => 'Croatia', 'CZ' => 'Czech Republic', 'CD' => 'Democratic Republic of the Congo', 'DK' => 'Denmark', 'DJ' => 'Djibouti', 'EG' => 'Egypt', 'EE' => 'Estonia', 'ET' => 'Ethiopia', 'FJ' => 'Fiji', 'FI' => 'Finland', 'FR' => 'France', 'PF' => 'French Polynesia', 'GA' => 'Gabon', 'GM' => 'Gambia', 'DE' => 'Germany', 'GH' => 'Ghana', 'GR' => 'Greece', 'GU' => 'Guam', 'HK' => 'Hong Kong', 'HU' => 'Hungary', 'IS' => 'Iceland', 'IN' => 'India', 'ID' => 'Indonesia', 'IQ' => 'Iraq', 'IE' => 'Ireland', 'IL' => 'Israel', 'IT' => 'Italy', 'JP' => 'Japan', 'JO' => 'Jordan', 'KZ' => 'Kazakhstan', 'KE' => 'Kenya', 'KW' => 'Kuwait', 'KG' => 'Kyrgyzstan', 'LA' => 'Laos', 'LV' => 'Latvia', 'LB' => 'Lebanon', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'MO' => 'Macao', 'MK' => 'Macedonia', 'MG' => 'Madagascar', 'MW' => 'Malawi', 'MY' => 'Malaysia', 'MV' => 'Maldives', 'MT' => 'Malta', 'MU' => 'Mauritius', 'MX' => 'Mexico', 'MN' => 'Mongolia', 'MA' => 'Morocco', 'MZ' => 'Mozambique', 'MM' => 'Myanmar(Burma)', 'NA' => 'Namibia', 'NP' => 'Nepal', 'NL' => 'Netherlands', 'NC' => 'New Caledonia', 'NZ' => 'New Zealand', 'NG' => 'Nigeria', 'MP' => 'Northern Mariana Islands', 'NO' => 'Norway', 'OM' => 'Oman', 'PK' => 'Pakistan', 'PW' => 'Palau', 'PG' => 'Papua New Guinea', 'PH' => 'Philippines', 'PL' => 'Poland', 'PT' => 'Portugal', 'QA' => 'Qatar', 'CG' => 'Republic of the Congo', 'RO' => 'Romania', 'RU' => 'Russia', 'RW' => 'Rwanda', 'WS' => 'Samoa', 'ST' => 'S�o Tom� And Pr�ncipe', 'SA' => 'Saudi Arabia', 'SN' => 'Senegal', 'RS' => 'Serbia', 'SC' => 'Seychelles', 'SL' => 'Sierra Leone', 'SG' => 'Singapore', 'SK' => 'Slovakia', 'SI' => 'Slovenia', 'SB' => 'Solomon Islands', 'ZA' => 'South Africa', 'KR' => 'South Korea', 'ES' => 'Spain', 'LK' => 'Sri Lanka', 'SE' => 'Sweden', 'CH' => 'Switzerland', 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania', 'TH' => 'Thailand', 'TG' => 'Togo', 'TO' => 'Tonga', 'TN' => 'Tunisia', 'TR' => 'Turkey', 'TM' => 'Turkmenistan', 'UG' => 'Uganda', 'UA' => 'Ukraine', 'AE' => 'United Arab Emirates', 'GB' => 'United Kingdom', 'US' => 'United States', 'UZ' => 'Uzbekistan', 'VU' => 'Vanuatu', 'VN' => 'Vietnam', 'YE' => 'Yemen', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe' );
110
+ array_walk($em_countries_array, '__');
111
+ }
112
+ if($add_blank !== false){
113
+ if(is_array($add_blank)){
114
+ $em_countries_array = $add_blank + $em_countries_array;
115
+ }else{
116
+ array_unshift($em_countries_array, $add_blank);
117
+ }
118
+ }
119
+ return $em_countries_array;
120
+ }
121
+
122
+ /**
123
+ * Works like check_admin_referrer(), but also in public mode. If in admin mode, it triggers an error like in check_admin_referrer(), if outside admin it just exits with an error.
124
+ * @param string $action
125
+ */
126
+ function em_verify_nonce($action, $nonce_name='_wpnonce'){
127
+ if( is_admin() ){
128
+ if( !wp_verify_nonce($_REQUEST[$nonce_name] && $action) ) check_admin_referer('trigger_error');
129
+ }else{
130
+ if( !wp_verify_nonce($_REQUEST[$nonce_name] && $action) ) exit( __('Trying to perform an illegal action.','dbem') );
131
+ }
132
  }
133
 
134
  /**
145
  return $indexed_users;
146
  }
147
 
148
+ function em_get_attributes(){
149
+ //We also get a list of attribute names and create a ddm list (since placeholders are fixed)
150
+ $formats =
151
+ get_option ( 'dbem_event_list_item_format' ).
152
+ get_option ( 'dbem_event_page_title_format' ).
153
+ get_option ( 'dbem_full_calendar_event_format' ).
154
+ get_option ( 'dbem_location_baloon_format' ).
155
+ get_option ( 'dbem_location_event_list_item_format' ).
156
+ get_option ( 'dbem_location_page_title_format' ).
157
+ get_option ( 'dbem_map_text_format' ).
158
+ get_option ( 'dbem_rss_description_format' ).
159
+ get_option ( 'dbem_rss_title_format' ).
160
+ get_option ( 'dbem_single_event_format' ).
161
+ get_option ( 'dbem_single_location_format' ).
162
+ get_option ( 'dbem_placeholders_custom' );
163
+ //We now have one long string of formats, get all the attribute placeholders
164
+ preg_match_all('/#_ATT\{.+?\}(\{.+?\})?/', $formats, $placeholders);
165
+ //Now grab all the unique attributes we can use in our event.
166
+ $attributes = array();
167
+ foreach($placeholders[0] as $result) {
168
+ $attribute = substr( substr($result, 0, strpos($result, '}')), 6 );
169
+ if( !in_array($attribute, $attributes) ){
170
+ $attributes[] = $attribute ;
171
+ }
172
+ }
173
+ return $attributes;
174
+ }
175
+
176
  /*
177
  * UI Helpers
178
  * previously dbem_UI_helpers.php functions
239
  <?php
240
  }
241
 
242
+ function em_options_radio($name, $options, $title='') {
243
  $option = get_option($name);
244
  ?>
245
  <tr valign="top" id='<?php echo $name;?>_row'>
246
+ <?php if( !empty($title) ): ?>
247
+ <th scope="row"><?php _e($title,'dbem'); ?></th>
248
+ <td>
249
+ <?php else: ?>
250
+ <td colspan="2">
251
+ <?php endif; ?>
252
  <table>
253
  <?php foreach($options as $value => $text): ?>
254
  <tr>
em-ical.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * generates an ical feed on init if url is correct
4
+ */
5
+ function em_ical( $regenerate = false ){
6
+ $cal_file_request = preg_match('/calendar.ics/', $_SERVER['REQUEST_URI']); //are we askig for the ics file directly but doesn't exist?
7
+ if ( !empty( $_REQUEST['em_ical']) || $cal_file_request || $regenerate ) {
8
+
9
+ //send headers
10
+ if( $_REQUEST['em_ical'] != '2' && !$regenerate ){
11
+ header('Content-type: text/calendar; charset=utf-8');
12
+ header('Content-Disposition: inline; filename="calendar.ics"');
13
+ }
14
+
15
+ ob_start();
16
+ $description_format = str_replace ( ">", "&gt;", str_replace ( "<", "&lt;", get_option ( 'dbem_ical_description_format' ) ) );
17
+ $events = EM_Events::get( array( get_option('dbem_ical_limit'), 'owner'=>false, 'orderby'=>'event_start_date' ) );
18
+
19
+ $blog_desc = ent2ncr(convert_chars(strip_tags(get_bloginfo()))) . " - " . __('Calendar','dbem');
20
+
21
+ echo "BEGIN:VCALENDAR
22
+ METHOD:PUBLISH
23
+ CALSCALE:GREGORIAN
24
+ VERSION:2.0
25
+ PRODID:-//Events Manager//1.0//EN
26
+ X-WR-CALNAME:{$blog_desc}";
27
+ /* @var EM_Event $EM_Event */
28
+ foreach ( $events as $EM_Event ) {
29
+
30
+ $description = $EM_Event->output($description_format);
31
+ $description = ent2ncr(convert_chars(strip_tags($description)));
32
+
33
+ $dateStart = date('Ymd\THis\Z',$EM_Event->start);
34
+ $dateEnd = date('Ymd\THis\Z',$EM_Event->end);
35
+ $dateModified = date('Ymd\THis\Z', $EM_Event->modified);
36
+
37
+ $location = $EM_Event->output('#_LOCATION');
38
+ $location = ent2ncr(convert_chars(strip_tags($location)));
39
+
40
+ $categories = $EM_Event->category->name;
41
+
42
+ //FIXME we need a modified date for events
43
+ echo "
44
+ BEGIN:VEVENT
45
+ UID:{$EM_Event->id}
46
+ DTSTART:{$dateStart}
47
+ DTEND:{$dateEnd}
48
+ DTSTAMP:{$dateModified}
49
+ ORGANIZER:MAILTO:{$EM_Event->contact->user_email}
50
+ CATEGORIES:{$categories}
51
+ LOCATION:{$location}
52
+ SUMMARY:{$description}
53
+ END:VEVENT";
54
+ }
55
+ echo "\r\n"."END:VCALENDAR";
56
+
57
+ $calendar = ob_get_clean(); //get the contents to output
58
+
59
+ //let's create a cache file
60
+ if($regenerate || $cal_file_request){
61
+ $file = fopen( ABSPATH . "/caleadar.ics", 'w');
62
+ if($file){
63
+ fwrite($file, $calendar, strlen($calendar));
64
+ fclose($file);
65
+ }
66
+ }
67
+ if($regenerate){
68
+ return ($file == true);
69
+ }
70
+ echo $calendar;
71
+ die ();
72
+ }
73
+ }
74
+ add_action ( 'init', 'em_ical' );
75
+
76
+ function em_update_ical($result, $EM_Event){
77
+ em_ical(true);
78
+ }
79
+ add_filter('em_event_save','em_update_ical', 1, 2);
80
+ ?>
em-install.php CHANGED
@@ -10,27 +10,32 @@ define('EM_OLD_CATEGORIES_TABLE', 'dbem_categories'); //TABLE NAME
10
 
11
  function em_install() {
12
  $old_version = get_option('dbem_version');
 
 
 
 
13
  if( EM_VERSION > $old_version || $old_version == '' ){
14
  // Creates the events table if necessary
15
  em_create_events_table();
16
  em_create_events_meta_table();
17
  em_create_locations_table();
18
  em_create_bookings_table();
19
- em_create_people_table();
20
  em_create_categories_table();
 
 
 
21
  em_add_options();
22
 
23
  //Migrate?
24
- if( $old_version < 2.3 && $old_version != '' ){
25
  em_migrate_to_new_tables();
26
- em_import_verify();
27
  }
28
  //Upate Version
29
  update_option('dbem_version', EM_VERSION);
30
 
31
  // wp-content must be chmodded 777. Maybe just wp-content.
32
- if( !file_exists(ABSPATH."/".EM_IMAGE_UPLOAD_DIR))
33
- @mkdir(ABSPATH."/".EM_IMAGE_UPLOAD_DIR, 0777); //do we need to 777 it? it'll be owner apache anyway, like normal uploads
34
 
35
  em_create_events_page();
36
  }
@@ -44,7 +49,9 @@ function em_create_events_table() {
44
  $table_name = $wpdb->prefix.EM_EVENTS_TABLE;
45
  $sql = "CREATE TABLE ".$table_name." (
46
  event_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
47
- event_author bigint(20) unsigned DEFAULT NULL,
 
 
48
  event_name tinytext NOT NULL,
49
  event_start_time time NOT NULL,
50
  event_end_time time NOT NULL,
@@ -52,8 +59,7 @@ function em_create_events_table() {
52
  event_end_date date NULL,
53
  event_notes text NULL DEFAULT NULL,
54
  event_rsvp bool NOT NULL DEFAULT 0,
55
- event_seats int(5),
56
- event_contactperson_id bigint(20) unsigned NULL,
57
  location_id bigint(20) unsigned NOT NULL,
58
  recurrence_id bigint(20) unsigned NULL,
59
  event_category_id bigint(20) unsigned NULL DEFAULT NULL,
@@ -64,8 +70,12 @@ function em_create_events_table() {
64
  recurrence_interval int(4) NULL DEFAULT NULL,
65
  recurrence_freq tinytext NULL DEFAULT NULL,
66
  recurrence_byday tinytext NULL DEFAULT NULL,
67
- recurrence_byweekno int(4) NULL DEFAULT NULL,
68
- PRIMARY KEY (event_id)
 
 
 
 
69
  ) DEFAULT CHARSET=utf8 ;";
70
 
71
  $old_table_name = $wpdb->prefix.EM_OLD_EVENTS_TABLE;
@@ -81,11 +91,12 @@ function em_create_events_table() {
81
  $wpdb->query("INSERT INTO ".$table_name." (event_name, event_start_date, event_start_time, event_end_time, location_id) VALUES ('Traditional music session', '$in_four_weeks', '20:00:00', '22:00:00', 2)");
82
  $wpdb->query("INSERT INTO ".$table_name." (event_name, event_start_date, event_start_time, event_end_time, location_id) VALUES ('6 Nations, Italy VS Ireland', '$in_one_year','22:00:00', '24:00:00', 3)");
83
  }else{
 
 
 
 
84
  dbDelta($sql);
85
  }
86
- if( get_option('dbem_version') != '' && get_option('dbem_version') <= 3.092){
87
- $wpdb->query("UPDATE $table_name SET event_date_created='".current_time('mysql')."', event_date_modified='".current_time('mysql')."'");
88
- }
89
  }
90
 
91
  function em_create_events_meta_table(){
@@ -99,7 +110,7 @@ function em_create_events_meta_table(){
99
  meta_key varchar(255) DEFAULT NULL,
100
  meta_value longtext,
101
  meta_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
102
- KEY post_id (object_id),
103
  KEY meta_key (meta_key),
104
  PRIMARY KEY (meta_id)
105
  ) DEFAULT CHARSET=utf8 ";
@@ -118,21 +129,25 @@ function em_create_locations_table() {
118
  // Creating the events table
119
  $sql = "CREATE TABLE ".$table_name." (
120
  location_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
 
121
  location_name tinytext NOT NULL,
122
  location_owner bigint(20) unsigned DEFAULT 0 NOT NULL,
123
  location_address tinytext NOT NULL,
124
  location_town tinytext NOT NULL,
125
- location_province tinytext,
 
 
126
  location_latitude float DEFAULT NULL,
127
  location_longitude float DEFAULT NULL,
128
  location_description text DEFAULT NULL,
129
- PRIMARY KEY (location_id)
 
 
130
  ) DEFAULT CHARSET=utf8 ;";
131
 
132
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
133
 
134
- $old_table_name = $wpdb->prefix.EM_OLD_LOCATIONS_TABLE;
135
-
136
  if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name && $wpdb->get_var("SHOW TABLES LIKE '$old_table_name'") != $old_table_name) {
137
  dbDelta($sql);
138
  //Add default values
@@ -140,6 +155,9 @@ function em_create_locations_table() {
140
  $wpdb->query("INSERT INTO ".$table_name." (location_name, location_address, location_town, location_latitude, location_longitude) VALUES ('The Crane Bar', '2, Sea Road','Galway', 53.2692, -9.06151)");
141
  $wpdb->query("INSERT INTO ".$table_name." (location_name, location_address, location_town, location_latitude, location_longitude) VALUES ('Taaffes Bar', '19 Shop Street','Galway', 53.2725, -9.05321)");
142
  }else{
 
 
 
143
  dbDelta($sql);
144
  }
145
  }
@@ -152,30 +170,19 @@ function em_create_bookings_table() {
152
  $sql = "CREATE TABLE ".$table_name." (
153
  booking_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
154
  event_id bigint(20) unsigned NOT NULL,
155
- person_id bigint(20) unsigned NOT NULL,
156
- booking_seats int(5) NOT NULL,
157
  booking_comment text DEFAULT NULL,
158
  booking_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
159
  booking_status bool NOT NULL DEFAULT 1,
 
160
  PRIMARY KEY (booking_id)
161
  ) DEFAULT CHARSET=utf8 ;";
162
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
163
- dbDelta($sql);
164
- }
165
-
166
- function em_create_people_table() {
167
-
168
- global $wpdb, $user_level;
169
- $table_name = $wpdb->prefix.EM_PEOPLE_TABLE;
170
 
171
- $sql = "CREATE TABLE ".$table_name." (
172
- person_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
173
- person_name tinytext NOT NULL,
174
- person_email tinytext NOT NULL,
175
- person_phone tinytext NOT NULL,
176
- PRIMARY KEY (person_id)
177
- ) DEFAULT CHARSET=utf8 ;";
178
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
179
  dbDelta($sql);
180
  }
181
 
@@ -188,9 +195,11 @@ function em_create_categories_table() {
188
  // Creating the events table
189
  $sql = "CREATE TABLE ".$table_name." (
190
  category_id bigint(20) unsigned NOT NULL auto_increment,
 
191
  category_owner bigint(20) unsigned DEFAULT 0 NOT NULL,
192
  category_name tinytext NOT NULL,
193
- PRIMARY KEY (category_id)
 
194
  ) DEFAULT CHARSET=utf8 ;";
195
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
196
 
@@ -205,13 +214,60 @@ function em_create_categories_table() {
205
  }
206
 
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  function em_add_options() {
209
- $contact_person_email_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) will attend #_NAME on #F #j, #Y. He wants to reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces reserved, #_AVAILABLESPACES are still available.").'<br/><br/>-------------------------------<br/>'.__('Powered by Events Manager','dbem').' - http://wp-events-plugin.com';
210
- $contact_person_email_cancelled_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) cancelled his booking at #_NAME on #F #j, #Y. He wanted to reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces reserved, #_AVAILABLESPACES are still available.").'<br/><br/>-------------------------------<br/>'.__('Powered by Events Manager','dbem').' - http://wp-events-plugin.com';
211
- $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br/>You have successfully reserved #_BOOKINGSPACES space/spaces for #_NAME.").'<br/><br/>-------------------------------<br/>'.__('Powered by Events Manager','dbem').' - http://wp-events-plugin.com';
212
- $respondent_email_pending_body_localizable = __("Dear #_BOOKINGNAME, <br/>You have requested #_BOOKEDSPACES space/spaces for #_NAME.<br/>Your booking is currently pending approval by our administrators. Once approved you will receive an automatic confirmation.").'<br/><br/>-------------------------------<br/>'.__('Powered by Events Manager','dbem').' - http://wp-events-plugin.com';
213
- $respondent_email_rejected_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_NAME on #F #j, #Y has been rejected.").'<br/><br/>-------------------------------<br/>'.__('Powered by Events Manager','dbem').' - http://wp-events-plugin.com';
214
- $respondent_email_cancelled_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_NAME on #F #j, #Y has been cancelled.").'<br/><br/>-------------------------------<br/>'.__('Powered by Events Manager','dbem').' - http://wp-events-plugin.com';
215
 
216
  $dbem_options = array(
217
  //defaults
@@ -221,17 +277,17 @@ function em_add_options() {
221
  'dbem_events_default_orderby' => 'start_date,start_time,name',
222
  'dbem_events_default_order' => 'ASC',
223
  'dbem_events_default_limit' => 10,
224
- 'dbem_permissions_events' => 0, //can others view other's events
225
  'dbem_list_events_page' => 1,
226
  //Event Formatting
227
  'dbem_events_page_title' => __('Events','dbem'),
228
  'dbem_events_page_time_limit' => 0,
229
  'dbem_event_list_item_format' => '<li>#j #M #Y - #H:#i<br/> #_EVENTLINK<br/>#_LOCATIONTOWN </li>',
230
  'dbem_display_calendar_in_events_page' => 0,
231
- 'dbem_single_event_format' => '<h3>#_NAME</h3><p>#j #M #Y - #H:#i</p><p>#_LOCATIONTOWN</p>',
232
  'dbem_event_page_title_format' => '#_NAME',
233
  'dbem_no_events_message' => __('No events','dbem'),
234
  //Location Formatting
 
235
  'dbem_location_page_title_format' => '#_LOCATIONNAME',
236
  'dbem_location_event_list_item_format' => "<li>#_LOCATIONNAME - #j #M #Y - #H:#i</li>",
237
  'dbem_location_list_item_format' => '#_LOCATIONLINK<ul><li>#_LOCATIONADDRESS</li><li>#_LOCATIONTOWN</li></ul>',
@@ -278,57 +334,77 @@ function em_add_options() {
278
  'dbem_rsvp_enabled'=> 1,
279
  'dbem_categories_enabled'=> 1,
280
  'dbem_placeholders_custom' => '',
281
- //Privacy Settings
282
- 'dbem_permissions_events' => 0,
283
- 'dbem_permissions_locations' => 0,
284
- 'dbem_permissions_categories' => 0,
285
  //Title rewriting compatability
286
  'dbem_disable_title_rewrites'=> false,
287
  'dbem_title_html' => '<h2>#_PAGETITLE</h2>',
288
  //Bookings
289
- 'dbem_default_contact_person' => 1, //admin
290
  'dbem_bookings_approval' => 1, //approval is on by default
291
- 'dbem_bookings_notify_admin' => 0,
292
- 'dbem_bookings_contact_email' => 1,
293
- 'dbem_bookings_contact_email_subject' => __("New booking",'dbem'),
294
- 'dbem_bookings_contact_email_body' => str_replace("<br/>", "\n\r", $contact_person_email_body_localizable),
295
- 'dbem_contactperson_email_cancelled_subject' => __("Booking Cancelled",'dbem'),
296
- 'dbem_contactperson_email_cancelled_body' => str_replace("<br/>", "\n\r", $contact_person_email_cancelled_body_localizable),
297
- 'dbem_bookings_email_pending_subject' => __("Booking Pending",'dbem'),
298
- 'dbem_bookings_email_pending_body' => str_replace("<br/>", "\n\r", $respondent_email_pending_body_localizable),
299
- 'dbem_bookings_email_rejected_subject' => __("Booking Rejected",'dbem'),
300
- 'dbem_bookings_email_rejected_body' => str_replace("<br/>", "\n\r", $respondent_email_rejected_body_localizable),
301
- 'dbem_bookings_email_confirmed_subject' => __('Booking Confirmed','dbem'),
302
- 'dbem_bookings_email_confirmed_body' => str_replace("<br/>", "\n\r", $respondent_email_body_localizable),
303
- 'dbem_bookings_email_cancelled_subject' => __('Booking Cancelled','dbem'),
304
- 'dbem_bookings_email_cancelled_body' => str_replace("<br/>", "\n\r", $respondent_email_cancelled_body_localizable),
 
 
 
 
 
 
 
 
 
 
 
305
  //Flags
306
  'dbem_hello_to_user' => 1,
 
 
 
 
 
307
  );
308
 
309
  foreach($dbem_options as $key => $value){
310
  add_option($key, $value);
311
  }
312
- //Customization for new options on updated plugins (not new installs)
313
- if( get_option('dbem_version') != '' && get_option('dbem_version') <= 3.091){
314
- //New options, defaults for updates
315
- add_option('dbem_admin_notice_3.0.91',1);
316
- update_option('dbem_bookings_approval',0); //Previously in <3.0.9 bookings were never approvable
317
- update_option('dbem_bookings_approval_warning',1); //One off warning for old EM users to activate this new feature
318
- update_option('dbem_permissions_events',1); //set to 2, so updaters don't get a surprise!
319
- update_option('dbem_permissions_locations',2); //set to 2, so updaters don't get a surprise!
320
- update_option('dbem_permissions_categories',2); //set to 2, so updaters don't get a surprise!
321
- //Contact person email flag
322
- update_option('dbem_bookings_contact_email',get_option('dbem_rsvp_notify_contact'));
323
- //Booking emails
324
- if( get_option('dbem_respondent_email_body') != '' ){
325
- update_option('dbem_bookings_email_confirmed_body', get_option('dbem_respondent_email_body'));
326
  }
327
- }elseif( get_option('dbem_version') != '' && get_option('dbem_version') <= 3.092 ){
328
- update_option('dbem_bookings_contact_email_subject', get_option('dbem_contactperson_email_subject'));
329
- update_option('dbem_bookings_contact_email_body', get_option('dbem_contactperson_email_body'));
330
  }
331
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
 
333
  function em_create_events_page(){
334
  global $wpdb,$current_user;
@@ -352,248 +428,31 @@ function em_create_events_page(){
352
  function em_migrate_to_new_tables(){
353
  global $wpdb, $current_user;
354
  get_currentuserinfo();
355
- $errors = array();
356
- // migrating events
357
- $events_required = array('event_id', 'event_name','event_start_time','event_end_time','event_start_date','event_rsvp','location_id','recurrence');
358
- $events = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.EM_OLD_EVENTS_TABLE,ARRAY_A) ;
359
- $event_fields = array('event_id','event_author','event_name','event_start_time','event_end_time','event_start_date','event_end_date','event_notes','event_rsvp','event_seats','event_contactperson_id','location_id','recurrence_id','event_category_id','event_attributes');
360
- if( count($events) > 0 ){
361
- $events_values = array();
362
- foreach($events as $event) {
363
- foreach($event as $key => $value){
364
- if( in_array($key, $event_fields) ){
365
- if($value == '' && !in_array($key,$events_required)){ $event[$key] = 'NULL'; }
366
- elseif ( $value == '-1' && !in_array($key,$events_required) ) { $event[$key] = 'NULL'; }
367
- else { $event[$key] = "'".$wpdb->escape($event[$key])."'"; }
368
- }else{
369
- unset($event[$key]);
370
- }
371
- }
372
- $events_values[] = "\n".'('. implode(', ', $event).')';
373
- }
374
- $events_keys = array_keys($event);
375
- if( count($events_values) > 0 ){
376
- $events_sql = "INSERT INTO " . $wpdb->prefix.EM_EVENTS_TABLE .
377
- "(`" . implode('` ,`', $events_keys) . "`) VALUES".
378
- implode(', ', $events_values);
379
- $wpdb->query($events_sql);
380
- if($wpdb->last_error != ''){
381
- $errors[] = $wpdb->last_error;
382
- }
383
- }
384
- }
385
-
386
- // inserting recurrences into events
387
- $table_name = $wpdb->prefix.EM_EVENTS_TABLE;
388
- $results = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.EM_RECURRENCE_TABLE, ARRAY_A);
389
- if( count($results) > 0 ){
390
- foreach($results as $recurrence_raw){
391
- //Save copy of recurrence_id
392
- $recurrence_id = $recurrence_raw['recurrence_id'];
393
- //First insert the event into events table
394
- $recurrence = array( //Save new array with correct indexes
395
- 'event_author' => $current_user->ID,
396
- 'event_name' => $recurrence_raw['recurrence_name'],
397
- 'event_start_date' => $recurrence_raw['recurrence_start_date'],
398
- 'event_end_date' => $recurrence_raw['recurrence_end_date'],
399
- 'event_start_time' => $recurrence_raw['recurrence_start_time'],
400
- 'event_end_time' => $recurrence_raw['recurrence_end_time'],
401
- 'event_notes' => $recurrence_raw['recurrence_notes'],
402
- 'location_id' => $recurrence_raw['location_id'],
403
- 'recurrence' => 1,
404
- 'recurrence_interval' => $recurrence_raw['recurrence_interval'],
405
- 'recurrence_freq' => $recurrence_raw['recurrence_freq'],
406
- 'recurrence_byday' => $recurrence_raw['recurrence_byday'],
407
- 'recurrence_byweekno' => $recurrence_raw['recurrence_byweekno']
408
- );
409
- $result = $wpdb->insert($table_name, $recurrence, array('%d','%s','%s','%s','%s','%s','%s','%d','%d','%d','%d','%d','%d'));
410
- //Then change the id of all the events with recurrence_id
411
- if($result == 1){
412
- $wpdb->query("UPDATE {$table_name} SET recurrence_id='{$wpdb->insert_id}' WHERE recurrence_id='{$recurrence_id}'");
413
- }else{
414
- //FIXME Better fallback in case of bad install
415
- _e('We could not mirgrate old recurrence data over. DONT WORRY! You can just delete the current plugin, and re-install the previous 2.2.2 version and you wont lose any of your data. Either way, please contact the developers to let them know of this bug.', 'dbem');
416
- }
417
- }
418
- }
419
 
420
- // migrating locations
421
- $locations_required = array('location_id', 'location_name', 'location_address', 'location_town');
422
- $locations = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.EM_OLD_LOCATIONS_TABLE,ARRAY_A) ;
423
- $location_fields = array('location_id','location_name','location_address','location_town','location_province','location_latitude','location_longitude','location_description');
424
- if( count($locations) > 0 ){
425
- $locations_values = array();
426
- foreach($locations as $location) {
427
- foreach($location as $key => $value){
428
- if( in_array($key, $location_fields) ){
429
- if($value == '' && !in_array($key, $locations_required)){ $location[$key] = 'NULL'; }
430
- elseif ( $value == '-1' && !in_array($key, $locations_required) ) { $location[$key] = 'NULL'; }
431
- else { $location[$key] = "'".$wpdb->escape($location[$key])."'"; }
432
- }else{
433
- unset($location[$key]);
434
- }
435
- }
436
- $locations_values[] = "\n".'('. implode(', ', $location).')';
437
- }
438
- $locations_keys = array_keys($location);
439
- if( count($locations_values) > 0 ){
440
- $locations_sql = "INSERT INTO " . $wpdb->prefix.EM_LOCATIONS_TABLE .
441
- "(`" . implode('` ,`', $locations_keys) . "`) VALUES".
442
- implode(', ', $locations_values);
443
- $wpdb->query($locations_sql);
444
- }
445
- }
446
 
447
- // migrating people
448
- $people = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.EM_OLD_PEOPLE_TABLE,ARRAY_A) ;
449
- if( count($people) > 0 ){
450
- $people_values = array();
451
- $people_fields = array('person_id', 'person_name', 'person_email', 'person_phone');
452
- foreach($people as $person) {
453
- foreach($person as $key => $value){
454
- if( in_array($key, $people_fields) ){
455
- $person[$key] = "'".$wpdb->escape($person[$key])."'";
456
- }else{
457
- unset($person[$key]);
458
- }
459
- }
460
- $people_values[] = "\n".'('. implode(', ', $person).')';
461
- }
462
- $people_keys = array_keys($person);
463
- if( count($people_values) > 0 ){
464
- $people_sql = "INSERT INTO " . $wpdb->prefix.EM_PEOPLE_TABLE .
465
- "(`" . implode('` ,`', $people_keys) . "`) VALUES".
466
- implode(', ', $people_values);
467
- $wpdb->query($people_sql);
468
- }
469
- }
470
-
471
- // migrating bookings
472
- $bookings = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.EM_OLD_BOOKINGS_TABLE,ARRAY_A) ;
473
- if( count($bookings) > 0 ){
474
- $bookings_values = array();
475
- $booking_fields = array('booking_id', 'event_id', 'person_id', 'booking_seats', 'booking_comment');
476
- foreach($bookings as $booking) {
477
- foreach($booking as $key => $value){
478
- if( in_array($key, $booking_fields) ){
479
- if($value == '' && $key == 'booking_comment'){ $booking[$key] = 'NULL'; }
480
- elseif ( $value == '-1' ) { $booking[$key] = '0'; }
481
- else { $booking[$key] = "'".$wpdb->escape($booking[$key])."'"; }
482
- }else{
483
- unset($booking[$key]);
484
  }
 
 
485
  }
486
- $bookings_values[] = "\n".'('. implode(', ', $booking).')';
487
  }
488
- $bookings_keys = array_keys($booking);
489
- if( count($bookings_values) > 0 ){
490
- $bookings_sql = "INSERT INTO " . $wpdb->prefix.EM_BOOKINGS_TABLE .
491
- "(`" . implode('` ,`', $bookings_keys) . "`) VALUES".
492
- implode(', ', $bookings_values);
493
- $wpdb->query($bookings_sql);
494
- }
495
-
496
- // migrating categories
497
- $categories = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.EM_OLD_CATEGORIES_TABLE,ARRAY_A) ;
498
- $categories_fields = array('category_id', 'category_name');
499
- foreach($categories as $category) {
500
- foreach($category as $key => $val){
501
- if( !in_array($key, $categories_fields) ){
502
- unset($category[$key]);
503
- }
504
- }
505
- $wpdb->insert($wpdb->prefix.EM_CATEGORIES_TABLE, $category);
506
- }
507
- }
508
-
509
- if( count($errors) > 0 && is_array($errors) ){
510
- $func = create_function('', '?>
511
- <div id="em_page_error" class="error">
512
- <p>SQL Errors:</p>
513
- <ul>
514
- <li>'. implode('</li><li>', $errors) .'</li>
515
- </ul>
516
- </div>
517
- <?php
518
- ');
519
- add_action ( 'admin_notices', $func);
520
- }
521
- }
522
-
523
- function em_reimport(){
524
- //Check for reimport request
525
- global $wpdb;
526
- if($_GET['em_reimport'] == 1 ){
527
- check_admin_referer( 'em_reimport' );
528
- $p = $wpdb->prefix;
529
- $table_bookings = $p.EM_BOOKINGS_TABLE;
530
- $table_categories = $p.EM_CATEGORIES_TABLE;
531
- $table_events = $p.EM_EVENTS_TABLE;
532
- $table_locations = $p.EM_LOCATIONS_TABLE;
533
- $table_people = $p.EM_PEOPLE_TABLE;
534
- $wpdb->query('DROP TABLE '.$table_bookings.', '.$table_categories.', '.$table_events.', '.$table_locations.', '.$table_people.';');
535
- update_option('dbem_version','2');
536
- em_install();
537
- }
538
- }
539
- add_action('admin_init', 'em_reimport');
540
-
541
- /**
542
- * If importing from 2.x to 3.x, this function will be called to verify the import went well.
543
- * @return string|string
544
- */
545
- function em_import_verify(){
546
- global $wpdb;
547
- $p = $wpdb->prefix;
548
- //Now go through each table and compare row counts, if all match (events is old recurrences + events, then we're fine
549
- $results[] = ( $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_BOOKINGS_TABLE.";") == $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_BOOKINGS_TABLE.";") );
550
- $results[] = ( $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_CATEGORIES_TABLE.";") ."==". $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_CATEGORIES_TABLE.";") );
551
- $results[] = ( $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_EVENTS_TABLE.";") == $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_EVENTS_TABLE.";") + $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_RECURRENCE_TABLE.";") );
552
- $results[] = ( $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_LOCATIONS_TABLE.";") == $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_LOCATIONS_TABLE.";") );
553
- $results[] = ( $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_PEOPLE_TABLE.";") == $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_PEOPLE_TABLE.";") );
554
- /* Debugging
555
- echo "BOOKINGS : " . $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_BOOKINGS_TABLE.";") ."==". $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_BOOKINGS_TABLE);
556
- echo "<br/>CATEGORIES : ". $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_CATEGORIES_TABLE.";") == $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_CATEGORIES_TABLE.";");
557
- echo "<br/>EVENTS : ". $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_EVENTS_TABLE.";") .'=='. $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_EVENTS_TABLE.";") .'+'. $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_RECURRENCE_TABLE.";");
558
- echo "<br/>LOCATIONS : ". $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_LOCATIONS_TABLE.";") .'=='. $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_LOCATIONS_TABLE.";");
559
- echo "<br/>PEOPLE : ". $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_PEOPLE_TABLE.";") .'=='. $wpdb->get_var("SELECT COUNT(*) FROM ".$p.EM_OLD_PEOPLE_TABLE.";");
560
- */
561
- if( in_array(false, $results) ){
562
- update_option( 'dbem_import_fail', 1 );
563
- return false;
564
- }else{
565
- update_option( 'dbem_import_fail', 0 );
566
- add_action ( 'admin_notices', 'em_import_message_success' );
567
- return true;
568
- }
569
- }
570
-
571
- /**
572
- * Gets called if re-import was successful.
573
- */
574
- function em_import_message_success(){
575
- ?>
576
- <div id="em_page_error" class="updated">
577
- <p><?php _e('Events Manager successfully imported your events, please check your records to verify.','dbem')?></p>
578
- </div>
579
- <?php
580
- }
581
-
582
- /*
583
- * If import failed, a persistant message will show unless ignored.
584
- */
585
- function em_import_message_fail(){
586
- if( $_GET['em_dismiss_import'] == '1' ){
587
- update_option('dbem_import_fail', 0);
588
- }
589
- if( get_option('dbem_import_fail') == 1 ){
590
- $dismiss_link_joiner = ( count($_GET) > 0 ) ? '&amp;':'?';
591
- ?>
592
- <div id="em_page_error" class="error">
593
- <p><?php printf( __('Something has gone wrong when importing your old event. See the <a href="%s">support page</a> for more information. <a href="%s">Dismiss this message</a>','dbem'), get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-support', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'em_dismiss_import=1'); ?></p>
594
- </div>
595
- <?php
596
- }
597
  }
598
- add_action ( 'admin_notices', 'em_import_message_fail' );
599
  ?>
10
 
11
  function em_install() {
12
  $old_version = get_option('dbem_version');
13
+ //Won't upgrade 2 anymore, let 3 do that and we worry about 3.
14
+ if( $old_version != '' && $old_version < 3.095 ){
15
+ die('Cannot proceed with installation, please upgrade to the version 3.0.96 from <a href="http://wordpress.org/extend/plugins/events-manager/download/">here</a> first before upgrading to this version.');
16
+ }
17
  if( EM_VERSION > $old_version || $old_version == '' ){
18
  // Creates the events table if necessary
19
  em_create_events_table();
20
  em_create_events_meta_table();
21
  em_create_locations_table();
22
  em_create_bookings_table();
 
23
  em_create_categories_table();
24
+ em_create_tickets_table();
25
+ em_create_tickets_bookings_table();
26
+ em_set_capabilities();
27
  em_add_options();
28
 
29
  //Migrate?
30
+ if( $old_version < 4 && $old_version != '' ){
31
  em_migrate_to_new_tables();
 
32
  }
33
  //Upate Version
34
  update_option('dbem_version', EM_VERSION);
35
 
36
  // wp-content must be chmodded 777. Maybe just wp-content.
37
+ if(!file_exists("../".EM_IMAGE_UPLOAD_DIR))
38
+ mkdir("../".EM_IMAGE_UPLOAD_DIR, 0777); //do we need to 777 it? it'll be owner apache anyway, like normal uploads
39
 
40
  em_create_events_page();
41
  }
49
  $table_name = $wpdb->prefix.EM_EVENTS_TABLE;
50
  $sql = "CREATE TABLE ".$table_name." (
51
  event_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
52
+ event_slug VARCHAR( 200 ) NOT NULL,
53
+ event_owner bigint(20) unsigned DEFAULT NULL,
54
+ event_status int(1) NULL DEFAULT NULL,
55
  event_name tinytext NOT NULL,
56
  event_start_time time NOT NULL,
57
  event_end_time time NOT NULL,
59
  event_end_date date NULL,
60
  event_notes text NULL DEFAULT NULL,
61
  event_rsvp bool NOT NULL DEFAULT 0,
62
+ event_spaces int(5),
 
63
  location_id bigint(20) unsigned NOT NULL,
64
  recurrence_id bigint(20) unsigned NULL,
65
  event_category_id bigint(20) unsigned NULL DEFAULT NULL,
70
  recurrence_interval int(4) NULL DEFAULT NULL,
71
  recurrence_freq tinytext NULL DEFAULT NULL,
72
  recurrence_byday tinytext NULL DEFAULT NULL,
73
+ recurrence_byweekno int(4) NULL DEFAULT NULL,
74
+ blog_id bigint(20) unsigned NULL DEFAULT NULL,
75
+ PRIMARY KEY (event_id),
76
+ INDEX (event_status),
77
+ INDEX (blog_id),
78
+ INDEX (event_slug)
79
  ) DEFAULT CHARSET=utf8 ;";
80
 
81
  $old_table_name = $wpdb->prefix.EM_OLD_EVENTS_TABLE;
91
  $wpdb->query("INSERT INTO ".$table_name." (event_name, event_start_date, event_start_time, event_end_time, location_id) VALUES ('Traditional music session', '$in_four_weeks', '20:00:00', '22:00:00', 2)");
92
  $wpdb->query("INSERT INTO ".$table_name." (event_name, event_start_date, event_start_time, event_end_time, location_id) VALUES ('6 Nations, Italy VS Ireland', '$in_one_year','22:00:00', '24:00:00', 3)");
93
  }else{
94
+ if( get_option('dbem_version') < 4 ){
95
+ $wpdb->query("ALTER TABLE $table_name CHANGE event_seats event_spaces int(5)");
96
+ $wpdb->query("ALTER TABLE $table_name CHANGE event_author event_owner BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
97
+ }
98
  dbDelta($sql);
99
  }
 
 
 
100
  }
101
 
102
  function em_create_events_meta_table(){
110
  meta_key varchar(255) DEFAULT NULL,
111
  meta_value longtext,
112
  meta_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
113
+ KEY object_id (object_id),
114
  KEY meta_key (meta_key),
115
  PRIMARY KEY (meta_id)
116
  ) DEFAULT CHARSET=utf8 ";
129
  // Creating the events table
130
  $sql = "CREATE TABLE ".$table_name." (
131
  location_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
132
+ location_slug VARCHAR( 200 ) NOT NULL,
133
  location_name tinytext NOT NULL,
134
  location_owner bigint(20) unsigned DEFAULT 0 NOT NULL,
135
  location_address tinytext NOT NULL,
136
  location_town tinytext NOT NULL,
137
+ location_state tinytext NULL,
138
+ location_postcode VARCHAR( 10 ) NULL,
139
+ location_country CHAR( 2 ) NOT NULL,
140
  location_latitude float DEFAULT NULL,
141
  location_longitude float DEFAULT NULL,
142
  location_description text DEFAULT NULL,
143
+ PRIMARY KEY (location_id),
144
+ INDEX (location_country),
145
+ INDEX (location_slug)
146
  ) DEFAULT CHARSET=utf8 ;";
147
 
148
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
149
 
150
+ $old_table_name = $wpdb->prefix.EM_OLD_LOCATIONS_TABLE; //for 3.0
 
151
  if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name && $wpdb->get_var("SHOW TABLES LIKE '$old_table_name'") != $old_table_name) {
152
  dbDelta($sql);
153
  //Add default values
155
  $wpdb->query("INSERT INTO ".$table_name." (location_name, location_address, location_town, location_latitude, location_longitude) VALUES ('The Crane Bar', '2, Sea Road','Galway', 53.2692, -9.06151)");
156
  $wpdb->query("INSERT INTO ".$table_name." (location_name, location_address, location_town, location_latitude, location_longitude) VALUES ('Taaffes Bar', '19 Shop Street','Galway', 53.2725, -9.05321)");
157
  }else{
158
+ if( get_option('dbem_version') < 4 && get_option('dbem_version') != '' ){
159
+ $wpdb->query('ALTER TABLE wp_em_locations CHANGE location_province location_state TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL');
160
+ }
161
  dbDelta($sql);
162
  }
163
  }
170
  $sql = "CREATE TABLE ".$table_name." (
171
  booking_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
172
  event_id bigint(20) unsigned NOT NULL,
173
+ person_id bigint(20) unsigned NOT NULL,
174
+ booking_spaces int(5) NOT NULL,
175
  booking_comment text DEFAULT NULL,
176
  booking_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
177
  booking_status bool NOT NULL DEFAULT 1,
178
+ booking_price decimal(6,2) unsigned NOT NULL,
179
  PRIMARY KEY (booking_id)
180
  ) DEFAULT CHARSET=utf8 ;";
181
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
 
 
 
 
 
 
 
182
 
183
+ if( get_option('dbem_version') != '' && get_option('dbem_version') < 4){
184
+ $wpdb->query("ALTER TABLE $table_name CHANGE `booking_seats` `booking_spaces` INT( 5 ) NULL DEFAULT NULL");
185
+ }
 
 
 
 
 
186
  dbDelta($sql);
187
  }
188
 
195
  // Creating the events table
196
  $sql = "CREATE TABLE ".$table_name." (
197
  category_id bigint(20) unsigned NOT NULL auto_increment,
198
+ category_slug VARCHAR( 200 ) NOT NULL,
199
  category_owner bigint(20) unsigned DEFAULT 0 NOT NULL,
200
  category_name tinytext NOT NULL,
201
+ PRIMARY KEY (category_id),
202
+ INDEX (category_slug)
203
  ) DEFAULT CHARSET=utf8 ;";
204
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
205
 
214
  }
215
 
216
 
217
+ //Add the categories table
218
+ function em_create_tickets_table() {
219
+
220
+ global $wpdb, $user_level;
221
+ $table_name = $wpdb->prefix.EM_TICKETS_TABLE;
222
+
223
+ // Creating the events table
224
+ $sql = "CREATE TABLE {$table_name} (
225
+ ticket_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
226
+ event_id BIGINT( 20 ) UNSIGNED NOT NULL ,
227
+ ticket_name TINYTEXT NOT NULL ,
228
+ ticket_description TEXT NULL ,
229
+ ticket_price DECIMAL( 10 ) NULL ,
230
+ ticket_start DATETIME NULL ,
231
+ ticket_end DATETIME NULL ,
232
+ ticket_min INT( 10 ) NULL ,
233
+ ticket_max INT( 10 ) NULL ,
234
+ ticket_spaces TINYINT NULL ,
235
+ PRIMARY KEY (ticket_id),
236
+ INDEX (event_id)
237
+ ) DEFAULT CHARSET=utf8 ;";
238
+
239
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
240
+ dbDelta($sql);
241
+ }
242
+
243
+ //Add the categories table
244
+ function em_create_tickets_bookings_table() {
245
+ global $wpdb, $user_level;
246
+ $table_name = $wpdb->prefix.EM_TICKETS_BOOKINGS_TABLE;
247
+
248
+ // Creating the events table
249
+ $sql = "CREATE TABLE {$table_name} (
250
+ ticket_booking_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
251
+ booking_id bigint(20) unsigned NOT NULL,
252
+ ticket_id bigint(20) unsigned NOT NULL,
253
+ ticket_booking_spaces int(6) NOT NULL,
254
+ ticket_booking_price decimal(6,2) NOT NULL,
255
+ PRIMARY KEY (ticket_booking_id),
256
+ INDEX (booking_id),
257
+ INDEX (ticket_id)
258
+ ) DEFAULT CHARSET=utf8 ;";
259
+
260
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
261
+ dbDelta($sql);
262
+ }
263
+
264
  function em_add_options() {
265
+ $contact_person_email_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) will attend #_NAME on #F #j, #Y. He wants to reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces reserved, #_AVAILABLESPACES are still available.<br/>Yours faithfully,<br/>Events Manager - http://wp-events-plugin.com",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
266
+ $contact_person_email_cancelled_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) cancelled his booking at #_NAME on #F #j, #Y. He wanted to reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces reserved, #_AVAILABLESPACES are still available.<br/>Yours faithfully,<br/>Events Manager - http://wp-events-plugin.com",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
267
+ $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br/>you have successfully reserved #_BOOKINGSPACES space/spaces for #_NAME.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
268
+ $respondent_email_pending_body_localizable = __("Dear #_BOOKINGNAME, <br/>You have requested #_BOOKEDSPACES space/spaces for #_NAME.<br/>Your booking is currently pending approval by our administrators. Once approved you will receive an automatic confirmation.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
269
+ $respondent_email_rejected_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_NAME on #F #j, #Y has been rejected.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
270
+ $respondent_email_cancelled_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_NAME on #F #j, #Y has been cancelled.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
271
 
272
  $dbem_options = array(
273
  //defaults
277
  'dbem_events_default_orderby' => 'start_date,start_time,name',
278
  'dbem_events_default_order' => 'ASC',
279
  'dbem_events_default_limit' => 10,
 
280
  'dbem_list_events_page' => 1,
281
  //Event Formatting
282
  'dbem_events_page_title' => __('Events','dbem'),
283
  'dbem_events_page_time_limit' => 0,
284
  'dbem_event_list_item_format' => '<li>#j #M #Y - #H:#i<br/> #_EVENTLINK<br/>#_LOCATIONTOWN </li>',
285
  'dbem_display_calendar_in_events_page' => 0,
286
+ 'dbem_single_event_format' => '<p>Date(s) - #j #M #Y #@_{ \u\n\t\i\l j M Y}<br />#_DESCRIPTION<br />Time - #_24HSTARTTIME - #_24HENDTIME<br /></p><p>Where - #_LOCATIONLINK, #_LOCATIONTOWN</p>#_MAP<br/>#_BOOKINGFORM',
287
  'dbem_event_page_title_format' => '#_NAME',
288
  'dbem_no_events_message' => __('No events','dbem'),
289
  //Location Formatting
290
+ 'dbem_location_default_country' => 'US',
291
  'dbem_location_page_title_format' => '#_LOCATIONNAME',
292
  'dbem_location_event_list_item_format' => "<li>#_LOCATIONNAME - #j #M #Y - #H:#i</li>",
293
  'dbem_location_list_item_format' => '#_LOCATIONLINK<ul><li>#_LOCATIONADDRESS</li><li>#_LOCATIONTOWN</li></ul>',
334
  'dbem_rsvp_enabled'=> 1,
335
  'dbem_categories_enabled'=> 1,
336
  'dbem_placeholders_custom' => '',
 
 
 
 
337
  //Title rewriting compatability
338
  'dbem_disable_title_rewrites'=> false,
339
  'dbem_title_html' => '<h2>#_PAGETITLE</h2>',
340
  //Bookings
341
+ 'dbem_bookings_form_max' => 20,
342
  'dbem_bookings_approval' => 1, //approval is on by default
343
+ 'dbem_bookings_approval_reserved' => 0, //overbooking before approval?
344
+ 'dbem_bookings_approval_overbooking' => 0, //overbooking possible when approving?
345
+ //Emails
346
+ 'dbem_default_contact_person' => 1, //admin
347
+ 'dbem_bookings_notify_admin' => 0,
348
+ 'dbem_bookings_contact_email' => 1,
349
+ 'dbem_bookings_contact_email_subject' => __("New booking",'dbem'),
350
+ 'dbem_bookings_contact_email_body' => str_replace("<br/>", "\n\r", $contact_person_email_body_localizable),
351
+ 'dbem_contactperson_email_cancelled_subject' => __("Booking Cancelled",'dbem'),
352
+ 'dbem_contactperson_email_cancelled_body' => str_replace("<br/>", "\n\r", $contact_person_email_cancelled_body_localizable),
353
+ 'dbem_bookings_email_pending_subject' => __("Booking Pending",'dbem'),
354
+ 'dbem_bookings_email_pending_body' => str_replace("<br/>", "\n\r", $respondent_email_pending_body_localizable),
355
+ 'dbem_bookings_email_rejected_subject' => __("Booking Rejected",'dbem'),
356
+ 'dbem_bookings_email_rejected_body' => str_replace("<br/>", "\n\r", $respondent_email_rejected_body_localizable),
357
+ 'dbem_bookings_email_confirmed_subject' => __('Booking Confirmed','dbem'),
358
+ 'dbem_bookings_email_confirmed_body' => str_replace("<br/>", "\n\r", $respondent_email_body_localizable),
359
+ 'dbem_bookings_email_cancelled_subject' => __('Booking Cancelled','dbem'),
360
+ 'dbem_bookings_email_cancelled_body' => str_replace("<br/>", "\n\r", $respondent_email_cancelled_body_localizable),
361
+ //Bookings Form - beta
362
+ 'dbem_bookings_page' => '<p>Date/Time - #j #M #Y #_12HSTARTTIME #@_{ \u\n\t\i\l j M Y}<br />Where - #_LOCATIONLINK</p>#_EXCERPT #_BOOKINGFORM<p>'.__('Powered by','dbem').'<a href="http://wp-events-plugin.com">events manager</a></p>',
363
+ 'dbem_bookings_page_title' => __('Bookings - #_NAME','dbem'),
364
+ //Ticket Specific Options
365
+ 'dbem_bookings_tickets_priority' => 0,
366
+ 'dbem_bookings_tickets_show_unavailable' => 0,
367
+ 'dbem_bookings_tickets_show_loggedout' => 1,
368
  //Flags
369
  'dbem_hello_to_user' => 1,
370
+ //BP Settings
371
+ 'dbem_bp_events_list_format_header' => '<ul>',
372
+ 'dbem_bp_events_list_format' => '<li>#_EVENTLINK - #j #M #Y #_12HSTARTTIME #@_{ \u\n\t\i\l j M Y}<ul><li>#_LOCATIONLINK - #_LOCATIONADDRESS, #_LOCATIONTOWN</li></ul></li>',
373
+ 'dbem_bp_events_list_format_footer' => '</ul>',
374
+ 'dbem_bp_events_list_none_format' => '<p>'.__('No Events','dbem').'</p>'
375
  );
376
 
377
  foreach($dbem_options as $key => $value){
378
  add_option($key, $value);
379
  }
380
+ }
381
+
382
+ function em_set_mass_caps( $roles, $caps ){
383
+ global $wp_roles;
384
+ foreach( $roles as $user_role ){
385
+ foreach($caps as $cap){
386
+ $wp_roles->add_cap($user_role, $cap);
 
 
 
 
 
 
 
387
  }
 
 
 
388
  }
389
+ }
390
+
391
+ function em_set_capabilities(){
392
+ //Get default roles
393
+ global $wp_roles;
394
+ if( get_option('dbem_version') == '' || get_option('dbem_version') < 4 ){
395
+ //Assign caps in groups, as we go down, permissions are "looser"
396
+ $caps = array('publish_others_events', 'edit_others_events', 'delete_others_events', 'edit_others_locations', 'delete_others_locations', 'manage_others_bookings', 'edit_categories');
397
+ em_set_mass_caps( array('administrator','editor'), $caps );
398
+
399
+ //Add all the open caps
400
+ $users = array('administrator','editor');
401
+ $caps = array('edit_events', 'edit_locations', 'delete_events', 'manage_bookings', 'delete_locations', 'edit_recurrences', 'read_others_locations');
402
+ em_set_mass_caps( array('administrator','editor'), $caps );
403
+ if( get_option('dbem_version') == '' ){ //so pre v4 doesn't get security loopholes
404
+ em_set_mass_caps(array('contributor','author','subscriber'), $caps);
405
+ }
406
+ }
407
+ }
408
 
409
  function em_create_events_page(){
410
  global $wpdb,$current_user;
428
  function em_migrate_to_new_tables(){
429
  global $wpdb, $current_user;
430
  get_currentuserinfo();
431
+ $errors = array();
432
+
433
+ //approve all old events
434
+ $wpdb->query('UPDATE '.$wpdb->prefix.EM_EVENTS_TABLE.' SET event_status=1');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
 
436
+ //give all old events a default ticket
437
+ $wpdb->query("INSERT INTO ".$wpdb->prefix.EM_TICKETS_TABLE." (`event_id`, `ticket_name`, `ticket_spaces`) SELECT event_id, 'Standard' as ticket_name, event_spaces FROM ".$wpdb->prefix.EM_EVENTS_TABLE." WHERE recurrence!=1 and event_rsvp=1");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
 
439
+ //make slugs the ids for now
440
+
441
+ //create permalinks for each location, category, event
442
+ $array = array('event' => $wpdb->prefix.EM_EVENTS_TABLE, 'location' => $wpdb->prefix.EM_LOCATIONS_TABLE, 'category' => $wpdb->prefix.EM_CATEGORIES_TABLE);
443
+ foreach( $array as $prefix => $table ){
444
+ $used_slugs = array();
445
+ $results = $wpdb->get_results("SELECT {$prefix}_id AS id, {$prefix}_slug AS slug, {$prefix}_name AS name FROM $table", ARRAY_A);
446
+ foreach($results as $row){
447
+ $slug = sanitize_title($row['name']);
448
+ $count = 2;
449
+ while( in_array($slug, $used_slugs) ){
450
+ $slug = preg_replace('/\-[0-9]+$/', '', $slug).'-'.$count;
451
+ $count++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  }
453
+ $wpdb->query("UPDATE $table SET {$prefix}_slug='$slug' WHERE {$prefix}_id={$row['id']}");
454
+ $used_slugs[] = $slug;
455
  }
 
456
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  }
 
458
  ?>
em-rss.php CHANGED
@@ -1,7 +1,9 @@
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">
@@ -31,8 +33,9 @@ function em_rss() {
31
  </channel>
32
  </rss>
33
  <?php
 
34
  die ();
35
  }
36
  }
37
- add_action ( 'init', 'em_rss' );
38
  ?>
1
  <?php
2
  function em_rss() {
3
+ global $post, $wp_query;
4
+ if ( !empty($_REQUEST['dbem_rss']) || (is_object($post) && $post->ID == get_option('dbem_events_page') && $wp_query->get('rss')) ) {
5
  header ( "Content-type: text/xml" );
6
+ ob_start();
7
  echo "<?xml version='1.0'?>\n";
8
  ?>
9
  <rss version="2.0">
33
  </channel>
34
  </rss>
35
  <?php
36
+ echo apply_filters('em_rss', ob_get_clean());
37
  die ();
38
  }
39
  }
40
+ add_action ( 'template_redirect', 'em_rss' );
41
  ?>
events-manager.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
- Version: 3.0.95
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
8
  Author URI: http://wp-events-plugin.com
9
  */
@@ -40,12 +40,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
40
  //Known Bugs
41
  //FIXME admin panel showing future events shows event of day before
42
  //FIXME when saving event, select screen has reversed order of events
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");
@@ -69,8 +82,14 @@ include_once('classes/em-location.php');
69
  include_once('classes/em-locations.php');
70
  include_once("classes/em-mailer.php") ;
71
  include_once('classes/em-map.php');
 
72
  include_once('classes/em-people.php');
73
  include_once('classes/em-person.php');
 
 
 
 
 
74
  //Admin Files
75
  if( is_admin() ){
76
  include_once('admin/em-admin.php');
@@ -91,25 +110,33 @@ if( is_admin() ){
91
  include_once('admin/bookings/em-pending.php');
92
  include_once('admin/bookings/em-person.php');
93
  }
 
 
 
 
 
94
 
95
 
96
  // Setting constants
97
- define('EM_VERSION', 3.095); //self expanatory
 
98
  define('EM_CATEGORIES_TABLE', 'em_categories'); //TABLE NAME
99
  define('EM_EVENTS_TABLE','em_events'); //TABLE NAME
 
 
100
  define('EM_META_TABLE','em_meta'); //TABLE NAME
101
  define('EM_RECURRENCE_TABLE','dbem_recurrence'); //TABLE NAME
102
  define('EM_LOCATIONS_TABLE','em_locations'); //TABLE NAME
103
  define('EM_BOOKINGS_TABLE','em_bookings'); //TABLE NAME
104
  define('EM_PEOPLE_TABLE','em_people'); //TABLE NAME
105
- define('EM_MIN_CAPABILITY', 'edit_posts'); // Minimum user level to access calendars
106
- define('EM_SETTING_CAPABILITY', 'activate_plugins'); // Minimum user level to access calendars
 
107
  define("EM_IMAGE_UPLOAD_DIR", "wp-content/uploads/locations-pics");
 
 
108
  //TODO reorganize how defaults are created, e.g. is it necessary to create false entries? They are false by default... less code, but maybe not verbose enough...
109
 
110
- // DEBUG constant for developing
111
- // if you are hacking this plugin, set to TRUE, a log will show in admin pages
112
- define('DEBUG', false);
113
 
114
  // FILTERS
115
  // filters for general events field (corresponding to those of "the _title")
@@ -133,13 +160,42 @@ add_filter('dbem_notes_rss', 'ent2ncr', 8);
133
  add_filter('dbem_notes_map', 'convert_chars', 8);
134
  add_filter('dbem_notes_map', 'js_escape');
135
 
136
- // LOCALIZATION
137
- // Localised date formats as in the jquery UI datepicker plugin
138
- // TODO Sort out dates, (ref: output idea)
139
- function em_load_plugin_textdomain(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  load_plugin_textdomain('dbem', false, dirname( plugin_basename( __FILE__ ) ).'/includes/langs');
141
  }
142
- add_filter('plugins_loaded','em_load_plugin_textdomain');
 
 
 
 
 
 
 
 
 
 
143
 
144
  /**
145
  * This function will load an event into the global $EM_Event variable during page initialization, provided an event_id is given in the url via GET or POST.
@@ -148,33 +204,43 @@ add_filter('plugins_loaded','em_load_plugin_textdomain');
148
  * @return null
149
  */
150
  function em_load_event(){
151
- global $EM_Event, $EM_Recurrences, $EM_Location, $EM_Mailer, $EM_Person, $EM_Booking, $EM_Category;
152
- $EM_Recurrences = array();
153
- if( isset( $_REQUEST['event_id'] ) && is_numeric($_REQUEST['event_id']) ){
154
- $EM_Event = new EM_Event($_REQUEST['event_id']);
155
- }
156
- if( isset($_REQUEST['recurrence_id']) && is_numeric($_REQUEST['recurrence_id']) ){
157
- //Eventually we can just remove this.... each event has an event_id regardless of what it is.
158
- $EM_Event = new EM_Event($_REQUEST['recurrence_id']);
159
- }
160
- if( isset($_REQUEST['location_id']) && is_numeric($_REQUEST['location_id']) ){
161
- $EM_Location = new EM_Location($_REQUEST['location_id']);
162
- }
163
- if( isset($_REQUEST['person_id']) && is_numeric($_REQUEST['person_id']) ){
164
- $EM_Person = new EM_Person($_REQUEST['person_id']);
165
- }
166
- if( isset($_REQUEST['booking_id']) && is_numeric($_REQUEST['booking_id']) ){
167
- $EM_Booking = new EM_Booking($_REQUEST['booking_id']);
168
- }
169
- if( isset($_REQUEST['category_id']) && is_numeric($_REQUEST['category_id']) ){
170
- $EM_Category = new EM_Category($_REQUEST['category_id']);
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
- $EM_Mailer = new EM_Mailer();
173
- define('EM_URI', get_permalink(get_option("dbem_events_page"))); //PAGE URI OF EM
174
- define('EM_RSS_URI', get_bloginfo('wpurl')."/?dbem_rss=main"); //RSS PAGE URI
175
  }
176
- add_action('init', 'em_load_event', 1);
177
-
 
178
  /**
179
  * Settings link in the plugins page menu
180
  * @param array $links
@@ -201,7 +267,7 @@ function em_create_events_submenu () {
201
  //Count pending bookings
202
  $num = '';
203
  if( get_option('dbem_bookings_approval') == 1){
204
- $bookings_pending_count = count(EM_Bookings::get(array('status'=>0)));
205
  //TODO Add flexible permissions
206
  if($bookings_pending_count > 0){
207
  $num = '<span class="update-plugins count-'.$bookings_pending_count.'"><span class="plugin-count">'.$bookings_pending_count.'</span></span>';
@@ -210,19 +276,14 @@ function em_create_events_submenu () {
210
  add_object_page(__('Events', 'dbem'),__('Events', 'dbem').$num,EM_MIN_CAPABILITY,'events-manager','em_admin_events_page', '../wp-content/plugins/events-manager/includes/images/calendar-16.png');
211
  // Add a submenu to the custom top-level menu:
212
  $plugin_pages = array();
213
- $plugin_pages[] = add_submenu_page('events-manager', __('Edit'),__('Edit'),EM_MIN_CAPABILITY,'events-manager','em_admin_events_page');
214
- $plugin_pages[] = add_submenu_page('events-manager', __('Add new', 'dbem'), __('Add new','dbem'), EM_MIN_CAPABILITY, 'events-manager-event', "em_admin_event_page");
215
- if( get_option('dbem_permissions_locations') != 1 || em_verify_admin() ){
216
- $plugin_pages[] = add_submenu_page('events-manager', __('Locations', 'dbem'), __('Locations', 'dbem'), EM_MIN_CAPABILITY, 'events-manager-locations', "em_admin_locations_page");
217
- }
218
- if(get_option('dbem_rsvp_enabled') == 1){
219
- $plugin_pages[] = add_submenu_page('events-manager', __('Bookings', 'dbem'), __('Bookings', 'dbem').$num, EM_MIN_CAPABILITY, 'events-manager-bookings', "em_bookings_page");
220
- }
221
- if( get_option('dbem_permissions_categories') != 1 || em_verify_admin() ){
222
- $plugin_pages[] = add_submenu_page('events-manager', __('Event Categories','dbem'),__('Categories','dbem'), EM_MIN_CAPABILITY, "events-manager-categories", 'em_admin_categories_page');
223
- }
224
- $plugin_pages[] = add_submenu_page('events-manager', __('Events Manager Settings','dbem'),__('Settings','dbem'), EM_SETTING_CAPABILITY, "events-manager-options", 'em_admin_options_page');
225
- $plugin_pages[] = add_submenu_page('events-manager', __('Getting Help for Events Manager','dbem'),__('Help','dbem'), EM_SETTING_CAPABILITY, "events-manager-help", 'em_admin_help_page');
226
  foreach($plugin_pages as $plugin_page){
227
  add_action( 'admin_print_scripts-'. $plugin_page, 'em_admin_load_scripts' );
228
  add_action( 'admin_head-'. $plugin_page, 'em_admin_general_script' );
@@ -232,16 +293,40 @@ function em_create_events_submenu () {
232
  }
233
  add_action('admin_menu','em_create_events_submenu');
234
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
  /**
237
  * Enqueing public scripts and styles
238
  */
239
  function em_enqueue_public() {
240
- wp_enqueue_script ( 'jquery' ); //make sure we have jquery loaded
241
- wp_enqueue_script('events-manager', WP_PLUGIN_URL.'/events-manager/includes/js/em_maps.js', array('jquery'));
 
 
 
 
242
  wp_enqueue_style('events-manager', WP_PLUGIN_URL.'/events-manager/includes/css/events_manager.css'); //main css
243
  }
244
- add_action ( 'template_redirect', 'em_enqueue_public' );
245
 
246
  /**
247
  * Add a link to the favourites menu
@@ -257,6 +342,8 @@ add_filter ( 'favorite_actions', 'em_favorite_menu' );
257
 
258
  /* Creating the wp_events table to store event data*/
259
  function em_activate() {
 
 
260
  require_once(WP_PLUGIN_DIR.'/events-manager/em-install.php');
261
  em_install();
262
  }
@@ -265,4 +352,34 @@ register_activation_hook( __FILE__,'em_activate');
265
  if( !empty($_GET['em_reimport']) || get_option('dbem_import_fail') == '1' ){
266
  require_once(WP_PLUGIN_DIR.'/events-manager/em-install.php');
267
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
+ Version: 3.096
5
  Plugin URI: http://wp-events-plugin.com
6
+ Description: A complete event management solution for wordpress. Recurring events, locations, google maps, rss, bookings and more!
7
  Author: Davide Benini, Marcus Sykes
8
  Author URI: http://wp-events-plugin.com
9
  */
40
  //Known Bugs
41
  //FIXME admin panel showing future events shows event of day before
42
  //FIXME when saving event, select screen has reversed order of events
43
+ //DEBUG MODE
44
+ if( !defined('WP_DEBUG') && get_option('dbem_wp_debug') ){
45
+ define('WP_DEBUG',true);
46
+ }
47
+ function dbem_debug_mode(){
48
+ if( !empty($_REQUEST['dbem_debug_off']) ){
49
+ update_option('dbem_debug',0);
50
+ wp_redirect($_SERVER['HTTP_REFERER']);
51
+ }
52
+ if( current_user_can('activate_plugins') ){
53
+ include_once('em-debug.php');
54
+ }
55
+ }
56
+ add_action('plugins_loaded', 'dbem_debug_mode');
57
 
58
  // INCLUDES
59
  include_once('classes/em-object.php'); //Base object, any files below may depend on this
60
  //Template Tags & Template Logic
61
+ include_once("em-actions.php");
62
  include_once("em-bookings.php");
63
  include_once("em-events.php");
64
  include_once("em-functions.php");
82
  include_once('classes/em-locations.php');
83
  include_once("classes/em-mailer.php") ;
84
  include_once('classes/em-map.php');
85
+ include_once('classes/em-notices.php');
86
  include_once('classes/em-people.php');
87
  include_once('classes/em-person.php');
88
+ include_once('classes/em-permalinks.php');
89
+ include_once('classes/em-ticket-booking.php');
90
+ include_once('classes/em-ticket.php');
91
+ include_once('classes/em-tickets-bookings.php');
92
+ include_once('classes/em-tickets.php');
93
  //Admin Files
94
  if( is_admin() ){
95
  include_once('admin/em-admin.php');
110
  include_once('admin/bookings/em-pending.php');
111
  include_once('admin/bookings/em-person.php');
112
  }
113
+ /* Only load the component if BuddyPress is loaded and initialized. */
114
+ function bp_em_init() {
115
+ require( dirname( __FILE__ ) . '/buddypress/bp-em-core.php' );
116
+ }
117
+ add_action( 'bp_init', 'bp_em_init' );
118
 
119
 
120
  // Setting constants
121
+ define('EM_VERSION', 4.0012); //self expanatory
122
+ define('EM_DIR', dirname( __FILE__ )); //an absolute path to this directory
123
  define('EM_CATEGORIES_TABLE', 'em_categories'); //TABLE NAME
124
  define('EM_EVENTS_TABLE','em_events'); //TABLE NAME
125
+ define('EM_TICKETS_TABLE', 'em_tickets'); //TABLE NAME
126
+ define('EM_TICKETS_BOOKINGS_TABLE', 'em_tickets_bookings'); //TABLE NAME
127
  define('EM_META_TABLE','em_meta'); //TABLE NAME
128
  define('EM_RECURRENCE_TABLE','dbem_recurrence'); //TABLE NAME
129
  define('EM_LOCATIONS_TABLE','em_locations'); //TABLE NAME
130
  define('EM_BOOKINGS_TABLE','em_bookings'); //TABLE NAME
131
  define('EM_PEOPLE_TABLE','em_people'); //TABLE NAME
132
+ define('EM_MIN_CAPABILITY', 'edit_events'); // Minimum user level to add events
133
+ define('EM_EDITOR_CAPABILITY', 'publish_events'); // Minimum user level to access calendars
134
+ define('EM_SETTING_CAPABILITY', 'activate_plugins'); // Minimum user level to edit settings in EM
135
  define("EM_IMAGE_UPLOAD_DIR", "wp-content/uploads/locations-pics");
136
+ // Localised date formats as in the jquery UI datepicker plugin but for php date
137
+ $localised_date_formats = array("am" => "d.m.Y","ar" => "d/m/Y", "bg" => "d.m.Y", "ca" => "m/d/Y", "cs" => "d.m.Y", "da" => "d-m-Y", "de" =>"d.m.Y", "es" => "d/m/Y", "en" => "m/d/Y", "fi" => "d.m.Y", "fr" => "d/m/Y", "he" => "d/m/Y", "hu" => "Y-m-d", "hy" => "d.m.Y", "id" => "d/m/Y", "is" => "d/m/Y", "it" => "d/m/Y", "ja" => "Y/m/d", "ko" => "Y-m-d", "lt" => "Y-m-d", "lv" => "d-m-Y", "nl" => "d.m.Y", "no" => "Y-m-d", "pl" => "Y-m-d", "pt" => "d/m/Y", "ro" => "m/d/Y", "ru" => "d.m.Y", "sk" => "d.m.Y", "sv" => "Y-m-d", "th" => "d/m/Y", "tr" => "d.m.Y", "ua" => "d.m.Y", "uk" => "d.m.Y", "us" => "m/d/Y", "CN" => "Y-m-d", "TW" => "Y/m/d");
138
  //TODO reorganize how defaults are created, e.g. is it necessary to create false entries? They are false by default... less code, but maybe not verbose enough...
139
 
 
 
 
140
 
141
  // FILTERS
142
  // filters for general events field (corresponding to those of "the _title")
160
  add_filter('dbem_notes_map', 'convert_chars', 8);
161
  add_filter('dbem_notes_map', 'js_escape');
162
 
163
+ /**
164
+ * Perform plugins_loaded actions
165
+ */
166
+ function em_plugins_loaded(){
167
+ //Capabilities
168
+ global $em_capabilities_array;
169
+ $em_capabilities_array = apply_filters('em_capabilities_array', array(
170
+ 'publish_events' => sprintf(__('You do not have permission to publish %s','dbem'),__('events','dbem')),
171
+ 'edit_categories' => sprintf(__('You do not have permission to edit %s','dbem'),__('categories','dbem')),
172
+ 'delete_others_events' => sprintf(__('You do not have permission to delete others %s','dbem'),__('events','dbem')),
173
+ 'delete_others_locations' => sprintf(__('You do not have permission to delete others %s','dbem'),__('locations','dbem')),
174
+ 'edit_others_locations' => sprintf(__('You do not have permission to edit others %s','dbem'),__('locations','dbem')),
175
+ 'manage_others_bookings' => sprintf(__('You do not have permission to manage others %s','dbem'),__('bookings','dbem')),
176
+ 'edit_others_events' => sprintf(__('You do not have permission to edit others %s','dbem'),__('events','dbem')),
177
+ 'delete_locations' => sprintf(__('You do not have permission to delete %s','dbem'),__('locations','dbem')),
178
+ 'delete_events' => sprintf(__('You do not have permission to delete %s','dbem'),__('events','dbem')),
179
+ 'edit_locations' => sprintf(__('You do not have permission to edit %s','dbem'),__('locations','dbem')),
180
+ 'manage_bookings' => sprintf(__('You do not have permission to manage %s','dbem'),__('bookings','dbem')),
181
+ 'read_others_locations' => sprintf(__('You cannot to view others %s','dbem'),__('locations','dbem')),
182
+ 'edit_recurrences' => sprintf(__('You do not have permission to edit %s','dbem'),__('recurrences','dbem')),
183
+ 'edit_events' => sprintf(__('You do not have permission to edit %s','dbem'),__('events','dbem'))
184
+ ));
185
+ // LOCALIZATION
186
  load_plugin_textdomain('dbem', false, dirname( plugin_basename( __FILE__ ) ).'/includes/langs');
187
  }
188
+ add_filter('plugins_loaded','em_plugins_loaded');
189
+
190
+ /**
191
+ * Perform init actions
192
+ */
193
+ function em_init(){
194
+ //Hard Links
195
+ define('EM_URI', get_permalink(get_option("dbem_events_page"))); //PAGE URI OF EM
196
+ define('EM_RSS_URI', trailingslashit(EM_URI)."rss/"); //RSS PAGE URI
197
+ }
198
+ add_filter('init','em_init');
199
 
200
  /**
201
  * This function will load an event into the global $EM_Event variable during page initialization, provided an event_id is given in the url via GET or POST.
204
  * @return null
205
  */
206
  function em_load_event(){
207
+ global $EM_Event, $EM_Recurrences, $EM_Location, $EM_Mailer, $EM_Person, $EM_Booking, $EM_Category, $EM_Ticket, $current_user;
208
+ if( !defined('EM_LOADED') ){
209
+ $EM_Recurrences = array();
210
+ if( isset( $_REQUEST['event_id'] ) && is_numeric($_REQUEST['event_id']) && !is_object($EM_Event) ){
211
+ $EM_Event = new EM_Event($_REQUEST['event_id']);
212
+ }elseif( isset($_REQUEST['event_slug']) && !is_object($EM_Event) ){
213
+ $EM_Event = new EM_Event( $_REQUEST['event_slug'] );
214
+ }
215
+ if( isset($_REQUEST['location_id']) && is_numeric($_REQUEST['location_id']) && !is_object($EM_Location) ){
216
+ $EM_Location = new EM_Location($_REQUEST['location_id']);
217
+ }elseif( isset($_REQUEST['location_slug']) && !is_object($EM_Location) ){
218
+ $EM_Location = new EM_Location($_REQUEST['location_slug']);
219
+ }
220
+ if( is_user_logged_in() || (!empty($_REQUEST['person_id']) && is_numeric($_REQUEST['person_id'])) ){
221
+ //make the request id take priority, this shouldn't make it into unwanted objects if they use theobj::get_person().
222
+ if( !empty($_REQUEST['person_id']) ){
223
+ $EM_Person = new EM_Person( $_REQUEST['person_id'] );
224
+ }else{
225
+ $EM_Person = new EM_Person( get_current_user_id() );
226
+ }
227
+ }
228
+ if( isset($_REQUEST['booking_id']) && is_numeric($_REQUEST['booking_id']) && !is_object($_REQUEST['booking_id']) ){
229
+ $EM_Booking = new EM_Booking($_REQUEST['booking_id']);
230
+ }
231
+ if( isset($_REQUEST['category_id']) && is_numeric($_REQUEST['category_id']) && !is_object($_REQUEST['category_id']) ){
232
+ $EM_Category = new EM_Category($_REQUEST['category_id']);
233
+ }
234
+ if( isset($_REQUEST['ticket_id']) && is_numeric($_REQUEST['ticket_id']) && !is_object($_REQUEST['ticket_id']) ){
235
+ $EM_Ticket = new EM_Ticket($_REQUEST['ticket_id']);
236
+ }
237
+ $EM_Mailer = new EM_Mailer();
238
+ define('EM_LOADED',true);
239
  }
 
 
 
240
  }
241
+ add_action('template_redirect', 'em_load_event');
242
+ if(is_admin()){ add_action('init', 'em_load_event', 2); }
243
+
244
  /**
245
  * Settings link in the plugins page menu
246
  * @param array $links
267
  //Count pending bookings
268
  $num = '';
269
  if( get_option('dbem_bookings_approval') == 1){
270
+ $bookings_pending_count = count(EM_Bookings::get(array('status'=>0))->bookings);
271
  //TODO Add flexible permissions
272
  if($bookings_pending_count > 0){
273
  $num = '<span class="update-plugins count-'.$bookings_pending_count.'"><span class="plugin-count">'.$bookings_pending_count.'</span></span>';
276
  add_object_page(__('Events', 'dbem'),__('Events', 'dbem').$num,EM_MIN_CAPABILITY,'events-manager','em_admin_events_page', '../wp-content/plugins/events-manager/includes/images/calendar-16.png');
277
  // Add a submenu to the custom top-level menu:
278
  $plugin_pages = array();
279
+ $plugin_pages[] = add_submenu_page('events-manager', __('Edit'),__('Edit'),'edit_events','events-manager','em_admin_events_page');
280
+ $plugin_pages[] = add_submenu_page('events-manager', __('Add new', 'dbem'), __('Add new','dbem'), 'edit_events', 'events-manager-event', "em_admin_event_page");
281
+ $plugin_pages[] = add_submenu_page('events-manager', __('Locations', 'dbem'), __('Locations', 'dbem'), 'edit_locations', 'events-manager-locations', "em_admin_locations_page");
282
+ $plugin_pages[] = add_submenu_page('events-manager', __('Bookings', 'dbem'), __('Bookings', 'dbem').$num, 'manage_bookings', 'events-manager-bookings', "em_bookings_page");
283
+ $plugin_pages[] = add_submenu_page('events-manager', __('Event Categories','dbem'),__('Categories','dbem'), 'edit_categories', "events-manager-categories", 'em_admin_categories_page');
284
+ $plugin_pages[] = add_submenu_page('events-manager', __('Events Manager Settings','dbem'),__('Settings','dbem'), 'activate_plugins', "events-manager-options", 'em_admin_options_page');
285
+ $plugin_pages[] = add_submenu_page('events-manager', __('Getting Help for Events Manager','dbem'),__('Help','dbem'), 'activate_plugins', "events-manager-help", 'em_admin_help_page');
286
+ $plugin_pages = apply_filters('em_create_events_submenu',$plugin_pages);
 
 
 
 
 
287
  foreach($plugin_pages as $plugin_page){
288
  add_action( 'admin_print_scripts-'. $plugin_page, 'em_admin_load_scripts' );
289
  add_action( 'admin_head-'. $plugin_page, 'em_admin_general_script' );
293
  }
294
  add_action('admin_menu','em_create_events_submenu');
295
 
296
+ /**
297
+ * Works much like <a href="http://codex.wordpress.org/Function_Reference/locate_template" target="_blank">locate_template</a>, except it takes a string instead of an array of templates, we only need to load one.
298
+ * @param string $template_name
299
+ * @param boolean $load
300
+ * @uses locate_template()
301
+ * @return string
302
+ */
303
+ function em_locate_template( $template_name, $load=false ) {
304
+ //First we check if there are overriding tempates in the child or parent theme
305
+ $located = locate_template(array('plugins/events-manager/'.$template_name));
306
+ if( !$located ){
307
+ if ( file_exists(EM_DIR.'/templates/'.$template_name) ) {
308
+ $located = EM_DIR.'/templates/'.$template_name;
309
+ }
310
+ }
311
+ if( $load ){
312
+ include($located);
313
+ }
314
+ return $located;
315
+ }
316
 
317
  /**
318
  * Enqueing public scripts and styles
319
  */
320
  function em_enqueue_public() {
321
+ //Scripts
322
+ wp_enqueue_script('events-manager', WP_PLUGIN_URL.'/events-manager/includes/js/em_maps.js', array('jquery', 'jquery-form')); //jQuery will load as dependency
323
+ wp_localize_script('events-manager','EM', array(
324
+ 'ajaxurl' => admin_url( 'admin-ajax.php' )
325
+ ));
326
+ //Styles
327
  wp_enqueue_style('events-manager', WP_PLUGIN_URL.'/events-manager/includes/css/events_manager.css'); //main css
328
  }
329
+ add_action ( 'init', 'em_enqueue_public' );
330
 
331
  /**
332
  * Add a link to the favourites menu
342
 
343
  /* Creating the wp_events table to store event data*/
344
  function em_activate() {
345
+ global $wp_rewrite;
346
+ $wp_rewrite->flush_rules();
347
  require_once(WP_PLUGIN_DIR.'/events-manager/em-install.php');
348
  em_install();
349
  }
352
  if( !empty($_GET['em_reimport']) || get_option('dbem_import_fail') == '1' ){
353
  require_once(WP_PLUGIN_DIR.'/events-manager/em-install.php');
354
  }
355
+
356
+ /**
357
+ * reset capabilities for testing purposes
358
+ */
359
+ function em_set_capabilities2(){
360
+ //Get default roles
361
+ global $wp_roles;
362
+ //if( get_option('dbem_version') == '' && get_option('dbem_version') < 4 ){
363
+ //Assign caps in groups, as we go down, permissions are "looser"
364
+ $func = 'remove_cap';
365
+ //Delete
366
+ $wp_roles->$func('administrator', 'delete_events');
367
+ $wp_roles->$func('editor', 'delete_events');
368
+ //Publish Events
369
+ $wp_roles->$func('administrator', 'publish_events');
370
+ $wp_roles->$func('editor', 'publish_events');
371
+ //Edit Others Events
372
+ $wp_roles->$func('administrator', 'edit_others_events');
373
+ $wp_roles->$func('editor', 'edit_others_events');
374
+ //Add/Edit Events
375
+ $wp_roles->$func('administrator', 'edit_events');
376
+ $wp_roles->$func('editor', 'edit_events');
377
+ //if(get_option('dbem_version') == ''){
378
+ $wp_roles->$func('contributor', 'edit_events');
379
+ $wp_roles->$func('author', 'edit_events');
380
+ $wp_roles->$func('subscriber', 'edit_events');
381
+ //}
382
+ //}
383
+ }
384
+ //add_action('admin_init', 'em_set_capabilities2');
385
  ?>
includes/css/events_manager.css CHANGED
@@ -1,46 +1,22 @@
1
- table#dbem-bookings-table tfoot td.booking-result {
2
- font-weight: bold;
3
- background:#6D6D6D url(../../../wp-admin/images/menu-bits.gif) repeat-x scroll left top;
4
- color: #eee;
5
- }
6
-
7
- table#dbem-bookings-table tfoot th {
8
- text-align: right;
9
- padding-right: 1em;
10
- }
11
-
12
- table.dbem-rsvp-form {
13
- width: 80%;
14
  }
15
- table.dbem-rsvp-form th {
16
- text-align: left;
17
- width: 30%;
18
- }
19
-
20
- table.dbem-rsvp-form td {
21
- padding-left: 1em;
22
- text-align: left;
23
- }
24
-
25
- table.dbem-rsvp-form td input {
26
- margin:0px;
27
- }
28
 
29
- div.dbem-rsvp-message {
30
  margin-bottom: 1em;
31
  background-color: #FDDD73;
32
  padding: 5px;
33
  border: 2px solid #FF9100;
34
  }
35
 
36
- div.dbem-rsvp-message-success {
37
  margin-bottom: 1em;
38
  background-color: #5BBF58;
39
  padding: 5px;
40
  border: 2px solid #499B47;
41
  }
42
 
43
- div.dbem-rsvp-message-error {
44
  margin-bottom: 1em;
45
  background-color: #DF9477;
46
  padding: 5px;
@@ -65,7 +41,7 @@ table#bookings-table {
65
  table#bookings-table td {
66
  padding: 5px 0;
67
  }
68
- table#bookings-table td.seats-number {
69
  text-align: right;
70
  padding-right: 20px;
71
  }
@@ -73,7 +49,7 @@ table#bookings-table th {
73
  text-align: left;
74
  margin-left: 5px;
75
  }
76
- table#bookings-table tr#booked-seats td{
77
  border-top: 2px solid #999;
78
  }
79
 
@@ -81,7 +57,7 @@ table#bookings-table td.total-label {
81
  text-align: right;
82
  }
83
 
84
- table#bookings-table tr#booked-seats td.seats-number, table#bookings-table tr#available-seats td.seats-number {
85
  font-weight: bold;
86
  }
87
 
@@ -108,7 +84,7 @@ table.dbem-calendar-table td.eventful a, table.dbem-calendar-table td.eventful-t
108
  font-weight: bold;
109
  color: #FD7E29;
110
  }
111
- table.dbem-calendar-table td.eventless-today, table.dbem-calendar-table td.eventful-today {
112
  background-color: #CFCFCF;
113
  }
114
  table.dbem-calendar-table thead {
1
+ #em-booking-form {
2
+ position:relative;
 
 
 
 
 
 
 
 
 
 
 
3
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ div.em-booking-message {
6
  margin-bottom: 1em;
7
  background-color: #FDDD73;
8
  padding: 5px;
9
  border: 2px solid #FF9100;
10
  }
11
 
12
+ div.em-booking-message-success {
13
  margin-bottom: 1em;
14
  background-color: #5BBF58;
15
  padding: 5px;
16
  border: 2px solid #499B47;
17
  }
18
 
19
+ div.em-booking-message-error {
20
  margin-bottom: 1em;
21
  background-color: #DF9477;
22
  padding: 5px;
41
  table#bookings-table td {
42
  padding: 5px 0;
43
  }
44
+ table#bookings-table td.spaces-number {
45
  text-align: right;
46
  padding-right: 20px;
47
  }
49
  text-align: left;
50
  margin-left: 5px;
51
  }
52
+ table#bookings-table tr#booked-spaces td{
53
  border-top: 2px solid #999;
54
  }
55
 
57
  text-align: right;
58
  }
59
 
60
+ table#bookings-table tr#booked-spaces td.spaces-number, table#bookings-table tr#available-spaces td.spaces-number {
61
  font-weight: bold;
62
  }
63
 
84
  font-weight: bold;
85
  color: #FD7E29;
86
  }
87
+ table.dbem-calendar-table td.eventless-today {
88
  background-color: #CFCFCF;
89
  }
90
  table.dbem-calendar-table thead {
includes/css/events_manager_admin.css CHANGED
@@ -1,7 +1,7 @@
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;
@@ -51,10 +51,38 @@ p#recurrence_warning {
51
  div#icon-events{
52
  background:url('../images/calendar-32.png') no-repeat center;
53
  }
 
 
 
 
54
 
55
  /* Events Add Page */
56
  #event-form #event-name, #location-form, #location-name { margin: 2px 0 7px; padding: 6px 5px; width: 100%; }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  /* Google Map Object */
59
  #location-balloon-content h3 { background:none; text-shadow:none; }
60
 
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.warning {
5
  border: 2px solid #FD0000;
6
  background: #FF7146;
7
  color: #fff;
51
  div#icon-events{
52
  background:url('../images/calendar-32.png') no-repeat center;
53
  }
54
+ /* Events List */
55
+ table.events-table tr.pending { background:#FCFFA8 }
56
+ table.events-table tr.past { background:#E4E4E4 }
57
+ table.events-table .category { color:#888; }
58
 
59
  /* Events Add Page */
60
  #event-form #event-name, #location-form, #location-name { margin: 2px 0 7px; padding: 6px 5px; width: 100%; }
61
 
62
+ /*Tickets*/
63
+ .em-tickets-row .ticket-status span.ticket_on { display:block; width:10px; height:10px; background:green; }
64
+ .em-tickets-row .ticket-status span.ticket_off { display:block; width:10px; height:10px; background:red; }
65
+ .em-tickets-row .ticket-status span.ticket_new { display:block; width:10px; height:10px; background:grey; }
66
+ #event-tickets th { width:auto; }
67
+ #event-tickets th.ticket-status { width:20px; }
68
+ #em-tickets-form { margin-top:10px; display:none; }
69
+ #em-tickets-form input[type=text] { width:97%; padding:2px; color:#666; }
70
+ #em-tickets-form { background-color:#fff; color:#333; display:none; width:350px; padding:15px; text-align:left; border:2px solid #333; opacity:0.8; -moz-border-radius:6px; -webkit-border-radius:6px; -moz-box-shadow: 0 0 50px #ccc; -webkit-box-shadow: 0 0 50px #ccc; }
71
+ #em-tickets-form h4 { font-size:16px; margin:0px; padding:0px; }
72
+ #em-tickets-form form { overflow:auto; }
73
+ #em-tickets-form .close { background:url(../images/close.png) 0px 0px no-repeat !important; position:absolute; right:-15px; top:-15px; cursor:pointer; height:35px; width:35px; border:none; padding:0px; margin:0px; }
74
+ #em-tickets-form #wp-submit { display:block; clear:both; }
75
+
76
+ /* Booking admin area */
77
+ #em-booking-details .inside { padding:5px 10px; }
78
+ .stuffbox .inside h4 { font-size:16px; font-weight:normal; margin:10px 0px 20px; font-weight:bold; }
79
+ /* Ticket table info */
80
+ table.em-tickets-bookings-table { width:90%; border:1px #efefef solid; margin:10px 0px; }
81
+ table.em-tickets-bookings-table th, table.em-tickets-bookings-table td { padding:5px 5px; margin:0px; }
82
+ table.em-tickets-bookings-table thead th, table.em-tickets-bookings-table tfoot th { background:#cdcdcd; text-align:center }
83
+ table.em-tickets-bookings-table tbody td.ticket-type { text-align:left; padding-left:10px; }
84
+ table.em-tickets-bookings-table tbody td { text-align:center; }
85
+
86
  /* Google Map Object */
87
  #location-balloon-content h3 { background:none; text-shadow:none; }
88
 
includes/images/close.png ADDED
Binary file
includes/js/em_admin.js CHANGED
@@ -1,24 +1,107 @@
1
  jQuery(document).ready( function($) {
2
- // Managing bookings delete operations -old
3
- $('a.bookingdelbutton').click( function(){
4
- eventId = (jQuery(this).parents('table:first').attr('id').split("-"))[3];
5
- idToRemove = (jQuery(this).parents('tr:first').attr('id').split("-"))[1];
6
- $.ajax({
7
- type: "POST",
8
- url: "admin.php?page=events-manager-bookings&action=remove_booking",
9
- data: "booking_id="+ idToRemove,
10
- success: function(){
11
- $('tr#booking-' + idToRemove).fadeOut('slow');
12
- $.getJSON("admin.php?page=events-manager-people&dbem_ajax_action=booking_data",{id: eventId, ajax: 'true'}, function(data){
13
- booked = data[0].bookedSeats;
14
- available = data[0].availableSeats;
15
- $('td#booked-seats').text(booked);
16
- $('td#available-seats').text(available);
17
- });
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  });
20
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  //Manageing Bookings
23
  //Widgets and filter submissions
24
  $('.em_bookings_events_table form, .em_bookings_pending_table form').live('submit', function(e){
@@ -42,7 +125,7 @@ jQuery(document).ready( function($) {
42
  });
43
  //Approve/Reject Links
44
  $('.em-bookings-approve,.em-bookings-reject,.em-bookings-unapprove,.em-bookings-delete').live('click', function(){
45
- var el = $(this);
46
  if( el.hasClass('em-bookings-delete') ){
47
  if( !confirm("Are you sure you want to delete?") ){ return false; }
48
  }
@@ -52,59 +135,7 @@ jQuery(document).ready( function($) {
52
  td.load( url );
53
  return false;
54
  });
55
-
56
- //Attributes
57
- $('#mtm_add_tag').click( function(event){
58
- event.preventDefault();
59
- //Get All meta rows
60
- var metas = $('#mtm_body').children();
61
- //Copy first row and change values
62
- var metaCopy = $(metas[0]).clone(true);
63
- newId = metas.length + 1;
64
- metaCopy.attr('id', 'mtm_'+newId);
65
- metaCopy.find('a').attr('rel', newId);
66
- metaCopy.find('[name=mtm_1_ref]').attr({
67
- name:'mtm_'+newId+'_ref' ,
68
- value:''
69
- });
70
- metaCopy.find('[name=mtm_1_content]').attr({
71
- name:'mtm_'+newId+'_content' ,
72
- value:''
73
- });
74
- metaCopy.find('[name=mtm_1_name]').attr({
75
- name:'mtm_'+newId+'_name' ,
76
- value:''
77
- });
78
- //Insert into end of file
79
- $('#mtm_body').append(metaCopy);
80
- //Duplicate the last entry, remove values and rename id
81
- });
82
- $('#mtm_body a').click( function(event){
83
- event.preventDefault();
84
- //Only remove if there's more than 1 meta tag
85
- if($('#mtm_body').children().length > 1){
86
- //Remove the item
87
- var parents = $(this).parents('#mtm_body tr').first().remove();
88
- //Renumber all the items
89
- $('#mtm_body').children().each( function(i){
90
- metaCopy = $(this);
91
- oldId = metaCopy.attr('id').replace('mtm_','');
92
- newId = i+1;
93
- metaCopy.attr('id', 'mtm_'+newId);
94
- metaCopy.find('a').attr('rel', newId);
95
- metaCopy.find('[name=mtm_'+ oldId +'_ref]').attr('name', 'mtm_'+newId+'_ref');
96
- metaCopy.find('[name=mtm_'+ oldId +'_content]').attr('name', 'mtm_'+newId+'_content');
97
- metaCopy.find('[name=mtm_'+ oldId +'_name]').attr( 'name', 'mtm_'+newId+'_name');
98
- });
99
- }else{
100
- metaCopy = $(this).parents('#mtm_body tr').first();
101
- metaCopy.find('[name=mtm_1_ref]').attr('value', '');
102
- metaCopy.find('[name=mtm_1_content]').attr('value', '');
103
- metaCopy.find('[name=mtm_1_name]').attr( 'value', '');
104
- alert("If you don't want any meta tags, just leave the text boxes blank and submit");
105
- }
106
- });
107
-
108
  //Datepicker
109
  if( $('#date-to-submit').length > 0 ){
110
  $("#localised-date").datepicker({
@@ -126,9 +157,20 @@ jQuery(document).ready( function($) {
126
  $("#localised-date").val(start_date_formatted);
127
  $("#localised-end-date").val(end_date_formatted);
128
  }
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
 
131
-
132
  //Location stuff - only needed if inputs for location exist
133
  if( $('select#location-select-id, input#location-name').length > 0 ){
134
 
@@ -178,8 +220,19 @@ jQuery(document).ready( function($) {
178
  }
179
  }
180
  $('#location-select-id').change( function(){get_map_by_id($(this).val())} );
181
- $('#location-town, #location-address').change( function(){
182
- var address = $('#location-address').val() + ', ' + $('#location-town').val();
 
 
 
 
 
 
 
 
 
 
 
183
  if( address != '' && $('#em-map').length > 0 ){
184
  geocoder.geocode( { 'address': address }, function(results, status) {
185
  if (status == google.maps.GeocoderStatus.OK) {
@@ -242,19 +295,85 @@ jQuery(document).ready( function($) {
242
  });
243
  },
244
  formatItem: function(item) {
245
- return item.value + '<br><span style="font-size:11px"><em>'+ item.address + ', ' + item.town;
246
  },
247
  formatResult: function(item){
248
  return item.value;
249
  }
250
  }).result(function(e, item) {
251
  e.preventDefault();
252
- $( "input#location-name" ).val(item.value);
 
253
  $('input#location-address').val(item.address);
254
  $('input#location-town').val(item.town);
 
 
 
 
 
 
 
255
  get_map_by_id(item.id);
256
  });
257
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  });
259
 
260
 
1
  jQuery(document).ready( function($) {
2
+ //Events List
3
+ //Approve/Reject Links
4
+ $('.em-event-delete').live('click', function(){
5
+ if( !confirm("Are you sure you want to delete?") ){ return false; }
6
+ var url = em_ajaxify( el.attr('href'));
7
+ var td = el.parents('td').first();
8
+ td.html("Loading...");
9
+ td.load( url );
10
+ return false;
11
+ });
12
+ //Tickets
13
+ //Tickets overlay
14
+ var triggers = $("#em-tickets-add").overlay({
15
+ mask: {
16
+ color: '#ebecff',
17
+ loadSpeed: 200,
18
+ opacity: 0.9
19
+ },
20
+ closeOnClick: true,
21
+ onLoad: function(){
22
+ $('#ui-datepicker-div').appendTo('#em-tickets-form form');
23
+ }
24
+ });
25
+ //Submitting ticket (Add/Edit)
26
+ $('#em-tickets-form form').submit(function(e){
27
+ e.preventDefault();
28
+ $('#em-tickets-intro').remove();
29
+ //first we get the template to insert this to
30
+ if( $('#em-tickets-form form input[name=prev_slot]').val() ){
31
+ //grab slot and populate
32
+ var slot = $('#'+$('#em-tickets-form form input[name=prev_slot]').val());
33
+ var rowNo = slot.attr('id').replace('em-tickets-row-','');
34
+ var edit = true;
35
+ }else{
36
+ //create copy of template slot, insert so ready for population
37
+ var rowNo = $('#em-tickets-body').children('tr').length+1;
38
+ var slot = $('#em-tickets-template').clone().attr('id','em-tickets-row-'+ rowNo).appendTo($('#em-tickets-body'));
39
+ var edit = false;
40
+ slot.show();
41
+ }
42
+ var postData = {};
43
+ $.each($('#em-tickets-form form *[name]'), function(index,el){
44
+ el = $(el);
45
+ slot.find('input.'+el.attr('name')).attr({
46
+ 'value' : el.attr('value'),
47
+ 'name' : 'em_tickets['+rowNo+']['+el.attr('name')+']'
48
+ });
49
+ slot.find('span.'+el.attr('name')).text(el.attr('value'));
50
+ });
51
+ //sort out dates and localization masking
52
+ var start_pub = $("#em-tickets-form input[name=ticket_start_pub]").val();
53
+ var end_pub = $("#em-tickets-form input[name=ticket_end_pub]").val();
54
+ $('#em-tickets-form *[name]').attr('value','');
55
+ $('#em-tickets-form .close').trigger('click');
56
+ return false;
57
  });
58
+ //Edit a Ticket
59
+ $('.ticket-actions-edit').live('click',function(e){
60
+ //first, populate form, then, trigger click
61
+ e.preventDefault();
62
+ $('#em-tickets-add').trigger('click');
63
+ var rowId = $(this).parents('tr').first().attr('id');
64
+ $('#em-tickets-form *[name]').attr('value','');
65
+ $.each( $('#'+rowId+' *[name]'), function(index,el){
66
+ var el = $(el);
67
+ var selector = el.attr('class');
68
+ $('#em-tickets-form *[name='+selector+']').attr('value',el.attr('value'));
69
+ });
70
+ $("#em-tickets-form input[name=prev_slot]").attr('value',rowId);
71
+ $("#em-tickets-form input[name=ticket_start_pub]").datepicker('refresh');
72
+ $("#em-tickets-form input[name=ticket_end_pub]").datepicker('refresh');
73
 
74
+ date_dateFormat = $("#localised-date").datepicker('option', 'dateFormat');
75
+ if( $('#em-tickets-form input[name=ticket_start]').val() != '' || $('#em-tickets-form input[name=ticket_end]').val() != '' ){
76
+ start_date_formatted = $.datepicker.formatDate( date_dateFormat, $.datepicker.parseDate('yy-mm-dd', $('#em-tickets-form input[name=ticket_start]').val()) );
77
+ end_date_formatted = $.datepicker.formatDate( date_dateFormat, $.datepicker.parseDate('yy-mm-dd', $('#em-tickets-form input[name=ticket_end]').val()) );
78
+ $("#em-tickets-form input[name=ticket_start_pub]").val(start_date_formatted);
79
+ $("#em-tickets-form input[name=ticket_end_pub]").val(end_date_formatted);
80
+ }
81
+ return false;
82
+ });
83
+ //Delete a ticket
84
+ $('.ticket-actions-delete').live('click',function(e){
85
+ e.preventDefault();
86
+ var el = $(this);
87
+ var rowId = $(this).parents('tr').first().attr('id');
88
+ if( $('#'+rowId+' input.ticket_id').attr('value') == '' ){
89
+ //not saved to db yet, so just remove
90
+ $('#'+rowId).remove();
91
+ }else{
92
+ //only will happen if no bookings made
93
+ el.text('Deleting...');
94
+ $.getJSON( $(this).attr('href'), {'em_ajax_action':'delete_ticket', 'id':$('#'+rowId+' input.ticket_id').attr('value')}, function(data){
95
+ if(data.result){
96
+ $('#'+rowId).remove();
97
+ }else{
98
+ el.text('Delete');
99
+ alert(data.error);
100
+ }
101
+ });
102
+ }
103
+ return false;
104
+ });
105
  //Manageing Bookings
106
  //Widgets and filter submissions
107
  $('.em_bookings_events_table form, .em_bookings_pending_table form').live('submit', function(e){
125
  });
126
  //Approve/Reject Links
127
  $('.em-bookings-approve,.em-bookings-reject,.em-bookings-unapprove,.em-bookings-delete').live('click', function(){
128
+ var el = $(this);
129
  if( el.hasClass('em-bookings-delete') ){
130
  if( !confirm("Are you sure you want to delete?") ){ return false; }
131
  }
135
  td.load( url );
136
  return false;
137
  });
138
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  //Datepicker
140
  if( $('#date-to-submit').length > 0 ){
141
  $("#localised-date").datepicker({
157
  $("#localised-date").val(start_date_formatted);
158
  $("#localised-end-date").val(end_date_formatted);
159
  }
160
+ $("#em-tickets-form input[name=ticket_start_pub]").datepicker({
161
+ altField: "#em-tickets-form input[name=ticket_start]",
162
+ altFormat: "yy-mm-dd",
163
+ changeMonth: true,
164
+ changeYear: true
165
+ });
166
+ $("#em-tickets-form input[name=ticket_end_pub]").datepicker({
167
+ altField: "#em-tickets-form input[name=ticket_end]",
168
+ altFormat: "yy-mm-dd",
169
+ changeMonth: true,
170
+ changeYear: true
171
+ });
172
  }
173
 
 
174
  //Location stuff - only needed if inputs for location exist
175
  if( $('select#location-select-id, input#location-name').length > 0 ){
176
 
220
  }
221
  }
222
  $('#location-select-id').change( function(){get_map_by_id($(this).val())} );
223
+ $('#location-town, #location-address, #location-state, #location-postcode, #location-country').change( function(){
224
+ //build address
225
+ var addresses = [ $('#location-address').val(), $('#location-town').val(), $('#location-state').val(), $('#location-postcode').val() ];
226
+ var address = '';
227
+ jQuery.each( addresses, function(i, val){
228
+ if( val != '' ){
229
+ address = ( address == '' ) ? address+val:address+', '+val;
230
+ }
231
+ });
232
+ //do country last, as it's using the text version
233
+ if( $('#location-country option:selected').val() != 0 ){
234
+ address = ( address == '' ) ? address+$('#location-country option:selected').text():address+', '+$('#location-country option:selected').text();
235
+ }
236
  if( address != '' && $('#em-map').length > 0 ){
237
  geocoder.geocode( { 'address': address }, function(results, status) {
238
  if (status == google.maps.GeocoderStatus.OK) {
295
  });
296
  },
297
  formatItem: function(item) {
298
+ return item.value + '<br><span style="font-size:11px"><em>'+ item.address + ', ' + item.town+"</em></span>";
299
  },
300
  formatResult: function(item){
301
  return item.value;
302
  }
303
  }).result(function(e, item) {
304
  e.preventDefault();
305
+ $("input#location-id" ).val(item.id);
306
+ $("input#location-name" ).val(item.value);
307
  $('input#location-address').val(item.address);
308
  $('input#location-town').val(item.town);
309
+ $('input#location-state').val(item.state);
310
+ $('input#location-postcode').val(item.postcode);
311
+ if( item.country == '' ){
312
+ $('select#location-country option:selected').removeAttr('selected');
313
+ }else{
314
+ $('select#location-country option[value="'+item.country+'"]').attr('selected', 'selected');
315
+ }
316
  get_map_by_id(item.id);
317
  });
318
  }
319
+
320
+ //previously in em-admin.php
321
+ function updateIntervalDescriptor () {
322
+ $(".interval-desc").hide();
323
+ var number = "-plural";
324
+ if ($('input#recurrence-interval').val() == 1 || $('input#recurrence-interval').val() == "")
325
+ number = "-singular"
326
+ var descriptor = "span#interval-"+$("select#recurrence-frequency").val()+number;
327
+ $(descriptor).show();
328
+ }
329
+ function updateIntervalSelectors () {
330
+ $('p.alternate-selector').hide();
331
+ $('p#'+ $('select#recurrence-frequency').val() + "-selector").show();
332
+ }
333
+ function updateShowHideRecurrence () {
334
+ if( $('input#event-recurrence').attr("checked")) {
335
+ $("#event_recurrence_pattern").fadeIn();
336
+ $("#event-date-explanation").hide();
337
+ $("#recurrence-dates-explanation").show();
338
+ $("h3#recurrence-dates-title").show();
339
+ $("h3#event-date-title").hide();
340
+ } else {
341
+ $("#event_recurrence_pattern").hide();
342
+ $("#recurrence-dates-explanation").hide();
343
+ $("#event-date-explanation").show();
344
+ $("h3#recurrence-dates-title").hide();
345
+ $("h3#event-date-title").show();
346
+ }
347
+ }
348
+ $("#recurrence-dates-explanation").hide();
349
+ $("#date-to-submit").hide();
350
+ $("#end-date-to-submit").hide();
351
+
352
+ $("#localised-date").show();
353
+ $("#localised-end-date").show();
354
+
355
+ $('input.select-all').change(function(){
356
+ if($(this).is(':checked'))
357
+ $('input.row-selector').attr('checked', true);
358
+ else
359
+ $('input.row-selector').attr('checked', false);
360
+ });
361
+
362
+ updateIntervalDescriptor();
363
+ updateIntervalSelectors();
364
+ updateShowHideRecurrence();
365
+ $('input#event-recurrence').change(updateShowHideRecurrence);
366
+
367
+ // recurrency elements
368
+ $('input#recurrence-interval').keyup(updateIntervalDescriptor);
369
+ $('select#recurrence-frequency').change(updateIntervalDescriptor);
370
+ $('select#recurrence-frequency').change(updateIntervalSelectors);
371
+
372
+ // hiding or showing notes according to their content
373
+ $('.postbox h3').prepend('<a class="togbox">+</a> ');
374
+ $('#event_notes h3').click( function() {
375
+ $(this).parent().first().toggleClass('closed');
376
+ });
377
  });
378
 
379
 
includes/js/em_maps.js CHANGED
@@ -1,91 +1,91 @@
1
- var maps = {};
2
-
3
- jQuery(document).ready( function($){
4
- if( $('.em-location-map').length > 0 || $('.em-locations-map').length > 0 ){
5
- var script = document.createElement("script");
6
- script.setAttribute("src", "http://maps.google.com/maps/api/js?sensor=false&callback=em_maps");
7
- script.setAttribute("type", "text/javascript");
8
- document.documentElement.firstChild.appendChild(script);
9
- }
10
- });
11
-
12
- //Load single maps (each map is treated as a seperate map.
13
- function em_maps() {
14
- //Find all the maps on this page
15
- jQuery('.em-location-map').each( function(index){
16
- el = jQuery(this);
17
- var map_id = el.attr('id').replace('em-location-map-','');
18
- em_LatLng = new google.maps.LatLng( jQuery('#em-location-map-coords-'+map_id+' .lat').text(), jQuery('#em-location-map-coords-'+map_id+' .lng').text());
19
- maps[map_id] = new google.maps.Map( document.getElementById('em-location-map-'+map_id), {
20
- zoom: 14,
21
- center: em_LatLng,
22
- mapTypeId: google.maps.MapTypeId.ROADMAP,
23
- mapTypeControl: false
24
- });
25
- var marker = new google.maps.Marker({
26
- position: em_LatLng,
27
- map: maps[map_id]
28
- });
29
- var infowindow = new google.maps.InfoWindow({ content: document.getElementById('em-location-map-info-'+map_id).firstElementChild });
30
- infowindow.open(maps[map_id],marker);
31
- //JS Hook for handling map after instantiation
32
- if( jQuery.isFunction(em_maps_location_hook) ){ em_maps_location_hook( maps[map_id], infowindow ); }
33
- });
34
- jQuery('.em-locations-map').each( function(index){
35
- var el = jQuery(this);
36
- var map_id = el.attr('id').replace('em-locations-map-','');
37
- var em_data = jQuery.parseJSON( jQuery('#em-locations-map-coords-'+map_id).text() );
38
- jQuery.getJSON(document.URL, em_data , function(data){
39
- if(data.length > 0){
40
- var myLatlng = new google.maps.LatLng(data[0].location_latitude,data[0].location_longitude);
41
- var myOptions = {
42
- mapTypeId: google.maps.MapTypeId.ROADMAP
43
- };
44
- maps[map_id] = new google.maps.Map(document.getElementById("em-locations-map-"+map_id), myOptions);
45
-
46
- var minLatLngArr = [0,0];
47
- var maxLatLngArr = [0,0];
48
-
49
- for (var i = 0; i < data.length; i++) {
50
- if( !(data[i].location_latitude == 0 && data[i].location_longitude == 0) ){
51
- var latitude = parseFloat( data[i].location_latitude );
52
- var longitude = parseFloat( data[i].location_longitude );
53
- var location = new google.maps.LatLng( latitude, longitude );
54
- var marker = new google.maps.Marker({
55
- position: location,
56
- map: maps[map_id]
57
- });
58
- marker.setTitle(data[i].location_name);
59
- 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>';
60
- em_map_infobox(marker, myContent, maps[map_id]);
61
-
62
- //Get min and max long/lats
63
- minLatLngArr[0] = (latitude < minLatLngArr[0] || i == 0) ? latitude : minLatLngArr[0];
64
- minLatLngArr[1] = (longitude < minLatLngArr[1] || i == 0) ? longitude : minLatLngArr[1];
65
- maxLatLngArr[0] = (latitude > maxLatLngArr[0] || i == 0) ? latitude : maxLatLngArr[0];
66
- maxLatLngArr[1] = (longitude > maxLatLngArr[1] || i == 0) ? longitude : maxLatLngArr[1];
67
- }
68
- }
69
- // Zoom in to the bounds
70
- var minLatLng = new google.maps.LatLng(minLatLngArr[0],minLatLngArr[1]);
71
- var maxLatLng = new google.maps.LatLng(maxLatLngArr[0],maxLatLngArr[1]);
72
- var bounds = new google.maps.LatLngBounds(minLatLng,maxLatLng);
73
- maps[map_id].fitBounds(bounds);
74
- //Call a hook if exists
75
- if( jQuery.isFunction(em_maps_locations_hook) ){ em_maps_locations_hook( maps[map_id] ); }
76
- }else{
77
- el.children().first().html('No locations found');
78
- }
79
- });
80
- });
81
- }
82
-
83
- // The five markers show a secret message when clicked
84
- // but that message is not within the marker's instance data
85
-
86
- function em_map_infobox(marker, message, map) {
87
- var infowindow = new google.maps.InfoWindow({ content: message });
88
- google.maps.event.addListener(marker, 'click', function() {
89
- infowindow.open(map,marker);
90
- });
91
  }
1
+ var maps = {};
2
+
3
+ jQuery(document).ready( function($){
4
+ if( $('.em-location-map').length > 0 || $('.em-locations-map').length > 0 ){
5
+ var script = document.createElement("script");
6
+ script.setAttribute("src", "http://maps.google.com/maps/api/js?sensor=false&callback=em_maps");
7
+ script.setAttribute("type", "text/javascript");
8
+ document.documentElement.firstChild.appendChild(script);
9
+ }
10
+ });
11
+
12
+ //Load single maps (each map is treated as a seperate map.
13
+ function em_maps() {
14
+ //Find all the maps on this page
15
+ jQuery('.em-location-map').each( function(index){
16
+ el = jQuery(this);
17
+ var map_id = el.attr('id').replace('em-location-map-','');
18
+ em_LatLng = new google.maps.LatLng( jQuery('#em-location-map-coords-'+map_id+' .lat').text(), jQuery('#em-location-map-coords-'+map_id+' .lng').text());
19
+ maps[map_id] = new google.maps.Map( document.getElementById('em-location-map-'+map_id), {
20
+ zoom: 14,
21
+ center: em_LatLng,
22
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
23
+ mapTypeControl: false
24
+ });
25
+ var marker = new google.maps.Marker({
26
+ position: em_LatLng,
27
+ map: maps[map_id]
28
+ });
29
+ var infowindow = new google.maps.InfoWindow({ content: document.getElementById('em-location-map-info-'+map_id).firstElementChild });
30
+ infowindow.open(maps[map_id],marker);
31
+ //JS Hook for handling map after instantiation
32
+ if( jQuery.isFunction(em_maps_location_hook) ){ em_maps_location_hook( maps[map_id], infowindow ); }
33
+ });
34
+ jQuery('.em-locations-map').each( function(index){
35
+ var el = jQuery(this);
36
+ var map_id = el.attr('id').replace('em-locations-map-','');
37
+ var em_data = jQuery.parseJSON( jQuery('#em-locations-map-coords-'+map_id).text() );
38
+ jQuery.getJSON(document.URL, em_data , function(data){
39
+ if(data.length > 0){
40
+ var myLatlng = new google.maps.LatLng(data[0].location_latitude,data[0].location_longitude);
41
+ var myOptions = {
42
+ mapTypeId: google.maps.MapTypeId.ROADMAP
43
+ };
44
+ maps[map_id] = new google.maps.Map(document.getElementById("em-locations-map-"+map_id), myOptions);
45
+
46
+ var minLatLngArr = [0,0];
47
+ var maxLatLngArr = [0,0];
48
+
49
+ for (var i = 0; i < data.length; i++) {
50
+ if( !(data[i].location_latitude == 0 && data[i].location_longitude == 0) ){
51
+ var latitude = parseFloat( data[i].location_latitude );
52
+ var longitude = parseFloat( data[i].location_longitude );
53
+ var location = new google.maps.LatLng( latitude, longitude );
54
+ var marker = new google.maps.Marker({
55
+ position: location,
56
+ map: maps[map_id]
57
+ });
58
+ marker.setTitle(data[i].location_name);
59
+ 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>';
60
+ em_map_infobox(marker, myContent, maps[map_id]);
61
+
62
+ //Get min and max long/lats
63
+ minLatLngArr[0] = (latitude < minLatLngArr[0] || i == 0) ? latitude : minLatLngArr[0];
64
+ minLatLngArr[1] = (longitude < minLatLngArr[1] || i == 0) ? longitude : minLatLngArr[1];
65
+ maxLatLngArr[0] = (latitude > maxLatLngArr[0] || i == 0) ? latitude : maxLatLngArr[0];
66
+ maxLatLngArr[1] = (longitude > maxLatLngArr[1] || i == 0) ? longitude : maxLatLngArr[1];
67
+ }
68
+ }
69
+ // Zoom in to the bounds
70
+ var minLatLng = new google.maps.LatLng(minLatLngArr[0],minLatLngArr[1]);
71
+ var maxLatLng = new google.maps.LatLng(maxLatLngArr[0],maxLatLngArr[1]);
72
+ var bounds = new google.maps.LatLngBounds(minLatLng,maxLatLng);
73
+ maps[map_id].fitBounds(bounds);
74
+ //Call a hook if exists
75
+ if( jQuery.isFunction(em_maps_locations_hook) ){ em_maps_locations_hook( maps[map_id] ); }
76
+ }else{
77
+ el.children().first().html('No locations found');
78
+ }
79
+ });
80
+ });
81
+ }
82
+
83
+ // The five markers show a secret message when clicked
84
+ // but that message is not within the marker's instance data
85
+
86
+ function em_map_infobox(marker, message, map) {
87
+ var infowindow = new google.maps.InfoWindow({ content: message });
88
+ google.maps.event.addListener(marker, 'click', function() {
89
+ infowindow.open(map,marker);
90
+ });
91
  }
includes/js/em_ui.js CHANGED
@@ -24,4 +24,16 @@
24
  * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
25
  */;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false;}progress+=seperator;});words[wordAt]=v;v=words.join(options.multipleSeparator);}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value)return[""];if(!options.multiple)return[$.trim(value)];return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null;});}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);if(words.length==1)return words[0];var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""));}return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else{$input.val("");$input.trigger("result",null);}}});}};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else
26
  if(data[q]){return data[q];}else
27
- if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select();}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}}else if(this.setSelectionRange){this.setSelectionRange(start,end);}else if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end;}});}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}};})(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
24
  * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
25
  */;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false;}progress+=seperator;});words[wordAt]=v;v=words.join(options.multipleSeparator);}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value)return[""];if(!options.multiple)return[$.trim(value)];return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null;});}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);if(words.length==1)return words[0];var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""));}return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else{$input.val("");$input.trigger("result",null);}}});}};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else
26
  if(data[q]){return data[q];}else
27
+ if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select();}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}}else if(this.setSelectionRange){this.setSelectionRange(start,end);}else if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end;}});}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}};})(jQuery);
28
+
29
+ /* jQuery Tools 1.2.5 Overlay & Expose */
30
+ (function(a){function t(d,b){var c=this,j=d.add(c),o=a(window),k,f,m,g=a.tools.expose&&(b.mask||b.expose),n=Math.random().toString().slice(10);if(g){if(typeof g=="string")g={color:g};g.closeOnClick=g.closeOnEsc=false}var p=b.target||d.attr("rel");f=p?a(p):d;if(!f.length)throw"Could not find Overlay: "+p;d&&d.index(f)==-1&&d.click(function(e){c.load(e);return e.preventDefault()});a.extend(c,{load:function(e){if(c.isOpened())return c;var h=q[b.effect];if(!h)throw'Overlay: cannot find effect : "'+b.effect+
31
+ '"';b.oneInstance&&a.each(s,function(){this.close(e)});e=e||a.Event();e.type="onBeforeLoad";j.trigger(e);if(e.isDefaultPrevented())return c;m=true;g&&a(f).expose(g);var i=b.top,r=b.left,u=f.outerWidth({margin:true}),v=f.outerHeight({margin:true});if(typeof i=="string")i=i=="center"?Math.max((o.height()-v)/2,0):parseInt(i,10)/100*o.height();if(r=="center")r=Math.max((o.width()-u)/2,0);h[0].call(c,{top:i,left:r},function(){if(m){e.type="onLoad";j.trigger(e)}});g&&b.closeOnClick&&a.mask.getMask().one("click",
32
+ c.close);b.closeOnClick&&a(document).bind("click."+n,function(l){a(l.target).parents(f).length||c.close(l)});b.closeOnEsc&&a(document).bind("keydown."+n,function(l){l.keyCode==27&&c.close(l)});return c},close:function(e){if(!c.isOpened())return c;e=e||a.Event();e.type="onBeforeClose";j.trigger(e);if(!e.isDefaultPrevented()){m=false;q[b.effect][1].call(c,function(){e.type="onClose";j.trigger(e)});a(document).unbind("click."+n).unbind("keydown."+n);g&&a.mask.close();return c}},getOverlay:function(){return f},
33
+ getTrigger:function(){return d},getClosers:function(){return k},isOpened:function(){return m},getConf:function(){return b}});a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(e,h){a.isFunction(b[h])&&a(c).bind(h,b[h]);c[h]=function(i){i&&a(c).bind(h,i);return c}});k=f.find(b.close||".close");if(!k.length&&!b.close){k=a('<a class="close"></a>');f.prepend(k)}k.click(function(e){c.close(e)});b.load&&c.load()}a.tools=a.tools||{version:"1.2.5"};a.tools.overlay={addEffect:function(d,
34
+ b,c){q[d]=[b,c]},conf:{close:null,closeOnClick:true,closeOnEsc:true,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:false,mask:null,oneInstance:true,speed:"normal",target:null,top:"10%"}};var s=[],q={};a.tools.overlay.addEffect("default",function(d,b){var c=this.getConf(),j=a(window);if(!c.fixed){d.top+=j.scrollTop();d.left+=j.scrollLeft()}d.position=c.fixed?"fixed":"absolute";this.getOverlay().css(d).fadeIn(c.speed,b)},function(d){this.getOverlay().fadeOut(this.getConf().closeSpeed,
35
+ d)});a.fn.overlay=function(d){var b=this.data("overlay");if(b)return b;if(a.isFunction(d))d={onBeforeLoad:d};d=a.extend(true,{},a.tools.overlay.conf,d);this.each(function(){b=new t(a(this),d);s.push(b);a(this).data("overlay",b)});return d.api?b:this}})(jQuery);
36
+ (function(b){function k(){if(b.browser.msie){var a=b(document).height(),d=b(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,a-d<20?d:a]}return[b(document).width(),b(document).height()]}function h(a){if(a)return a.call(b.mask)}b.tools=b.tools||{version:"1.2.5"};var l;l=b.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,startOpacity:0,color:"#fff",onLoad:null,
37
+ onClose:null}};var c,i,e,g,j;b.mask={load:function(a,d){if(e)return this;if(typeof a=="string")a={color:a};a=a||g;g=a=b.extend(b.extend({},l.conf),a);c=b("#"+a.maskId);if(!c.length){c=b("<div/>").attr("id",a.maskId);b("body").append(c)}var m=k();c.css({position:"absolute",top:0,left:0,width:m[0],height:m[1],display:"none",opacity:a.startOpacity,zIndex:a.zIndex});a.color&&c.css("backgroundColor",a.color);if(h(a.onBeforeLoad)===false)return this;a.closeOnEsc&&b(document).bind("keydown.mask",function(f){f.keyCode==
38
+ 27&&b.mask.close(f)});a.closeOnClick&&c.bind("click.mask",function(f){b.mask.close(f)});b(window).bind("resize.mask",function(){b.mask.fit()});if(d&&d.length){j=d.eq(0).css("zIndex");b.each(d,function(){var f=b(this);/relative|absolute|fixed/i.test(f.css("position"))||f.css("position","relative")});i=d.css({zIndex:Math.max(a.zIndex+1,j=="auto"?0:j)})}c.css({display:"block"}).fadeTo(a.loadSpeed,a.opacity,function(){b.mask.fit();h(a.onLoad);e="full"});e=true;return this},close:function(){if(e){if(h(g.onBeforeClose)===
39
+ false)return this;c.fadeOut(g.closeSpeed,function(){h(g.onClose);i&&i.css({zIndex:j});e=false});b(document).unbind("keydown.mask");c.unbind("click.mask");b(window).unbind("resize.mask")}return this},fit:function(){if(e){var a=k();c.css({width:a[0],height:a[1]})}},getMask:function(){return c},isLoaded:function(a){return a?e=="full":e},getConf:function(){return g},getExposed:function(){return i}};b.fn.mask=function(a){b.mask.load(a);return this};b.fn.expose=function(a){b.mask.load(a,this);return this}})(jQuery);
includes/langs/events-manager.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Events Manager package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Events Manager 3.0.9\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/events-manager\n"
7
- "POT-Creation-Date: 2011-02-01 19:28:55+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -12,185 +12,335 @@ msgstr ""
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #: widgets/em-calendar.php:9
16
- msgid "Display your events in a calendar widget."
17
  msgstr ""
18
 
19
- #: widgets/em-calendar.php:10
20
- msgid "Events Calendar"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  msgstr ""
22
 
23
- #: widgets/em-calendar.php:40
24
  msgid "Calendar"
25
  msgstr ""
26
 
27
- #: widgets/em-calendar.php:49 widgets/em-locations.php:61
28
- #: widgets/em-events.php:70
 
 
 
 
 
 
 
 
29
  msgid "Title"
30
  msgstr ""
31
 
32
- #: widgets/em-calendar.php:53
33
  msgid "Show Long Events?"
34
  msgstr ""
35
 
36
- #: widgets/em-locations.php:9
37
- msgid "Display a list of event locations on Events Manager."
38
  msgstr ""
39
 
40
- #: widgets/em-locations.php:32
41
- msgid "No locations"
42
  msgstr ""
43
 
44
- #: widgets/em-locations.php:43
45
- msgid "Event Locations"
46
  msgstr ""
47
 
48
- #: widgets/em-locations.php:65
49
  msgid "Show number of locations"
50
  msgstr ""
51
 
52
- #: widgets/em-locations.php:69
53
  msgid "Scope of the locations"
54
  msgstr ""
55
 
56
- #: widgets/em-locations.php:71
57
  msgid "Locations with upcoming events"
58
  msgstr ""
59
 
60
- #: widgets/em-locations.php:72
61
  msgid "All locations"
62
  msgstr ""
63
 
64
- #: widgets/em-locations.php:73
65
  msgid "Locations with past events "
66
  msgstr ""
67
 
68
- #: widgets/em-locations.php:77
69
  msgid "Order of the locations"
70
  msgstr ""
71
 
72
- #: widgets/em-locations.php:79
73
  msgid "Ascendant"
74
  msgstr ""
75
 
76
- #: widgets/em-locations.php:80
77
  msgid "Descendant"
78
  msgstr ""
79
 
80
- #: widgets/em-locations.php:84 widgets/em-events.php:142
81
  msgid "List item format"
82
  msgstr ""
83
 
84
- #: widgets/em-events.php:9
85
- msgid "Display a list of events on Events Manager."
86
- msgstr ""
87
-
88
- #: widgets/em-events.php:38 em-install.php:229
89
- msgid "No events"
90
  msgstr ""
91
 
92
- #: widgets/em-events.php:41 widgets/em-events.php:61 widgets/em-events.php:151
93
- msgid "all events"
94
  msgstr ""
95
 
96
- #: widgets/em-events.php:53 em-template-tags.php:74 em-install.php:223
97
- #: em-install.php:237 em-install.php:238 em-install.php:256 em-install.php:334
98
- #: events-manager.php:207
99
- msgid "Events"
100
  msgstr ""
101
 
102
- #: widgets/em-events.php:74
103
  msgid "Number of events"
104
  msgstr ""
105
 
106
- #: widgets/em-events.php:78
107
  msgid "Scope of the events"
108
  msgstr ""
109
 
110
- #: widgets/em-events.php:80 admin/bookings/em-events.php:15
111
- #: admin/em-events.php:19 admin/em-events.php:61
 
112
  msgid "Future events"
113
  msgstr ""
114
 
115
- #: widgets/em-events.php:81 admin/bookings/em-events.php:14
116
- #: admin/em-events.php:18 admin/em-events.php:60
 
117
  msgid "All events"
118
  msgstr ""
119
 
120
- #: widgets/em-events.php:82 admin/bookings/em-events.php:13
121
- #: admin/em-events.php:17 admin/em-events.php:59
 
122
  msgid "Past events"
123
  msgstr ""
124
 
125
- #: widgets/em-events.php:86
126
  msgid "Time Limit"
127
  msgstr ""
128
 
129
- #: widgets/em-events.php:88 admin/em-options.php:196
130
  msgid "no limit"
131
  msgstr ""
132
 
133
- #: widgets/em-events.php:89 admin/em-options.php:197
134
  msgid "This month"
135
  msgstr ""
136
 
137
- #: widgets/em-events.php:90 admin/em-options.php:198
138
  msgid "Next two months"
139
  msgstr ""
140
 
141
- #: widgets/em-events.php:91
142
  msgid "Next three month"
143
  msgstr ""
144
 
145
- #: widgets/em-events.php:92
146
  msgid "Next six month"
147
  msgstr ""
148
 
149
- #: widgets/em-events.php:93
150
  msgid "Next twelve month"
151
  msgstr ""
152
 
153
- #: widgets/em-events.php:108
154
  msgid "Order By"
155
  msgstr ""
156
 
157
- #: widgets/em-events.php:112
158
  msgid "start date, start time, event name"
159
  msgstr ""
160
 
161
- #: widgets/em-events.php:113
162
  msgid "name, start date, start time"
163
  msgstr ""
164
 
165
- #: widgets/em-events.php:114
166
  msgid "name, end date, end time"
167
  msgstr ""
168
 
169
- #: widgets/em-events.php:115
170
  msgid "end date, end time, event name"
171
  msgstr ""
172
 
173
- #: widgets/em-events.php:126
174
  msgid "Order"
175
  msgstr ""
176
 
177
- #: widgets/em-events.php:130 admin/em-options.php:167
178
  msgid "Ascending"
179
  msgstr ""
180
 
181
- #: widgets/em-events.php:131 admin/em-options.php:168
182
  msgid "Descending"
183
  msgstr ""
184
 
185
- #: widgets/em-events.php:146
186
  msgid "Show all events link at bottom?"
187
  msgstr ""
188
 
189
- #: widgets/em-events.php:150
190
  msgid "All events link text?"
191
  msgstr ""
192
 
193
- #: em-functions.php:19
194
  msgid ""
195
  "<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We "
196
  "hope you like it around here.</p> \r\n"
@@ -206,322 +356,432 @@ msgid ""
206
  "again!</p>"
207
  msgstr ""
208
 
209
- #: em-functions.php:224 admin/em-options.php:295
210
- msgid "Yes"
211
  msgstr ""
212
 
213
- #: em-functions.php:225 admin/em-options.php:296
214
- msgid "No"
215
  msgstr ""
216
 
217
- #: em-ajax.php:75
218
- msgid "Booking Deleted"
219
  msgstr ""
220
 
221
- #: em-ajax.php:77
222
- msgid "Booking deletion unsuccessful"
 
223
  msgstr ""
224
 
225
- #: classes/em-map.php:21 classes/em-map.php:46
226
- msgid "Loading Map...."
227
  msgstr ""
228
 
229
- #: classes/em-map.php:55
230
- msgid "Map Unavailable"
 
 
 
 
 
 
 
 
 
 
231
  msgstr ""
232
 
233
- #: classes/em-location.php:41
234
  msgid "The location name"
235
  msgstr ""
236
 
237
- #: classes/em-location.php:41
238
  msgid "The location address"
239
  msgstr ""
240
 
241
- #: classes/em-location.php:41
242
  msgid "The location town"
243
  msgstr ""
244
 
245
- #: classes/em-location.php:143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  msgid "The image could not be loaded"
247
  msgstr ""
248
 
249
- #: classes/em-location.php:174
250
- msgid " is missing!"
251
  msgstr ""
252
 
253
- #: classes/em-location.php:182
254
  msgid "The image file is too big! Maximum size:"
255
  msgstr ""
256
 
257
- #: classes/em-location.php:188
258
  msgid "The image is too big! Maximum size allowed:"
259
  msgstr ""
260
 
261
- #: classes/em-location.php:191
262
  msgid "The image is in a wrong format!"
263
  msgstr ""
264
 
265
- #: classes/em-person.php:86 admin/em-options.php:23
266
- msgid "Changes saved."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  msgstr ""
268
 
269
- #: classes/em-person.php:86 classes/em-person.php:89
270
- msgid "Could not edit person details."
271
  msgstr ""
272
 
273
- #: classes/em-person.php:105
274
- msgid "Please provide a valid email address."
 
275
  msgstr ""
276
 
277
- #: classes/em-bookings.php:83
278
  msgid ""
279
  "Booking successful, pending confirmation (you will also receive an email "
280
  "once confirmed)."
281
  msgstr ""
282
 
283
- #: classes/em-bookings.php:85
284
  msgid "Booking successful."
285
  msgstr ""
286
 
287
- #: classes/em-bookings.php:88
288
  msgid ""
289
  "However, there were some problems whilst sending confirmation emails to you "
290
  "and/or the event contact person. You may want to contact them directly and "
291
  "letting them know of this error."
292
  msgstr ""
293
 
294
- #: classes/em-bookings.php:100
295
  msgid "Booking could not be created"
296
  msgstr ""
297
 
298
- #: classes/em-bookings.php:103
299
- msgid "Booking cannot be made, not enough seats available!"
300
- msgstr ""
301
-
302
- #: classes/em-bookings.php:163
303
  msgid "Bookings %s. Mails Sent."
304
  msgstr ""
305
 
306
- #: classes/em-bookings.php:167
307
  msgid "An error occurred."
308
  msgstr ""
309
 
310
- #: classes/em-bookings.php:418
311
  msgid "Booking details for \"%s\" as of %s"
312
  msgstr ""
313
 
314
- #: classes/em-booking.php:71 admin/bookings/em-events.php:136
315
- #: admin/em-events.php:174
 
 
 
316
  msgid "Pending"
317
  msgstr ""
318
 
319
- #: classes/em-booking.php:72
320
  msgid "Approved"
321
  msgstr ""
322
 
323
- #: classes/em-booking.php:73
324
  msgid "Rejected"
325
  msgstr ""
326
 
327
- #: classes/em-booking.php:74
328
  msgid "Cacncelled"
329
  msgstr ""
330
 
331
- #: classes/em-booking.php:101
332
- msgid "Changes saved"
333
  msgstr ""
334
 
335
- #: classes/em-booking.php:105
336
  msgid "Your booking has been recorded"
337
  msgstr ""
338
 
339
- #: classes/em-booking.php:108 classes/em-booking.php:109
340
- #: classes/em-booking.php:113 classes/em-booking.php:114
341
- msgid "There was a problem saving the booking."
 
 
 
 
 
 
 
342
  msgstr ""
343
 
344
- #: classes/em-booking.php:239
345
  msgid "Booking %s."
346
  msgstr ""
347
 
348
- #: classes/em-booking.php:241
349
  msgid "Mail Sent."
350
  msgstr ""
351
 
352
- #: classes/em-booking.php:244
353
  msgid "ERROR : Mail Not Sent."
354
  msgstr ""
355
 
356
- #: classes/em-booking.php:250
357
  msgid "Booking could not be %s."
358
  msgstr ""
359
 
360
- #: classes/em-booking.php:265
361
  msgid "Booking note successfully added."
362
  msgstr ""
363
 
364
- #: classes/em-booking.php:338
365
  msgid ""
366
  "Confirmation email could not be sent to contact person. Registrant should "
367
  "have gotten their email (only admin see this warning)."
368
  msgstr ""
369
 
370
- #: classes/em-booking.php:345
371
  msgid ""
372
  "Confirmation email could not be sent to admin. Registrant should have gotten "
373
  "their email (only admin see this warning)."
374
  msgstr ""
375
 
376
- #: classes/em-category.php:25
377
  msgid "The category name"
378
  msgstr ""
379
 
380
- #: classes/em-category.php:90 classes/em-event.php:407
381
- msgid "Missing fields: "
 
 
 
 
 
 
 
 
 
 
 
382
  msgstr ""
383
 
384
- #: classes/em-event.php:274
 
 
 
 
 
 
 
385
  msgid "There was a problem saving the location so event was not saved."
386
  msgstr ""
387
 
388
- #: classes/em-event.php:300 classes/em-event.php:329
 
 
 
 
389
  msgid "Something went wrong with the recurrence update..."
390
  msgstr ""
391
 
392
- #: classes/em-event.php:301 classes/em-event.php:330
393
  msgid "There was a problem saving the recurring events."
394
  msgstr ""
395
 
396
- #: classes/em-event.php:306
397
  msgid "New recurrent event inserted!"
398
  msgstr ""
399
 
400
- #: classes/em-event.php:310
401
  msgid "New event successfully inserted!"
402
  msgstr ""
403
 
404
- #: classes/em-event.php:313 classes/em-event.php:337
405
  msgid "Could not save the event details due to a database error."
406
  msgstr ""
407
 
408
- #: classes/em-event.php:333
409
  msgid "Recurrence updated!"
410
  msgstr ""
411
 
412
- #: classes/em-event.php:341
413
  msgid "updated"
414
  msgstr ""
415
 
416
- #: classes/em-event.php:384
417
- msgid "You are now viewing the duplicated event"
418
  msgstr ""
419
 
420
- #: classes/em-event.php:410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  msgid "Since the event is repeated, you must specify an event date."
422
  msgstr ""
423
 
424
- #: classes/em-event.php:414
425
  msgid "Events cannot start after they end."
426
  msgstr ""
427
 
428
- #: classes/em-event.php:417
429
  msgid ""
430
  "Dates must have correct formatting. Please use the date picker provided."
431
  msgstr ""
432
 
433
- #: classes/em-event.php:552 admin/bookings/em-cancelled.php:108
434
- #: admin/bookings/em-confirmed.php:108 admin/bookings/em-person.php:124
435
- #: admin/bookings/em-rejected.php:108 admin/bookings/em-pending.php:130
436
- #: events-manager.php:210
437
  msgid "Edit"
438
  msgstr ""
439
 
440
- #: classes/em-event.php:552 admin/bookings/em-events.php:101
441
- msgid "Event"
442
- msgstr ""
443
-
444
- #: classes/em-event.php:603
445
  msgid "N/A"
446
  msgstr ""
447
 
448
- #: classes/em-event.php:613
449
  msgid "Profile"
450
  msgstr ""
451
 
452
- #: classes/em-event.php:772
453
- msgid "You do not have permission to manage this event."
454
- msgstr ""
455
-
456
- #: classes/em-event.php:892
457
  msgid "Sunday"
458
  msgstr ""
459
 
460
- #: classes/em-event.php:892
461
  msgid "Monday"
462
  msgstr ""
463
 
464
- #: classes/em-event.php:892
465
  msgid "Tuesday"
466
  msgstr ""
467
 
468
- #: classes/em-event.php:892
469
  msgid "Wednesday"
470
  msgstr ""
471
 
472
- #: classes/em-event.php:892
473
  msgid "Thursday"
474
  msgstr ""
475
 
476
- #: classes/em-event.php:892
477
  msgid "Friday"
478
  msgstr ""
479
 
480
- #: classes/em-event.php:892
481
  msgid "Saturday"
482
  msgstr ""
483
 
484
- #: classes/em-event.php:893
485
  msgid "the first %s of the month"
486
  msgstr ""
487
 
488
- #: classes/em-event.php:893
489
  msgid "the second %s of the month"
490
  msgstr ""
491
 
492
- #: classes/em-event.php:893
493
  msgid "the third %s of the month"
494
  msgstr ""
495
 
496
- #: classes/em-event.php:893
497
  msgid "the fourth %s of the month"
498
  msgstr ""
499
 
500
- #: classes/em-event.php:893
501
  msgid "the last %s of the month"
502
  msgstr ""
503
 
504
- #: classes/em-event.php:894
505
  msgid "From %1$s to %2$s"
506
  msgstr ""
507
 
508
- #: classes/em-event.php:896
509
  msgid "everyday"
510
  msgstr ""
511
 
512
- #: classes/em-event.php:898
513
  msgid "every %s days"
514
  msgstr ""
515
 
516
- #: classes/em-event.php:908
517
  msgid "every week"
518
  msgstr ""
519
 
520
- #: classes/em-event.php:910
521
  msgid "every %s weeks"
522
  msgstr ""
523
 
524
- #: classes/em-event.php:922
525
  msgid "every %s months"
526
  msgstr ""
527
 
@@ -529,243 +789,697 @@ msgstr ""
529
  msgid "Please supply a valid email format."
530
  msgstr ""
531
 
532
- #: em-bookings.php:40
533
- msgid "Booking deleted"
534
  msgstr ""
535
 
536
- #: em-bookings.php:42
537
- msgid "There are no bookings associated to this name and e-mail"
538
  msgstr ""
539
 
540
- #: em-bookings.php:66
541
  msgid "Book now!"
542
  msgstr ""
543
 
544
- #: em-bookings.php:78 em-bookings.php:149 admin/em-categories.php:66
545
- #: admin/em-categories.php:73 admin/em-bookings.php:255
546
- #: admin/em-bookings.php:267 admin/em-admin.php:225 admin/em-locations.php:103
547
- #: admin/em-locations.php:111 admin/em-events.php:130 admin/em-people.php:57
548
- #: admin/em-people.php:145 admin/em-event.php:339
549
- msgid "Name"
550
- msgstr ""
551
-
552
- #: em-bookings.php:79 em-bookings.php:152
553
- msgid "E-Mail"
554
  msgstr ""
555
 
556
- #: em-bookings.php:80 admin/em-people.php:147
557
- msgid "Phone number"
 
558
  msgstr ""
559
 
560
- #: em-bookings.php:82 admin/em-people.php:148
561
- msgid "Seats"
 
 
562
  msgstr ""
563
 
564
- #: em-bookings.php:93 admin/em-bookings.php:274 admin/em-people.php:149
565
  msgid "Comment"
566
  msgstr ""
567
 
568
- #: em-bookings.php:96
569
  msgid "Send your booking"
570
  msgstr ""
571
 
572
- #: em-bookings.php:105 em-bookings.php:111
573
- msgid "Hide cancellation form"
574
  msgstr ""
575
 
576
- #: em-bookings.php:105 em-bookings.php:107 em-bookings.php:110
577
- #: em-bookings.php:114
578
- msgid "Cancel a booking"
 
579
  msgstr ""
580
 
581
- #: em-bookings.php:136 em-bookings.php:157
582
  msgid "Cancel your booking"
583
  msgstr ""
584
 
585
- #: admin/em-options.php:35 admin/em-help.php:17
586
- msgid "Event Related Placeholders"
587
  msgstr ""
588
 
589
- #: admin/em-options.php:36 admin/em-help.php:19
590
- msgid "Location Related Placeholders"
591
  msgstr ""
592
 
593
- #: admin/em-options.php:37 admin/em-help.php:21
594
- msgid "Booking Related Placeholders"
595
  msgstr ""
596
 
597
- #: admin/em-options.php:38
598
- msgid "This accepts %s and %s placeholders."
599
  msgstr ""
600
 
601
- #: admin/em-options.php:39
602
- msgid "This accepts %s placeholders."
603
  msgstr ""
604
 
605
- #: admin/em-options.php:40
606
- msgid "This accepts %s, %s and %s placeholders."
607
  msgstr ""
608
 
609
- #: admin/em-options.php:42 admin/em-options.php:432
610
- msgid "Save Changes"
611
  msgstr ""
612
 
613
- #: admin/em-options.php:42
614
- msgid "All"
 
615
  msgstr ""
616
 
617
- #: admin/em-options.php:46
618
- msgid "Collapse All"
619
  msgstr ""
620
 
621
- #: admin/em-options.php:47
622
- msgid "Expand All"
623
  msgstr ""
624
 
625
- #: admin/em-options.php:76
626
- msgid "Event Manager Options"
627
  msgstr ""
628
 
629
- #: admin/em-options.php:86 admin/em-options.php:124 admin/em-options.php:222
630
- #: admin/em-options.php:241 admin/em-options.php:257 admin/em-options.php:273
631
- #: admin/em-options.php:288 admin/em-options.php:309 admin/em-options.php:360
632
- #: admin/em-options.php:379 admin/em-options.php:393
633
- msgid "Click to toggle"
634
  msgstr ""
635
 
636
- #: admin/em-options.php:86
637
- msgid "General options"
 
 
 
638
  msgstr ""
639
 
640
- #: admin/em-options.php:90
641
- msgid "Use dropdown for locations?"
642
  msgstr ""
643
 
644
- #: admin/em-options.php:90
645
- msgid ""
646
- "Select yes to select location from a drow-down menu; location selection will "
647
- "be faster, but you will lose the ability to insert locations with events"
648
  msgstr ""
649
 
650
- #: admin/em-options.php:91
651
- msgid "Use recurrence?"
652
  msgstr ""
653
 
654
- #: admin/em-options.php:91
655
- msgid "Select yes to enable the recurrence features feature"
656
  msgstr ""
657
 
658
- #: admin/em-options.php:92
659
- msgid "Use RSVP?"
660
  msgstr ""
661
 
662
- #: admin/em-options.php:92
663
- msgid "Select yes to enable the RSVP feature"
664
  msgstr ""
665
 
666
- #: admin/em-options.php:93
667
- msgid "Use categories?"
668
  msgstr ""
669
 
670
- #: admin/em-options.php:93
671
- msgid "Select yes to enable the category features"
672
  msgstr ""
673
 
674
- #: admin/em-options.php:94
675
- msgid "Use attributes?"
 
 
676
  msgstr ""
677
 
678
- #: admin/em-options.php:94
679
- msgid "Select yes to enable the attributes feature"
 
 
680
  msgstr ""
681
 
682
- #: admin/em-options.php:98
683
- msgid "no default category"
684
  msgstr ""
685
 
686
- #: admin/em-options.php:103
687
- msgid "Default Category"
688
  msgstr ""
689
 
690
- #: admin/em-options.php:103
691
- msgid ""
692
- "This option allows you to select the default category when adding an event."
693
  msgstr ""
694
 
695
- #: admin/em-options.php:103 admin/em-options.php:112
696
- msgid "(not applicable with event ownership on presently, coming soon!)"
 
 
697
  msgstr ""
698
 
699
- #: admin/em-options.php:107
700
- msgid "no default location"
 
 
701
  msgstr ""
702
 
703
- #: admin/em-options.php:112
704
- msgid "Default Location"
705
  msgstr ""
706
 
707
- #: admin/em-options.php:112
708
- msgid ""
709
- "This option allows you to select the default location when adding an event."
710
  msgstr ""
711
 
712
- #: admin/em-options.php:114
713
- msgid "Custom Placeholders"
 
 
 
 
714
  msgstr ""
715
 
716
- #: admin/em-options.php:114
717
  msgid ""
718
- "You can add custom placeholders here, one per line in this format <code>#_ATT"
719
- "{key}</code>. They will not appear on event pages unless you insert them "
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
720
  "into another template below, but you may want to store extra information "
721
  "about an event for other uses. <a href='%s'>More information on placeholders."
722
  "</a>"
723
  msgstr ""
724
 
725
- #: admin/em-options.php:124 admin/em-options.php:138
726
  msgid "Events page"
727
  msgstr ""
728
 
729
- #: admin/em-options.php:133
730
  msgid "[No Events Page]"
731
  msgstr ""
732
 
733
- #: admin/em-options.php:138
734
  msgid "This option allows you to select which page to use as an events page"
735
  msgstr ""
736
 
737
- #: admin/em-options.php:141
738
  msgid "Show events page in lists?"
739
  msgstr ""
740
 
741
- #: admin/em-options.php:141
742
  msgid ""
743
  "Check this option if you want the events page to appear together with other "
744
  "pages in pages lists."
745
  msgstr ""
746
 
747
- #: admin/em-options.php:142
748
  msgid "Display calendar in events page?"
749
  msgstr ""
750
 
751
- #: admin/em-options.php:142
752
  msgid ""
753
  "This options allows to display the calendar in the events page, instead of "
754
  "the default list. It is recommended not to display both the calendar widget "
755
  "and a calendar page."
756
  msgstr ""
757
 
758
- #: admin/em-options.php:142
759
  msgid ""
760
  "If you would like to show events that span over more than one day, see the "
761
  "Calendar section on this page."
762
  msgstr ""
763
 
764
- #: admin/em-options.php:143
765
  msgid "Disable title rewriting?"
766
  msgstr ""
767
 
768
- #: admin/em-options.php:143
769
  msgid ""
770
  "Some wordpress themes don't follow best practices when generating navigation "
771
  "menus, and so the automatic title rewriting feature may cause problems, if "
@@ -773,11 +1487,11 @@ msgid ""
773
  "'Yes', and provide an appropriate HTML title format below."
774
  msgstr ""
775
 
776
- #: admin/em-options.php:144
777
  msgid "Event Manager titles"
778
  msgstr ""
779
 
780
- #: admin/em-options.php:144
781
  msgid ""
782
  "This only setting only matters if you selected 'Yes' to above. You will "
783
  "notice the events page titles aren't being rewritten, and you have a new "
@@ -787,140 +1501,140 @@ msgid ""
787
  "this title, see settings further down for page titles."
788
  msgstr ""
789
 
790
- #: admin/em-options.php:145
791
  msgid "Event List Limits"
792
  msgstr ""
793
 
794
- #: admin/em-options.php:145
795
  msgid "This will control how many events are shown on one list by default."
796
  msgstr ""
797
 
798
- #: admin/em-options.php:148
799
  msgid "Default event list ordering"
800
  msgstr ""
801
 
802
- #: admin/em-options.php:153
803
  msgid "Order by start date, start time, then event name"
804
  msgstr ""
805
 
806
- #: admin/em-options.php:154
807
  msgid "Order by name, start date, then start time"
808
  msgstr ""
809
 
810
- #: admin/em-options.php:155
811
  msgid "Order by name, end date, then end time"
812
  msgstr ""
813
 
814
- #: admin/em-options.php:156
815
  msgid "Order by end date, end time, then event name"
816
  msgstr ""
817
 
818
- #: admin/em-options.php:170
819
  msgid "All Ascending"
820
  msgstr ""
821
 
822
- #: admin/em-options.php:173
823
  msgid "All Descending"
824
  msgstr ""
825
 
826
- #: admin/em-options.php:187
827
  msgid ""
828
  "When Events Manager displays lists of events the default behaviour is "
829
  "ordering by start date in ascending order. To change this, modify the values "
830
  "above."
831
  msgstr ""
832
 
833
- #: admin/em-options.php:191
834
  msgid "Event list range limit"
835
  msgstr ""
836
 
837
- #: admin/em-options.php:199
838
  msgid "Next three months"
839
  msgstr ""
840
 
841
- #: admin/em-options.php:200
842
  msgid "Next six months"
843
  msgstr ""
844
 
845
- #: admin/em-options.php:201
846
  msgid "Next twelve months"
847
  msgstr ""
848
 
849
- #: admin/em-options.php:211
850
  msgid ""
851
  "Only show events starting within a certain time limit on the events page. "
852
  "Default is no time limit is applied."
853
  msgstr ""
854
 
855
- #: admin/em-options.php:222
856
  msgid "Events format"
857
  msgstr ""
858
 
859
- #: admin/em-options.php:226
860
  msgid "Default event list format header"
861
  msgstr ""
862
 
863
- #: admin/em-options.php:226
864
  msgid ""
865
  "This content will appear just above your code for the default event list "
866
  "format. Default is blank"
867
  msgstr ""
868
 
869
- #: admin/em-options.php:227
870
  msgid "Default event list format"
871
  msgstr ""
872
 
873
- #: admin/em-options.php:227
874
  msgid "The format of any events in a list."
875
  msgstr ""
876
 
877
- #: admin/em-options.php:228
878
  msgid "Default event list format footer"
879
  msgstr ""
880
 
881
- #: admin/em-options.php:228
882
  msgid ""
883
  "This content will appear just below your code for the default event list "
884
  "format. Default is blank"
885
  msgstr ""
886
 
887
- #: admin/em-options.php:229
888
  msgid "Single event page title format"
889
  msgstr ""
890
 
891
- #: admin/em-options.php:229
892
  msgid "The format of a single event page title."
893
  msgstr ""
894
 
895
- #: admin/em-options.php:230
896
  msgid "Default single event format"
897
  msgstr ""
898
 
899
- #: admin/em-options.php:230
900
  msgid "The format of a single event page."
901
  msgstr ""
902
 
903
- #: admin/em-options.php:231
904
  msgid "Events page title"
905
  msgstr ""
906
 
907
- #: admin/em-options.php:231
908
  msgid "The title on the multiple events page."
909
  msgstr ""
910
 
911
- #: admin/em-options.php:232
912
  msgid "No events message"
913
  msgstr ""
914
 
915
- #: admin/em-options.php:232
916
  msgid "The message displayed when no events are available."
917
  msgstr ""
918
 
919
- #: admin/em-options.php:233
920
  msgid "List events by date title"
921
  msgstr ""
922
 
923
- #: admin/em-options.php:233
924
  msgid ""
925
  "If viewing a page for events on a specific date, this is the title that "
926
  "would show up. To insert date values, use <a href=\"http://www.php.net/"
@@ -929,253 +1643,296 @@ msgid ""
929
  "<code>#j</code>, etc.<br/>"
930
  msgstr ""
931
 
932
- #: admin/em-options.php:241
933
  msgid "Calendar format"
934
  msgstr ""
935
 
936
- #: admin/em-options.php:245
937
  msgid "Small calendar title"
938
  msgstr ""
939
 
940
- #: admin/em-options.php:245
941
  msgid ""
942
  "The format of the title, corresponding to the text that appears when "
943
  "hovering on an eventful calendar day."
944
  msgstr ""
945
 
946
- #: admin/em-options.php:246
947
  msgid "Small calendar title separator"
948
  msgstr ""
949
 
950
- #: admin/em-options.php:246
951
  msgid ""
952
  "The separator appearing on the above title when more than one events are "
953
  "taking place on the same day."
954
  msgstr ""
955
 
956
- #: admin/em-options.php:247
957
  msgid "Full calendar events format"
958
  msgstr ""
959
 
960
- #: admin/em-options.php:247
961
  msgid ""
962
  "The format of each event when displayed in the full calendar. Remember to "
963
  "include <code>li</code> tags before and after the event."
964
  msgstr ""
965
 
966
- #: admin/em-options.php:248
967
  msgid "Show long events on calendar pages?"
968
  msgstr ""
969
 
970
- #: admin/em-options.php:248
971
  msgid ""
972
  "If you are showing a calendar on the events page (see Events format section "
973
  "on this page), you have the option of showing events that span over days on "
974
  "each day it occurs."
975
  msgstr ""
976
 
977
- #: admin/em-options.php:249
978
  msgid "Show list on day with single event?"
979
  msgstr ""
980
 
981
- #: admin/em-options.php:249
982
  msgid ""
983
  "By default, if a calendar day only has one event, it display a single event "
984
  "when clicking on the link of that calendar date. If you select Yes here, you "
985
  "will get always see a list of events."
986
  msgstr ""
987
 
988
- #: admin/em-options.php:257
989
  msgid "Locations format"
990
  msgstr ""
991
 
992
- #: admin/em-options.php:261
993
  msgid "Single location page title format"
994
  msgstr ""
995
 
996
- #: admin/em-options.php:261
997
  msgid "The format of a single location page title."
998
  msgstr ""
999
 
1000
- #: admin/em-options.php:262
1001
  msgid "Default single location page format"
1002
  msgstr ""
1003
 
1004
- #: admin/em-options.php:262
1005
  msgid "The format of a single location page."
1006
  msgstr ""
1007
 
1008
- #: admin/em-options.php:263
1009
  msgid "Default location balloon format"
1010
  msgstr ""
1011
 
1012
- #: admin/em-options.php:263
1013
  msgid ""
1014
  "The format of of the text appearing in the baloon describing the location in "
1015
  "the map."
1016
  msgstr ""
1017
 
1018
- #: admin/em-options.php:264
1019
  msgid "Default location event list format"
1020
  msgstr ""
1021
 
1022
- #: admin/em-options.php:264
1023
  msgid ""
1024
  "The format of the events the list inserted in the location page through the "
1025
  "<code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</"
1026
  "code> element."
1027
  msgstr ""
1028
 
1029
- #: admin/em-options.php:265
1030
  msgid "Default no events message"
1031
  msgstr ""
1032
 
1033
- #: admin/em-options.php:265
1034
  msgid ""
1035
  "The message to be displayed in the list generated by <code>#_NEXTEVENTS</"
1036
  "code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> when no events "
1037
  "are available."
1038
  msgstr ""
1039
 
1040
- #: admin/em-options.php:273
1041
  msgid "RSS feed format"
1042
  msgstr ""
1043
 
1044
- #: admin/em-options.php:277
1045
  msgid "RSS main title"
1046
  msgstr ""
1047
 
1048
- #: admin/em-options.php:277
1049
  msgid "The main title of your RSS events feed."
1050
  msgstr ""
1051
 
1052
- #: admin/em-options.php:278
1053
  msgid "RSS main description"
1054
  msgstr ""
1055
 
1056
- #: admin/em-options.php:278
1057
  msgid "The main description of your RSS events feed."
1058
  msgstr ""
1059
 
1060
- #: admin/em-options.php:279
1061
  msgid "RSS title format"
1062
  msgstr ""
1063
 
1064
- #: admin/em-options.php:279
1065
  msgid "The format of the title of each item in the events RSS feed."
1066
  msgstr ""
1067
 
1068
- #: admin/em-options.php:280
1069
  msgid "RSS description format"
1070
  msgstr ""
1071
 
1072
- #: admin/em-options.php:280
1073
  msgid "The format of the description of each item in the events RSS feed."
1074
  msgstr ""
1075
 
1076
- #: admin/em-options.php:288
1077
  msgid "Maps and geotagging"
1078
  msgstr ""
1079
 
1080
- #: admin/em-options.php:293
1081
  msgid "Enable Google Maps integration?"
1082
  msgstr ""
1083
 
1084
- #: admin/em-options.php:297
1085
  msgid "Check this option to enable Goggle Map integration."
1086
  msgstr ""
1087
 
1088
- #: admin/em-options.php:301
1089
- msgid "Map text format"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1090
  msgstr ""
1091
 
1092
- #: admin/em-options.php:301
1093
- msgid "The text format inside the map balloons."
 
 
 
1094
  msgstr ""
1095
 
1096
- #: admin/em-options.php:309
1097
- msgid "RSVP and bookings"
1098
  msgstr ""
1099
 
1100
- #: admin/em-options.php:313
1101
  msgid "Default contact person"
1102
  msgstr ""
1103
 
1104
- #: admin/em-options.php:313
1105
  msgid ""
1106
  "Select the default contact person. This user will be employed whenever a "
1107
  "contact person is not explicitly specified for an event"
1108
  msgstr ""
1109
 
1110
- #: admin/em-options.php:314
1111
- msgid "Approval Required?"
1112
- msgstr ""
1113
-
1114
- #: admin/em-options.php:314
1115
- msgid ""
1116
- "Bookings will not be confirmed until the event administrator approves it."
1117
- msgstr ""
1118
-
1119
- #: admin/em-options.php:315
1120
  msgid "Email events admin?"
1121
  msgstr ""
1122
 
1123
- #: admin/em-options.php:315
1124
  msgid ""
1125
  "If you would like every event booking confirmation email sent to an "
1126
  "administrator write their email here (leave blank to not send an email)."
1127
  msgstr ""
1128
 
1129
- #: admin/em-options.php:316
1130
  msgid "Email contact person?"
1131
  msgstr ""
1132
 
1133
- #: admin/em-options.php:316
1134
  msgid ""
1135
  "Check this option if you want the event contact to receive an email when "
1136
  "someone books places. An email will be sent when a booking is first made "
1137
  "(regardless if confirmed or pending)"
1138
  msgstr ""
1139
 
1140
- #: admin/em-options.php:318
1141
  msgid "Contact person booking confirmed"
1142
  msgstr ""
1143
 
1144
- #: admin/em-options.php:319
1145
  msgid ""
1146
  "An email will be sent to the event contact when a booking is first made."
1147
  msgstr ""
1148
 
1149
- #: admin/em-options.php:321
1150
  msgid "Contact person email subject"
1151
  msgstr ""
1152
 
1153
- #: admin/em-options.php:322
1154
  msgid "Contact person email"
1155
  msgstr ""
1156
 
1157
- #: admin/em-options.php:324
1158
  msgid "Contact person booking cancelled"
1159
  msgstr ""
1160
 
1161
- #: admin/em-options.php:325
1162
  msgid ""
1163
  "An email will be sent to the event contact if someone cancels their booking."
1164
  msgstr ""
1165
 
1166
- #: admin/em-options.php:327
1167
  msgid "Contact person cancellation subject"
1168
  msgstr ""
1169
 
1170
- #: admin/em-options.php:328
1171
  msgid "Contact person cancellation email"
1172
  msgstr ""
1173
 
1174
- #: admin/em-options.php:330
1175
  msgid "Confirmed booking email"
1176
  msgstr ""
1177
 
1178
- #: admin/em-options.php:331
1179
  msgid ""
1180
  "This is sent when a person's booking is confirmed. This will be sent "
1181
  "automatically if approvals are required and the booking is approved. If "
@@ -1183,254 +1940,187 @@ msgid ""
1183
  "booking."
1184
  msgstr ""
1185
 
1186
- #: admin/em-options.php:333
1187
  msgid "Booking confirmed email subject"
1188
  msgstr ""
1189
 
1190
- #: admin/em-options.php:334
1191
  msgid "Booking confirmed email"
1192
  msgstr ""
1193
 
1194
- #: admin/em-options.php:336
1195
  msgid "Pending booking email"
1196
  msgstr ""
1197
 
1198
- #: admin/em-options.php:337
1199
  msgid ""
1200
  "This will be sent to the person when they first submit their booking. Not "
1201
  "relevant if bookings don't require approval."
1202
  msgstr ""
1203
 
1204
- #: admin/em-options.php:339
1205
  msgid "Booking pending email subject"
1206
  msgstr ""
1207
 
1208
- #: admin/em-options.php:340
1209
  msgid "Booking pending email"
1210
  msgstr ""
1211
 
1212
- #: admin/em-options.php:342
1213
  msgid "Rejected booking email"
1214
  msgstr ""
1215
 
1216
- #: admin/em-options.php:343
1217
  msgid ""
1218
  "This will be sent automatically when a booking is rejected. Not relevant if "
1219
  "bookings don't require approval."
1220
  msgstr ""
1221
 
1222
- #: admin/em-options.php:345
1223
  msgid "Booking rejected email subject"
1224
  msgstr ""
1225
 
1226
- #: admin/em-options.php:345
1227
  msgid ""
1228
  "The subject of the email sent to the person making a booking that is "
1229
  "awaiting administrator approval. Not relevant if bookings don't require "
1230
  "approval."
1231
  msgstr ""
1232
 
1233
- #: admin/em-options.php:346
1234
  msgid "Booking rejected email"
1235
  msgstr ""
1236
 
1237
- #: admin/em-options.php:346
1238
  msgid ""
1239
  "The body of the email which will be sent to the person if the booking is "
1240
  "rejected. Not relevant if bookings don't require approval."
1241
  msgstr ""
1242
 
1243
- #: admin/em-options.php:349
1244
- msgid "Booking cancelled"
1245
- msgstr ""
1246
-
1247
- #: admin/em-options.php:350
1248
  msgid "This will be sent when a user cancels their booking."
1249
  msgstr ""
1250
 
1251
- #: admin/em-options.php:352
1252
  msgid "Booking cancelled email subject"
1253
  msgstr ""
1254
 
1255
- #: admin/em-options.php:353
1256
  msgid "Booking cancelled email"
1257
  msgstr ""
1258
 
1259
- #: admin/em-options.php:360
1260
  msgid "Email Settings"
1261
  msgstr ""
1262
 
1263
- #: admin/em-options.php:364
1264
  msgid "Notification sender name"
1265
  msgstr ""
1266
 
1267
- #: admin/em-options.php:364
1268
  msgid "Insert the display name of the notification sender."
1269
  msgstr ""
1270
 
1271
- #: admin/em-options.php:365
1272
  msgid "Notification sender address"
1273
  msgstr ""
1274
 
1275
- #: admin/em-options.php:365
1276
  msgid "Insert the address of the notification sender."
1277
  msgstr ""
1278
 
1279
- #: admin/em-options.php:366
1280
  msgid ""
1281
  "The port through which you e-mail notifications will be sent. Make sure the "
1282
  "firewall doesn't block this port"
1283
  msgstr ""
1284
 
1285
- #: admin/em-options.php:367
1286
  msgid "Mail sending method"
1287
  msgstr ""
1288
 
1289
- #: admin/em-options.php:367
1290
  msgid "PHP mail function"
1291
  msgstr ""
1292
 
1293
- #: admin/em-options.php:367
1294
  msgid "Select the method to send email notification."
1295
  msgstr ""
1296
 
1297
- #: admin/em-options.php:368
1298
  msgid "Use SMTP authentication?"
1299
  msgstr ""
1300
 
1301
- #: admin/em-options.php:368
1302
  msgid ""
1303
  "SMTP authentication is often needed. If you use GMail, make sure to set this "
1304
  "parameter to Yes"
1305
  msgstr ""
1306
 
1307
- #: admin/em-options.php:369
1308
  msgid ""
1309
  "The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set "
1310
  "this value to 'ssl://smtp.gmail.com:465'."
1311
  msgstr ""
1312
 
1313
- #: admin/em-options.php:370
1314
  msgid "SMTP username"
1315
  msgstr ""
1316
 
1317
- #: admin/em-options.php:370
1318
  msgid "Insert the username to be used to access your SMTP server."
1319
  msgstr ""
1320
 
1321
- #: admin/em-options.php:371
1322
  msgid "SMTP password"
1323
  msgstr ""
1324
 
1325
- #: admin/em-options.php:371
1326
  msgid "Insert the password to be used to access your SMTP server"
1327
  msgstr ""
1328
 
1329
- #: admin/em-options.php:379
1330
  msgid "Images size"
1331
  msgstr ""
1332
 
1333
- #: admin/em-options.php:383
1334
  msgid "Maximum width (px)"
1335
  msgstr ""
1336
 
1337
- #: admin/em-options.php:383
1338
  msgid "The maximum allowed width for images uploades"
1339
  msgstr ""
1340
 
1341
- #: admin/em-options.php:384
1342
  msgid "Maximum height (px)"
1343
  msgstr ""
1344
 
1345
- #: admin/em-options.php:384
1346
  msgid "The maximum allowed height for images uploaded, in pixels"
1347
  msgstr ""
1348
 
1349
- #: admin/em-options.php:385
1350
  msgid "Maximum size (bytes)"
1351
  msgstr ""
1352
 
1353
- #: admin/em-options.php:385
1354
  msgid "The maximum allowed size for images uploaded, in pixels"
1355
  msgstr ""
1356
 
1357
- #: admin/em-options.php:393
1358
- msgid "Management Permission Options"
1359
  msgstr ""
1360
 
1361
- #: admin/em-options.php:397
1362
  msgid ""
1363
  "Warning: Changing these values may result in exposing previously hidden "
1364
  "information to all users."
1365
  msgstr ""
1366
 
1367
- #: admin/em-options.php:398
1368
- msgid ""
1369
- "Note that currently \"users\" are considered as wordpress contributor users "
1370
- "upwards, as they can create and manage events (we're working on that). "
1371
- "Wordpress administrators can control all events/locations/categories/etc. on "
1372
- "Events Manager."
1373
- msgstr ""
1374
-
1375
- #: admin/em-options.php:400
1376
- msgid "Event Permissions"
1377
- msgstr ""
1378
-
1379
- #: admin/em-options.php:403
1380
- msgid ""
1381
- "Every user can create and manage their own events. Users can't view or "
1382
- "modify each others' events and booking data"
1383
- msgstr ""
1384
-
1385
- #: admin/em-options.php:404
1386
- msgid ""
1387
- "Every user can create/edit/delete any event on this site. (not recommended)"
1388
- msgstr ""
1389
-
1390
- #: admin/em-options.php:408
1391
- msgid "Location Permissions"
1392
- msgstr ""
1393
-
1394
- #: admin/em-options.php:411
1395
- msgid "Every user can create and manage their own location."
1396
- msgstr ""
1397
-
1398
- #: admin/em-options.php:411
1399
- msgid ""
1400
- "In future releases of Events Manager, sharing locations with more than one "
1401
- "user will be possible in this option, as well as connecting different user "
1402
- "defined locations to prevent duplicate listings."
1403
- msgstr ""
1404
-
1405
- #: admin/em-options.php:412
1406
- msgid ""
1407
- "Only event administrators can create and edit locations. User must choose "
1408
- "from these available locations."
1409
- msgstr ""
1410
-
1411
- #: admin/em-options.php:413
1412
- msgid ""
1413
- "Everyone can create/edit/delete all locations on this site. (not recommended)"
1414
- msgstr ""
1415
-
1416
- #: admin/em-options.php:417
1417
- msgid "Category Permissions"
1418
- msgstr ""
1419
-
1420
- #: admin/em-options.php:420
1421
- msgid "Every user can create and manage their own category."
1422
- msgstr ""
1423
-
1424
- #: admin/em-options.php:421
1425
- msgid ""
1426
- "Only event administrators can create and edit categories. User must choose "
1427
- "from these available categories."
1428
- msgstr ""
1429
-
1430
- #: admin/em-options.php:422
1431
  msgid ""
1432
- "Everyone can create/edit/delete all categories on the system. (not "
1433
- "recommended)"
1434
  msgstr ""
1435
 
1436
  #: admin/em-categories.php:10
@@ -1441,441 +2131,312 @@ msgstr ""
1441
  msgid "The category has been updated."
1442
  msgstr ""
1443
 
1444
- #: admin/em-categories.php:22 admin/em-locations.php:39 admin/em-event.php:100
1445
  msgid "Ach, there's a problem here:"
1446
  msgstr ""
1447
 
1448
- #: admin/em-categories.php:32
1449
  msgid "Categories Deleted"
1450
  msgstr ""
1451
 
1452
- #: admin/em-categories.php:46 events-manager.php:219
1453
  msgid "Categories"
1454
  msgstr ""
1455
 
1456
- #: admin/em-categories.php:65 admin/em-categories.php:72
1457
  msgid "ID"
1458
  msgstr ""
1459
 
1460
- #: admin/em-categories.php:96
1461
  msgid "No categories have been inserted yet!"
1462
  msgstr ""
1463
 
1464
- #: admin/em-categories.php:108 admin/em-categories.php:116
1465
  msgid "Add category"
1466
  msgstr ""
1467
 
1468
- #: admin/em-categories.php:112 admin/em-categories.php:163
1469
  msgid "Category name"
1470
  msgstr ""
1471
 
1472
- #: admin/em-categories.php:114 admin/em-categories.php:165
1473
  msgid "The name of the category"
1474
  msgstr ""
1475
 
1476
- #: admin/em-categories.php:137 admin/em-bookings.php:100
1477
- #: admin/em-bookings.php:150 admin/em-locations.php:144
1478
- #: admin/em-people.php:124 admin/em-event.php:54
1479
- msgid "Unauthorized Access"
1480
- msgstr ""
1481
-
1482
- #: admin/em-categories.php:137 admin/em-bookings.php:100
1483
- #: admin/em-bookings.php:150 admin/em-people.php:124 admin/em-event.php:54
1484
- msgid "You do not have the rights to manage this event."
1485
- msgstr ""
1486
-
1487
- #: admin/em-categories.php:147
1488
  msgid "Edit category"
1489
  msgstr ""
1490
 
1491
- #: admin/em-categories.php:168
1492
  msgid "Update category"
1493
  msgstr ""
1494
 
1495
- #: admin/em-bookings.php:82
1496
  msgid "Event Bookings Dashboard"
1497
  msgstr ""
1498
 
1499
- #: admin/em-bookings.php:84 admin/em-bookings.php:130
 
1500
  msgid "Pending Bookings"
1501
  msgstr ""
1502
 
1503
- #: admin/em-bookings.php:86
1504
  msgid "Events With Bookings Enabled"
1505
  msgstr ""
1506
 
1507
- #: admin/em-bookings.php:112
1508
- msgid "Manage %s Bookings"
1509
- msgstr ""
1510
-
1511
- #: admin/em-bookings.php:113
1512
- msgid "View/Edit Event"
1513
- msgstr ""
1514
-
1515
- #: admin/em-bookings.php:115 admin/em-event.php:280
1516
- msgid "export csv"
1517
  msgstr ""
1518
 
1519
  #: admin/em-bookings.php:117
1520
- msgid "Event Name"
1521
  msgstr ""
1522
 
1523
- #: admin/em-bookings.php:118
1524
- msgid "Seats confirmed"
1525
  msgstr ""
1526
 
1527
- #: admin/em-bookings.php:120 admin/em-admin.php:226
1528
- msgid "Date"
1529
  msgstr ""
1530
 
1531
- #: admin/em-bookings.php:126 admin/em-admin.php:227 admin/em-locations.php:196
1532
- #: admin/em-events.php:132 admin/em-event.php:398
1533
- msgid "Location"
1534
  msgstr ""
1535
 
1536
- #: admin/em-bookings.php:132
1537
  msgid "Confirmed Bookings"
1538
  msgstr ""
1539
 
1540
- #: admin/em-bookings.php:134
1541
  msgid "Rejected Bookings"
1542
  msgstr ""
1543
 
1544
- #: admin/em-bookings.php:136
1545
  msgid "Cancelled Bookings"
1546
  msgstr ""
1547
 
1548
- #: admin/em-bookings.php:160
1549
- msgid "Edit Booking"
1550
  msgstr ""
1551
 
1552
- #: admin/em-bookings.php:167
1553
- msgid "Booking Details"
1554
  msgstr ""
1555
 
1556
- #: admin/em-bookings.php:182
1557
- msgid "Booking Notes"
1558
  msgstr ""
1559
 
1560
- #: admin/em-bookings.php:185
1561
- msgid ""
1562
- "You can add private notes below for internal reference that only event "
1563
- "managers will see."
1564
  msgstr ""
1565
 
1566
- #: admin/em-bookings.php:190
1567
- msgid "wrote"
1568
  msgstr ""
1569
 
1570
- #: admin/em-bookings.php:222
1571
- msgid "Manage Person's Booking"
1572
  msgstr ""
1573
 
1574
- #: admin/em-bookings.php:223
1575
- msgid ""
1576
- "Are you sure you want to delete this person? All bookings corresponding to "
1577
- "this person will be deleted and this is not reversible."
1578
  msgstr ""
1579
 
1580
- #: admin/em-bookings.php:223
1581
- msgid "Delete Person"
1582
  msgstr ""
1583
 
1584
- #: admin/em-bookings.php:230
1585
- msgid "Personal Details"
1586
  msgstr ""
1587
 
1588
- #: admin/em-bookings.php:240
1589
- msgid "Past And Present Bookings"
1590
  msgstr ""
1591
 
1592
- #: admin/em-bookings.php:257
1593
  msgid "Date/Time"
1594
  msgstr ""
1595
 
1596
- #: admin/em-bookings.php:268 admin/em-people.php:58 admin/em-people.php:187
1597
- msgid "Phone"
1598
- msgstr ""
1599
-
1600
- #: admin/em-bookings.php:269 admin/em-people.php:59 admin/em-people.php:146
1601
- msgid "E-mail"
1602
- msgstr ""
1603
-
1604
- #: admin/em-bookings.php:273 admin/em-event.php:257
1605
- msgid "Spaces"
1606
- msgstr ""
1607
-
1608
- #: admin/em-bookings.php:277 admin/em-people.php:62
1609
- msgid "Save"
1610
  msgstr ""
1611
 
1612
- #: admin/em-admin.php:20
1613
- msgid ""
1614
- "<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We "
1615
- "hope you like it around here.</p> \r\n"
1616
- "\t\t\t<p>Now it's time to insert events lists through <a href='%s' "
1617
- "title='Widgets page'>widgets</a>, <a href='%s' title='Template tags "
1618
- "documentation'>template tags</a> or <a href='%s' title='Shortcodes "
1619
- "documentation'>shortcodes</a>.</p>\r\n"
1620
- "\t\t\t<p>By the way, have you taken a look at the <a href='%s' title='Change "
1621
- "settings'>Settings page</a>? That's where you customize the way events and "
1622
- "locations are displayed.</p>\r\n"
1623
- "\t\t\t<p>What? Tired of seeing this advice? I hear you, <a href='%s' "
1624
- "title='Don't show this advice again'>click here</a> and you won't see this "
1625
- "again!</p>"
1626
  msgstr ""
1627
 
1628
- #: admin/em-admin.php:38
1629
- msgid ""
1630
- "<strong>Events Manager has some new features!</strong><ul><li>Bookings can "
1631
- "now be approved before they count towards your event's space allocations.</"
1632
- "li><li>Events now have owners, and you can restrict users so they can only "
1633
- "manage events/locations/categories they create.<br/><br/>These new "
1634
- "permissions are enabled by default, but since you upgraded it has been "
1635
- "disabled to maintain the previous plugin behaviour. You can re-enable it "
1636
- "from the <a href=\"%s\">settings page</a>. <a href=\"%s\">Dismiss</a>"
1637
  msgstr ""
1638
 
1639
- #: admin/em-admin.php:51
1640
- msgid ""
1641
- "Uh Oh! For some reason wordpress could not create an events page for you (or "
1642
- "you just deleted it). Not to worry though, all you have to do is create an "
1643
- "empty page, name it whatever you want, and select it as your events page in "
1644
- "your <a href=\"%s\">settings page</a>. Sorry for the extra step! If you know "
1645
- "what you are doing, you may have done this on purpose, if so <a href=\"%s"
1646
- "\">ignore this message</a>"
1647
  msgstr ""
1648
 
1649
- #: admin/em-admin.php:59
1650
  msgid ""
1651
- "This page corresponds to <strong>Events Manager</strong> events page. Its "
1652
- "content will be overriden by <strong>Events Manager</strong>. If you want to "
1653
- "display your content, you can can assign another page to <strong>Events "
1654
- "Manager</strong> in the the <a href='%s'>Settings</a>. "
1655
- msgstr ""
1656
-
1657
- #: admin/em-admin.php:79
1658
- msgid "Displaying %s&#8211;%s of %s"
1659
- msgstr ""
1660
-
1661
- #: admin/em-admin.php:228 admin/em-locations.php:104
1662
- #: admin/em-locations.php:112
1663
- msgid "Address"
1664
- msgstr ""
1665
-
1666
- #: admin/em-admin.php:229 admin/em-locations.php:105
1667
- #: admin/em-locations.php:113
1668
- msgid "Town"
1669
- msgstr ""
1670
-
1671
- #: admin/em-admin.php:243
1672
- msgid "Some required fields are missing:"
1673
- msgstr ""
1674
-
1675
- #: admin/em-admin.php:246
1676
- msgid "Since the event is repeated, you must specify an end date"
1677
- msgstr ""
1678
-
1679
- #: admin/bookings/em-cancelled.php:34 admin/bookings/em-cancelled.php:36
1680
- #: admin/bookings/em-confirmed.php:35 admin/bookings/em-confirmed.php:37
1681
- #: admin/bookings/em-person.php:40 admin/bookings/em-person.php:42
1682
- #: admin/bookings/em-rejected.php:34 admin/bookings/em-rejected.php:36
1683
- #: admin/bookings/em-pending.php:49 admin/bookings/em-pending.php:51
1684
- msgid "Search"
1685
- msgstr ""
1686
-
1687
- #: admin/bookings/em-cancelled.php:45 admin/bookings/em-confirmed.php:46
1688
- #: admin/bookings/em-person.php:51 admin/bookings/em-rejected.php:45
1689
- #: admin/bookings/em-pending.php:60 admin/bookings/em-events.php:56
1690
- #: admin/em-locations.php:83 admin/em-events.php:86
1691
- msgid "Bulk Actions"
1692
- msgstr ""
1693
-
1694
- #: admin/bookings/em-cancelled.php:48 admin/bookings/em-cancelled.php:107
1695
- #: admin/bookings/em-confirmed.php:49 admin/bookings/em-person.php:54
1696
- #: admin/bookings/em-person.php:116 admin/bookings/em-rejected.php:48
1697
- #: admin/bookings/em-rejected.php:107 admin/bookings/em-pending.php:63
1698
- #: admin/bookings/em-pending.php:128
1699
- msgid "Approve"
1700
- msgstr ""
1701
-
1702
- #: admin/bookings/em-cancelled.php:51 admin/bookings/em-confirmed.php:52
1703
- #: admin/bookings/em-person.php:57 admin/bookings/em-rejected.php:51
1704
- #: admin/bookings/em-pending.php:66
1705
- msgid "Decline"
1706
- msgstr ""
1707
-
1708
- #: admin/bookings/em-cancelled.php:109 admin/bookings/em-person.php:125
1709
- #: admin/bookings/em-rejected.php:109
1710
- msgid "Delete"
1711
- msgstr ""
1712
-
1713
- #: admin/bookings/em-cancelled.php:121
1714
- msgid "No cancelled bookings."
1715
- msgstr ""
1716
-
1717
- #: admin/bookings/em-confirmed.php:107 admin/bookings/em-person.php:119
1718
- msgid "Unapprove"
1719
- msgstr ""
1720
-
1721
- #: admin/bookings/em-confirmed.php:120 admin/bookings/em-person.php:137
1722
- msgid "No confirmed bookings."
1723
- msgstr ""
1724
-
1725
- #: admin/bookings/em-person.php:122 admin/bookings/em-pending.php:129
1726
- msgid "Reject"
1727
- msgstr ""
1728
-
1729
- #: admin/bookings/em-rejected.php:121
1730
- msgid "No rejected bookings."
1731
- msgstr ""
1732
-
1733
- #: admin/bookings/em-pending.php:142
1734
- msgid "No pending bookings."
1735
- msgstr ""
1736
-
1737
- #: admin/bookings/em-events.php:29 admin/em-events.php:32
1738
- msgid "Past Events"
1739
- msgstr ""
1740
-
1741
- #: admin/bookings/em-events.php:32 admin/em-events.php:35
1742
- msgid "All Events"
1743
- msgstr ""
1744
-
1745
- #: admin/bookings/em-events.php:35 admin/em-events.php:38
1746
- msgid "Future Events"
1747
- msgstr ""
1748
-
1749
- #: admin/bookings/em-events.php:50 admin/em-events.php:75
1750
- msgid "Total"
1751
- msgstr ""
1752
-
1753
- #: admin/bookings/em-events.php:57 admin/em-locations.php:84
1754
- #: admin/em-events.php:87
1755
- msgid "Delete selected"
1756
  msgstr ""
1757
 
1758
- #: admin/bookings/em-events.php:59 admin/em-locations.php:86
1759
- #: admin/em-events.php:89
1760
- msgid "Apply"
1761
  msgstr ""
1762
 
1763
- #: admin/bookings/em-events.php:71 admin/em-events.php:100
1764
- msgid "Filter"
1765
  msgstr ""
1766
 
1767
- #. TODO localize
1768
- #. TODO localize
1769
- #: admin/bookings/em-events.php:91 admin/em-events.php:120
1770
- msgid "no events"
1771
  msgstr ""
1772
 
1773
- #: admin/bookings/em-events.php:102 admin/em-events.php:133
1774
- msgid "Date and time"
1775
  msgstr ""
1776
 
1777
- #: admin/bookings/em-events.php:134 admin/em-events.php:172
1778
- msgid "Booked Seats"
 
 
 
 
 
 
 
 
 
 
 
 
1779
  msgstr ""
1780
 
1781
- #: admin/em-locations.php:21
1782
- msgid "Locations Deleted"
 
 
 
 
 
 
 
1783
  msgstr ""
1784
 
1785
- #: admin/em-locations.php:26
1786
- msgid "The location has been added."
 
 
 
 
 
 
1787
  msgstr ""
1788
 
1789
- #: admin/em-locations.php:28
1790
- msgid "The location has been updated."
 
 
 
 
1791
  msgstr ""
1792
 
1793
- #: admin/em-locations.php:65 events-manager.php:213
1794
- msgid "Locations"
1795
  msgstr ""
1796
 
1797
- #: admin/em-locations.php:66 admin/em-events.php:55
1798
- msgid "Add New"
 
 
 
 
1799
  msgstr ""
1800
 
1801
- #: admin/em-locations.php:132
1802
- msgid "No venues have been inserted yet!"
 
 
 
 
1803
  msgstr ""
1804
 
1805
- #: admin/em-locations.php:144
1806
- msgid "You do not have the rights to manage this location."
 
 
1807
  msgstr ""
1808
 
1809
- #: admin/em-locations.php:149
1810
- msgid "Add location"
1811
  msgstr ""
1812
 
1813
- #: admin/em-locations.php:152
1814
- msgid "Edit location"
 
 
1815
  msgstr ""
1816
 
1817
- #: admin/em-locations.php:176
1818
- msgid "Location Name"
1819
  msgstr ""
1820
 
1821
- #: admin/em-locations.php:181
1822
- msgid "The name of the location"
1823
  msgstr ""
1824
 
1825
- #: admin/em-locations.php:186 admin/em-event.php:388
1826
- msgid "Coordinates"
 
1827
  msgstr ""
1828
 
1829
- #: admin/em-locations.php:204 admin/em-event.php:436
1830
- msgid "Address:"
1831
  msgstr ""
1832
 
1833
- #: admin/em-locations.php:207 admin/em-event.php:439
1834
- msgid ""
1835
- "The address of the location where the event takes place. Example: 21, "
1836
- "Dominick Street"
1837
  msgstr ""
1838
 
1839
- #: admin/em-locations.php:211 admin/em-event.php:443
1840
- msgid "Town:"
1841
  msgstr ""
1842
 
1843
- #: admin/em-locations.php:214 admin/em-event.php:446
1844
- msgid ""
1845
- "The town where the location is located. If you're using the Google Map "
1846
- "integration and want to avoid geotagging ambiguities include the country in "
1847
- "the town field. Example: Verona, Italy."
1848
  msgstr ""
1849
 
1850
- #: admin/em-locations.php:222 admin/em-event.php:455
1851
- msgid "Location not found"
1852
  msgstr ""
1853
 
1854
- #: admin/em-locations.php:234 admin/em-event.php:466
1855
- msgid "Details"
1856
  msgstr ""
1857
 
1858
- #: admin/em-locations.php:241
1859
- msgid "Details about the location"
1860
  msgstr ""
1861
 
1862
- #: admin/em-locations.php:247
1863
- msgid "Location image"
1864
  msgstr ""
1865
 
1866
- #: admin/em-locations.php:253
1867
- msgid "No image uploaded for this location yet"
1868
  msgstr ""
1869
 
1870
- #: admin/em-locations.php:256
1871
- msgid "Upload/change picture"
1872
  msgstr ""
1873
 
1874
- #: admin/em-locations.php:262
1875
- msgid "Update location"
1876
  msgstr ""
1877
 
1878
- #: admin/em-help.php:10 events-manager.php:222
1879
  msgid "Getting Help for Events Manager"
1880
  msgstr ""
1881
 
@@ -1891,343 +2452,265 @@ msgid ""
1891
  "be displayed."
1892
  msgstr ""
1893
 
1894
- #: admin/em-events.php:78 admin/em-events.php:80
1895
- msgid "Search Events"
1896
- msgstr ""
1897
-
1898
- #: admin/em-events.php:167 admin/em-event.php:305
1899
- msgid "Category"
1900
- msgstr ""
1901
-
1902
- #: admin/em-events.php:180
1903
- msgid "Duplicate this event"
1904
- msgstr ""
1905
-
1906
- #: admin/em-events.php:203 admin/em-event.php:61 admin/em-event.php:208
1907
- msgid "Reschedule"
1908
- msgstr ""
1909
-
1910
- #: admin/em-people.php:81
1911
- msgid "No people have responded to your events yet!"
1912
  msgstr ""
1913
 
1914
- #: admin/em-people.php:84
1915
- msgid ""
1916
- "This table collects the data about the people who responded to your events"
1917
  msgstr ""
1918
 
1919
- #: admin/em-people.php:142
1920
- msgid "Bookings data"
1921
  msgstr ""
1922
 
1923
- #: admin/em-people.php:163
1924
- msgid "Booked"
1925
  msgstr ""
1926
 
1927
- #: admin/em-people.php:168
1928
- msgid "Available"
1929
  msgstr ""
1930
 
1931
- #. #-#-#-#-# plugin.pot (Events Manager 3.0.9) #-#-#-#-#
1932
  #. Plugin Name of the plugin/theme
1933
- #: admin/em-people.php:187
1934
  msgid "Events Manager"
1935
  msgstr ""
1936
 
1937
- #: admin/em-event.php:30
1938
- msgid "There was an error duplicating the event. Try again maybe?"
1939
- msgstr ""
1940
-
1941
- #: admin/em-event.php:63
1942
- msgid "Edit Event"
1943
- msgstr ""
1944
-
1945
- #: admin/em-event.php:67
1946
- msgid "Insert New Event"
1947
- msgstr ""
1948
-
1949
- #: admin/em-event.php:94
1950
  msgid "Mon"
1951
  msgstr ""
1952
 
1953
- #: admin/em-event.php:94
1954
  msgid "Tue"
1955
  msgstr ""
1956
 
1957
- #: admin/em-event.php:94
1958
  msgid "Wed"
1959
  msgstr ""
1960
 
1961
- #: admin/em-event.php:94
1962
  msgid "Thu"
1963
  msgstr ""
1964
 
1965
- #: admin/em-event.php:94
1966
  msgid "Fri"
1967
  msgstr ""
1968
 
1969
- #: admin/em-event.php:94
1970
  msgid "Sat"
1971
  msgstr ""
1972
 
1973
- #: admin/em-event.php:94
1974
  msgid "Sun"
1975
  msgstr ""
1976
 
1977
- #: admin/em-event.php:120
1978
- msgid "WARNING: This is a recurring event."
1979
- msgstr ""
1980
-
1981
- #: admin/em-event.php:122
1982
- msgid ""
1983
- "Modifying these data all the events linked to this recurrence will be "
1984
- "rescheduled"
1985
- msgstr ""
1986
-
1987
- #: admin/em-event.php:124
1988
- msgid "and all booking information will be deleted!"
1989
- msgstr ""
1990
-
1991
- #. TODO Terminology confusing with methods, maybe worth changing?
1992
- #: admin/em-event.php:127
1993
- msgid "WARNING: This is a recurrence."
1994
- msgstr ""
1995
-
1996
- #: admin/em-event.php:129
1997
- msgid ""
1998
- "If you change these data and save, this will become an independent event."
1999
- msgstr ""
2000
-
2001
- #: admin/em-event.php:144
2002
  msgid "Recurrence"
2003
  msgstr ""
2004
 
2005
- #: admin/em-event.php:151
2006
  msgid "Repeated event"
2007
  msgstr ""
2008
 
2009
- #: admin/em-event.php:158
2010
- msgid "Daily"
2011
- msgstr ""
2012
-
2013
- #: admin/em-event.php:158
2014
- msgid "Weekly"
2015
- msgstr ""
2016
-
2017
- #: admin/em-event.php:158
2018
- msgid "Monthly"
2019
- msgstr ""
2020
-
2021
- #: admin/em-event.php:164 admin/em-event.php:187
2022
  msgid "Every"
2023
  msgstr ""
2024
 
2025
- #: admin/em-event.php:167
2026
- msgid "day"
2027
- msgstr ""
2028
-
2029
- #: admin/em-event.php:169
2030
- msgid "days"
2031
- msgstr ""
2032
-
2033
- #: admin/em-event.php:171
2034
  msgid "week"
2035
  msgstr ""
2036
 
2037
- #: admin/em-event.php:173
2038
  msgid "weeks"
2039
  msgstr ""
2040
 
2041
- #: admin/em-event.php:175
2042
  msgid "month"
2043
  msgstr ""
2044
 
2045
- #: admin/em-event.php:177
2046
  msgid "months"
2047
  msgstr ""
2048
 
2049
- #: admin/em-event.php:190
2050
- msgid "first"
2051
- msgstr ""
2052
-
2053
- #: admin/em-event.php:190
2054
- msgid "second"
2055
- msgstr ""
2056
-
2057
- #: admin/em-event.php:190
2058
- msgid "third"
2059
  msgstr ""
2060
 
2061
- #: admin/em-event.php:190
2062
- msgid "fourth"
2063
  msgstr ""
2064
 
2065
- #: admin/em-event.php:190
2066
- msgid "last"
2067
  msgstr ""
2068
 
2069
- #: admin/em-event.php:201
2070
- msgid ""
2071
- "Check if your event happens more than once according to a regular pattern"
2072
  msgstr ""
2073
 
2074
- #: admin/em-event.php:213
2075
- msgid "This is't a recurrent event"
2076
  msgstr ""
2077
 
2078
- #: admin/em-event.php:226
2079
- msgid "Contact Person"
2080
  msgstr ""
2081
 
2082
- #: admin/em-event.php:229
2083
- msgid "Contact"
2084
  msgstr ""
2085
 
2086
- #: admin/em-event.php:231
2087
- msgid "Select..."
 
2088
  msgstr ""
2089
 
2090
- #: admin/em-event.php:242
2091
- msgid "RSVP"
2092
  msgstr ""
2093
 
2094
- #: admin/em-event.php:246
2095
- msgid "Enable registration for this event"
2096
  msgstr ""
2097
 
2098
- #: admin/em-event.php:269
2099
- msgid "Available Spaces"
2100
  msgstr ""
2101
 
2102
- #: admin/em-event.php:270
2103
- msgid "Confirmed Spaces"
2104
  msgstr ""
2105
 
2106
- #: admin/em-event.php:271
2107
- msgid "Pending Spaces"
 
 
2108
  msgstr ""
2109
 
2110
- #: admin/em-event.php:278
2111
- msgid "manage bookings"
2112
  msgstr ""
2113
 
2114
- #: admin/em-event.php:279
2115
- msgid "printable view"
 
2116
  msgstr ""
2117
 
2118
- #: admin/em-event.php:288
2119
- msgid "No responses yet!"
2120
  msgstr ""
2121
 
2122
- #: admin/em-event.php:310
2123
- msgid "Category:"
2124
  msgstr ""
2125
 
2126
- #: admin/em-event.php:312
2127
- msgid "no category"
 
 
 
2128
  msgstr ""
2129
 
2130
- #: admin/em-event.php:326
2131
- msgid "No categories available, <a href=\"%s\">create one here first</a>"
2132
  msgstr ""
2133
 
2134
- #: admin/em-event.php:344
2135
- msgid "The event name. Example: Birthday party"
2136
  msgstr ""
2137
 
2138
- #: admin/em-event.php:349
2139
- msgid "Event date"
2140
  msgstr ""
2141
 
2142
- #: admin/em-event.php:352
2143
- msgid "Recurrence dates"
2144
  msgstr ""
2145
 
2146
- #: admin/em-event.php:362
2147
- msgid "The event date."
2148
  msgstr ""
2149
 
2150
- #: admin/em-event.php:365
2151
- msgid ""
2152
- "When not reoccurring, this event spans between the beginning and end date."
2153
  msgstr ""
2154
 
2155
- #: admin/em-event.php:370
2156
- msgid "The recurrence beginning and end date."
2157
  msgstr ""
2158
 
2159
- #: admin/em-event.php:376
2160
- msgid "Event time"
2161
  msgstr ""
2162
 
2163
- #: admin/em-event.php:383
2164
- msgid "The time of the event beginning and end"
 
 
2165
  msgstr ""
2166
 
2167
- #: admin/em-event.php:407
2168
- msgid "Location:"
2169
  msgstr ""
2170
 
2171
- #: admin/em-event.php:424
2172
  msgid ""
2173
- "The name of the location where the event takes place. You can use the name "
2174
- "of a venue, a square, etc"
 
 
2175
  msgstr ""
2176
 
2177
- #: admin/em-event.php:429
2178
- msgid "Name:"
 
 
 
2179
  msgstr ""
2180
 
2181
- #: admin/em-event.php:432
2182
- msgid "Select a location for your event"
2183
  msgstr ""
2184
 
2185
- #: admin/em-event.php:473
2186
- msgid "Details about the event"
2187
  msgstr ""
2188
 
2189
- #: admin/em-event.php:480
2190
- msgid "Attributes"
2191
  msgstr ""
2192
 
2193
- #: admin/em-event.php:536
2194
- msgid "Not defined in templates"
2195
  msgstr ""
2196
 
2197
- #: admin/em-event.php:580
2198
- msgid ""
2199
- "In order to use attributes, you must define some in your templates, "
2200
- "otherwise they'll never show. Go to Events > Settings to add attribute "
2201
- "placeholders."
2202
  msgstr ""
2203
 
2204
- #: admin/em-event.php:592
2205
- msgid "Submit Event"
2206
  msgstr ""
2207
 
2208
- #: admin/em-event.php:606
2209
- msgid ""
2210
- "Are you sure you want to reschedule this recurring event? If you do this, "
2211
- "you will lose all booking information and the old recurring events will be "
2212
- "deleted."
2213
  msgstr ""
2214
 
2215
- #: admin/em-event.php:616
2216
- msgid ""
2217
- "Are you sure you want to disable bookings? If you do this and save, you will "
2218
- "lose all previous bookings. If you wish to prevent further bookings, reduce "
2219
- "the number of seats available to the amount of bookings you currently have"
2220
  msgstr ""
2221
 
2222
  #: em-template-tags-depreciated.php:146
2223
  msgid "Ach, some problems here:"
2224
  msgstr ""
2225
 
2226
- #: em-install.php:197
2227
  msgid "Uncategorized"
2228
  msgstr ""
2229
 
2230
- #: em-install.php:205
2231
  msgid ""
2232
  "#_BOOKINGNAME (#_BOOKINGEMAIL) will attend #_NAME on #F #j, #Y. He wants to "
2233
  "reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces "
@@ -2235,14 +2718,14 @@ msgid ""
2235
  ">Events Manager - http://wp-events-plugin.com"
2236
  msgstr ""
2237
 
2238
- #: em-install.php:205 em-install.php:206 em-install.php:207 em-install.php:208
2239
- #: em-install.php:209 em-install.php:210
2240
  msgid ""
2241
  "<br/><br/>-------------------------------<br/>Powered by Events Manager - "
2242
  "http://wp-events-plugin.com"
2243
  msgstr ""
2244
 
2245
- #: em-install.php:206
2246
  msgid ""
2247
  "#_BOOKINGNAME (#_BOOKINGEMAIL) cancelled his booking at #_NAME on #F #j, #Y. "
2248
  "He wanted to reserve #_BOOKINGSPACES spaces.<br/> Now there are "
@@ -2250,119 +2733,169 @@ msgid ""
2250
  ">Yours faithfully,<br/>Events Manager - http://wp-events-plugin.com"
2251
  msgstr ""
2252
 
2253
- #: em-install.php:207
2254
  msgid ""
2255
  "Dear #_BOOKINGNAME, <br/>you have successfully reserved #_BOOKINGSPACES "
2256
  "space/spaces for #_NAME.<br/>Yours faithfully,<br/>#_CONTACTNAME"
2257
  msgstr ""
2258
 
2259
- #: em-install.php:208
2260
  msgid ""
2261
  "Dear #_BOOKINGNAME, <br/>You have requested #_BOOKEDSPACES space/spaces for "
2262
  "#_NAME.<br/>Your booking is currently pending approval by our "
2263
- "administrators. Once approved you will receive an automatic confrimation.<br/"
2264
  ">Yours faithfully,<br/>#_CONTACTNAME"
2265
  msgstr ""
2266
 
2267
- #: em-install.php:209
2268
  msgid ""
2269
  "Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces "
2270
  "at #_NAME on #F #j, #Y has been rejected.<br/>Yours faithfully,<br/"
2271
  ">#_CONTACTNAME"
2272
  msgstr ""
2273
 
2274
- #: em-install.php:210
2275
  msgid ""
2276
  "Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces "
2277
  "at #_NAME on #F #j, #Y has been cancelled.<br/>Yours faithfully,<br/"
2278
  ">#_CONTACTNAME"
2279
  msgstr ""
2280
 
2281
- #: em-install.php:234
2282
  msgid "<li>No events in this location</li>"
2283
  msgstr ""
2284
 
2285
- #: em-install.php:280
2286
  msgid "New booking"
2287
  msgstr ""
2288
 
2289
- #: em-install.php:282 em-install.php:290
2290
  msgid "Booking Cancelled"
2291
  msgstr ""
2292
 
2293
- #: em-install.php:284
2294
- msgid "Reservation Pending"
2295
  msgstr ""
2296
 
2297
- #: em-install.php:286
2298
- msgid "Reservation Rejected"
2299
  msgstr ""
2300
 
2301
- #: em-install.php:288
2302
  msgid "Booking Confirmed"
2303
  msgstr ""
2304
 
2305
- #. FIXME Better fallback in case of bad install
2306
- #: em-install.php:407
2307
- msgid ""
2308
- "We could not mirgrate old recurrence data over. DONT WORRY! You can just "
2309
- "delete the current plugin, and re-install the previous 2.2.2 version and you "
2310
- "wont lose any of your data. Either way, please contact the developers to let "
2311
- "them know of this bug."
2312
  msgstr ""
2313
 
2314
- #: em-install.php:569
2315
- msgid ""
2316
- "Events Manager successfully imported your events, please check your records "
2317
- "to verify."
2318
  msgstr ""
2319
 
2320
- #: em-install.php:585
2321
  msgid ""
2322
- "Something has gone wrong when importing your old event. See the <a href=\"%s"
2323
- "\">support page</a> for more information. <a href=\"%s\">Dismiss this "
2324
- "message</a>"
2325
  msgstr ""
2326
 
2327
- #: events-manager.php:187 events-manager.php:221
2328
- msgid "Settings"
2329
  msgstr ""
2330
 
2331
- #: events-manager.php:211
2332
- msgid "Add new"
2333
  msgstr ""
2334
 
2335
- #: events-manager.php:216
2336
- msgid "Bookings"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2337
  msgstr ""
2338
 
2339
- #: events-manager.php:219
2340
  msgid "Event Categories"
2341
  msgstr ""
2342
 
2343
- #: events-manager.php:221
2344
  msgid "Events Manager Settings"
2345
  msgstr ""
2346
 
2347
- #: events-manager.php:222
2348
  msgid "Help"
2349
  msgstr ""
2350
 
2351
- #: events-manager.php:250
2352
  msgid "Add an event"
2353
  msgstr ""
2354
 
2355
- #. #-#-#-#-# plugin.pot (Events Manager 3.0.9) #-#-#-#-#
2356
  #. Plugin URI of the plugin/theme
2357
- #. #-#-#-#-# plugin.pot (Events Manager 3.0.9) #-#-#-#-#
2358
  #. Author URI of the plugin/theme
2359
  msgid "http://wp-events-plugin.com"
2360
  msgstr ""
2361
 
2362
  #. Description of the plugin/theme
2363
  msgid ""
2364
- "Manage events specifying precise spatial data (Location, Town, Province, "
2365
- "etc)."
2366
  msgstr ""
2367
 
2368
  #. Author of the plugin/theme
2
  # This file is distributed under the same license as the Events Manager package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Events Manager 4.0b\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/events-manager\n"
7
+ "POT-Creation-Date: 2011-03-30 11:15:24+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #: buddypress/bp-em-activity.php:67
16
+ msgid "%s added a the event %s"
17
  msgstr ""
18
 
19
+ #: buddypress/bp-em-activity.php:89
20
+ msgid "%s is attending %s."
21
+ msgstr ""
22
+
23
+ #: buddypress/bp-em-activity.php:91
24
+ msgid "%s will not be attending %s anymore."
25
+ msgstr ""
26
+
27
+ #: buddypress/bp-em-notifications.php:33
28
+ msgid "%s high-fived you!"
29
+ msgstr ""
30
+
31
+ #: buddypress/bp-em-notifications.php:35
32
+ msgid ""
33
+ "%s sent you a high-five! Why not send one back?\n"
34
+ "\n"
35
+ "To see %s's profile: %s\n"
36
+ "\n"
37
+ "To send %s a high five: %s\n"
38
+ "\n"
39
+ "---------------------\n"
40
+ msgstr ""
41
+
42
+ #: buddypress/bp-em-notifications.php:45
43
+ msgid "To disable these notifications please log in and go to: %s"
44
+ msgstr ""
45
+
46
+ #: buddypress/bp-em-notifications.php:96 buddypress/screens/profile.php:27
47
+ #: buddypress/bp-em-core.php:50 buddypress/bp-em-core.php:103
48
+ #: widgets/em-events.php:13 em-template-tags.php:74 em-install.php:282
49
+ #: em-install.php:299 em-install.php:300 em-install.php:306 em-install.php:325
50
+ #: em-install.php:418 em-actions.php:156 events-manager.php:276
51
+ msgid "Events"
52
+ msgstr ""
53
+
54
+ #: buddypress/bp-em-notifications.php:97 em-functions.php:271
55
+ #: admin/em-options.php:316
56
+ msgid "Yes"
57
+ msgstr ""
58
+
59
+ #: buddypress/bp-em-notifications.php:98 em-functions.php:272
60
+ #: admin/em-options.php:317
61
+ msgid "No"
62
+ msgstr ""
63
+
64
+ #: buddypress/bp-em-notifications.php:102
65
+ msgid "Action One"
66
+ msgstr ""
67
+
68
+ #: buddypress/bp-em-notifications.php:108
69
+ msgid "Action Two"
70
+ msgstr ""
71
+
72
+ #: buddypress/bp-em-notifications.php:145
73
+ msgid "Multiple high-fives"
74
+ msgstr ""
75
+
76
+ #: buddypress/bp-em-notifications.php:145
77
+ msgid "%d new high-fives, multi-five!"
78
+ msgstr ""
79
+
80
+ #: buddypress/bp-em-notifications.php:149
81
+ msgid "%s sent you a high-five!"
82
+ msgstr ""
83
+
84
+ #: buddypress/screens/my-locations.php:48 buddypress/bp-em-core.php:92
85
+ msgid "My Locations"
86
+ msgstr ""
87
+
88
+ #: buddypress/screens/my-locations.php:62
89
+ msgid "Edit Location"
90
+ msgstr ""
91
+
92
+ #: buddypress/screens/my-locations.php:64
93
+ msgid "Add Location"
94
+ msgstr ""
95
+
96
+ #: buddypress/screens/profile.php:11
97
+ msgid ""
98
+ "You are currently viewing your public page, this is what other users will "
99
+ "see."
100
+ msgstr ""
101
+
102
+ #: buddypress/screens/profile.php:34 buddypress/screens/my-events.php:41
103
+ #: buddypress/bp-em-core.php:82
104
+ msgid "My Events"
105
+ msgstr ""
106
+
107
+ #: buddypress/screens/profile.php:47 em-install.php:374
108
+ msgid "No Events"
109
+ msgstr ""
110
+
111
+ #: buddypress/screens/profile.php:51 buddypress/bp-em-core.php:72
112
+ msgid "Events I'm Attending"
113
+ msgstr ""
114
+
115
+ #: buddypress/screens/my-events.php:55 templates/forms/events/editor.php:16
116
+ #: admin/em-event.php:35
117
+ msgid "Edit Event"
118
+ msgstr ""
119
+
120
+ #: buddypress/screens/my-events.php:57
121
+ msgid "Add Event"
122
+ msgstr ""
123
+
124
+ #: buddypress/screens/settings.php:26
125
+ msgid "Events Settings Header"
126
+ msgstr ""
127
+
128
+ #: buddypress/screens/settings.php:30
129
+ msgid "Events Settings"
130
+ msgstr ""
131
+
132
+ #: buddypress/screens/settings.php:38
133
+ msgid "Changes Saved."
134
+ msgstr ""
135
+
136
+ #: buddypress/screens/settings.php:44
137
+ msgid "Do you love clicking checkboxes?"
138
+ msgstr ""
139
+
140
+ #: buddypress/screens/settings.php:46 buddypress/bp-em-admin.php:54
141
+ msgid "Save Settings"
142
+ msgstr ""
143
+
144
+ #: buddypress/screens/attending.php:23
145
+ msgid "Attending"
146
+ msgstr ""
147
+
148
+ #: buddypress/bp-em-admin.php:33
149
+ msgid "Events Admin"
150
+ msgstr ""
151
+
152
+ #: buddypress/bp-em-admin.php:36
153
+ msgid "Settings Updated."
154
+ msgstr ""
155
+
156
+ #: buddypress/bp-em-admin.php:42
157
+ msgid "Option One"
158
+ msgstr ""
159
+
160
+ #: buddypress/bp-em-admin.php:47
161
+ msgid "Option Two"
162
+ msgstr ""
163
+
164
+ #: buddypress/bp-em-core.php:62
165
+ msgid "My Profile"
166
  msgstr ""
167
 
168
+ #: widgets/em-calendar.php:13 em-ical.php:19
169
  msgid "Calendar"
170
  msgstr ""
171
 
172
+ #: widgets/em-calendar.php:16
173
+ msgid "Display your events in a calendar widget."
174
+ msgstr ""
175
+
176
+ #: widgets/em-calendar.php:17
177
+ msgid "Events Calendar"
178
+ msgstr ""
179
+
180
+ #: widgets/em-calendar.php:58 widgets/em-locations.php:67
181
+ #: widgets/em-events.php:77
182
  msgid "Title"
183
  msgstr ""
184
 
185
+ #: widgets/em-calendar.php:62
186
  msgid "Show Long Events?"
187
  msgstr ""
188
 
189
+ #: widgets/em-locations.php:13
190
+ msgid "Event Locations"
191
  msgstr ""
192
 
193
+ #: widgets/em-locations.php:19
194
+ msgid "Display a list of event locations on Events Manager."
195
  msgstr ""
196
 
197
+ #: widgets/em-locations.php:44
198
+ msgid "No locations"
199
  msgstr ""
200
 
201
+ #: widgets/em-locations.php:71
202
  msgid "Show number of locations"
203
  msgstr ""
204
 
205
+ #: widgets/em-locations.php:75
206
  msgid "Scope of the locations"
207
  msgstr ""
208
 
209
+ #: widgets/em-locations.php:77
210
  msgid "Locations with upcoming events"
211
  msgstr ""
212
 
213
+ #: widgets/em-locations.php:78
214
  msgid "All locations"
215
  msgstr ""
216
 
217
+ #: widgets/em-locations.php:79
218
  msgid "Locations with past events "
219
  msgstr ""
220
 
221
+ #: widgets/em-locations.php:83
222
  msgid "Order of the locations"
223
  msgstr ""
224
 
225
+ #: widgets/em-locations.php:85
226
  msgid "Ascendant"
227
  msgstr ""
228
 
229
+ #: widgets/em-locations.php:86
230
  msgid "Descendant"
231
  msgstr ""
232
 
233
+ #: widgets/em-locations.php:90 widgets/em-events.php:149
234
  msgid "List item format"
235
  msgstr ""
236
 
237
+ #: widgets/em-events.php:21 widgets/em-events.php:54 widgets/em-events.php:158
238
+ msgid "all events"
 
 
 
 
239
  msgstr ""
240
 
241
+ #: widgets/em-events.php:23
242
+ msgid "Display a list of events on Events Manager."
243
  msgstr ""
244
 
245
+ #: widgets/em-events.php:51 em-install.php:288
246
+ msgid "No events"
 
 
247
  msgstr ""
248
 
249
+ #: widgets/em-events.php:81
250
  msgid "Number of events"
251
  msgstr ""
252
 
253
+ #: widgets/em-events.php:85
254
  msgid "Scope of the events"
255
  msgstr ""
256
 
257
+ #: widgets/em-events.php:87 templates/buddypress/events/my-events.php:15
258
+ #: admin/bookings/em-events.php:15 admin/em-events.php:20
259
+ #: admin/em-events.php:53
260
  msgid "Future events"
261
  msgstr ""
262
 
263
+ #: widgets/em-events.php:88 templates/buddypress/events/my-events.php:14
264
+ #: admin/bookings/em-events.php:14 admin/em-events.php:19
265
+ #: admin/em-events.php:52
266
  msgid "All events"
267
  msgstr ""
268
 
269
+ #: widgets/em-events.php:89 templates/buddypress/events/my-events.php:13
270
+ #: admin/bookings/em-events.php:13 admin/em-events.php:18
271
+ #: admin/em-events.php:51
272
  msgid "Past events"
273
  msgstr ""
274
 
275
+ #: widgets/em-events.php:93
276
  msgid "Time Limit"
277
  msgstr ""
278
 
279
+ #: widgets/em-events.php:95 admin/em-options.php:217
280
  msgid "no limit"
281
  msgstr ""
282
 
283
+ #: widgets/em-events.php:96 admin/em-options.php:218
284
  msgid "This month"
285
  msgstr ""
286
 
287
+ #: widgets/em-events.php:97 admin/em-options.php:219
288
  msgid "Next two months"
289
  msgstr ""
290
 
291
+ #: widgets/em-events.php:98
292
  msgid "Next three month"
293
  msgstr ""
294
 
295
+ #: widgets/em-events.php:99
296
  msgid "Next six month"
297
  msgstr ""
298
 
299
+ #: widgets/em-events.php:100
300
  msgid "Next twelve month"
301
  msgstr ""
302
 
303
+ #: widgets/em-events.php:115
304
  msgid "Order By"
305
  msgstr ""
306
 
307
+ #: widgets/em-events.php:119
308
  msgid "start date, start time, event name"
309
  msgstr ""
310
 
311
+ #: widgets/em-events.php:120
312
  msgid "name, start date, start time"
313
  msgstr ""
314
 
315
+ #: widgets/em-events.php:121
316
  msgid "name, end date, end time"
317
  msgstr ""
318
 
319
+ #: widgets/em-events.php:122
320
  msgid "end date, end time, event name"
321
  msgstr ""
322
 
323
+ #: widgets/em-events.php:133
324
  msgid "Order"
325
  msgstr ""
326
 
327
+ #: widgets/em-events.php:137 admin/em-options.php:188
328
  msgid "Ascending"
329
  msgstr ""
330
 
331
+ #: widgets/em-events.php:138 admin/em-options.php:189
332
  msgid "Descending"
333
  msgstr ""
334
 
335
+ #: widgets/em-events.php:153
336
  msgid "Show all events link at bottom?"
337
  msgstr ""
338
 
339
+ #: widgets/em-events.php:157
340
  msgid "All events link text?"
341
  msgstr ""
342
 
343
+ #: em-functions.php:9
344
  msgid ""
345
  "<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We "
346
  "hope you like it around here.</p> \r\n"
356
  "again!</p>"
357
  msgstr ""
358
 
359
+ #: em-functions.php:130
360
+ msgid "Trying to perform an illegal action."
361
  msgstr ""
362
 
363
+ #: classes/em-map.php:21 classes/em-map.php:46
364
+ msgid "Loading Map...."
365
  msgstr ""
366
 
367
+ #: classes/em-map.php:55
368
+ msgid "Map Unavailable"
369
  msgstr ""
370
 
371
+ #: classes/em-ticket.php:100 classes/em-ticket-booking.php:67
372
+ #: classes/em-booking.php:116
373
+ msgid "Changes saved"
374
  msgstr ""
375
 
376
+ #: classes/em-ticket.php:105
377
+ msgid "Ticket created"
378
  msgstr ""
379
 
380
+ #: classes/em-ticket.php:108 classes/em-ticket.php:109
381
+ #: classes/em-ticket.php:113 classes/em-ticket.php:114
382
+ msgid "There was a problem saving the ticket."
383
+ msgstr ""
384
+
385
+ #: classes/em-ticket.php:158 classes/em-ticket-booking.php:102
386
+ #: classes/em-category.php:126 classes/em-event.php:528
387
+ msgid "Missing fields: "
388
+ msgstr ""
389
+
390
+ #: classes/em-ticket.php:272
391
+ msgid "You cannot delete a ticket that has a booking on it."
392
  msgstr ""
393
 
394
+ #: classes/em-location.php:48
395
  msgid "The location name"
396
  msgstr ""
397
 
398
+ #: classes/em-location.php:48
399
  msgid "The location address"
400
  msgstr ""
401
 
402
+ #: classes/em-location.php:48
403
  msgid "The location town"
404
  msgstr ""
405
 
406
+ #: classes/em-location.php:48
407
+ msgid "The country"
408
+ msgstr ""
409
+
410
+ #: classes/em-location.php:108
411
+ msgid "%s successfully updated."
412
+ msgstr ""
413
+
414
+ #: classes/em-location.php:108 classes/em-location.php:116
415
+ #: classes/em-location.php:159 classes/em-location.php:161
416
+ #: templates/forms/locations/editor.php:40
417
+ #: templates/buddypress/events/my-events.php:79 admin/em-bookings.php:131
418
+ #: admin/em-locations.php:170 admin/em-events.php:127 admin/em-event.php:318
419
+ #: em-actions.php:221
420
+ msgid "Location"
421
+ msgstr ""
422
+
423
+ #: classes/em-location.php:116
424
+ msgid "%s successfully added."
425
+ msgstr ""
426
+
427
+ #: classes/em-location.php:122
428
+ msgid "You do not have permission to create/edit %s."
429
+ msgstr ""
430
+
431
+ #: classes/em-location.php:122 classes/em-location.php:164
432
+ #: events-manager.php:173 events-manager.php:174 events-manager.php:177
433
+ #: events-manager.php:179 events-manager.php:181
434
+ msgid "locations"
435
+ msgstr ""
436
+
437
+ #: classes/em-location.php:159 em-actions.php:158
438
+ msgid "%s successfully deleted."
439
+ msgstr ""
440
+
441
+ #: classes/em-location.php:161 em-actions.php:161
442
+ msgid "%s could not be deleted."
443
+ msgstr ""
444
+
445
+ #: classes/em-location.php:164
446
+ msgid "You do not have permission to delete %s."
447
+ msgstr ""
448
+
449
+ #: classes/em-location.php:209
450
  msgid "The image could not be loaded"
451
  msgstr ""
452
 
453
+ #: classes/em-location.php:242 classes/em-location.php:244
454
+ msgid " is required."
455
  msgstr ""
456
 
457
+ #: classes/em-location.php:253
458
  msgid "The image file is too big! Maximum size:"
459
  msgstr ""
460
 
461
+ #: classes/em-location.php:259
462
  msgid "The image is too big! Maximum size allowed:"
463
  msgstr ""
464
 
465
+ #: classes/em-location.php:262
466
  msgid "The image is in a wrong format!"
467
  msgstr ""
468
 
469
+ #: classes/em-tickets-bookings.php:69 classes/em-tickets-bookings.php:70
470
+ #: classes/em-booking.php:124 classes/em-booking.php:125
471
+ #: classes/em-booking.php:134 classes/em-booking.php:140
472
+ msgid "There was a problem saving the booking."
473
+ msgstr ""
474
+
475
+ #: classes/em-tickets-bookings.php:91 classes/em-bookings.php:93
476
+ msgid "Booking cannot be made, not enough spaces available!"
477
+ msgstr ""
478
+
479
+ #: classes/em-tickets-bookings.php:141 templates/forms/events/editor.php:7
480
+ #: templates/forms/locations/editor.php:7 admin/em-event.php:26
481
+ msgid "You do not have the rights to manage this %s."
482
+ msgstr ""
483
+
484
+ #: classes/em-tickets-bookings.php:141
485
+ msgid "Booking"
486
+ msgstr ""
487
+
488
+ #: classes/em-tickets-bookings.php:169 classes/em-tickets.php:112
489
+ msgid "Standard"
490
  msgstr ""
491
 
492
+ #: classes/em-ticket-booking.php:72
493
+ msgid "Ticket booking created"
494
  msgstr ""
495
 
496
+ #: classes/em-ticket-booking.php:75 classes/em-ticket-booking.php:76
497
+ #: classes/em-ticket-booking.php:80 classes/em-ticket-booking.php:81
498
+ msgid "There was a problem saving the ticket booking."
499
  msgstr ""
500
 
501
+ #: classes/em-bookings.php:73
502
  msgid ""
503
  "Booking successful, pending confirmation (you will also receive an email "
504
  "once confirmed)."
505
  msgstr ""
506
 
507
+ #: classes/em-bookings.php:75
508
  msgid "Booking successful."
509
  msgstr ""
510
 
511
+ #: classes/em-bookings.php:78
512
  msgid ""
513
  "However, there were some problems whilst sending confirmation emails to you "
514
  "and/or the event contact person. You may want to contact them directly and "
515
  "letting them know of this error."
516
  msgstr ""
517
 
518
+ #: classes/em-bookings.php:90
519
  msgid "Booking could not be created"
520
  msgstr ""
521
 
522
+ #: classes/em-bookings.php:245 classes/em-bookings.php:251
 
 
 
 
523
  msgid "Bookings %s. Mails Sent."
524
  msgstr ""
525
 
526
+ #: classes/em-bookings.php:255
527
  msgid "An error occurred."
528
  msgstr ""
529
 
530
+ #: classes/em-bookings.php:505
531
  msgid "Booking details for \"%s\" as of %s"
532
  msgstr ""
533
 
534
+ #: classes/em-booking.php:91 classes/em-event.php:201
535
+ #: templates/buddypress/events/my-events.php:45
536
+ #: templates/buddypress/events/my-events.php:123
537
+ #: admin/bookings/em-events.php:135 admin/em-events.php:70
538
+ #: admin/em-events.php:171
539
  msgid "Pending"
540
  msgstr ""
541
 
542
+ #: classes/em-booking.php:92 classes/em-event.php:202 admin/em-events.php:69
543
  msgid "Approved"
544
  msgstr ""
545
 
546
+ #: classes/em-booking.php:93
547
  msgid "Rejected"
548
  msgstr ""
549
 
550
+ #: classes/em-booking.php:94
551
  msgid "Cacncelled"
552
  msgstr ""
553
 
554
+ #: classes/em-booking.php:95
555
+ msgid "Awaiting Online Payment"
556
  msgstr ""
557
 
558
+ #: classes/em-booking.php:121
559
  msgid "Your booking has been recorded"
560
  msgstr ""
561
 
562
+ #: classes/em-booking.php:189
563
+ msgid "You are trying to book a non-existent ticket for this event."
564
+ msgstr ""
565
+
566
+ #: classes/em-booking.php:211
567
+ msgid "You must request at least one space to book an event."
568
+ msgstr ""
569
+
570
+ #: classes/em-booking.php:394
571
+ msgid "Not approved, spaces full."
572
  msgstr ""
573
 
574
+ #: classes/em-booking.php:402
575
  msgid "Booking %s."
576
  msgstr ""
577
 
578
+ #: classes/em-booking.php:405
579
  msgid "Mail Sent."
580
  msgstr ""
581
 
582
+ #: classes/em-booking.php:408
583
  msgid "ERROR : Mail Not Sent."
584
  msgstr ""
585
 
586
+ #: classes/em-booking.php:414 classes/em-event.php:485
587
  msgid "Booking could not be %s."
588
  msgstr ""
589
 
590
+ #: classes/em-booking.php:429
591
  msgid "Booking note successfully added."
592
  msgstr ""
593
 
594
+ #: classes/em-booking.php:503
595
  msgid ""
596
  "Confirmation email could not be sent to contact person. Registrant should "
597
  "have gotten their email (only admin see this warning)."
598
  msgstr ""
599
 
600
+ #: classes/em-booking.php:510
601
  msgid ""
602
  "Confirmation email could not be sent to admin. Registrant should have gotten "
603
  "their email (only admin see this warning)."
604
  msgstr ""
605
 
606
+ #: classes/em-category.php:28
607
  msgid "The category name"
608
  msgstr ""
609
 
610
+ #: classes/em-event.php:207
611
+ msgid "WARNING: This is a recurring event."
612
+ msgstr ""
613
+
614
+ #: classes/em-event.php:207
615
+ msgid ""
616
+ "Modifications to this event will cause all recurrences of this event to be "
617
+ "deleted and recreated and previous bookings will be deleted! You can edit "
618
+ "individual recurrences and disassociate them with this recurring event."
619
+ msgstr ""
620
+
621
+ #: classes/em-event.php:209
622
+ msgid "WARNING: This is a recurrence in a set of recurring events."
623
  msgstr ""
624
 
625
+ #: classes/em-event.php:209
626
+ msgid ""
627
+ "If you update this event data and save, it will become an independent event, "
628
+ "and will not be deleted or modified automatically if you reschedule the "
629
+ "original recurring event details."
630
+ msgstr ""
631
+
632
+ #: classes/em-event.php:322
633
  msgid "There was a problem saving the location so event was not saved."
634
  msgstr ""
635
 
636
+ #: classes/em-event.php:357 classes/em-event.php:392
637
+ msgid "Something went wrong with creating tickets."
638
+ msgstr ""
639
+
640
+ #: classes/em-event.php:364 classes/em-event.php:398
641
  msgid "Something went wrong with the recurrence update..."
642
  msgstr ""
643
 
644
+ #: classes/em-event.php:365 classes/em-event.php:399
645
  msgid "There was a problem saving the recurring events."
646
  msgstr ""
647
 
648
+ #: classes/em-event.php:370
649
  msgid "New recurrent event inserted!"
650
  msgstr ""
651
 
652
+ #: classes/em-event.php:374
653
  msgid "New event successfully inserted!"
654
  msgstr ""
655
 
656
+ #: classes/em-event.php:377 classes/em-event.php:406
657
  msgid "Could not save the event details due to a database error."
658
  msgstr ""
659
 
660
+ #: classes/em-event.php:402
661
  msgid "Recurrence updated!"
662
  msgstr ""
663
 
664
+ #: classes/em-event.php:410
665
  msgid "updated"
666
  msgstr ""
667
 
668
+ #: classes/em-event.php:481
669
+ msgid "Event %s."
670
  msgstr ""
671
 
672
+ #: classes/em-event.php:503
673
+ msgid "%s successfully duplicated."
674
+ msgstr ""
675
+
676
+ #: classes/em-event.php:503 classes/em-event.php:697
677
+ #: templates/forms/events/editor.php:7 admin/bookings/em-events.php:100
678
+ #: admin/em-event.php:26 em-actions.php:156
679
+ msgid "Event"
680
+ msgstr ""
681
+
682
+ #: classes/em-event.php:507
683
+ msgid "You are not allowed to manage this %s."
684
+ msgstr ""
685
+
686
+ #: classes/em-event.php:507 em-actions.php:142
687
+ msgid "event"
688
+ msgstr ""
689
+
690
+ #: classes/em-event.php:531
691
  msgid "Since the event is repeated, you must specify an event date."
692
  msgstr ""
693
 
694
+ #: classes/em-event.php:535
695
  msgid "Events cannot start after they end."
696
  msgstr ""
697
 
698
+ #: classes/em-event.php:538
699
  msgid ""
700
  "Dates must have correct formatting. Please use the date picker provided."
701
  msgstr ""
702
 
703
+ #: classes/em-event.php:697 admin/em-event.php:490 admin/em-event.php:549
704
+ #: events-manager.php:279
 
 
705
  msgid "Edit"
706
  msgstr ""
707
 
708
+ #: classes/em-event.php:755 em-bookings.php:129 em-bookings.php:151
 
 
 
 
709
  msgid "N/A"
710
  msgstr ""
711
 
712
+ #: classes/em-event.php:765 classes/em-event.php:774
713
  msgid "Profile"
714
  msgstr ""
715
 
716
+ #: classes/em-event.php:1065 templates/forms/events/recurrence-box.php:4
 
 
 
 
717
  msgid "Sunday"
718
  msgstr ""
719
 
720
+ #: classes/em-event.php:1065 templates/forms/events/recurrence-box.php:4
721
  msgid "Monday"
722
  msgstr ""
723
 
724
+ #: classes/em-event.php:1065 templates/forms/events/recurrence-box.php:4
725
  msgid "Tuesday"
726
  msgstr ""
727
 
728
+ #: classes/em-event.php:1065 templates/forms/events/recurrence-box.php:4
729
  msgid "Wednesday"
730
  msgstr ""
731
 
732
+ #: classes/em-event.php:1065 templates/forms/events/recurrence-box.php:4
733
  msgid "Thursday"
734
  msgstr ""
735
 
736
+ #: classes/em-event.php:1065 templates/forms/events/recurrence-box.php:4
737
  msgid "Friday"
738
  msgstr ""
739
 
740
+ #: classes/em-event.php:1065 templates/forms/events/recurrence-box.php:4
741
  msgid "Saturday"
742
  msgstr ""
743
 
744
+ #: classes/em-event.php:1066
745
  msgid "the first %s of the month"
746
  msgstr ""
747
 
748
+ #: classes/em-event.php:1066
749
  msgid "the second %s of the month"
750
  msgstr ""
751
 
752
+ #: classes/em-event.php:1066
753
  msgid "the third %s of the month"
754
  msgstr ""
755
 
756
+ #: classes/em-event.php:1066
757
  msgid "the fourth %s of the month"
758
  msgstr ""
759
 
760
+ #: classes/em-event.php:1066
761
  msgid "the last %s of the month"
762
  msgstr ""
763
 
764
+ #: classes/em-event.php:1067
765
  msgid "From %1$s to %2$s"
766
  msgstr ""
767
 
768
+ #: classes/em-event.php:1069
769
  msgid "everyday"
770
  msgstr ""
771
 
772
+ #: classes/em-event.php:1071
773
  msgid "every %s days"
774
  msgstr ""
775
 
776
+ #: classes/em-event.php:1080
777
  msgid "every week"
778
  msgstr ""
779
 
780
+ #: classes/em-event.php:1082
781
  msgid "every %s weeks"
782
  msgstr ""
783
 
784
+ #: classes/em-event.php:1093
785
  msgid "every %s months"
786
  msgstr ""
787
 
789
  msgid "Please supply a valid email format."
790
  msgstr ""
791
 
792
+ #: em-bookings.php:74 admin/em-options.php:385
793
+ msgid "Booking cancelled"
794
  msgstr ""
795
 
796
+ #: em-bookings.php:77
797
+ msgid "You must log in to cancel your booking."
798
  msgstr ""
799
 
800
+ #: em-bookings.php:97
801
  msgid "Book now!"
802
  msgstr ""
803
 
804
+ #: em-bookings.php:114 admin/em-bookings.php:267
805
+ msgid "Ticket Type"
 
 
 
 
 
 
 
 
806
  msgstr ""
807
 
808
+ #: em-bookings.php:115 admin/em-bookings.php:177 admin/em-bookings.php:269
809
+ #: admin/em-event.php:435 admin/em-event.php:670
810
+ msgid "Price"
811
  msgstr ""
812
 
813
+ #: em-bookings.php:116 em-bookings.php:144
814
+ #: templates/forms/events/bookings-box.php:10 admin/em-bookings.php:178
815
+ #: admin/em-bookings.php:268 admin/em-people.php:33
816
+ msgid "Spaces"
817
  msgstr ""
818
 
819
+ #: em-bookings.php:158 admin/em-bookings.php:290 admin/em-people.php:34
820
  msgid "Comment"
821
  msgstr ""
822
 
823
+ #: em-bookings.php:162
824
  msgid "Send your booking"
825
  msgstr ""
826
 
827
+ #: em-bookings.php:169
828
+ msgid "No more tickets available at this time."
829
  msgstr ""
830
 
831
+ #: em-bookings.php:171
832
+ msgid ""
833
+ "You must <a href=\"%s\">register</a> or <a href=\"%s\">log in</a> in order "
834
+ "to create and manage your bookings."
835
  msgstr ""
836
 
837
+ #: em-bookings.php:219 em-bookings.php:233
838
  msgid "Cancel your booking"
839
  msgstr ""
840
 
841
+ #: templates/forms/events/bookings-box.php:6 admin/em-event.php:424
842
+ msgid "Enable registration for this event"
843
  msgstr ""
844
 
845
+ #: templates/forms/events/bookings-box.php:12
846
+ msgid "This is a limit for total number of booking spaces."
847
  msgstr ""
848
 
849
+ #: templates/forms/events/bookings-box.php:23 admin/em-event.php:194
850
+ msgid "Available Spaces"
851
  msgstr ""
852
 
853
+ #: templates/forms/events/bookings-box.php:24 admin/em-event.php:195
854
+ msgid "Confirmed Spaces"
855
  msgstr ""
856
 
857
+ #: templates/forms/events/bookings-box.php:25 admin/em-event.php:196
858
+ msgid "Pending Spaces"
859
  msgstr ""
860
 
861
+ #: templates/forms/events/bookings-box.php:30 admin/em-event.php:203
862
+ msgid "manage bookings"
863
  msgstr ""
864
 
865
+ #: templates/forms/events/bookings-box.php:31 admin/em-event.php:204
866
+ msgid "printable view"
867
  msgstr ""
868
 
869
+ #: templates/forms/events/bookings-box.php:32 admin/em-bookings.php:120
870
+ #: admin/em-event.php:205
871
+ msgid "export csv"
872
  msgstr ""
873
 
874
+ #: templates/forms/events/bookings-box.php:40 admin/em-event.php:213
875
+ msgid "No responses yet!"
876
  msgstr ""
877
 
878
+ #: templates/forms/events/categories-box.php:8 admin/em-event.php:234
879
+ msgid "Category:"
880
  msgstr ""
881
 
882
+ #: templates/forms/events/categories-box.php:10 admin/em-event.php:236
883
+ msgid "no category"
884
  msgstr ""
885
 
886
+ #: templates/forms/events/editor.php:7 templates/forms/locations/editor.php:7
887
+ #: admin/em-categories.php:141 admin/em-bookings.php:105
888
+ #: admin/em-bookings.php:159 admin/em-bookings.php:208
889
+ #: admin/em-locations.php:119 admin/em-people.php:9 admin/em-event.php:26
890
+ msgid "Unauthorized Access"
891
  msgstr ""
892
 
893
+ #: templates/forms/events/editor.php:14
894
+ #: templates/forms/events/recurrence-box.php:58
895
+ #: templates/buddypress/events/my-events.php:160 admin/em-events.php:209
896
+ #: admin/em-event.php:33 admin/em-event.php:153
897
+ msgid "Reschedule"
898
  msgstr ""
899
 
900
+ #: templates/forms/events/editor.php:20 admin/em-event.php:39
901
+ msgid "Insert New Event"
902
  msgstr ""
903
 
904
+ #: templates/forms/events/editor.php:56 admin/em-bookings.php:122
905
+ msgid "Event Name"
 
 
906
  msgstr ""
907
 
908
+ #: templates/forms/events/editor.php:60 admin/em-event.php:268
909
+ msgid "The event name. Example: Birthday party"
910
  msgstr ""
911
 
912
+ #: templates/forms/events/editor.php:63
913
+ msgid "When"
914
  msgstr ""
915
 
916
+ #: templates/forms/events/editor.php:66
917
+ msgid "Starts on "
918
  msgstr ""
919
 
920
+ #: templates/forms/events/editor.php:69
921
+ msgid "from"
922
  msgstr ""
923
 
924
+ #: templates/forms/events/editor.php:71
925
+ msgid "to"
926
  msgstr ""
927
 
928
+ #: templates/forms/events/editor.php:73
929
+ msgid "and ends on"
930
  msgstr ""
931
 
932
+ #: templates/forms/events/editor.php:79
933
+ msgid ""
934
+ "This event spans every day between the beginning and end date, with start/"
935
+ "end times applying to each day."
936
  msgstr ""
937
 
938
+ #: templates/forms/events/editor.php:82
939
+ msgid ""
940
+ "For a recurring event, a one day event will be created on each recurring "
941
+ "date within this date range."
942
  msgstr ""
943
 
944
+ #: templates/forms/events/editor.php:95
945
+ msgid "Where"
946
  msgstr ""
947
 
948
+ #: templates/forms/events/editor.php:121
949
+ msgid "Choose from one of your locations"
950
  msgstr ""
951
 
952
+ #: templates/forms/events/editor.php:121
953
+ msgid "or <a href=\"%s\">add a new location</a>"
 
954
  msgstr ""
955
 
956
+ #: templates/forms/events/editor.php:126
957
+ #: templates/forms/locations/editor.php:87 admin/em-locations.php:217
958
+ #: admin/em-event.php:395
959
+ msgid "Location not found"
960
  msgstr ""
961
 
962
+ #: templates/forms/events/editor.php:135
963
+ #: templates/forms/locations/editor.php:97 admin/em-locations.php:229
964
+ #: admin/em-event.php:406
965
+ msgid "Details"
966
  msgstr ""
967
 
968
+ #: templates/forms/events/editor.php:139
969
+ msgid "Details about the event."
970
  msgstr ""
971
 
972
+ #: templates/forms/events/editor.php:139
973
+ msgid "HTML Allowed."
 
974
  msgstr ""
975
 
976
+ #: templates/forms/events/editor.php:152 admin/em-event.php:419
977
+ msgid "Bookings/Registration"
978
+ msgstr ""
979
+
980
+ #: templates/forms/events/editor.php:160 admin/em-event.php:654
981
+ msgid "Submit Event"
982
  msgstr ""
983
 
984
+ #: templates/forms/events/editor.php:171 admin/em-event.php:692
985
  msgid ""
986
+ "Are you sure you want to reschedule this recurring event? If you do this, "
987
+ "you will lose all booking information and the old recurring events will be "
988
+ "deleted."
989
+ msgstr ""
990
+
991
+ #: templates/forms/events/editor.php:181 admin/em-event.php:702
992
+ msgid ""
993
+ "Are you sure you want to disable bookings? If you do this and save, you will "
994
+ "lose all previous bookings. If you wish to prevent further bookings, reduce "
995
+ "the number of spaces available to the amount of bookings you currently have"
996
+ msgstr ""
997
+
998
+ #: templates/forms/events/recurrence-box.php:8
999
+ msgid "This event repeats"
1000
+ msgstr ""
1001
+
1002
+ #: templates/forms/events/recurrence-box.php:11 admin/em-event.php:103
1003
+ msgid "Daily"
1004
+ msgstr ""
1005
+
1006
+ #: templates/forms/events/recurrence-box.php:11 admin/em-event.php:103
1007
+ msgid "Weekly"
1008
+ msgstr ""
1009
+
1010
+ #: templates/forms/events/recurrence-box.php:11 admin/em-event.php:103
1011
+ msgid "Monthly"
1012
+ msgstr ""
1013
+
1014
+ #: templates/forms/events/recurrence-box.php:15
1015
+ msgid "every"
1016
+ msgstr ""
1017
+
1018
+ #: templates/forms/events/recurrence-box.php:18 admin/em-event.php:112
1019
+ msgid "day"
1020
+ msgstr ""
1021
+
1022
+ #: templates/forms/events/recurrence-box.php:20 admin/em-event.php:114
1023
+ msgid "days"
1024
+ msgstr ""
1025
+
1026
+ #: templates/forms/events/recurrence-box.php:22
1027
+ msgid "week on"
1028
+ msgstr ""
1029
+
1030
+ #: templates/forms/events/recurrence-box.php:24
1031
+ msgid "weeks on"
1032
+ msgstr ""
1033
+
1034
+ #: templates/forms/events/recurrence-box.php:26
1035
+ msgid "month on the"
1036
+ msgstr ""
1037
+
1038
+ #: templates/forms/events/recurrence-box.php:28
1039
+ msgid "months on the"
1040
+ msgstr ""
1041
+
1042
+ #: templates/forms/events/recurrence-box.php:39 admin/em-event.php:135
1043
+ msgid "first"
1044
+ msgstr ""
1045
+
1046
+ #: templates/forms/events/recurrence-box.php:39 admin/em-event.php:135
1047
+ msgid "second"
1048
+ msgstr ""
1049
+
1050
+ #: templates/forms/events/recurrence-box.php:39 admin/em-event.php:135
1051
+ msgid "third"
1052
+ msgstr ""
1053
+
1054
+ #: templates/forms/events/recurrence-box.php:39 admin/em-event.php:135
1055
+ msgid "fourth"
1056
+ msgstr ""
1057
+
1058
+ #: templates/forms/events/recurrence-box.php:39 admin/em-event.php:135
1059
+ msgid "last"
1060
+ msgstr ""
1061
+
1062
+ #: templates/forms/events/recurrence-box.php:46
1063
+ msgid "of each month"
1064
+ msgstr ""
1065
+
1066
+ #: templates/forms/events/recurrence-box.php:51 admin/em-event.php:146
1067
+ msgid ""
1068
+ "Check if your event happens more than once according to a regular pattern"
1069
+ msgstr ""
1070
+
1071
+ #: templates/forms/events/recurrence-box.php:63 admin/em-event.php:158
1072
+ msgid "This is't a recurrent event"
1073
+ msgstr ""
1074
+
1075
+ #: templates/forms/locations/editor.php:7
1076
+ msgid "location"
1077
+ msgstr ""
1078
+
1079
+ #: templates/forms/locations/editor.php:12 admin/em-locations.php:124
1080
+ msgid "Add location"
1081
+ msgstr ""
1082
+
1083
+ #: templates/forms/locations/editor.php:15 admin/em-locations.php:127
1084
+ msgid "Edit location"
1085
+ msgstr ""
1086
+
1087
+ #: templates/forms/locations/editor.php:17 admin/em-locations.php:129
1088
+ msgid "required"
1089
+ msgstr ""
1090
+
1091
+ #: templates/forms/locations/editor.php:31 admin/em-locations.php:150
1092
+ msgid "Location Name"
1093
+ msgstr ""
1094
+
1095
+ #: templates/forms/locations/editor.php:36 admin/em-locations.php:155
1096
+ msgid "The name of the location"
1097
+ msgstr ""
1098
+
1099
+ #: templates/forms/locations/editor.php:43 admin/em-locations.php:173
1100
+ msgid ""
1101
+ "If you're using the Google Maps, the more detail you provide, the more "
1102
+ "accurate Google can be at finding your location. If your address isn't being "
1103
+ "found, please <a='http://maps.google.com'>try it on maps.google.com</a> by "
1104
+ "adding all the fields below seperated by commas."
1105
+ msgstr ""
1106
+
1107
+ #: templates/forms/locations/editor.php:49 admin/em-locations.php:179
1108
+ #: admin/em-event.php:356
1109
+ msgid "Address:"
1110
+ msgstr ""
1111
+
1112
+ #: templates/forms/locations/editor.php:55 admin/em-locations.php:185
1113
+ #: admin/em-event.php:362
1114
+ msgid "City/Town:"
1115
+ msgstr ""
1116
+
1117
+ #: templates/forms/locations/editor.php:61 admin/em-locations.php:191
1118
+ #: admin/em-event.php:368
1119
+ msgid "State/County:"
1120
+ msgstr ""
1121
+
1122
+ #: templates/forms/locations/editor.php:67 admin/em-locations.php:197
1123
+ #: admin/em-event.php:374
1124
+ msgid "Postcode:"
1125
+ msgstr ""
1126
+
1127
+ #: templates/forms/locations/editor.php:73 admin/em-locations.php:203
1128
+ #: admin/em-event.php:380
1129
+ msgid "Country:"
1130
+ msgstr ""
1131
+
1132
+ #: templates/forms/locations/editor.php:76 admin/em-locations.php:206
1133
+ #: admin/em-event.php:383
1134
+ msgid "none selected"
1135
+ msgstr ""
1136
+
1137
+ #: templates/forms/locations/editor.php:101 admin/em-locations.php:236
1138
+ msgid "Details about the location"
1139
+ msgstr ""
1140
+
1141
+ #: templates/forms/locations/editor.php:105 admin/em-locations.php:242
1142
+ msgid "Location image"
1143
+ msgstr ""
1144
+
1145
+ #: templates/forms/locations/editor.php:111 admin/em-locations.php:248
1146
+ msgid "No image uploaded for this location yet"
1147
+ msgstr ""
1148
+
1149
+ #: templates/forms/locations/editor.php:114 admin/em-locations.php:251
1150
+ msgid "Upload/change picture"
1151
+ msgstr ""
1152
+
1153
+ #: templates/forms/locations/editor.php:116 admin/em-locations.php:258
1154
+ msgid "Update location"
1155
+ msgstr ""
1156
+
1157
+ #: templates/buddypress/events/my-events.php:41
1158
+ #: templates/buddypress/locations/my-locations.php:25
1159
+ #: admin/em-locations.php:42 admin/em-events.php:47
1160
+ msgid "Add New"
1161
+ msgstr ""
1162
+
1163
+ #: templates/buddypress/events/my-events.php:43
1164
+ msgid "Upcoming"
1165
+ msgstr ""
1166
+
1167
+ #: templates/buddypress/events/my-events.php:47
1168
+ #: admin/bookings/em-events.php:29
1169
+ msgid "Past Events"
1170
+ msgstr ""
1171
+
1172
+ #: templates/buddypress/events/my-events.php:50
1173
+ #: templates/buddypress/events/my-events.php:52 admin/em-events.php:74
1174
+ #: admin/em-events.php:76
1175
+ msgid "Search Events"
1176
+ msgstr ""
1177
+
1178
+ #. TODO localize
1179
+ #. TODO localize
1180
+ #. TODO localize
1181
+ #: templates/buddypress/events/my-events.php:67
1182
+ #: admin/bookings/em-events.php:90 admin/em-events.php:115
1183
+ msgid "no events"
1184
+ msgstr ""
1185
+
1186
+ #: templates/buddypress/events/my-events.php:77
1187
+ #: templates/buddypress/locations/my-locations.php:53
1188
+ #: templates/buddypress/locations/my-locations.php:61
1189
+ #: admin/em-categories.php:70 admin/em-categories.php:77
1190
+ #: admin/em-bookings.php:175 admin/em-bookings.php:234
1191
+ #: admin/em-locations.php:78 admin/em-locations.php:86 admin/em-events.php:125
1192
+ #: admin/em-people.php:30 admin/em-event.php:263 admin/em-event.php:668
1193
+ msgid "Name"
1194
+ msgstr ""
1195
+
1196
+ #: templates/buddypress/events/my-events.php:80
1197
+ #: admin/bookings/em-events.php:101 admin/em-events.php:128
1198
+ msgid "Date and time"
1199
+ msgstr ""
1200
+
1201
+ #: templates/buddypress/events/my-events.php:120 admin/em-events.php:168
1202
+ #: events-manager.php:282
1203
+ msgid "Bookings"
1204
+ msgstr ""
1205
+
1206
+ #: templates/buddypress/events/my-events.php:121 admin/em-events.php:169
1207
+ #: admin/em-people.php:48
1208
+ msgid "Booked"
1209
+ msgstr ""
1210
+
1211
+ #: templates/buddypress/events/my-events.php:129
1212
+ #: admin/bookings/em-cancelled.php:112 admin/bookings/em-confirmed.php:117
1213
+ #: admin/bookings/em-person.php:127 admin/bookings/em-rejected.php:112
1214
+ #: admin/bookings/em-pending.php:134 admin/em-events.php:176
1215
+ #: admin/em-event.php:492 admin/em-event.php:549
1216
+ msgid "Delete"
1217
+ msgstr ""
1218
+
1219
+ #: templates/buddypress/events/my-events.php:134 admin/em-events.php:183
1220
+ msgid "Duplicate this event"
1221
+ msgstr ""
1222
+
1223
+ #: templates/buddypress/events/my-events.php:141 admin/em-events.php:190
1224
+ #: admin/em-event.php:229
1225
+ msgid "Category"
1226
+ msgstr ""
1227
+
1228
+ #: templates/buddypress/locations/my-locations.php:27
1229
+ #: admin/em-locations.php:52
1230
+ msgid "My %s"
1231
+ msgstr ""
1232
+
1233
+ #: templates/buddypress/locations/my-locations.php:27
1234
+ #: templates/buddypress/locations/my-locations.php:30
1235
+ #: admin/em-locations.php:41 admin/em-locations.php:52
1236
+ #: admin/em-locations.php:55 em-actions.php:221 events-manager.php:281
1237
+ msgid "Locations"
1238
+ msgstr ""
1239
+
1240
+ #: templates/buddypress/locations/my-locations.php:30
1241
+ #: admin/em-locations.php:55
1242
+ msgid "All %s"
1243
+ msgstr ""
1244
+
1245
+ #: templates/buddypress/locations/my-locations.php:37
1246
+ #: admin/bookings/em-cancelled.php:49 admin/bookings/em-confirmed.php:50
1247
+ #: admin/bookings/em-person.php:51 admin/bookings/em-rejected.php:49
1248
+ #: admin/bookings/em-pending.php:64 admin/bookings/em-events.php:56
1249
+ #: admin/em-locations.php:62 admin/em-events.php:82
1250
+ msgid "Bulk Actions"
1251
+ msgstr ""
1252
+
1253
+ #: templates/buddypress/locations/my-locations.php:38
1254
+ #: admin/bookings/em-events.php:57 admin/em-locations.php:63
1255
+ #: admin/em-events.php:83
1256
+ msgid "Delete selected"
1257
+ msgstr ""
1258
+
1259
+ #: templates/buddypress/locations/my-locations.php:40
1260
+ #: admin/bookings/em-events.php:59 admin/em-locations.php:65
1261
+ #: admin/em-events.php:85
1262
+ msgid "Apply"
1263
+ msgstr ""
1264
+
1265
+ #: templates/buddypress/locations/my-locations.php:54
1266
+ #: templates/buddypress/locations/my-locations.php:62
1267
+ #: admin/em-locations.php:79 admin/em-locations.php:87
1268
+ msgid "Address"
1269
+ msgstr ""
1270
+
1271
+ #: templates/buddypress/locations/my-locations.php:55
1272
+ #: templates/buddypress/locations/my-locations.php:63
1273
+ msgid "Country"
1274
+ msgstr ""
1275
+
1276
+ #: templates/buddypress/locations/my-locations.php:82
1277
+ #: admin/em-locations.php:107
1278
+ msgid "No venues have been inserted yet!"
1279
+ msgstr ""
1280
+
1281
+ #: admin/em-options.php:38
1282
+ msgid "Changes saved."
1283
+ msgstr ""
1284
+
1285
+ #: admin/em-options.php:53 admin/em-help.php:17
1286
+ msgid "Event Related Placeholders"
1287
+ msgstr ""
1288
+
1289
+ #: admin/em-options.php:54 admin/em-help.php:19
1290
+ msgid "Location Related Placeholders"
1291
+ msgstr ""
1292
+
1293
+ #: admin/em-options.php:55 admin/em-help.php:21
1294
+ msgid "Booking Related Placeholders"
1295
+ msgstr ""
1296
+
1297
+ #: admin/em-options.php:56
1298
+ msgid "This accepts %s and %s placeholders."
1299
+ msgstr ""
1300
+
1301
+ #: admin/em-options.php:57
1302
+ msgid "This accepts %s placeholders."
1303
+ msgstr ""
1304
+
1305
+ #: admin/em-options.php:58
1306
+ msgid "This accepts %s, %s and %s placeholders."
1307
+ msgstr ""
1308
+
1309
+ #: admin/em-options.php:60 admin/em-options.php:481
1310
+ msgid "Save Changes"
1311
+ msgstr ""
1312
+
1313
+ #: admin/em-options.php:60
1314
+ msgid "All"
1315
+ msgstr ""
1316
+
1317
+ #: admin/em-options.php:64
1318
+ msgid "Collapse All"
1319
+ msgstr ""
1320
+
1321
+ #: admin/em-options.php:65
1322
+ msgid "Expand All"
1323
+ msgstr ""
1324
+
1325
+ #: admin/em-options.php:94
1326
+ msgid "Event Manager Options"
1327
+ msgstr ""
1328
+
1329
+ #: admin/em-options.php:104 admin/em-options.php:145 admin/em-options.php:243
1330
+ #: admin/em-options.php:262 admin/em-options.php:278 admin/em-options.php:294
1331
+ #: admin/em-options.php:309 admin/em-options.php:330 admin/em-options.php:346
1332
+ #: admin/em-options.php:396 admin/em-options.php:415 admin/em-options.php:429
1333
+ msgid "Click to toggle"
1334
+ msgstr ""
1335
+
1336
+ #: admin/em-options.php:104
1337
+ msgid "General options"
1338
+ msgstr ""
1339
+
1340
+ #: admin/em-options.php:108
1341
+ msgid "Use dropdown for locations?"
1342
+ msgstr ""
1343
+
1344
+ #: admin/em-options.php:108
1345
+ msgid ""
1346
+ "Select yes to select location from a drow-down menu; location selection will "
1347
+ "be faster, but you will lose the ability to insert locations with events"
1348
+ msgstr ""
1349
+
1350
+ #: admin/em-options.php:109
1351
+ msgid "Use recurrence?"
1352
+ msgstr ""
1353
+
1354
+ #: admin/em-options.php:109
1355
+ msgid "Select yes to enable the recurrence features feature"
1356
+ msgstr ""
1357
+
1358
+ #: admin/em-options.php:110
1359
+ msgid "Use RSVP?"
1360
+ msgstr ""
1361
+
1362
+ #: admin/em-options.php:110
1363
+ msgid "Select yes to enable the RSVP feature"
1364
+ msgstr ""
1365
+
1366
+ #: admin/em-options.php:111
1367
+ msgid "Use categories?"
1368
+ msgstr ""
1369
+
1370
+ #: admin/em-options.php:111
1371
+ msgid "Select yes to enable the category features"
1372
+ msgstr ""
1373
+
1374
+ #: admin/em-options.php:112
1375
+ msgid "Use attributes?"
1376
+ msgstr ""
1377
+
1378
+ #: admin/em-options.php:112
1379
+ msgid "Select yes to enable the attributes feature"
1380
+ msgstr ""
1381
+
1382
+ #: admin/em-options.php:116
1383
+ msgid "no default category"
1384
+ msgstr ""
1385
+
1386
+ #: admin/em-options.php:121
1387
+ msgid "Default Category"
1388
+ msgstr ""
1389
+
1390
+ #: admin/em-options.php:121
1391
+ msgid ""
1392
+ "This option allows you to select the default category when adding an event."
1393
+ msgstr ""
1394
+
1395
+ #: admin/em-options.php:121 admin/em-options.php:130
1396
+ msgid "(not applicable with event ownership on presently, coming soon!)"
1397
+ msgstr ""
1398
+
1399
+ #: admin/em-options.php:125
1400
+ msgid "no default location"
1401
+ msgstr ""
1402
+
1403
+ #: admin/em-options.php:130
1404
+ msgid "Default Location"
1405
+ msgstr ""
1406
+
1407
+ #: admin/em-options.php:130
1408
+ msgid ""
1409
+ "This option allows you to select the default location when adding an event."
1410
+ msgstr ""
1411
+
1412
+ #: admin/em-options.php:133
1413
+ msgid "Default Location Country"
1414
+ msgstr ""
1415
+
1416
+ #: admin/em-options.php:133
1417
+ msgid "no default country"
1418
+ msgstr ""
1419
+
1420
+ #: admin/em-options.php:133
1421
+ msgid ""
1422
+ "If you select a default country, that will be pre-selected when creating a "
1423
+ "new location."
1424
+ msgstr ""
1425
+
1426
+ #: admin/em-options.php:135
1427
+ msgid "Custom Placeholders"
1428
+ msgstr ""
1429
+
1430
+ #: admin/em-options.php:135
1431
+ msgid ""
1432
+ "You can add custom placeholders here, one per line in this format <code>#_ATT"
1433
+ "{key}</code>. They will not appear on event pages unless you insert them "
1434
  "into another template below, but you may want to store extra information "
1435
  "about an event for other uses. <a href='%s'>More information on placeholders."
1436
  "</a>"
1437
  msgstr ""
1438
 
1439
+ #: admin/em-options.php:145 admin/em-options.php:159
1440
  msgid "Events page"
1441
  msgstr ""
1442
 
1443
+ #: admin/em-options.php:154
1444
  msgid "[No Events Page]"
1445
  msgstr ""
1446
 
1447
+ #: admin/em-options.php:159
1448
  msgid "This option allows you to select which page to use as an events page"
1449
  msgstr ""
1450
 
1451
+ #: admin/em-options.php:162
1452
  msgid "Show events page in lists?"
1453
  msgstr ""
1454
 
1455
+ #: admin/em-options.php:162
1456
  msgid ""
1457
  "Check this option if you want the events page to appear together with other "
1458
  "pages in pages lists."
1459
  msgstr ""
1460
 
1461
+ #: admin/em-options.php:163
1462
  msgid "Display calendar in events page?"
1463
  msgstr ""
1464
 
1465
+ #: admin/em-options.php:163
1466
  msgid ""
1467
  "This options allows to display the calendar in the events page, instead of "
1468
  "the default list. It is recommended not to display both the calendar widget "
1469
  "and a calendar page."
1470
  msgstr ""
1471
 
1472
+ #: admin/em-options.php:163
1473
  msgid ""
1474
  "If you would like to show events that span over more than one day, see the "
1475
  "Calendar section on this page."
1476
  msgstr ""
1477
 
1478
+ #: admin/em-options.php:164
1479
  msgid "Disable title rewriting?"
1480
  msgstr ""
1481
 
1482
+ #: admin/em-options.php:164
1483
  msgid ""
1484
  "Some wordpress themes don't follow best practices when generating navigation "
1485
  "menus, and so the automatic title rewriting feature may cause problems, if "
1487
  "'Yes', and provide an appropriate HTML title format below."
1488
  msgstr ""
1489
 
1490
+ #: admin/em-options.php:165
1491
  msgid "Event Manager titles"
1492
  msgstr ""
1493
 
1494
+ #: admin/em-options.php:165
1495
  msgid ""
1496
  "This only setting only matters if you selected 'Yes' to above. You will "
1497
  "notice the events page titles aren't being rewritten, and you have a new "
1501
  "this title, see settings further down for page titles."
1502
  msgstr ""
1503
 
1504
+ #: admin/em-options.php:166
1505
  msgid "Event List Limits"
1506
  msgstr ""
1507
 
1508
+ #: admin/em-options.php:166
1509
  msgid "This will control how many events are shown on one list by default."
1510
  msgstr ""
1511
 
1512
+ #: admin/em-options.php:169
1513
  msgid "Default event list ordering"
1514
  msgstr ""
1515
 
1516
+ #: admin/em-options.php:174
1517
  msgid "Order by start date, start time, then event name"
1518
  msgstr ""
1519
 
1520
+ #: admin/em-options.php:175
1521
  msgid "Order by name, start date, then start time"
1522
  msgstr ""
1523
 
1524
+ #: admin/em-options.php:176
1525
  msgid "Order by name, end date, then end time"
1526
  msgstr ""
1527
 
1528
+ #: admin/em-options.php:177
1529
  msgid "Order by end date, end time, then event name"
1530
  msgstr ""
1531
 
1532
+ #: admin/em-options.php:191
1533
  msgid "All Ascending"
1534
  msgstr ""
1535
 
1536
+ #: admin/em-options.php:194
1537
  msgid "All Descending"
1538
  msgstr ""
1539
 
1540
+ #: admin/em-options.php:208
1541
  msgid ""
1542
  "When Events Manager displays lists of events the default behaviour is "
1543
  "ordering by start date in ascending order. To change this, modify the values "
1544
  "above."
1545
  msgstr ""
1546
 
1547
+ #: admin/em-options.php:212
1548
  msgid "Event list range limit"
1549
  msgstr ""
1550
 
1551
+ #: admin/em-options.php:220
1552
  msgid "Next three months"
1553
  msgstr ""
1554
 
1555
+ #: admin/em-options.php:221
1556
  msgid "Next six months"
1557
  msgstr ""
1558
 
1559
+ #: admin/em-options.php:222
1560
  msgid "Next twelve months"
1561
  msgstr ""
1562
 
1563
+ #: admin/em-options.php:232
1564
  msgid ""
1565
  "Only show events starting within a certain time limit on the events page. "
1566
  "Default is no time limit is applied."
1567
  msgstr ""
1568
 
1569
+ #: admin/em-options.php:243
1570
  msgid "Events format"
1571
  msgstr ""
1572
 
1573
+ #: admin/em-options.php:247
1574
  msgid "Default event list format header"
1575
  msgstr ""
1576
 
1577
+ #: admin/em-options.php:247
1578
  msgid ""
1579
  "This content will appear just above your code for the default event list "
1580
  "format. Default is blank"
1581
  msgstr ""
1582
 
1583
+ #: admin/em-options.php:248
1584
  msgid "Default event list format"
1585
  msgstr ""
1586
 
1587
+ #: admin/em-options.php:248
1588
  msgid "The format of any events in a list."
1589
  msgstr ""
1590
 
1591
+ #: admin/em-options.php:249
1592
  msgid "Default event list format footer"
1593
  msgstr ""
1594
 
1595
+ #: admin/em-options.php:249
1596
  msgid ""
1597
  "This content will appear just below your code for the default event list "
1598
  "format. Default is blank"
1599
  msgstr ""
1600
 
1601
+ #: admin/em-options.php:250
1602
  msgid "Single event page title format"
1603
  msgstr ""
1604
 
1605
+ #: admin/em-options.php:250
1606
  msgid "The format of a single event page title."
1607
  msgstr ""
1608
 
1609
+ #: admin/em-options.php:251
1610
  msgid "Default single event format"
1611
  msgstr ""
1612
 
1613
+ #: admin/em-options.php:251
1614
  msgid "The format of a single event page."
1615
  msgstr ""
1616
 
1617
+ #: admin/em-options.php:252
1618
  msgid "Events page title"
1619
  msgstr ""
1620
 
1621
+ #: admin/em-options.php:252
1622
  msgid "The title on the multiple events page."
1623
  msgstr ""
1624
 
1625
+ #: admin/em-options.php:253
1626
  msgid "No events message"
1627
  msgstr ""
1628
 
1629
+ #: admin/em-options.php:253
1630
  msgid "The message displayed when no events are available."
1631
  msgstr ""
1632
 
1633
+ #: admin/em-options.php:254
1634
  msgid "List events by date title"
1635
  msgstr ""
1636
 
1637
+ #: admin/em-options.php:254
1638
  msgid ""
1639
  "If viewing a page for events on a specific date, this is the title that "
1640
  "would show up. To insert date values, use <a href=\"http://www.php.net/"
1643
  "<code>#j</code>, etc.<br/>"
1644
  msgstr ""
1645
 
1646
+ #: admin/em-options.php:262
1647
  msgid "Calendar format"
1648
  msgstr ""
1649
 
1650
+ #: admin/em-options.php:266
1651
  msgid "Small calendar title"
1652
  msgstr ""
1653
 
1654
+ #: admin/em-options.php:266
1655
  msgid ""
1656
  "The format of the title, corresponding to the text that appears when "
1657
  "hovering on an eventful calendar day."
1658
  msgstr ""
1659
 
1660
+ #: admin/em-options.php:267
1661
  msgid "Small calendar title separator"
1662
  msgstr ""
1663
 
1664
+ #: admin/em-options.php:267
1665
  msgid ""
1666
  "The separator appearing on the above title when more than one events are "
1667
  "taking place on the same day."
1668
  msgstr ""
1669
 
1670
+ #: admin/em-options.php:268
1671
  msgid "Full calendar events format"
1672
  msgstr ""
1673
 
1674
+ #: admin/em-options.php:268
1675
  msgid ""
1676
  "The format of each event when displayed in the full calendar. Remember to "
1677
  "include <code>li</code> tags before and after the event."
1678
  msgstr ""
1679
 
1680
+ #: admin/em-options.php:269
1681
  msgid "Show long events on calendar pages?"
1682
  msgstr ""
1683
 
1684
+ #: admin/em-options.php:269
1685
  msgid ""
1686
  "If you are showing a calendar on the events page (see Events format section "
1687
  "on this page), you have the option of showing events that span over days on "
1688
  "each day it occurs."
1689
  msgstr ""
1690
 
1691
+ #: admin/em-options.php:270
1692
  msgid "Show list on day with single event?"
1693
  msgstr ""
1694
 
1695
+ #: admin/em-options.php:270
1696
  msgid ""
1697
  "By default, if a calendar day only has one event, it display a single event "
1698
  "when clicking on the link of that calendar date. If you select Yes here, you "
1699
  "will get always see a list of events."
1700
  msgstr ""
1701
 
1702
+ #: admin/em-options.php:278
1703
  msgid "Locations format"
1704
  msgstr ""
1705
 
1706
+ #: admin/em-options.php:282
1707
  msgid "Single location page title format"
1708
  msgstr ""
1709
 
1710
+ #: admin/em-options.php:282
1711
  msgid "The format of a single location page title."
1712
  msgstr ""
1713
 
1714
+ #: admin/em-options.php:283
1715
  msgid "Default single location page format"
1716
  msgstr ""
1717
 
1718
+ #: admin/em-options.php:283
1719
  msgid "The format of a single location page."
1720
  msgstr ""
1721
 
1722
+ #: admin/em-options.php:284
1723
  msgid "Default location balloon format"
1724
  msgstr ""
1725
 
1726
+ #: admin/em-options.php:284
1727
  msgid ""
1728
  "The format of of the text appearing in the baloon describing the location in "
1729
  "the map."
1730
  msgstr ""
1731
 
1732
+ #: admin/em-options.php:285
1733
  msgid "Default location event list format"
1734
  msgstr ""
1735
 
1736
+ #: admin/em-options.php:285
1737
  msgid ""
1738
  "The format of the events the list inserted in the location page through the "
1739
  "<code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</"
1740
  "code> element."
1741
  msgstr ""
1742
 
1743
+ #: admin/em-options.php:286
1744
  msgid "Default no events message"
1745
  msgstr ""
1746
 
1747
+ #: admin/em-options.php:286
1748
  msgid ""
1749
  "The message to be displayed in the list generated by <code>#_NEXTEVENTS</"
1750
  "code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> when no events "
1751
  "are available."
1752
  msgstr ""
1753
 
1754
+ #: admin/em-options.php:294
1755
  msgid "RSS feed format"
1756
  msgstr ""
1757
 
1758
+ #: admin/em-options.php:298
1759
  msgid "RSS main title"
1760
  msgstr ""
1761
 
1762
+ #: admin/em-options.php:298
1763
  msgid "The main title of your RSS events feed."
1764
  msgstr ""
1765
 
1766
+ #: admin/em-options.php:299
1767
  msgid "RSS main description"
1768
  msgstr ""
1769
 
1770
+ #: admin/em-options.php:299
1771
  msgid "The main description of your RSS events feed."
1772
  msgstr ""
1773
 
1774
+ #: admin/em-options.php:300
1775
  msgid "RSS title format"
1776
  msgstr ""
1777
 
1778
+ #: admin/em-options.php:300
1779
  msgid "The format of the title of each item in the events RSS feed."
1780
  msgstr ""
1781
 
1782
+ #: admin/em-options.php:301
1783
  msgid "RSS description format"
1784
  msgstr ""
1785
 
1786
+ #: admin/em-options.php:301
1787
  msgid "The format of the description of each item in the events RSS feed."
1788
  msgstr ""
1789
 
1790
+ #: admin/em-options.php:309
1791
  msgid "Maps and geotagging"
1792
  msgstr ""
1793
 
1794
+ #: admin/em-options.php:314
1795
  msgid "Enable Google Maps integration?"
1796
  msgstr ""
1797
 
1798
+ #: admin/em-options.php:318
1799
  msgid "Check this option to enable Goggle Map integration."
1800
  msgstr ""
1801
 
1802
+ #: admin/em-options.php:322
1803
+ msgid "Map text format"
1804
+ msgstr ""
1805
+
1806
+ #: admin/em-options.php:322
1807
+ msgid "The text format inside the map balloons."
1808
+ msgstr ""
1809
+
1810
+ #: admin/em-options.php:330
1811
+ msgid "Booking and Ticketing Options"
1812
+ msgstr ""
1813
+
1814
+ #: admin/em-options.php:334
1815
+ msgid "Approval Required?"
1816
+ msgstr ""
1817
+
1818
+ #: admin/em-options.php:334
1819
+ msgid ""
1820
+ "Bookings will not be confirmed until the event administrator approves it."
1821
+ msgstr ""
1822
+
1823
+ #: admin/em-options.php:335
1824
+ msgid "Show unavailable tickets?"
1825
+ msgstr ""
1826
+
1827
+ #: admin/em-options.php:335
1828
+ msgid "You can choose whether or not to show unavailable tickets to visitors."
1829
+ msgstr ""
1830
+
1831
+ #: admin/em-options.php:336
1832
+ msgid "Reserved unconfirmed spaces?"
1833
+ msgstr ""
1834
+
1835
+ #: admin/em-options.php:336
1836
+ msgid ""
1837
+ "By default, event spaces become unavailable once there are enough CONFIRMED "
1838
+ "bookings. To reserve spaces even if unnapproved, choose yes."
1839
+ msgstr ""
1840
+
1841
+ #: admin/em-options.php:337
1842
+ msgid "Show multiple tickets if logged out?"
1843
+ msgstr ""
1844
+
1845
+ #: admin/em-options.php:337
1846
+ msgid ""
1847
+ "If logged out, a user will be asked to register in order to book. However, "
1848
+ "we can show available tickets if you have more than one ticket."
1849
+ msgstr ""
1850
+
1851
+ #: admin/em-options.php:338
1852
+ msgid "Allow overbooking when approving?"
1853
  msgstr ""
1854
 
1855
+ #: admin/em-options.php:338
1856
+ msgid ""
1857
+ "If you get a lot of pending bookings and you decide to allow more bookings "
1858
+ "than spaces allow, setting this to yes will allow you to override the event "
1859
+ "space limit when manually approving."
1860
  msgstr ""
1861
 
1862
+ #: admin/em-options.php:346
1863
+ msgid "Booking Email Templates"
1864
  msgstr ""
1865
 
1866
+ #: admin/em-options.php:350
1867
  msgid "Default contact person"
1868
  msgstr ""
1869
 
1870
+ #: admin/em-options.php:350
1871
  msgid ""
1872
  "Select the default contact person. This user will be employed whenever a "
1873
  "contact person is not explicitly specified for an event"
1874
  msgstr ""
1875
 
1876
+ #: admin/em-options.php:351
 
 
 
 
 
 
 
 
 
1877
  msgid "Email events admin?"
1878
  msgstr ""
1879
 
1880
+ #: admin/em-options.php:351
1881
  msgid ""
1882
  "If you would like every event booking confirmation email sent to an "
1883
  "administrator write their email here (leave blank to not send an email)."
1884
  msgstr ""
1885
 
1886
+ #: admin/em-options.php:352
1887
  msgid "Email contact person?"
1888
  msgstr ""
1889
 
1890
+ #: admin/em-options.php:352
1891
  msgid ""
1892
  "Check this option if you want the event contact to receive an email when "
1893
  "someone books places. An email will be sent when a booking is first made "
1894
  "(regardless if confirmed or pending)"
1895
  msgstr ""
1896
 
1897
+ #: admin/em-options.php:354
1898
  msgid "Contact person booking confirmed"
1899
  msgstr ""
1900
 
1901
+ #: admin/em-options.php:355
1902
  msgid ""
1903
  "An email will be sent to the event contact when a booking is first made."
1904
  msgstr ""
1905
 
1906
+ #: admin/em-options.php:357
1907
  msgid "Contact person email subject"
1908
  msgstr ""
1909
 
1910
+ #: admin/em-options.php:358
1911
  msgid "Contact person email"
1912
  msgstr ""
1913
 
1914
+ #: admin/em-options.php:360
1915
  msgid "Contact person booking cancelled"
1916
  msgstr ""
1917
 
1918
+ #: admin/em-options.php:361
1919
  msgid ""
1920
  "An email will be sent to the event contact if someone cancels their booking."
1921
  msgstr ""
1922
 
1923
+ #: admin/em-options.php:363
1924
  msgid "Contact person cancellation subject"
1925
  msgstr ""
1926
 
1927
+ #: admin/em-options.php:364
1928
  msgid "Contact person cancellation email"
1929
  msgstr ""
1930
 
1931
+ #: admin/em-options.php:366
1932
  msgid "Confirmed booking email"
1933
  msgstr ""
1934
 
1935
+ #: admin/em-options.php:367
1936
  msgid ""
1937
  "This is sent when a person's booking is confirmed. This will be sent "
1938
  "automatically if approvals are required and the booking is approved. If "
1940
  "booking."
1941
  msgstr ""
1942
 
1943
+ #: admin/em-options.php:369
1944
  msgid "Booking confirmed email subject"
1945
  msgstr ""
1946
 
1947
+ #: admin/em-options.php:370
1948
  msgid "Booking confirmed email"
1949
  msgstr ""
1950
 
1951
+ #: admin/em-options.php:372
1952
  msgid "Pending booking email"
1953
  msgstr ""
1954
 
1955
+ #: admin/em-options.php:373
1956
  msgid ""
1957
  "This will be sent to the person when they first submit their booking. Not "
1958
  "relevant if bookings don't require approval."
1959
  msgstr ""
1960
 
1961
+ #: admin/em-options.php:375
1962
  msgid "Booking pending email subject"
1963
  msgstr ""
1964
 
1965
+ #: admin/em-options.php:376
1966
  msgid "Booking pending email"
1967
  msgstr ""
1968
 
1969
+ #: admin/em-options.php:378
1970
  msgid "Rejected booking email"
1971
  msgstr ""
1972
 
1973
+ #: admin/em-options.php:379
1974
  msgid ""
1975
  "This will be sent automatically when a booking is rejected. Not relevant if "
1976
  "bookings don't require approval."
1977
  msgstr ""
1978
 
1979
+ #: admin/em-options.php:381
1980
  msgid "Booking rejected email subject"
1981
  msgstr ""
1982
 
1983
+ #: admin/em-options.php:381
1984
  msgid ""
1985
  "The subject of the email sent to the person making a booking that is "
1986
  "awaiting administrator approval. Not relevant if bookings don't require "
1987
  "approval."
1988
  msgstr ""
1989
 
1990
+ #: admin/em-options.php:382
1991
  msgid "Booking rejected email"
1992
  msgstr ""
1993
 
1994
+ #: admin/em-options.php:382
1995
  msgid ""
1996
  "The body of the email which will be sent to the person if the booking is "
1997
  "rejected. Not relevant if bookings don't require approval."
1998
  msgstr ""
1999
 
2000
+ #: admin/em-options.php:386
 
 
 
 
2001
  msgid "This will be sent when a user cancels their booking."
2002
  msgstr ""
2003
 
2004
+ #: admin/em-options.php:388
2005
  msgid "Booking cancelled email subject"
2006
  msgstr ""
2007
 
2008
+ #: admin/em-options.php:389
2009
  msgid "Booking cancelled email"
2010
  msgstr ""
2011
 
2012
+ #: admin/em-options.php:396
2013
  msgid "Email Settings"
2014
  msgstr ""
2015
 
2016
+ #: admin/em-options.php:400
2017
  msgid "Notification sender name"
2018
  msgstr ""
2019
 
2020
+ #: admin/em-options.php:400
2021
  msgid "Insert the display name of the notification sender."
2022
  msgstr ""
2023
 
2024
+ #: admin/em-options.php:401
2025
  msgid "Notification sender address"
2026
  msgstr ""
2027
 
2028
+ #: admin/em-options.php:401
2029
  msgid "Insert the address of the notification sender."
2030
  msgstr ""
2031
 
2032
+ #: admin/em-options.php:402
2033
  msgid ""
2034
  "The port through which you e-mail notifications will be sent. Make sure the "
2035
  "firewall doesn't block this port"
2036
  msgstr ""
2037
 
2038
+ #: admin/em-options.php:403
2039
  msgid "Mail sending method"
2040
  msgstr ""
2041
 
2042
+ #: admin/em-options.php:403
2043
  msgid "PHP mail function"
2044
  msgstr ""
2045
 
2046
+ #: admin/em-options.php:403
2047
  msgid "Select the method to send email notification."
2048
  msgstr ""
2049
 
2050
+ #: admin/em-options.php:404
2051
  msgid "Use SMTP authentication?"
2052
  msgstr ""
2053
 
2054
+ #: admin/em-options.php:404
2055
  msgid ""
2056
  "SMTP authentication is often needed. If you use GMail, make sure to set this "
2057
  "parameter to Yes"
2058
  msgstr ""
2059
 
2060
+ #: admin/em-options.php:405
2061
  msgid ""
2062
  "The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set "
2063
  "this value to 'ssl://smtp.gmail.com:465'."
2064
  msgstr ""
2065
 
2066
+ #: admin/em-options.php:406
2067
  msgid "SMTP username"
2068
  msgstr ""
2069
 
2070
+ #: admin/em-options.php:406
2071
  msgid "Insert the username to be used to access your SMTP server."
2072
  msgstr ""
2073
 
2074
+ #: admin/em-options.php:407
2075
  msgid "SMTP password"
2076
  msgstr ""
2077
 
2078
+ #: admin/em-options.php:407
2079
  msgid "Insert the password to be used to access your SMTP server"
2080
  msgstr ""
2081
 
2082
+ #: admin/em-options.php:415
2083
  msgid "Images size"
2084
  msgstr ""
2085
 
2086
+ #: admin/em-options.php:419
2087
  msgid "Maximum width (px)"
2088
  msgstr ""
2089
 
2090
+ #: admin/em-options.php:419
2091
  msgid "The maximum allowed width for images uploades"
2092
  msgstr ""
2093
 
2094
+ #: admin/em-options.php:420
2095
  msgid "Maximum height (px)"
2096
  msgstr ""
2097
 
2098
+ #: admin/em-options.php:420
2099
  msgid "The maximum allowed height for images uploaded, in pixels"
2100
  msgstr ""
2101
 
2102
+ #: admin/em-options.php:421
2103
  msgid "Maximum size (bytes)"
2104
  msgstr ""
2105
 
2106
+ #: admin/em-options.php:421
2107
  msgid "The maximum allowed size for images uploaded, in pixels"
2108
  msgstr ""
2109
 
2110
+ #: admin/em-options.php:429
2111
+ msgid "User Capabilities"
2112
  msgstr ""
2113
 
2114
+ #: admin/em-options.php:433
2115
  msgid ""
2116
  "Warning: Changing these values may result in exposing previously hidden "
2117
  "information to all users."
2118
  msgstr ""
2119
 
2120
+ #: admin/em-options.php:440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2121
  msgid ""
2122
+ "You can now give fine grained control with regards to what your users can do "
2123
+ "with events. Each user role can have perform different sets of actions."
2124
  msgstr ""
2125
 
2126
  #: admin/em-categories.php:10
2131
  msgid "The category has been updated."
2132
  msgstr ""
2133
 
2134
+ #: admin/em-categories.php:22
2135
  msgid "Ach, there's a problem here:"
2136
  msgstr ""
2137
 
2138
+ #: admin/em-categories.php:34
2139
  msgid "Categories Deleted"
2140
  msgstr ""
2141
 
2142
+ #: admin/em-categories.php:50 events-manager.php:283
2143
  msgid "Categories"
2144
  msgstr ""
2145
 
2146
+ #: admin/em-categories.php:69 admin/em-categories.php:76
2147
  msgid "ID"
2148
  msgstr ""
2149
 
2150
+ #: admin/em-categories.php:100
2151
  msgid "No categories have been inserted yet!"
2152
  msgstr ""
2153
 
2154
+ #: admin/em-categories.php:112 admin/em-categories.php:120
2155
  msgid "Add category"
2156
  msgstr ""
2157
 
2158
+ #: admin/em-categories.php:116 admin/em-categories.php:167
2159
  msgid "Category name"
2160
  msgstr ""
2161
 
2162
+ #: admin/em-categories.php:118 admin/em-categories.php:169
2163
  msgid "The name of the category"
2164
  msgstr ""
2165
 
2166
+ #: admin/em-categories.php:151
 
 
 
 
 
 
 
 
 
 
 
2167
  msgid "Edit category"
2168
  msgstr ""
2169
 
2170
+ #: admin/em-categories.php:172
2171
  msgid "Update category"
2172
  msgstr ""
2173
 
2174
+ #: admin/em-bookings.php:84
2175
  msgid "Event Bookings Dashboard"
2176
  msgstr ""
2177
 
2178
+ #: admin/em-bookings.php:87 admin/em-bookings.php:136
2179
+ #: admin/em-bookings.php:186
2180
  msgid "Pending Bookings"
2181
  msgstr ""
2182
 
2183
+ #: admin/em-bookings.php:90
2184
  msgid "Events With Bookings Enabled"
2185
  msgstr ""
2186
 
2187
+ #: admin/em-bookings.php:105 admin/em-bookings.php:208 admin/em-people.php:9
2188
+ msgid "You do not have the rights to manage this event."
 
 
 
 
 
 
 
 
2189
  msgstr ""
2190
 
2191
  #: admin/em-bookings.php:117
2192
+ msgid "Manage %s Bookings"
2193
  msgstr ""
2194
 
2195
+ #: admin/em-bookings.php:118 admin/em-bookings.php:170
2196
+ msgid "View/Edit Event"
2197
  msgstr ""
2198
 
2199
+ #: admin/em-bookings.php:123
2200
+ msgid "Spaces confirmed"
2201
  msgstr ""
2202
 
2203
+ #: admin/em-bookings.php:125
2204
+ msgid "Date"
 
2205
  msgstr ""
2206
 
2207
+ #: admin/em-bookings.php:139 admin/em-bookings.php:189
2208
  msgid "Confirmed Bookings"
2209
  msgstr ""
2210
 
2211
+ #: admin/em-bookings.php:141 admin/em-bookings.php:191
2212
  msgid "Rejected Bookings"
2213
  msgstr ""
2214
 
2215
+ #: admin/em-bookings.php:143 admin/em-bookings.php:193
2216
  msgid "Cancelled Bookings"
2217
  msgstr ""
2218
 
2219
+ #: admin/em-bookings.php:159
2220
+ msgid "You do not have the rights to manage this ticket."
2221
  msgstr ""
2222
 
2223
+ #: admin/em-bookings.php:169
2224
+ msgid "Ticket for %s"
2225
  msgstr ""
2226
 
2227
+ #: admin/em-bookings.php:171
2228
+ msgid "View Event Bookings"
2229
  msgstr ""
2230
 
2231
+ #: admin/em-bookings.php:176 admin/em-event.php:669
2232
+ msgid "Description"
 
 
2233
  msgstr ""
2234
 
2235
+ #: admin/em-bookings.php:179
2236
+ msgid "Min"
2237
  msgstr ""
2238
 
2239
+ #: admin/em-bookings.php:180
2240
+ msgid "Max"
2241
  msgstr ""
2242
 
2243
+ #: admin/em-bookings.php:181
2244
+ msgid "Start"
 
 
2245
  msgstr ""
2246
 
2247
+ #: admin/em-bookings.php:182
2248
+ msgid "End"
2249
  msgstr ""
2250
 
2251
+ #: admin/em-bookings.php:218
2252
+ msgid "Edit Booking"
2253
  msgstr ""
2254
 
2255
+ #: admin/em-bookings.php:225
2256
+ msgid "Event Details"
2257
  msgstr ""
2258
 
2259
+ #: admin/em-bookings.php:236
2260
  msgid "Date/Time"
2261
  msgstr ""
2262
 
2263
+ #: admin/em-bookings.php:248 admin/em-bookings.php:351
2264
+ msgid "Personal Details"
 
 
 
 
 
 
 
 
 
 
 
 
2265
  msgstr ""
2266
 
2267
+ #: admin/em-bookings.php:256
2268
+ msgid "Booking Details"
 
 
 
 
 
 
 
 
 
 
 
 
2269
  msgstr ""
2270
 
2271
+ #: admin/em-bookings.php:283
2272
+ msgid "Totals"
 
 
 
 
 
 
 
2273
  msgstr ""
2274
 
2275
+ #: admin/em-bookings.php:300
2276
+ msgid "Booking Notes"
 
 
 
 
 
 
2277
  msgstr ""
2278
 
2279
+ #: admin/em-bookings.php:303
2280
  msgid ""
2281
+ "You can add private notes below for internal reference that only event "
2282
+ "managers will see."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2283
  msgstr ""
2284
 
2285
+ #: admin/em-bookings.php:308
2286
+ msgid "wrote"
 
2287
  msgstr ""
2288
 
2289
+ #: admin/em-bookings.php:340
2290
+ msgid "Manage Person's Booking"
2291
  msgstr ""
2292
 
2293
+ #: admin/em-bookings.php:342
2294
+ msgid "Edit User"
 
 
2295
  msgstr ""
2296
 
2297
+ #: admin/em-bookings.php:362
2298
+ msgid "Past And Present Bookings"
2299
  msgstr ""
2300
 
2301
+ #: admin/em-admin.php:20
2302
+ msgid ""
2303
+ "<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We "
2304
+ "hope you like it around here.</p> \r\n"
2305
+ "\t\t\t<p>Now it's time to insert events lists through <a href='%s' "
2306
+ "title='Widgets page'>widgets</a>, <a href='%s' title='Template tags "
2307
+ "documentation'>template tags</a> or <a href='%s' title='Shortcodes "
2308
+ "documentation'>shortcodes</a>.</p>\r\n"
2309
+ "\t\t\t<p>By the way, have you taken a look at the <a href='%s' title='Change "
2310
+ "settings'>Settings page</a>? That's where you customize the way events and "
2311
+ "locations are displayed.</p>\r\n"
2312
+ "\t\t\t<p>What? Tired of seeing this advice? I hear you, <a href='%s' "
2313
+ "title='Don't show this advice again'>click here</a> and you won't see this "
2314
+ "again!</p>"
2315
  msgstr ""
2316
 
2317
+ #: admin/em-admin.php:38
2318
+ msgid ""
2319
+ "<strong>Events Manager has some new features!</strong><ul><li>Bookings can "
2320
+ "now be approved before they count towards your event's space allocations.</"
2321
+ "li><li>Events now have owners, and you can restrict users so they can only "
2322
+ "manage events/locations/categories they create.<br/><br/>These new "
2323
+ "permissions are enabled by default, but since you upgraded it has been "
2324
+ "disabled to maintain the previous plugin behaviour. You can re-enable it "
2325
+ "from the <a href=\"%s\">settings page</a>. <a href=\"%s\">Dismiss</a>"
2326
  msgstr ""
2327
 
2328
+ #: admin/em-admin.php:51
2329
+ msgid ""
2330
+ "Uh Oh! For some reason wordpress could not create an events page for you (or "
2331
+ "you just deleted it). Not to worry though, all you have to do is create an "
2332
+ "empty page, name it whatever you want, and select it as your events page in "
2333
+ "your <a href=\"%s\">settings page</a>. Sorry for the extra step! If you know "
2334
+ "what you are doing, you may have done this on purpose, if so <a href=\"%s"
2335
+ "\">ignore this message</a>"
2336
  msgstr ""
2337
 
2338
+ #: admin/em-admin.php:59
2339
+ msgid ""
2340
+ "This page corresponds to <strong>Events Manager</strong> events page. Its "
2341
+ "content will be overriden by <strong>Events Manager</strong>. If you want to "
2342
+ "display your content, you can can assign another page to <strong>Events "
2343
+ "Manager</strong> in the the <a href='%s'>Settings</a>. "
2344
  msgstr ""
2345
 
2346
+ #: admin/em-admin.php:86
2347
+ msgid "Displaying %s&#8211;%s of %s"
2348
  msgstr ""
2349
 
2350
+ #: admin/bookings/em-cancelled.php:38 admin/bookings/em-cancelled.php:40
2351
+ #: admin/bookings/em-confirmed.php:39 admin/bookings/em-confirmed.php:41
2352
+ #: admin/bookings/em-person.php:40 admin/bookings/em-person.php:42
2353
+ #: admin/bookings/em-rejected.php:38 admin/bookings/em-rejected.php:40
2354
+ #: admin/bookings/em-pending.php:53 admin/bookings/em-pending.php:55
2355
+ msgid "Search"
2356
  msgstr ""
2357
 
2358
+ #: admin/bookings/em-cancelled.php:52 admin/bookings/em-confirmed.php:53
2359
+ #: admin/bookings/em-person.php:54 admin/bookings/em-person.php:115
2360
+ #: admin/bookings/em-rejected.php:52 admin/bookings/em-rejected.php:110
2361
+ #: admin/bookings/em-pending.php:67 admin/bookings/em-pending.php:132
2362
+ #: admin/em-events.php:178
2363
+ msgid "Approve"
2364
  msgstr ""
2365
 
2366
+ #: admin/bookings/em-cancelled.php:55 admin/bookings/em-confirmed.php:56
2367
+ #: admin/bookings/em-person.php:57 admin/bookings/em-rejected.php:55
2368
+ #: admin/bookings/em-pending.php:70
2369
+ msgid "Decline"
2370
  msgstr ""
2371
 
2372
+ #: admin/bookings/em-cancelled.php:110 admin/bookings/em-person.php:121
2373
+ msgid "Restore"
2374
  msgstr ""
2375
 
2376
+ #: admin/bookings/em-cancelled.php:111 admin/bookings/em-confirmed.php:118
2377
+ #: admin/bookings/em-person.php:126 admin/bookings/em-rejected.php:111
2378
+ #: admin/bookings/em-pending.php:135
2379
+ msgid "Edit/View"
2380
  msgstr ""
2381
 
2382
+ #: admin/bookings/em-cancelled.php:124
2383
+ msgid "No cancelled bookings."
2384
  msgstr ""
2385
 
2386
+ #: admin/bookings/em-confirmed.php:113 admin/bookings/em-person.php:118
2387
+ msgid "Unapprove"
2388
  msgstr ""
2389
 
2390
+ #: admin/bookings/em-confirmed.php:115 admin/bookings/em-person.php:124
2391
+ #: admin/bookings/em-pending.php:133
2392
+ msgid "Reject"
2393
  msgstr ""
2394
 
2395
+ #: admin/bookings/em-confirmed.php:130 admin/bookings/em-person.php:139
2396
+ msgid "No confirmed bookings."
2397
  msgstr ""
2398
 
2399
+ #: admin/bookings/em-rejected.php:124
2400
+ msgid "No rejected bookings."
 
 
2401
  msgstr ""
2402
 
2403
+ #: admin/bookings/em-pending.php:147
2404
+ msgid "No pending bookings."
2405
  msgstr ""
2406
 
2407
+ #: admin/bookings/em-events.php:32
2408
+ msgid "All Events"
 
 
 
2409
  msgstr ""
2410
 
2411
+ #: admin/bookings/em-events.php:35
2412
+ msgid "Future Events"
2413
  msgstr ""
2414
 
2415
+ #: admin/bookings/em-events.php:50 admin/em-events.php:67
2416
+ msgid "Total"
2417
  msgstr ""
2418
 
2419
+ #: admin/bookings/em-events.php:71 admin/em-events.php:96
2420
+ msgid "Filter"
2421
  msgstr ""
2422
 
2423
+ #: admin/bookings/em-events.php:133 admin/em-event.php:439
2424
+ msgid "Booked Spaces"
2425
  msgstr ""
2426
 
2427
+ #: admin/em-locations.php:80 admin/em-locations.php:88
2428
+ msgid "Town"
2429
  msgstr ""
2430
 
2431
+ #: admin/em-locations.php:119
2432
+ msgid "You do not have the rights to manage this location."
2433
  msgstr ""
2434
 
2435
+ #: admin/em-locations.php:160 admin/em-event.php:308
2436
+ msgid "Coordinates"
2437
  msgstr ""
2438
 
2439
+ #: admin/em-help.php:10 events-manager.php:285
2440
  msgid "Getting Help for Events Manager"
2441
  msgstr ""
2442
 
2452
  "be displayed."
2453
  msgstr ""
2454
 
2455
+ #: admin/em-people.php:27
2456
+ msgid "Bookings data"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2457
  msgstr ""
2458
 
2459
+ #: admin/em-people.php:31
2460
+ msgid "E-mail"
 
2461
  msgstr ""
2462
 
2463
+ #: admin/em-people.php:32
2464
+ msgid "Phone number"
2465
  msgstr ""
2466
 
2467
+ #: admin/em-people.php:53
2468
+ msgid "Available"
2469
  msgstr ""
2470
 
2471
+ #: admin/em-people.php:72
2472
+ msgid "Phone"
2473
  msgstr ""
2474
 
2475
+ #. #-#-#-#-# plugin.pot (Events Manager 4.0b) #-#-#-#-#
2476
  #. Plugin Name of the plugin/theme
2477
+ #: admin/em-people.php:72
2478
  msgid "Events Manager"
2479
  msgstr ""
2480
 
2481
+ #: admin/em-event.php:66
 
 
 
 
 
 
 
 
 
 
 
 
2482
  msgid "Mon"
2483
  msgstr ""
2484
 
2485
+ #: admin/em-event.php:66
2486
  msgid "Tue"
2487
  msgstr ""
2488
 
2489
+ #: admin/em-event.php:66
2490
  msgid "Wed"
2491
  msgstr ""
2492
 
2493
+ #: admin/em-event.php:66
2494
  msgid "Thu"
2495
  msgstr ""
2496
 
2497
+ #: admin/em-event.php:66
2498
  msgid "Fri"
2499
  msgstr ""
2500
 
2501
+ #: admin/em-event.php:66
2502
  msgid "Sat"
2503
  msgstr ""
2504
 
2505
+ #: admin/em-event.php:66
2506
  msgid "Sun"
2507
  msgstr ""
2508
 
2509
+ #: admin/em-event.php:89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2510
  msgid "Recurrence"
2511
  msgstr ""
2512
 
2513
+ #: admin/em-event.php:96
2514
  msgid "Repeated event"
2515
  msgstr ""
2516
 
2517
+ #: admin/em-event.php:109 admin/em-event.php:132
 
 
 
 
 
 
 
 
 
 
 
 
2518
  msgid "Every"
2519
  msgstr ""
2520
 
2521
+ #: admin/em-event.php:116
 
 
 
 
 
 
 
 
2522
  msgid "week"
2523
  msgstr ""
2524
 
2525
+ #: admin/em-event.php:118
2526
  msgid "weeks"
2527
  msgstr ""
2528
 
2529
+ #: admin/em-event.php:120
2530
  msgid "month"
2531
  msgstr ""
2532
 
2533
+ #: admin/em-event.php:122
2534
  msgid "months"
2535
  msgstr ""
2536
 
2537
+ #: admin/em-event.php:170
2538
+ msgid "Event Owner/Contact Person"
 
 
 
 
 
 
 
 
2539
  msgstr ""
2540
 
2541
+ #: admin/em-event.php:173
2542
+ msgid "Select..."
2543
  msgstr ""
2544
 
2545
+ #: admin/em-event.php:183
2546
+ msgid "Bookings Stats"
2547
  msgstr ""
2548
 
2549
+ #: admin/em-event.php:250
2550
+ msgid "No categories available, <a href=\"%s\">create one here first</a>"
 
2551
  msgstr ""
2552
 
2553
+ #: admin/em-event.php:272
2554
+ msgid "Event date"
2555
  msgstr ""
2556
 
2557
+ #: admin/em-event.php:273
2558
+ msgid "Recurrence dates"
2559
  msgstr ""
2560
 
2561
+ #: admin/em-event.php:282
2562
+ msgid "The event date."
2563
  msgstr ""
2564
 
2565
+ #: admin/em-event.php:285
2566
+ msgid ""
2567
+ "When not reoccurring, this event spans between the beginning and end date."
2568
  msgstr ""
2569
 
2570
+ #: admin/em-event.php:290
2571
+ msgid "The recurrence beginning and end date."
2572
  msgstr ""
2573
 
2574
+ #: admin/em-event.php:296
2575
+ msgid "Event time"
2576
  msgstr ""
2577
 
2578
+ #: admin/em-event.php:303
2579
+ msgid "The time of the event beginning and end"
2580
  msgstr ""
2581
 
2582
+ #: admin/em-event.php:327
2583
+ msgid "Location:"
2584
  msgstr ""
2585
 
2586
+ #: admin/em-event.php:343
2587
+ msgid ""
2588
+ "The name of the location where the event takes place. You can use the name "
2589
+ "of a venue, a square, etc"
2590
  msgstr ""
2591
 
2592
+ #: admin/em-event.php:348
2593
+ msgid "Name:"
2594
  msgstr ""
2595
 
2596
+ #: admin/em-event.php:352
2597
+ msgid ""
2598
+ "Create a location or start typing to search a previously created location."
2599
  msgstr ""
2600
 
2601
+ #: admin/em-event.php:413
2602
+ msgid "Details about the event"
2603
  msgstr ""
2604
 
2605
+ #: admin/em-event.php:428
2606
+ msgid "Tickets"
2607
  msgstr ""
2608
 
2609
+ #: admin/em-event.php:429
2610
+ msgid ""
2611
+ "You have single or multiple tickets, where certain tickets become availalble "
2612
+ "under certain conditions, e.g. early bookings, group discounts, maximum "
2613
+ "bookings per ticket, etc."
2614
  msgstr ""
2615
 
2616
+ #: admin/em-event.php:434
2617
+ msgid "Ticket Name"
2618
  msgstr ""
2619
 
2620
+ #: admin/em-event.php:436
2621
+ msgid "Min/Max"
2622
  msgstr ""
2623
 
2624
+ #: admin/em-event.php:437
2625
+ msgid "Start/End"
2626
  msgstr ""
2627
 
2628
+ #: admin/em-event.php:438
2629
+ msgid "Avail. Spaces"
2630
  msgstr ""
2631
 
2632
+ #: admin/em-event.php:446
2633
+ msgid "Add new ticket"
2634
  msgstr ""
2635
 
2636
+ #: admin/em-event.php:461
2637
+ msgid "Free"
 
2638
  msgstr ""
2639
 
2640
+ #: admin/em-event.php:494
2641
+ msgid "View Bookings"
2642
  msgstr ""
2643
 
2644
+ #: admin/em-event.php:571
2645
+ msgid "Attributes"
2646
  msgstr ""
2647
 
2648
+ #: admin/em-event.php:603
2649
+ msgid ""
2650
+ "You don't have any custom attributes defined in any of your Events Manager "
2651
+ "template settings. Please add them the <a href='%s'>settings page</a>"
2652
  msgstr ""
2653
 
2654
+ #: admin/em-event.php:610
2655
+ msgid "Depreciated Attributes"
2656
  msgstr ""
2657
 
2658
+ #: admin/em-event.php:611
2659
  msgid ""
2660
+ "If you see any attributes under here, that means they're not used in Events "
2661
+ "Manager anymore. To add them, you need to add the custom attribute again to "
2662
+ "a formatting option in the settings page. To remove any of these depreciated "
2663
+ "attributes, give it a blank value and save."
2664
  msgstr ""
2665
 
2666
+ #: admin/em-event.php:642
2667
+ msgid ""
2668
+ "In order to use attributes, you must define some in your templates, "
2669
+ "otherwise they'll never show. Go to Events > Settings to add attribute "
2670
+ "placeholders."
2671
  msgstr ""
2672
 
2673
+ #: admin/em-event.php:666
2674
+ msgid "Create a ticket"
2675
  msgstr ""
2676
 
2677
+ #: admin/em-event.php:672
2678
+ msgid "Available ticket spaces"
2679
  msgstr ""
2680
 
2681
+ #: admin/em-event.php:673
2682
+ msgid "If left blank, spaces are determined by event limit."
2683
  msgstr ""
2684
 
2685
+ #: admin/em-event.php:675
2686
+ msgid "Start date of ticket availability"
2687
  msgstr ""
2688
 
2689
+ #: admin/em-event.php:676
2690
+ msgid "End date of ticket availability"
 
 
 
2691
  msgstr ""
2692
 
2693
+ #: admin/em-event.php:677
2694
+ msgid "Minimum tickets required per booking"
2695
  msgstr ""
2696
 
2697
+ #: admin/em-event.php:678
2698
+ msgid "Maximum tickets required per booking"
 
 
 
2699
  msgstr ""
2700
 
2701
+ #: admin/em-event.php:683
2702
+ msgid "Add Ticket"
 
 
 
2703
  msgstr ""
2704
 
2705
  #: em-template-tags-depreciated.php:146
2706
  msgid "Ach, some problems here:"
2707
  msgstr ""
2708
 
2709
+ #: em-install.php:210
2710
  msgid "Uncategorized"
2711
  msgstr ""
2712
 
2713
+ #: em-install.php:265
2714
  msgid ""
2715
  "#_BOOKINGNAME (#_BOOKINGEMAIL) will attend #_NAME on #F #j, #Y. He wants to "
2716
  "reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces "
2718
  ">Events Manager - http://wp-events-plugin.com"
2719
  msgstr ""
2720
 
2721
+ #: em-install.php:265 em-install.php:266 em-install.php:267 em-install.php:268
2722
+ #: em-install.php:269 em-install.php:270
2723
  msgid ""
2724
  "<br/><br/>-------------------------------<br/>Powered by Events Manager - "
2725
  "http://wp-events-plugin.com"
2726
  msgstr ""
2727
 
2728
+ #: em-install.php:266
2729
  msgid ""
2730
  "#_BOOKINGNAME (#_BOOKINGEMAIL) cancelled his booking at #_NAME on #F #j, #Y. "
2731
  "He wanted to reserve #_BOOKINGSPACES spaces.<br/> Now there are "
2733
  ">Yours faithfully,<br/>Events Manager - http://wp-events-plugin.com"
2734
  msgstr ""
2735
 
2736
+ #: em-install.php:267
2737
  msgid ""
2738
  "Dear #_BOOKINGNAME, <br/>you have successfully reserved #_BOOKINGSPACES "
2739
  "space/spaces for #_NAME.<br/>Yours faithfully,<br/>#_CONTACTNAME"
2740
  msgstr ""
2741
 
2742
+ #: em-install.php:268
2743
  msgid ""
2744
  "Dear #_BOOKINGNAME, <br/>You have requested #_BOOKEDSPACES space/spaces for "
2745
  "#_NAME.<br/>Your booking is currently pending approval by our "
2746
+ "administrators. Once approved you will receive an automatic confirmation.<br/"
2747
  ">Yours faithfully,<br/>#_CONTACTNAME"
2748
  msgstr ""
2749
 
2750
+ #: em-install.php:269
2751
  msgid ""
2752
  "Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces "
2753
  "at #_NAME on #F #j, #Y has been rejected.<br/>Yours faithfully,<br/"
2754
  ">#_CONTACTNAME"
2755
  msgstr ""
2756
 
2757
+ #: em-install.php:270
2758
  msgid ""
2759
  "Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces "
2760
  "at #_NAME on #F #j, #Y has been cancelled.<br/>Yours faithfully,<br/"
2761
  ">#_CONTACTNAME"
2762
  msgstr ""
2763
 
2764
+ #: em-install.php:294 em-debug.php:18
2765
  msgid "<li>No events in this location</li>"
2766
  msgstr ""
2767
 
2768
+ #: em-install.php:349
2769
  msgid "New booking"
2770
  msgstr ""
2771
 
2772
+ #: em-install.php:351 em-install.php:359
2773
  msgid "Booking Cancelled"
2774
  msgstr ""
2775
 
2776
+ #: em-install.php:353
2777
+ msgid "Booking Pending"
2778
  msgstr ""
2779
 
2780
+ #: em-install.php:355
2781
+ msgid "Booking Rejected"
2782
  msgstr ""
2783
 
2784
+ #: em-install.php:357
2785
  msgid "Booking Confirmed"
2786
  msgstr ""
2787
 
2788
+ #: em-install.php:362
2789
+ msgid "Powered by"
 
 
 
 
 
2790
  msgstr ""
2791
 
2792
+ #: em-install.php:363
2793
+ msgid "Bookings - #_NAME"
 
 
2794
  msgstr ""
2795
 
2796
+ #: em-debug.php:44
2797
  msgid ""
2798
+ "You are in Events Manager debug mode. To turn debug mode off, go to the <a "
2799
+ "href=\"%s\">settings</a> page."
 
2800
  msgstr ""
2801
 
2802
+ #: em-actions.php:28
2803
+ msgid "No ticket id provided"
2804
  msgstr ""
2805
 
2806
+ #: em-actions.php:142
2807
+ msgid "You are now viewing the duplicated %s."
2808
  msgstr ""
2809
 
2810
+ #: em-actions.php:222
2811
+ msgid "%s successfully deleted"
2812
+ msgstr ""
2813
+
2814
+ #: events-manager.php:170
2815
+ msgid "You do not have permission to publish %s"
2816
+ msgstr ""
2817
+
2818
+ #: events-manager.php:170 events-manager.php:172 events-manager.php:176
2819
+ #: events-manager.php:178 events-manager.php:183
2820
+ msgid "events"
2821
+ msgstr ""
2822
+
2823
+ #: events-manager.php:171 events-manager.php:179 events-manager.php:182
2824
+ #: events-manager.php:183
2825
+ msgid "You do not have permission to edit %s"
2826
+ msgstr ""
2827
+
2828
+ #: events-manager.php:171
2829
+ msgid "categories"
2830
+ msgstr ""
2831
+
2832
+ #: events-manager.php:172 events-manager.php:173
2833
+ msgid "You do not have permission to delete others %s"
2834
+ msgstr ""
2835
+
2836
+ #: events-manager.php:174 events-manager.php:176
2837
+ msgid "You do not have permission to edit others %s"
2838
+ msgstr ""
2839
+
2840
+ #: events-manager.php:175
2841
+ msgid "You do not have permission to manage others %s"
2842
+ msgstr ""
2843
+
2844
+ #: events-manager.php:175 events-manager.php:180
2845
+ msgid "bookings"
2846
+ msgstr ""
2847
+
2848
+ #: events-manager.php:177 events-manager.php:178
2849
+ msgid "You do not have permission to delete %s"
2850
+ msgstr ""
2851
+
2852
+ #: events-manager.php:180
2853
+ msgid "You do not have permission to manage %s"
2854
+ msgstr ""
2855
+
2856
+ #: events-manager.php:181
2857
+ msgid "You cannot to view others %s"
2858
+ msgstr ""
2859
+
2860
+ #: events-manager.php:182
2861
+ msgid "recurrences"
2862
+ msgstr ""
2863
+
2864
+ #: events-manager.php:256 events-manager.php:284
2865
+ msgid "Settings"
2866
+ msgstr ""
2867
+
2868
+ #: events-manager.php:280
2869
+ msgid "Add new"
2870
  msgstr ""
2871
 
2872
+ #: events-manager.php:283
2873
  msgid "Event Categories"
2874
  msgstr ""
2875
 
2876
+ #: events-manager.php:284
2877
  msgid "Events Manager Settings"
2878
  msgstr ""
2879
 
2880
+ #: events-manager.php:285
2881
  msgid "Help"
2882
  msgstr ""
2883
 
2884
+ #: events-manager.php:338
2885
  msgid "Add an event"
2886
  msgstr ""
2887
 
2888
+ #. #-#-#-#-# plugin.pot (Events Manager 4.0b) #-#-#-#-#
2889
  #. Plugin URI of the plugin/theme
2890
+ #. #-#-#-#-# plugin.pot (Events Manager 4.0b) #-#-#-#-#
2891
  #. Author URI of the plugin/theme
2892
  msgid "http://wp-events-plugin.com"
2893
  msgstr ""
2894
 
2895
  #. Description of the plugin/theme
2896
  msgid ""
2897
+ "A complete event management solution for wordpress. Recurring events, "
2898
+ "locations, google maps, rss, bookings and more!"
2899
  msgstr ""
2900
 
2901
  #. Author of the plugin/theme
includes/{sample-placeholers → sample-placeholders}/booking-email.html RENAMED
File without changes
includes/{sample-placeholers → sample-placeholders}/event-single.html RENAMED
File without changes
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wp-events-plugin.com
4
  Tags: events, booking, calendar, locations, maps, geotagging, admin, dashboard, plugin, template, theme, widget
5
  Requires at least: 2.9
6
  Tested up to: 3.1
7
- Stable tag: 3.0.95
8
 
9
  Fully featured events management including recurring events, location management, calendar, Google map integration, booking management and more.
10
 
@@ -86,7 +86,7 @@ Sure, there are a few ways to do this:
86
 
87
  = How does Events Manager work? =
88
 
89
- When installed, events Manager creates a special Events page. This page is used for the dynamic content of the events. All the events link actually link to this page, which gets rendered differently for each event.
90
 
91
  = Are events posts? =
92
 
@@ -108,6 +108,11 @@ At this stage, Events Manager is available in German, Spanish, Czech, Italian, D
108
 
109
  == Changelog ==
110
 
 
 
 
 
 
111
  = 3.0.95 =
112
  * removed some php warnings
113
  * fixed blank widget defaults (resave current widgets to replace blanks with defaults)
@@ -252,4 +257,4 @@ At this stage, Events Manager is available in German, Spanish, Czech, Italian, D
252
  * Added a setting to revert to 2.2
253
  * optimizing EM_Locations and removing redundant code across objects
254
 
255
- For changelog of 2.x and lower, see the readme.txt file of version 2.2.2
4
  Tags: events, booking, calendar, locations, maps, geotagging, admin, dashboard, plugin, template, theme, widget
5
  Requires at least: 2.9
6
  Tested up to: 3.1
7
+ Stable tag: 3.0.96
8
 
9
  Fully featured events management including recurring events, location management, calendar, Google map integration, booking management and more.
10
 
86
 
87
  = How does Events Manager work? =
88
 
89
+ When installed, events Manager creates a special “Events” page. This page is used for the dynamic content of the events. All the events link actually link to this page, which gets rendered differently for each event.
90
 
91
  = Are events posts? =
92
 
108
 
109
  == Changelog ==
110
 
111
+ = 3.0.96 =
112
+ * fixed js hook bug, you must now bind your function to the document's custom em_maps_locations_hook and em_maps_location_hook event triggers using jquery
113
+ * fixed tinymce bug with linking which cropped up in 3.1 due to new WP linking window.
114
+ * event_date_modified now properly updated
115
+
116
  = 3.0.95 =
117
  * removed some php warnings
118
  * fixed blank widget defaults (resave current widgets to replace blanks with defaults)
257
  * Added a setting to revert to 2.2
258
  * optimizing EM_Locations and removing redundant code across objects
259
 
260
+ For changelog of 2.x and lower, see the readme.txt file of version 2.2.2
templates/buddypress/events/my-events.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
4
+ global $wpdb, $bp, $EM_Event, $EM_Notices;
5
+
6
+ $url = $bp->events->link . 'my-events/'; //url to this page
7
+ $order = ( !empty($_REQUEST ['order']) ) ? $_REQUEST ['order']:'ASC';
8
+ $limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
9
+ $page = ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:1;
10
+ $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
11
+ $search = ( !empty($_REQUEST['em_search']) ) ? $_REQUEST['em_search']:'';
12
+ $scope_names = array (
13
+ 'past' => __ ( 'Past events', 'dbem' ),
14
+ 'all' => __ ( 'All events', 'dbem' ),
15
+ 'future' => __ ( 'Future events', 'dbem' )
16
+ );
17
+ $scope = ( !empty($_REQUEST ['scope']) && array_key_exists($_REQUEST ['scope'], $scope_names) ) ? $_REQUEST ['scope']:'future';
18
+ if( isset($_REQUEST['status']) ){
19
+ $status = ($_REQUEST['status']) ? 1:0;
20
+ }else{
21
+ $status = false;
22
+ }
23
+ $args = array(
24
+ 'scope' => $scope,
25
+ 'limit' => 0,
26
+ 'order' => $order,
27
+ 'search' => $search,
28
+ 'owner' => get_current_user_id(),
29
+ 'status' => $status
30
+ );
31
+ $events = EM_Events::get( $args );
32
+ $events_count = count ( $events );
33
+ $future_count = EM_Events::count( array('status'=>1, 'owner' =>get_current_user_id(), 'scope' => 'future'));
34
+ $pending_count = EM_Events::count( array('status'=>0, 'owner' =>get_current_user_id(), 'scope' => 'all') );
35
+ $use_events_end = get_option('dbem_use_event_end');
36
+ echo $EM_Notices;
37
+ ?>
38
+ <div class="wrap">
39
+ <?php echo $EM_Notices; ?>
40
+ <form id="posts-filter" action="<?php echo $url; ?>" method="get">
41
+ <a href="<?php echo $url?>edit/" class="button add-new-h2"><?php _e('Add New','dbem'); ?></a>
42
+ <div class="subsubsub">
43
+ <a href='<?php echo $url; ?>' <?php echo ( !isset($_GET['status']) ) ? 'class="current"':''; ?>><?php _e ( 'Upcoming', 'dbem' ); ?> <span class="count">(<?php echo $future_count; ?>)</span></a> &nbsp;|&nbsp;
44
+ <?php if( !current_user_can('publish_events') ): ?>
45
+ <a href='<?php echo $url ?>?status=0' <?php echo ( isset($_GET['status']) && $_GET['status']=='0' ) ? 'class="current"':''; ?>><?php _e ( 'Pending', 'dbem' ); ?> <span class="count">(<?php echo $pending_count; ?>)</span></a> &nbsp;|&nbsp;
46
+ <?php endif; ?>
47
+ <a href='<?php echo $url; ?>?scope=past' <?php echo ( !empty($_REQUEST['scope']) && $_REQUEST['scope'] == 'past' ) ? 'class="current"':''; ?>><?php _e ( 'Past Events', 'dbem' ); ?></a>
48
+ </div>
49
+ <p class="search-box">
50
+ <label class="screen-reader-text" for="post-search-input"><?php _e('Search Events','dbem'); ?>:</label>
51
+ <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_REQUEST['em_search'])) ? $_REQUEST['em_search']:''; ?>" />
52
+ <input type="submit" value="<?php _e('Search Events','dbem'); ?>" class="button" />
53
+ </p>
54
+ <div class="tablenav">
55
+ <?php
56
+ if ( $events_count >= $limit ) {
57
+ $events_nav = em_admin_paginate( $events_count, $limit, $page);
58
+ echo $events_nav;
59
+ }
60
+ ?>
61
+ <br class="clear" />
62
+ </div>
63
+
64
+ <?php
65
+ if (empty ( $events )) {
66
+ // TODO localize
67
+ _e ( 'no events','dbem' );
68
+ } else {
69
+ ?>
70
+
71
+ <table class="widefat events-table">
72
+ <thead>
73
+ <tr>
74
+ <th class='manage-column column-cb check-column' scope='col'>
75
+ <input class='select-all' type="checkbox" value='1' />
76
+ </th>
77
+ <th><?php _e ( 'Name', 'dbem' ); ?></th>
78
+ <th>&nbsp;</th>
79
+ <th><?php _e ( 'Location', 'dbem' ); ?></th>
80
+ <th colspan="2"><?php _e ( 'Date and time', 'dbem' ); ?></th>
81
+ </tr>
82
+ </thead>
83
+ <tbody>
84
+ <?php
85
+ $rowno = 0;
86
+ $event_count = 0;
87
+ foreach ( $events as $event ) {
88
+ /* @var $event EM_Event */
89
+ if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
90
+ $rowno++;
91
+ $class = ($rowno % 2) ? 'alternate' : '';
92
+ // FIXME set to american
93
+ $localised_start_date = date_i18n('D d M Y', $event->start);
94
+ $localised_end_date = date_i18n('D d M Y', $event->end);
95
+ $style = "";
96
+ $today = date ( "Y-m-d" );
97
+ $location_summary = "<b>" . $event->location->name . "</b><br/>" . $event->location->address . " - " . $event->location->town;
98
+ $category = new EM_Category($event->category_id);
99
+
100
+ if ($event->start_date < $today && $event->end_date < $today){
101
+ $class .= " past";
102
+ }
103
+ //Check pending approval events
104
+ if ( !$event->status ){
105
+ $class .= " pending";
106
+ }
107
+ ?>
108
+ <tr class="event <?php echo trim($class); ?>" <?php echo $style; ?> id="event_<?php echo $event->id ?>">
109
+ <td>
110
+ <input type='checkbox' class='row-selector' value='<?php echo $event->id; ?>' name='events[]' />
111
+ </td>
112
+ <td>
113
+ <strong>
114
+ <a class="row-title" href="<?php echo $url; ?>edit/?event_id=<?php echo $event->id ?>"><?php echo ($event->name); ?></a>
115
+ </strong>
116
+ <?php
117
+ if( get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1 ){
118
+ ?>
119
+ <br/>
120
+ <a href="<?php echo $url ?>bookings/?event_id=<?php echo $event->id ?>"><?php echo __("Bookings",'dbem'); ?></a> &ndash;
121
+ <?php _e("Booked",'dbem'); ?>: <?php echo $event->get_bookings()->get_booked_spaces()."/".$event->get_spaces(); ?>
122
+ <?php if( get_option('dbem_bookings_approval') == 1 ): ?>
123
+ | <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_spaces(); ?>
124
+ <?php endif;
125
+ }
126
+ ?>
127
+ <div class="row-actions">
128
+ <?php if( current_user_can('delete_events')) : ?>
129
+ <span class="trash"><a href="<?php echo $url ?>?action=event_delete&amp;event_id=<?php echo $event->id ?>" class="em-event-delete"><?php _e('Delete','dbem'); ?></a></span>
130
+ <?php endif; ?>
131
+ </div>
132
+ </td>
133
+ <td>
134
+ <a href="<?php echo $url ?>duplicate/?event_id=<?php echo $event->id ?>" title="<?php _e ( 'Duplicate this event', 'dbem' ); ?>">
135
+ <strong>+</strong>
136
+ </a>
137
+ </td>
138
+ <td>
139
+ <?php echo $location_summary; ?>
140
+ <?php if( is_object($category) && !empty($category->name) ) : ?>
141
+ <br/><span class="category"><strong><?php _e( 'Category', 'dbem' ); ?>: </strong><?php echo $category->name ?></span>
142
+ <?php endif; ?>
143
+ </td>
144
+
145
+ <td>
146
+ <?php echo $localised_start_date; ?>
147
+ <?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
148
+ <br />
149
+ <?php
150
+ //TODO Should 00:00 - 00:00 be treated as an all day event?
151
+ echo substr ( $event->start_time, 0, 5 ) . " - " . substr ( $event->end_time, 0, 5 );
152
+ ?>
153
+ </td>
154
+ <td>
155
+ <?php
156
+ if ( $event->is_recurrence() ) {
157
+ ?>
158
+ <strong>
159
+ <?php echo $event->get_recurrence_description(); ?> <br />
160
+ <a href="<?php echo $url ?>edit/?event_id=<?php echo $event->recurrence_id ?>"><?php _e ( 'Reschedule', 'dbem' ); ?></a>
161
+ </strong>
162
+ <?php
163
+ }
164
+ ?>
165
+ </td>
166
+ </tr>
167
+ <?php
168
+ }
169
+ $event_count++;
170
+ }
171
+ ?>
172
+ </tbody>
173
+ </table>
174
+ <?php
175
+ } // end of table
176
+ ?>
177
+ <div class='tablenav'>
178
+ <div class="alignleft actions">
179
+ <br class='clear' />
180
+ </div>
181
+ <?php if ( $events_count >= $limit ) : ?>
182
+ <div class="tablenav-pages">
183
+ <?php
184
+ echo $events_nav;
185
+ ?>
186
+ </div>
187
+ <?php endif; ?>
188
+ <br class='clear' />
189
+ </div>
190
+ </form>
191
+ </div>
templates/buddypress/locations/my-locations.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $wpdb, $bp, $EM_Location, $EM_Notices;
3
+ $url = $bp->events->link . 'my-locations/'; //url to this page
4
+ $limit = ( !empty($_REQUEST['limit']) ) ? $_REQUEST['limit'] : 20;//Default limit
5
+ $page = ( !empty($_REQUEST['pno']) ) ? $_REQUEST['pno']:1;
6
+ $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
7
+ if( !empty($bp->action_variables[0]) && $bp->action_variables[0] == 'others' && current_user_can('read_others_locations') ){
8
+ $locations = EM_Locations::get();
9
+ $locations_mine_count = EM_Locations::count( array('owner'=>get_current_user_id()) );
10
+ $locations_all_count = count($locations);
11
+ }else{
12
+ $locations = EM_Locations::get( array('owner'=>get_current_user_id()) );
13
+ $locations_mine_count = count($locations);
14
+ $locations_all_count = current_user_can('read_others_locations') ? EM_Locations::count():0;
15
+ }
16
+ $locations_count = count($locations);
17
+ ?>
18
+ <div class='wrap'>
19
+ <?php echo $EM_Notices; ?>
20
+
21
+ <form id='locations-filter' method='post' action=''>
22
+ <input type='hidden' name='page' value='locations'/>
23
+ <input type='hidden' name='limit' value='<?php echo $limit ?>' />
24
+ <input type='hidden' name='p' value='<?php echo $page ?>' />
25
+ <a href="<?php echo $url?>edit/" class="button add-new-h2"><?php _e('Add New','dbem'); ?></a>
26
+ <div class="subsubsub">
27
+ <a href='<?php echo $url; ?>' <?php echo ( empty($bp->action_variables[0]) || $bp->action_variables[0] != 'all' ) ? 'class="current"':''; ?>><?php echo sprintf( __( 'My %s', 'dbem' ), __('Locations','dbem')); ?> <span class="count">(<?php echo $locations_mine_count; ?>)</span></a>
28
+ <?php if( current_user_can('read_others_locations') ): ?>
29
+ &nbsp;|&nbsp;
30
+ <a href='<?php echo $url ?>others/' <?php echo ( !empty($bp->action_variables[0]) && $bp->action_variables[0] == 'all' ) ? 'class="current"':''; ?>><?php echo sprintf( __( 'All %s', 'dbem' ), __('Locations','dbem')); ?><span class="count">(<?php echo $locations_all_count; ?>)</span></a>
31
+ <?php endif; ?>
32
+ </div>
33
+ <?php if ( $locations_count > 0 ) : ?>
34
+ <div class='tablenav'>
35
+ <div class="alignleft actions">
36
+ <select name="action">
37
+ <option value="" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
38
+ <option value="location_delete"><?php _e ( 'Delete selected','dbem' ); ?></option>
39
+ </select>
40
+ <input type="submit" value="<?php _e ( 'Apply' ); ?>" id="doaction2" class="button-secondary action" />
41
+ </div>
42
+ <?php
43
+ if ( $locations_count >= $limit ) {
44
+ $locations_nav = em_admin_paginate( $locations_count, $limit, $page );
45
+ echo $locations_nav;
46
+ }
47
+ ?>
48
+ </div>
49
+ <table class='widefat'>
50
+ <thead>
51
+ <tr>
52
+ <th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
53
+ <th><?php _e('Name', 'dbem') ?></th>
54
+ <th><?php _e('Address', 'dbem') ?></th>
55
+ <th><?php _e('Country', 'dbem') ?></th>
56
+ </tr>
57
+ </thead>
58
+ <tfoot>
59
+ <tr>
60
+ <th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
61
+ <th><?php _e('Name', 'dbem') ?></th>
62
+ <th><?php _e('Address', 'dbem') ?></th>
63
+ <th><?php _e('Country', 'dbem') ?></th>
64
+ </tr>
65
+ </tfoot>
66
+ <tbody>
67
+ <?php $i = 1; ?>
68
+ <?php foreach ($locations as $EM_Location) : ?>
69
+ <?php if( $i >= $offset && $i <= $offset+$limit ): ?>
70
+ <tr>
71
+ <td><input type='checkbox' class ='row-selector' value='<?php echo $EM_Location->id ?>' name='locations[]'/></td>
72
+ <td><a href='<?php echo $url; ?>edit/?location_id=<?php echo $EM_Location->id ?>'><?php echo $EM_Location->name ?></a></td>
73
+ <td><?php echo $EM_Location->address. ', '.$EM_Location->town. ', '.$EM_Location->state. ' '.$EM_Location->postcode ?></td>
74
+ <td><?php echo $EM_Location->get_country() ?></td>
75
+ </tr>
76
+ <?php endif; ?>
77
+ <?php $i++; ?>
78
+ <?php endforeach; ?>
79
+ </tbody>
80
+ </table>
81
+ <?php else: ?>
82
+ <p><?php _e('No venues have been inserted yet!', 'dbem') ?></p>
83
+ <?php endif; ?>
84
+ </form>
85
+ </div>
86
+ <?php
templates/forms/events/attributes-box.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $attributes = em_get_attributes();
3
+ $has_depreciated = false;
4
+ ?>
5
+ <?php if( count( $attributes ) > 0 ) : ?>
6
+ <div class="inside">
7
+ <?php foreach( $attributes as $name) : ?>
8
+ <div>
9
+ <label for="em_attributes[<?php echo $name ?>]"><?php echo $name ?></label>
10
+ <input type="text" name="em_attributes[<?php echo $name ?>]" value="<?php echo ( is_array($EM_Event->attributes) && array_key_exists($name, $EM_Event->attributes) ) ? htmlspecialchars($EM_Event->attributes[$name], ENT_QUOTES):''; ?>" />
11
+ </div>
12
+ <?php endforeach; ?>
13
+ </div>
14
+ <?php endif; ?>
templates/forms/events/bookings-box.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $EM_Event;
3
+ ?>
4
+ <p>
5
+ <input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox' <?php echo ($EM_Event->rsvp) ? 'checked="checked"' : ''; ?> />
6
+ <?php _e ( 'Enable registration for this event', 'dbem' )?>
7
+ </p>
8
+ <div id='rsvp-data'>
9
+ <p>
10
+ <?php _e ( 'Spaces','dbem' ); ?> :
11
+ <input id="spaces-input" type="text" name="event_spaces" size='5' value="<?php echo ($EM_Event->get_spaces() > 0) ? $EM_Event->get_spaces():10 ?>" /><br />
12
+ <em><?php _e('This is a limit for total number of booking spaces.','dbem'); ?></em>
13
+ </p>
14
+ <!-- START RSVP Stats -->
15
+ <?php
16
+ if ($EM_Event->rsvp ) {
17
+ $available_spaces = $EM_Event->get_bookings()->get_available_spaces();
18
+ $booked_spaces = $EM_Event->get_bookings()->get_booked_spaces();
19
+
20
+ if ( count($EM_Event->get_bookings()->bookings) > 0 ) {
21
+ ?>
22
+ <p>
23
+ <strong><?php echo __('Available Spaces','dbem').': '.$EM_Event->get_bookings()->get_available_spaces(); ?></strong><br />
24
+ <strong><?php echo __('Confirmed Spaces','dbem').': '.$EM_Event->get_bookings()->get_booked_spaces(); ?></strong><br />
25
+ <strong><?php echo __('Pending Spaces','dbem').': '.$EM_Event->get_bookings()->get_pending_spaces(); ?></strong>
26
+ </p>
27
+
28
+ <div id='major-publishing-actions'>
29
+ <div id='publishing-action'>
30
+ <a id='printable' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&event_id=".$EM_Event->id ?>'><?php _e('manage bookings','dbem')?></a><br />
31
+ <a target='_blank' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=bookings_report&event_id=".$EM_Event->id ?>'><?php _e('printable view','dbem')?></a>
32
+ <a href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=".$EM_Event->id ?>'><?php _e('export csv','dbem')?></a>
33
+ <br class='clear'/>
34
+ </div>
35
+ <br class='clear'/>
36
+ </div>
37
+ <?php
38
+ } else {
39
+ ?>
40
+ <p><em><?php _e('No responses yet!')?></em></p>
41
+ <?php
42
+ }
43
+ }
44
+ ?>
45
+ <!-- END RSVP Stats -->
46
+ </div>
templates/forms/events/categories-box.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $EM_Event;
3
+ if(get_option('dbem_categories_enabled')) :?>
4
+ <?php $categories = EM_Categories::get(array('orderby'=>'category_name')); ?>
5
+ <?php if( count($categories) > 0 ): ?>
6
+ <!-- START Categories -->
7
+ <div class="inside">
8
+ <label for="event_category_id"><?php _e ( 'Category:', 'dbem' ); ?></label>
9
+ <select name="event_category_id">
10
+ <option value="" <?php echo ($EM_Event->category_id == '') ? "selected='selected'":'' ?>><?php _e('no category','dbem') ?></option>
11
+ <?php
12
+ foreach ( $categories as $EM_Category ){
13
+ $selected = ($EM_Category->id == $EM_Event->category_id) ? "selected='selected'": '';
14
+ ?>
15
+ <option value="<?php echo $EM_Category->id ?>" <?php echo $selected ?>>
16
+ <?php echo $EM_Category->name ?>
17
+ </option>
18
+ <?php
19
+ }
20
+ ?>
21
+ </select>
22
+ </div>
23
+ <!-- END Categories -->
24
+ <?php endif; ?>
25
+ <?php endif; ?>
templates/forms/events/editor.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $EM_Event, $current_user, $localised_date_formats, $EM_Notices;
3
+
4
+ //check that user can access this page
5
+ if( is_object($EM_Event) && !$EM_Event->can_manage('edit_events','edit_others_events') ){
6
+ ?>
7
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php echo sprintf(__('You do not have the rights to manage this %s.','dbem'),__('Event','dbem')); ?></p></div>
8
+ <?php
9
+ return false;
10
+ }
11
+
12
+ if( is_object($EM_Event) && $EM_Event->id > 0 ){
13
+ if($EM_Event->is_recurring()){
14
+ $title = __( "Reschedule", 'dbem' )." '{$EM_Event->name}'";
15
+ }else{
16
+ $title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
17
+ }
18
+ } else {
19
+ $EM_Event = ( is_object($EM_Event) && get_class($EM_Event) == 'EM_Event') ? $EM_Event : new EM_Event();
20
+ $title = __ ( "Insert New Event", 'dbem' );
21
+ //Give a default location & category
22
+ $default_cat = get_option('dbem_default_category');
23
+ $default_loc = get_option('dbem_default_location');
24
+ if( is_numeric($default_cat) && $default_cat > 0 ){
25
+ $EM_Event->category_id = $default_cat;
26
+ $EM_Event->category = new EM_Category($default_cat);
27
+ }
28
+ if( is_numeric($default_loc) && $default_loc > 0 && ( empty($EM_Event->location->id) && empty($EM_Event->location->name) && empty($EM_Event->location->address) && empty($EM_Event->location->town) ) ){
29
+ $EM_Event->location_id = $default_loc;
30
+ $EM_Event->location = new EM_Location($default_loc);
31
+ }
32
+ }
33
+
34
+ // change prefix according to event/recurrence
35
+ $pref = "event_";
36
+
37
+ $locale_code = substr ( get_locale (), 0, 2 );
38
+ $localised_date_format = $localised_date_formats[$locale_code];
39
+
40
+ //FIXME time useage is very flimsy imho
41
+ $hours_locale_regexp = "H:i";
42
+ // Setting 12 hours format for those countries using it
43
+ if (preg_match ( "/en|sk|zh|us|uk/", $locale_code ))
44
+ $hours_locale_regexp = "h:iA";
45
+ ?>
46
+
47
+ <?php echo $EM_Notices; ?>
48
+ <form id="event-form" method="post" action="">
49
+ <div class="wrap">
50
+ <?php if ( count($EM_Event->warnings) > 0 ) : ?>
51
+ <?php foreach($EM_Event->warnings as $warning): ?>
52
+ <p class="warning"><?php echo $warning; ?></p>
53
+ <?php endforeach; ?>
54
+ <?php endif; ?>
55
+
56
+ <h4><?php _e ( 'Event Name', 'dbem' ); ?></h4>
57
+ <div class="inside">
58
+ <input type="text" name="event_name" id="event-name" value="<?php echo htmlspecialchars($EM_Event->name,ENT_QUOTES); ?>" />
59
+ <br />
60
+ <?php _e ( 'The event name. Example: Birthday party', 'dbem' )?>
61
+ </div>
62
+
63
+ <h4 id='event-date-title'><?php _e ( 'When', 'dbem' ); ?></h4>
64
+ <div class="inside">
65
+ <div>
66
+ <?php _e ( 'Starts on ', 'dbem' ); ?>
67
+ <input id="localised-date" type="text" name="localised_event_date" style="display: none;" />
68
+ <input id="date-to-submit" type="text" name="event_start_date" value="<?php echo $EM_Event->start_date ?>" style="background: #FCFFAA" />
69
+ <?php _e('from','dbem'); ?>
70
+ <input id="start-time" type="text" size="8" maxlength="8" name="event_start_time" value="<?php echo date( $hours_locale_regexp, strtotime($EM_Event->start_time) ); ?>" />
71
+ <?php _e('to','dbem'); ?>
72
+ <input id="end-time" type="text" size="8" maxlength="8" name="event_end_time" value="<?php echo date( $hours_locale_regexp, strtotime($EM_Event->end_time) ); ?>" />
73
+ <?php _e('and ends on','dbem'); ?>
74
+ <input id="localised-end-date" type="text" name="localised_event_end_date" style="display: none;" />
75
+ <input id="end-date-to-submit" type="text" name="event_end_date" value="<?php echo $EM_Event->end_date ?>" style="background: #FCFFAA" />
76
+ </div>
77
+ <div>
78
+ <span id='event-date-explanation'>
79
+ <?php _e( 'This event spans every day between the beginning and end date, with start/end times applying to each day.', 'dbem' ); ?>
80
+ </span>
81
+ <span id='recurrence-dates-explanation'>
82
+ <?php _e( 'For a recurring event, a one day event will be created on each recurring date within this date range.', 'dbem' ); ?>
83
+ </span>
84
+ </div>
85
+ </div>
86
+ <?php if( get_option('dbem_recurrence_enabled') && ($EM_Event->is_recurrence() || $EM_Event->is_recurring() || $EM_Event->id == '') ) : //for now we don't need to show recurrences for single saved events, as backend doesn't allow either ?>
87
+ <!-- START recurrence postbox -->
88
+ <div class="inside">
89
+ <?php em_locate_template('forms/events/recurrence-box.php', true); ?>
90
+ </div>
91
+ <!-- END recurrence postbox -->
92
+ <?php endif; ?>
93
+
94
+
95
+ <h4><?php _e ( 'Where', 'dbem' ); ?></h4>
96
+ <div class="inside">
97
+ <table id="dbem-location-data">
98
+ <tr>
99
+ <td style="padding-right:20px; vertical-align:top;">
100
+ <?php
101
+ $args = array();
102
+ $args['owner'] = current_user_can('read_others_locations') ? false:get_current_user_id();
103
+ $locations = EM_Locations::get($args);
104
+ ?>
105
+ <?php if( count($locations) > 0): ?>
106
+ <select name="location_id" id='location-select-id' size="1">
107
+ <?php
108
+ foreach($locations as $location) {
109
+ $selected = "";
110
+ if( is_object($EM_Event->location) ) {
111
+ if ($EM_Event->location->id == $location->id)
112
+ $selected = "selected='selected' ";
113
+ }
114
+ ?>
115
+ <option value="<?php echo $location->id ?>" title="<?php echo "{$location->latitude},{$location->longitude}" ?>" <?php echo $selected ?>><?php echo $location->name; ?></option>
116
+ <?php
117
+ }
118
+ ?>
119
+ </select>
120
+ <?php endif; ?>
121
+ <p><?php _e ( 'Choose from one of your locations', 'dbem' )?> <?php echo sprintf(__('or <a href="%s">add a new location</a>','dbem'),'#'); ?></p>
122
+ </td>
123
+ <?php if ( get_option ( 'dbem_gmap_is_active' ) ) : ?>
124
+ <td width="400">
125
+ <div id='em-map-404' style='width: 400px; vertical-align:middle; text-align: center;'>
126
+ <p><em><?php _e ( 'Location not found', 'dbem' ); ?></em></p>
127
+ </div>
128
+ <div id='em-map' style='width: 400px; height: 300px; display: none;'></div>
129
+ </td>
130
+ <?php endif; ?>
131
+ </tr>
132
+ </table>
133
+ </div>
134
+
135
+ <h4><?php _e ( 'Details', 'dbem' ); ?></h4>
136
+ <div class="inside">
137
+ <textarea name="content" rows="10" style="width:100%"><?php echo $EM_Event->notes ?></textarea>
138
+ <br />
139
+ <?php _e ( 'Details about the event.', 'dbem' )?><?php _e ( 'HTML Allowed.', 'dbem' )?>
140
+ </div>
141
+ <br/>
142
+ <div class="inside">
143
+ <?php em_locate_template('forms/events/categories-box.php', true); ?>
144
+ </div>
145
+
146
+ <?php if(get_option('dbem_attributes_enabled')) : ?>
147
+ <?php em_locate_template('forms/events/attributes-box.php', true); ?>
148
+ <?php endif; ?>
149
+
150
+ <?php if(get_option('dbem_rsvp_enabled')) : ?>
151
+ <!-- START RSVP -->
152
+ <h4 class='hndle'><span><?php _e('Bookings/Registration','dbem'); ?></span></h4>
153
+ <div class="inside">
154
+ <?php em_locate_template('forms/events/bookings-box.php', true); ?>
155
+ </div>
156
+ <!-- END RSVP -->
157
+ <?php endif; ?>
158
+ </div>
159
+ <p class="submit">
160
+ <input type="submit" name="events_update" value="<?php _e ( 'Submit Event', 'dbem' ); ?> &raquo;" />
161
+ </p>
162
+ <input type="hidden" name="event_id" value="<?php echo $EM_Event->id; ?>" />
163
+ <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('wpnonce_event_save'); ?>" />
164
+ <input type="hidden" name="action" value="event_save" />
165
+ </form>
166
+ <script type="text/javascript">
167
+ jQuery(document).ready( function($) {
168
+ <?php if( $EM_Event->is_recurring() ): ?>
169
+ //Recurrence Warnings
170
+ $('#event_form').submit( function(event){
171
+ confirmation = confirm('<?php _e('Are you sure you want to reschedule this recurring event? If you do this, you will lose all booking information and the old recurring events will be deleted.', 'dbem'); ?>');
172
+ if( confirmation == false ){
173
+ event.preventDefault();
174
+ }
175
+ });
176
+ <?php endif; ?>
177
+ <?php if( $EM_Event->rsvp == 1 ): ?>
178
+ //RSVP Warning
179
+ $('#rsvp-checkbox').click( function(event){
180
+ if( !this.checked ){
181
+ confirmation = confirm('<?php _e('Are you sure you want to disable bookings? If you do this and save, you will lose all previous bookings. If you wish to prevent further bookings, reduce the number of spaces available to the amount of bookings you currently have', 'dbem'); ?>');
182
+ if( confirmation == false ){
183
+ event.preventDefault();
184
+ }else{
185
+ $('#event_tickets').hide();
186
+ $("div#rsvp-data").hide();
187
+ }
188
+ }else{
189
+ $('#event_tickets').show();
190
+ $("div#rsvp-data").fadeIn();
191
+ }
192
+ });
193
+
194
+ if($('input#rsvp-checkbox').attr("checked")) {
195
+ $("div#rsvp-data").fadeIn();
196
+ } else {
197
+ $("div#rsvp-data").hide();
198
+ }
199
+ <?php endif; ?>
200
+ });
201
+ </script>
templates/forms/events/recurrence-box.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $EM_Event;
3
+
4
+ $days_names = array (1 => __ ( 'Monday' ), 2 => __ ( 'Tuesday' ), 3 => __ ( 'Wednesday' ), 4 => __ ( 'Thursday' ), 5 => __ ( 'Friday' ), 6 => __ ( 'Saturday' ), 0 => __ ( 'Sunday' ) );
5
+
6
+ if ( !$EM_Event->id || $EM_Event->is_recurring() ) : ?>
7
+ <input id="event-recurrence" type="checkbox" name="repeated_event" value="1" <?php echo ( $EM_Event->is_recurring() ) ? 'checked="checked"':'' ; ?> />
8
+ <?php _e ( 'This event repeats', 'dbem' ); ?>
9
+ <select id="recurrence-frequency" name="recurrence_freq">
10
+ <?php
11
+ $freq_options = array ("daily" => __ ( 'Daily', 'dbem' ), "weekly" => __ ( 'Weekly', 'dbem' ), "monthly" => __ ( 'Monthly', 'dbem' ) );
12
+ em_option_items ( $freq_options, $EM_Event->freq );
13
+ ?>
14
+ </select>
15
+ <?php _e ( 'every', 'dbem' )?>
16
+ <input id="recurrence-interval" name='recurrence_interval' size='2' value='<?php echo $EM_Event->interval ; ?>' />
17
+ <span class='interval-desc' id="interval-daily-singular">
18
+ <?php _e ( 'day', 'dbem' )?>
19
+ </span> <span class='interval-desc' id="interval-daily-plural">
20
+ <?php _e ( 'days', 'dbem' ) ?>
21
+ </span> <span class='interval-desc' id="interval-weekly-singular">
22
+ <?php _e ( 'week on', 'dbem'); ?>
23
+ </span> <span class='interval-desc' id="interval-weekly-plural">
24
+ <?php _e ( 'weeks on', 'dbem'); ?>
25
+ </span> <span class='interval-desc' id="interval-monthly-singular">
26
+ <?php _e ( 'month on the', 'dbem' )?>
27
+ </span> <span class='interval-desc' id="interval-monthly-plural">
28
+ <?php _e ( 'months on the', 'dbem' )?>
29
+ </span>
30
+ <p class="alternate-selector" id="weekly-selector">
31
+ <?php
32
+ $saved_bydays = ($EM_Event->is_recurring()) ? explode ( ",", $EM_Event->byday ) : array();
33
+ em_checkbox_items ( 'recurrence_bydays[]', $days_names, $saved_bydays );
34
+ ?>
35
+ </p>
36
+ <p class="alternate-selector" id="monthly-selector" style="display:inline;">
37
+ <select id="monthly-modifier" name="recurrence_byweekno">
38
+ <?php
39
+ $weekno_options = array ("1" => __ ( 'first', 'dbem' ), '2' => __ ( 'second', 'dbem' ), '3' => __ ( 'third', 'dbem' ), '4' => __ ( 'fourth', 'dbem' ), '-1' => __ ( 'last', 'dbem' ) );
40
+ em_option_items ( $weekno_options, $EM_Event->byweekno );
41
+ ?>
42
+ </select>
43
+ <select id="recurrence-weekday" name="recurrence_byday">
44
+ <?php em_option_items ( $days_names, $EM_Event->byday ); ?>
45
+ </select>
46
+ <?php _e('of each month','dbem'); ?>
47
+ &nbsp;
48
+ </p>
49
+
50
+ <p id="recurrence-tip">
51
+ <?php _e ( 'Check if your event happens more than once according to a regular pattern', 'dbem' )?>
52
+ </p>
53
+ <?php elseif( $EM_Event->is_recurrence() ) : ?>
54
+ <p>
55
+ <?php echo $EM_Event->get_recurrence_description(); ?>
56
+ <br />
57
+ <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php echo $EM_Event->recurrence_id; ?>">
58
+ <?php _e ( 'Reschedule', 'dbem' ); ?>
59
+ </a>
60
+ <input type="hidden" name="recurrence_id" value="<?php echo $EM_Event->recurrence_id; ?>" />
61
+ </p>
62
+ <?php else : ?>
63
+ <p><?php _e ( 'This is\'t a recurrent event', 'dbem' ) ?></p>
64
+ <?php endif; ?>
templates/forms/locations/editor.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $EM_Location, $EM_Notices;
3
+
4
+ //check that user can access this page
5
+ if( is_object($EM_Location) && !$EM_Location->can_manage('edit_locations','edit_others_locations') ){
6
+ ?>
7
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php echo sprintf(__('You do not have the rights to manage this %s.','dbem'),__('location','dbem')); ?></p></div>
8
+ <?php
9
+ return false;
10
+ }
11
+ if( empty($EM_Location) || !is_object($EM_Location) ){
12
+ $title = __('Add location', 'dbem');
13
+ $EM_Location = new EM_Location();
14
+ }else{
15
+ $title = __('Edit location', 'dbem');
16
+ }
17
+ $required = "<i>(".__('required','dbem').")</i>";
18
+ echo $EM_Notices;
19
+ ?>
20
+ <form enctype='multipart/form-data' name='editcat' id='location-form' method='post' action='admin.php?page=events-manager-locations' class='validate'>
21
+ <input type='hidden' name='action' value='location_save' />
22
+ <input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('location_save'); ?>' />
23
+ <input type='hidden' name='location_id' value='<?php echo $EM_Location->id ?>'/>
24
+ <input type='hidden' id='location-latitude' name='location_latitude' value='<?php echo $EM_Location->latitude; ?>' size='15' />
25
+ <input type='hidden' id='location-longitude' name='location_longitude' value='<?php echo $EM_Location->longitude; ?>' size='15' />
26
+
27
+ <h3><?php echo $title ?></h3>
28
+
29
+ <?php global $EM_Notices; echo $EM_Notices; ?>
30
+ <h4>
31
+ <?php _e ( 'Location Name', 'dbem' ); ?>
32
+ </h4>
33
+ <div class="inside">
34
+ <input name='location_name' id='location-name' type='text' value='<?php echo htmlspecialchars($EM_Location->name, ENT_QUOTES); ?>' size='40' />
35
+ <br />
36
+ <?php _e('The name of the location', 'dbem') ?>
37
+ </div>
38
+
39
+ <h4>
40
+ <?php _e ( 'Location', 'dbem' ); ?>
41
+ </h4>
42
+ <div class="inside">
43
+ <p><?php _e("If you're using the Google Maps, the more detail you provide, the more accurate Google can be at finding your location. If your address isn't being found, please <a='http://maps.google.com'>try it on maps.google.com</a> by adding all the fields below seperated by commas.",'dbem')?></p>
44
+ <table id="dbem-location-data">
45
+ <tr>
46
+ <td style="padding-right:20px; width:auto;">
47
+ <table>
48
+ <tr>
49
+ <th><?php _e ( 'Address:' )?>&nbsp;</th>
50
+ <td>
51
+ <input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Location->address, ENT_QUOTES); ; ?>" /> <?php echo $required; ?>
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <th><?php _e ( 'City/Town:' )?>&nbsp;</th>
56
+ <td>
57
+ <input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Location->town, ENT_QUOTES); ?>" /> <?php echo $required; ?>
58
+ </td>
59
+ </tr>
60
+ <tr>
61
+ <th><?php _e ( 'State/County:' )?>&nbsp;</th>
62
+ <td>
63
+ <input id="location-state" type="text" name="location_state" value="<?php echo htmlspecialchars($EM_Location->state, ENT_QUOTES); ?>" />
64
+ </td>
65
+ </tr>
66
+ <tr>
67
+ <th><?php _e ( 'Postcode:' )?>&nbsp;</th>
68
+ <td>
69
+ <input id="location-postcode" type="text" name="location_postcode" value="<?php echo htmlspecialchars($EM_Location->postcode, ENT_QUOTES); ?>" />
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <th><?php _e ( 'Country:' )?>&nbsp;</th>
74
+ <td>
75
+ <select id="location-country" name="location_country">
76
+ <?php foreach(em_get_countries(__('none selected','dbem')) as $country_key => $country_name): ?>
77
+ <option value="<?php echo $country_key; ?>" <?php echo ( $EM_Location->country === $country_key || ($EM_Location->country == '' && $EM_Location->id == '' && get_option('dbem_location_default_country')==$country_key) ) ? 'selected="selected"':''; ?>><?php echo $country_name; ?></option>
78
+ <?php endforeach; ?>
79
+ </select> <?php echo $required; ?>
80
+ </td>
81
+ </tr>
82
+ </table>
83
+ </td>
84
+ <?php if ( get_option ( 'dbem_gmap_is_active' ) ) : ?>
85
+ <td width="400">
86
+ <div id='em-map-404' style='width: 400px; vertical-align:middle; text-align: center;'>
87
+ <p><em><?php _e ( 'Location not found', 'dbem' ); ?></em></p>
88
+ </div>
89
+ <div id='em-map' style='width: 400px; height: 300px; display: none;'></div>
90
+ </td>
91
+ <?php endif; ?>
92
+ </tr>
93
+ </table>
94
+ </div>
95
+
96
+ <h4>
97
+ <?php _e ( 'Details', 'dbem' ); ?>
98
+ </h4>
99
+ <div class="inside">
100
+ <textarea name="content"><?php echo $EM_Location->description; ?></textarea>
101
+ <?php _e ( 'Details about the location', 'dbem' )?>
102
+ </div>
103
+
104
+ <h4>
105
+ <?php _e ( 'Location image', 'dbem' ); ?>
106
+ </h4>
107
+ <div class="inside" style="padding:10px;">
108
+ <?php if ($EM_Location->image_url != '') : ?>
109
+ <img src='<?php echo $EM_Location->image_url; ?>' alt='<?php echo $EM_Location->name ?>'/>
110
+ <?php else : ?>
111
+ <?php _e('No image uploaded for this location yet', 'debm') ?>
112
+ <?php endif; ?>
113
+ <br /><br />
114
+ <label for='location_image'><?php _e('Upload/change picture', 'dbem') ?></label> <input id='location-image' name='location_image' id='location_image' type='file' size='40' />
115
+ </div>
116
+ <p class='submit'><input type='submit' class='button-primary' name='submit' value='<?php _e('Update location', 'dbem') ?>' /></p>
117
+ </form>
templates/placeholders/attendees.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $this EM_Event */
3
+ $people = array();
4
+ foreach($this->get_bookings() as $EM_Booking){
5
+ $people[$EM_Booking->person->ID] = $EM_Booking->person;
6
+ }
7
+ ?>
8
+ <ul class="event-attendees">
9
+ <?php foreach($people as $EM_Person): ?>
10
+ <li><?php echo get_avatar($EM_Person->ID, 50); ?></li>
11
+ <?php endforeach; ?>
12
+ </ul>
widgets/em-events.php CHANGED
@@ -4,11 +4,11 @@
4
  * Standard events list widget
5
  */
6
  class EM_Widget extends WP_Widget {
 
7
  var $defaults;
8
 
9
  /** constructor */
10
  function EM_Widget() {
11
- //filter the new instance and replace blanks with defaults
12
  $this->defaults = array(
13
  'title' => __('Events','dbem'),
14
  'scope' => 'future',
@@ -25,8 +25,8 @@ class EM_Widget extends WP_Widget {
25
  }
26
 
27
  /** @see WP_Widget::widget */
28
- function widget($args, $instance) {
29
- $instance = array_merge($this->defaults, $instance);
30
  echo $args['before_widget'];
31
  echo $args['before_title'];
32
  echo $instance['title'];
@@ -71,7 +71,7 @@ class EM_Widget extends WP_Widget {
71
 
72
  /** @see WP_Widget::form */
73
  function form($instance) {
74
- $instance = array_merge($this->defaults, $instance);
75
  ?>
76
  <p>
77
  <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title'); ?>: </label>
4
  * Standard events list widget
5
  */
6
  class EM_Widget extends WP_Widget {
7
+
8
  var $defaults;
9
 
10
  /** constructor */
11
  function EM_Widget() {
 
12
  $this->defaults = array(
13
  'title' => __('Events','dbem'),
14
  'scope' => 'future',
25
  }
26
 
27
  /** @see WP_Widget::widget */
28
+ function widget($args, $instance) {
29
+ $instance = array_merge($this->defaults, $instance);
30
  echo $args['before_widget'];
31
  echo $args['before_title'];
32
  echo $instance['title'];
71
 
72
  /** @see WP_Widget::form */
73
  function form($instance) {
74
+ $instance = array_merge($this->defaults, $instance);
75
  ?>
76
  <p>
77
  <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title'); ?>: </label>