Version Description
- Fixed 12pm bug
- Re-added #_LOCATIONPAGEURL (although officially it's depreciated)
- Added default order by settings in options page
- Added default event list limits in options page
- Added orderby attribute for shortcode
- scope attribute now also allows searching between dates, e.g. "2010-01-01,2010-01-31"
- Fixed booking email reporting bug
Download this release
Release Info
Developer | netweblogic |
Plugin | Events Manager |
Version | 3.0.5 |
Comparing to | |
See all releases |
Code changes from version 3.0.4 to 3.0.5
- admin/options.php +34 -4
- classes/bookings.php +13 -3
- classes/event.php +10 -2
- classes/events.php +24 -3
- classes/location.php +10 -10
- classes/locations.php +8 -1
- classes/object.php +69 -6
- events-manager.php +2 -2
- events.php +2 -2
- install.php +4 -1
- readme.txt +10 -1
admin/options.php
CHANGED
@@ -5,10 +5,15 @@ function em_options_save(){
|
|
5 |
//Build the array of options here
|
6 |
foreach ($_POST as $postKey => $postValue){
|
7 |
if( substr($postKey, 0, 5) == 'dbem_' ){
|
8 |
-
//
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
13 |
}
|
14 |
function em_options_saved_notice(){
|
@@ -107,6 +112,31 @@ function dbem_options_subpanel() {
|
|
107 |
dbem_options_radio_binary ( __( 'Display calendar in events page?', 'dbem' ), 'dbem_display_calendar_in_events_page', __( 'This options allows to display the calendar in the events page, instead of the default list. It is recommended not to display both the calendar widget and a calendar page.','dbem' ) );
|
108 |
dbem_options_radio_binary ( __( 'Disable title rewriting?', 'dbem' ), 'dbem_disable_title_rewrites', __( "Some wordpress themes don't follow best practices when generating navigation menus, and so the automatic title rewriting feature may cause problems, if your menus aren't working correctly on the event pages, try setting this to 'Yes', and provide an appropriate HTML title format below.",'dbem' ) );
|
109 |
dbem_options_input_text ( __( 'Event Manager titles', 'dbem' ), 'dbem_title_html', __( "This only setting only matters if you selected 'Yes' to above. You will notice the events page titles aren't being rewritten, and you have a new title underneath the default page name. This is where you control the HTML of this title. Make sure you keep the #_PAGETITLE placeholder here, as that's what is rewritten by events manager. To control what's rewritten in this title, see settings further down for page titles.", 'dbem' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
echo $save_button;
|
111 |
?>
|
112 |
</table>
|
5 |
//Build the array of options here
|
6 |
foreach ($_POST as $postKey => $postValue){
|
7 |
if( substr($postKey, 0, 5) == 'dbem_' ){
|
8 |
+
//TODO some more validation/reporting
|
9 |
+
$numeric_options = array('dbem_locations_default_limit','dbem_events_default_limit');
|
10 |
+
if( in_array($postKey,$numeric_options) && !is_numeric($postValue) ){
|
11 |
+
//Do nothing, keep old setting.
|
12 |
+
}else{
|
13 |
+
//TODO slashes being added?
|
14 |
+
//$postValue = EM_Object::sanitize($postValue)
|
15 |
+
update_option($postKey, stripslashes($postValue));
|
16 |
+
}
|
17 |
}
|
18 |
}
|
19 |
function em_options_saved_notice(){
|
112 |
dbem_options_radio_binary ( __( 'Display calendar in events page?', 'dbem' ), 'dbem_display_calendar_in_events_page', __( 'This options allows to display the calendar in the events page, instead of the default list. It is recommended not to display both the calendar widget and a calendar page.','dbem' ) );
|
113 |
dbem_options_radio_binary ( __( 'Disable title rewriting?', 'dbem' ), 'dbem_disable_title_rewrites', __( "Some wordpress themes don't follow best practices when generating navigation menus, and so the automatic title rewriting feature may cause problems, if your menus aren't working correctly on the event pages, try setting this to 'Yes', and provide an appropriate HTML title format below.",'dbem' ) );
|
114 |
dbem_options_input_text ( __( 'Event Manager titles', 'dbem' ), 'dbem_title_html', __( "This only setting only matters if you selected 'Yes' to above. You will notice the events page titles aren't being rewritten, and you have a new title underneath the default page name. This is where you control the HTML of this title. Make sure you keep the #_PAGETITLE placeholder here, as that's what is rewritten by events manager. To control what's rewritten in this title, see settings further down for page titles.", 'dbem' ) );
|
115 |
+
dbem_options_input_text ( __( 'Event List Limits', 'dbem' ), 'dbem_events_default_limit', __( "This will control how many events are shown on one list by default.", 'dbem' ) );
|
116 |
+
?>
|
117 |
+
<tr valign="top" id='dbem_events_default_orderby_row'>
|
118 |
+
<th scope="row"><?php _e('Default event list ordering','dbem'); ?></th>
|
119 |
+
<td>
|
120 |
+
<select name="dbem_events_default_orderby" >
|
121 |
+
<?php $EM_Event = new EM_Event(); //TODO once php5 strict, this may be ok as a static call and avoid constcurting ?>
|
122 |
+
<?php foreach($EM_Event->get_fields() as $value) : ?>
|
123 |
+
<option value='<?php echo $value ?>' <?php echo ("$value" == get_option('dbem_events_default_orderby')) ? "selected='selected'" : ''; ?>>
|
124 |
+
<?php echo $value; ?>
|
125 |
+
</option>
|
126 |
+
<?php endforeach; ?>
|
127 |
+
</select>
|
128 |
+
<select name="dbem_events_default_order" >
|
129 |
+
<?php foreach( array(__('Ascending','dbem')=>'ASC',__('Descending','dbem')=>'DESC') as $key => $value) : ?>
|
130 |
+
<option value='<?php echo $value ?>' <?php echo ("$value" == get_option('dbem_events_default_order')) ? "selected='selected'" : ''; ?>>
|
131 |
+
<?php echo $key; ?>
|
132 |
+
</option>
|
133 |
+
<?php endforeach; ?>
|
134 |
+
</select>
|
135 |
+
<br/>
|
136 |
+
<?php _e('When Events Manager displays lists of events the default behaviour is ordering by start date in ascending order. To change this, modify the values above.','dbem'); ?>
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
<?php
|
140 |
echo $save_button;
|
141 |
?>
|
142 |
</table>
|
classes/bookings.php
CHANGED
@@ -51,7 +51,7 @@ class EM_Bookings extends EM_Object{
|
|
51 |
* @return boolean
|
52 |
*/
|
53 |
function add( $EM_Booking ){
|
54 |
-
global $wpdb;
|
55 |
if ( $this->get_available_seats() >= $EM_Booking->seats ) {
|
56 |
$EM_Booking->event_id = $this->event_id;
|
57 |
// checking whether the booker has already booked places
|
@@ -79,7 +79,11 @@ class EM_Bookings extends EM_Object{
|
|
79 |
if(!$email){
|
80 |
$this->feedback_message .= ' '.__('However, we were not able to send you an email.', 'dbem');
|
81 |
if( current_user_can('activate_plugins') ){
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
}
|
85 |
return true;
|
@@ -184,10 +188,16 @@ class EM_Bookings extends EM_Object{
|
|
184 |
|
185 |
//TODO offer subject changes
|
186 |
if( !$EM_Mailer->send(__('Reservation confirmed','dbem'),$booker_body, $EM_Booking->person->email) ){
|
|
|
|
|
|
|
187 |
return false;
|
188 |
}
|
189 |
if( !$EM_Mailer->send(__("New booking",'dbem'), $contact_body, $EM_Event->contact->user_email) && current_user_can('activate_plugins')){
|
190 |
-
$EM_Mailer->errors
|
|
|
|
|
|
|
191 |
return false;
|
192 |
}
|
193 |
|
51 |
* @return boolean
|
52 |
*/
|
53 |
function add( $EM_Booking ){
|
54 |
+
global $wpdb,$EM_Mailer;
|
55 |
if ( $this->get_available_seats() >= $EM_Booking->seats ) {
|
56 |
$EM_Booking->event_id = $this->event_id;
|
57 |
// checking whether the booker has already booked places
|
79 |
if(!$email){
|
80 |
$this->feedback_message .= ' '.__('However, we were not able to send you an email.', 'dbem');
|
81 |
if( current_user_can('activate_plugins') ){
|
82 |
+
if( is_array($this->errors) ){
|
83 |
+
$this->feedback_message .= '<br/><strong>Errors:</strong> (only admins see this message)<br/><ul><li>'. implode('</li><li>', $EM_Mailer->errors).'</li></ul>';
|
84 |
+
}else{
|
85 |
+
$this->feedback_message .= '<br/><strong>No errors returned by mailer</strong> (only admins see this message)';
|
86 |
+
}
|
87 |
}
|
88 |
}
|
89 |
return true;
|
188 |
|
189 |
//TODO offer subject changes
|
190 |
if( !$EM_Mailer->send(__('Reservation confirmed','dbem'),$booker_body, $EM_Booking->person->email) ){
|
191 |
+
foreach($EM_Mailer->errors as $error){
|
192 |
+
$this->errors[] = $error;
|
193 |
+
}
|
194 |
return false;
|
195 |
}
|
196 |
if( !$EM_Mailer->send(__("New booking",'dbem'), $contact_body, $EM_Event->contact->user_email) && current_user_can('activate_plugins')){
|
197 |
+
foreach($EM_Mailer->errors as $error){
|
198 |
+
$this->errors[] = $error;
|
199 |
+
}
|
200 |
+
$this->errors[] = 'Confirmation email could not be sent to contact person. Registrant should have gotten their email (only admin see this warning).';
|
201 |
return false;
|
202 |
}
|
203 |
|
classes/event.php
CHANGED
@@ -140,13 +140,21 @@ class EM_Event extends EM_Object{
|
|
140 |
//TODO make time handling less painful
|
141 |
$match = array();
|
142 |
if( preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_start_time'], $match ) ){
|
143 |
-
|
|
|
|
|
|
|
|
|
144 |
$this->start_time = $match[1].":".$match[2].":00";
|
145 |
}else{
|
146 |
$this->start_time = "00:00:00";
|
147 |
}
|
148 |
if( preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_end_time'], $match ) ){
|
149 |
-
|
|
|
|
|
|
|
|
|
150 |
$this->end_time = $match[1].":".$match[2].":00";
|
151 |
}else{
|
152 |
$this->end_time = $this->start_time;
|
140 |
//TODO make time handling less painful
|
141 |
$match = array();
|
142 |
if( preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_start_time'], $match ) ){
|
143 |
+
if( $match[3] == 'PM' && $match[1] != 12 ){
|
144 |
+
$match[1] = 12+$match[1];
|
145 |
+
}elseif( $match[3] == 'AM' && $match[1] == 12 ){
|
146 |
+
$match[1] = '00';
|
147 |
+
}
|
148 |
$this->start_time = $match[1].":".$match[2].":00";
|
149 |
}else{
|
150 |
$this->start_time = "00:00:00";
|
151 |
}
|
152 |
if( preg_match ( '/^([01]\d|2[0-3]):([0-5]\d)(AM|PM)?$/', $_POST['event_end_time'], $match ) ){
|
153 |
+
if( $match[3] == 'PM' && $match[1] != 12 ){
|
154 |
+
$match[1] = 12+$match[1];
|
155 |
+
}elseif( $match[3] == 'AM' && $match[1] == 12 ){
|
156 |
+
$match[1] = '00';
|
157 |
+
}
|
158 |
$this->end_time = $match[1].":".$match[2].":00";
|
159 |
}else{
|
160 |
$this->end_time = $this->start_time;
|
classes/events.php
CHANGED
@@ -41,18 +41,24 @@ class EM_Events extends EM_Object {
|
|
41 |
|
42 |
//Get the default conditions
|
43 |
$conditions = self::build_sql_conditions($args);
|
44 |
-
|
45 |
//Put it all together
|
46 |
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
//Create the SQL statement and execute
|
49 |
$sql = "
|
50 |
SELECT * FROM $events_table
|
51 |
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
52 |
$where
|
53 |
-
|
54 |
$limit $offset
|
55 |
-
";
|
56 |
|
57 |
$results = $wpdb->get_results($sql, ARRAY_A);
|
58 |
|
@@ -148,5 +154,20 @@ class EM_Events extends EM_Object {
|
|
148 |
$EM_Event_old = $EM_Event;
|
149 |
return $output;
|
150 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
?>
|
41 |
|
42 |
//Get the default conditions
|
43 |
$conditions = self::build_sql_conditions($args);
|
|
|
44 |
//Put it all together
|
45 |
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
46 |
|
47 |
+
//Get ordering instructions
|
48 |
+
$EM_Event = new EM_Event();
|
49 |
+
$accepted_fields = $EM_Event->get_fields(true);
|
50 |
+
$orderby = self::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order'));
|
51 |
+
//Now, build orderby sql
|
52 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
|
53 |
+
|
54 |
//Create the SQL statement and execute
|
55 |
$sql = "
|
56 |
SELECT * FROM $events_table
|
57 |
LEFT JOIN $locations_table ON {$locations_table}.location_id={$events_table}.location_id
|
58 |
$where
|
59 |
+
$orderby_sql
|
60 |
$limit $offset
|
61 |
+
";
|
62 |
|
63 |
$results = $wpdb->get_results($sql, ARRAY_A);
|
64 |
|
154 |
$EM_Event_old = $EM_Event;
|
155 |
return $output;
|
156 |
}
|
157 |
+
|
158 |
+
/*
|
159 |
+
* Adds custom Events search defaults
|
160 |
+
* @param array $args
|
161 |
+
* @return array
|
162 |
+
* @uses EM_Object#get_default_search()
|
163 |
+
*/
|
164 |
+
function get_default_search( $array = array() ){
|
165 |
+
$defaults = array(
|
166 |
+
'limit'=>get_option('dbem_events_default_limit'),
|
167 |
+
'orderby' => get_option('dbem_events_default_orderby'),
|
168 |
+
'order' => get_option('dbem_events_default_order')
|
169 |
+
);
|
170 |
+
return parent::get_default_search($defaults,$array);
|
171 |
+
}
|
172 |
}
|
173 |
?>
|
classes/location.php
CHANGED
@@ -199,12 +199,12 @@ class EM_Location extends EM_Object {
|
|
199 |
$match = true;
|
200 |
$replace = '';
|
201 |
switch( $result ){
|
202 |
-
case '#_MAP':
|
203 |
case '#_LOCATIONMAP':
|
204 |
$replace = EM_Map::get_single( array('location' => $this) );
|
205 |
break;
|
206 |
-
case '#_DESCRIPTION':
|
207 |
-
case '#_EXCERPT':
|
208 |
case '#_LOCATIONNOTES':
|
209 |
case '#_LOCATIONEXCERPT':
|
210 |
$replace = $this->description;
|
@@ -215,15 +215,16 @@ class EM_Location extends EM_Object {
|
|
215 |
break;
|
216 |
case '#_LOCATIONURL':
|
217 |
case '#_LOCATIONLINK':
|
|
|
218 |
$joiner = (stristr(EM_URI, "?")) ? "&" : "?";
|
219 |
$link = EM_URI.$joiner."location_id=".$this->id;
|
220 |
$replace = ($result == '#_LOCATIONURL') ? $link : '<a href="'.$link.'">'.$this->name.'</a>';
|
221 |
break;
|
222 |
-
case '#_PASTEVENTS':
|
223 |
case '#_LOCATIONPASTEVENTS':
|
224 |
-
case '#_NEXTEVENTS':
|
225 |
case '#_LOCATIONNEXTEVENTS':
|
226 |
-
case '#_ALLEVENTS':
|
227 |
case '#_LOCATIONALLEVENTS':
|
228 |
if ($result == '#_PASTEVENTS' || $result == '#_LOCATIONPASTEVENTS'){ $scope = 'past'; }
|
229 |
elseif ( $result == '#_NEXTEVENTS' || $result == '#_LOCATIONNEXTEVENTS' ){ $scope = 'future'; }
|
@@ -237,13 +238,13 @@ class EM_Location extends EM_Object {
|
|
237 |
$replace = get_option('dbem_location_no_events_message');
|
238 |
}
|
239 |
break;
|
240 |
-
case '#_IMAGE':
|
241 |
case '#_LOCATIONIMAGE':
|
242 |
if($this->image_url != ''){
|
243 |
$replace = "<img src='".$this->image_url."' alt='".$this->name."'/>";
|
244 |
}
|
245 |
break;
|
246 |
-
case '#_NAME':
|
247 |
case '#_LOCATIONNAME':
|
248 |
$replace = $this->name;
|
249 |
break;
|
@@ -266,8 +267,7 @@ class EM_Location extends EM_Object {
|
|
266 |
}
|
267 |
}
|
268 |
$name_filter = ($target == "html") ? 'dbem_general':'dbem_general_rss';
|
269 |
-
$location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name) , $location_string );
|
270 |
-
$location_string = str_replace('#_NAME', apply_filters($name_filter, $this->name) , $location_string );
|
271 |
return $location_string;
|
272 |
}
|
273 |
}
|
199 |
$match = true;
|
200 |
$replace = '';
|
201 |
switch( $result ){
|
202 |
+
case '#_MAP': //Depreciated
|
203 |
case '#_LOCATIONMAP':
|
204 |
$replace = EM_Map::get_single( array('location' => $this) );
|
205 |
break;
|
206 |
+
case '#_DESCRIPTION': //Depreciated
|
207 |
+
case '#_EXCERPT': //Depreciated
|
208 |
case '#_LOCATIONNOTES':
|
209 |
case '#_LOCATIONEXCERPT':
|
210 |
$replace = $this->description;
|
215 |
break;
|
216 |
case '#_LOCATIONURL':
|
217 |
case '#_LOCATIONLINK':
|
218 |
+
case '#_LOCATIONPAGEURL': //Depreciated
|
219 |
$joiner = (stristr(EM_URI, "?")) ? "&" : "?";
|
220 |
$link = EM_URI.$joiner."location_id=".$this->id;
|
221 |
$replace = ($result == '#_LOCATIONURL') ? $link : '<a href="'.$link.'">'.$this->name.'</a>';
|
222 |
break;
|
223 |
+
case '#_PASTEVENTS': //Depreciated
|
224 |
case '#_LOCATIONPASTEVENTS':
|
225 |
+
case '#_NEXTEVENTS': //Depreciated
|
226 |
case '#_LOCATIONNEXTEVENTS':
|
227 |
+
case '#_ALLEVENTS': //Depreciated
|
228 |
case '#_LOCATIONALLEVENTS':
|
229 |
if ($result == '#_PASTEVENTS' || $result == '#_LOCATIONPASTEVENTS'){ $scope = 'past'; }
|
230 |
elseif ( $result == '#_NEXTEVENTS' || $result == '#_LOCATIONNEXTEVENTS' ){ $scope = 'future'; }
|
238 |
$replace = get_option('dbem_location_no_events_message');
|
239 |
}
|
240 |
break;
|
241 |
+
case '#_IMAGE': //Depreciated
|
242 |
case '#_LOCATIONIMAGE':
|
243 |
if($this->image_url != ''){
|
244 |
$replace = "<img src='".$this->image_url."' alt='".$this->name."'/>";
|
245 |
}
|
246 |
break;
|
247 |
+
case '#_NAME': //Depreciated
|
248 |
case '#_LOCATIONNAME':
|
249 |
$replace = $this->name;
|
250 |
break;
|
267 |
}
|
268 |
}
|
269 |
$name_filter = ($target == "html") ? 'dbem_general':'dbem_general_rss';
|
270 |
+
$location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name) , $location_string ); //Depreciated
|
|
|
271 |
return $location_string;
|
272 |
}
|
273 |
}
|
classes/locations.php
CHANGED
@@ -42,13 +42,20 @@ class EM_Locations extends EM_Object {
|
|
42 |
$fields = $locations_table .".". implode(", {$locations_table}.", array_keys($EM_Location->fields));
|
43 |
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
//Create the SQL statement and execute
|
46 |
$sql = "
|
47 |
SELECT $fields FROM $locations_table
|
48 |
LEFT JOIN $events_table ON {$locations_table}.location_id={$events_table}.location_id
|
49 |
$where
|
50 |
GROUP BY location_id
|
51 |
-
|
52 |
$limit $offset
|
53 |
";
|
54 |
|
42 |
$fields = $locations_table .".". implode(", {$locations_table}.", array_keys($EM_Location->fields));
|
43 |
$where = ( count($conditions) > 0 ) ? " WHERE " . implode ( " AND ", $conditions ):'';
|
44 |
|
45 |
+
//Get ordering instructions
|
46 |
+
$accepted_fields = $EM_Location->get_fields(true);
|
47 |
+
$orderby = self::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order'));
|
48 |
+
//Now, build orderby sql
|
49 |
+
$orderby_sql = ( count($orderby) > 0 ) ? 'ORDER BY '. implode(', ', $orderby) : '';
|
50 |
+
|
51 |
+
|
52 |
//Create the SQL statement and execute
|
53 |
$sql = "
|
54 |
SELECT $fields FROM $locations_table
|
55 |
LEFT JOIN $events_table ON {$locations_table}.location_id={$events_table}.location_id
|
56 |
$where
|
57 |
GROUP BY location_id
|
58 |
+
$orderby_sql
|
59 |
$limit $offset
|
60 |
";
|
61 |
|
classes/object.php
CHANGED
@@ -18,7 +18,8 @@ class EM_Object {
|
|
18 |
$super_defaults = array(
|
19 |
'limit' => false,
|
20 |
'scope' => 'future',
|
21 |
-
'order' => 'ASC',
|
|
|
22 |
'format' => '',
|
23 |
'category' => 0,
|
24 |
'location' => 0,
|
@@ -61,6 +62,12 @@ class EM_Object {
|
|
61 |
unset($array['category']);
|
62 |
}
|
63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
//TODO validate search query array
|
65 |
//Clean the supplied array, so we only have allowed keys
|
66 |
foreach( array_keys($array) as $key){
|
@@ -83,11 +90,15 @@ class EM_Object {
|
|
83 |
}else{
|
84 |
$defaults['year'] = preg_match($year_regex, $defaults['year']) ? $defaults['year']:'';
|
85 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
//TODO should we clean format of malicious code over here and run everything thorugh this?
|
87 |
-
$defaults['order'] = ($defaults['order'] == "ASC") ? "ASC" : $super_defaults['order'];
|
88 |
$defaults['array'] = ($defaults['array'] == true);
|
89 |
$defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
|
90 |
-
$defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
|
91 |
$defaults['recurring'] = ($defaults['recurring'] == true);
|
92 |
return $defaults;
|
93 |
}
|
@@ -141,11 +152,17 @@ class EM_Object {
|
|
141 |
$date_start = date('Y-m-d', mktime(0,0,0,$date_month_start,1,$date_year_start));
|
142 |
$date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
|
143 |
$conditions[] = " ((event_start_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)) OR (event_end_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)))";
|
144 |
-
$
|
145 |
}
|
146 |
-
if( !isset($
|
147 |
//No date requested, so let's look at scope
|
148 |
-
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
//Scope can also be a specific date. However, if 'day', 'month', or 'year' are set, that will take precedence
|
150 |
$conditions [] = " ( (event_start_date = CAST('$scope' AS DATE)) OR (event_start_date <= CAST('$scope' AS DATE) AND event_end_date >= CAST('$scope' AS DATE)) )";
|
151 |
} else {
|
@@ -185,6 +202,37 @@ class EM_Object {
|
|
185 |
return $conditions;
|
186 |
}
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
/**
|
190 |
* Save an array into this class.
|
@@ -237,6 +285,21 @@ class EM_Object {
|
|
237 |
}
|
238 |
return $types;
|
239 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
/**
|
242 |
* Sanitize text before inserting into database
|
18 |
$super_defaults = array(
|
19 |
'limit' => false,
|
20 |
'scope' => 'future',
|
21 |
+
'order' => 'ASC', //hard-coded at end of this function
|
22 |
+
'orderby' => false,
|
23 |
'format' => '',
|
24 |
'category' => 0,
|
25 |
'location' => 0,
|
62 |
unset($array['category']);
|
63 |
}
|
64 |
}
|
65 |
+
//OrderBy - can be a comma-seperated array of field names to order by (field names of object, not db)
|
66 |
+
if( array_key_exists('orderby', $array)){
|
67 |
+
if( preg_match('/,/', $array['orderby']) ) {
|
68 |
+
$array['orderby'] = explode(',', $array['orderby']);
|
69 |
+
}
|
70 |
+
}
|
71 |
//TODO validate search query array
|
72 |
//Clean the supplied array, so we only have allowed keys
|
73 |
foreach( array_keys($array) as $key){
|
90 |
}else{
|
91 |
$defaults['year'] = preg_match($year_regex, $defaults['year']) ? $defaults['year']:'';
|
92 |
}
|
93 |
+
//Order - it's either ASC or DESC, so let's just validate
|
94 |
+
if( preg_match('/^([A-Za-z],?)+$/', $array['order']) ) {
|
95 |
+
$defaults['order'] = explode(',', $array['order']);
|
96 |
+
}elseif( !in_array($defaults['order'], array('ASC','DESC')) ){
|
97 |
+
$defaults['order'] = $super_defaults['order'];
|
98 |
+
}
|
99 |
//TODO should we clean format of malicious code over here and run everything thorugh this?
|
|
|
100 |
$defaults['array'] = ($defaults['array'] == true);
|
101 |
$defaults['limit'] = (is_numeric($defaults['limit'])) ? $defaults['limit']:$super_defaults['limit'];
|
|
|
102 |
$defaults['recurring'] = ($defaults['recurring'] == true);
|
103 |
return $defaults;
|
104 |
}
|
152 |
$date_start = date('Y-m-d', mktime(0,0,0,$date_month_start,1,$date_year_start));
|
153 |
$date_end = date('Y-m-t', mktime(0,0,0,$date_month_end,1,$date_year_end));
|
154 |
$conditions[] = " ((event_start_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)) OR (event_end_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)))";
|
155 |
+
$search_by_monthyear = true;
|
156 |
}
|
157 |
+
if( !isset($search_by_monthyear) ){
|
158 |
//No date requested, so let's look at scope
|
159 |
+
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2},[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
160 |
+
//This is an array, let's split it up
|
161 |
+
$dates = explode(',', $scope);
|
162 |
+
$date_start = $dates[0];
|
163 |
+
$date_end = $dates[1];
|
164 |
+
$conditions[] = " ((event_start_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)) OR (event_end_date BETWEEN CAST('$date_start' AS DATE) AND CAST('$date_end' AS DATE)))";
|
165 |
+
} elseif ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
|
166 |
//Scope can also be a specific date. However, if 'day', 'month', or 'year' are set, that will take precedence
|
167 |
$conditions [] = " ( (event_start_date = CAST('$scope' AS DATE)) OR (event_start_date <= CAST('$scope' AS DATE) AND event_end_date >= CAST('$scope' AS DATE)) )";
|
168 |
} else {
|
202 |
return $conditions;
|
203 |
}
|
204 |
|
205 |
+
function build_sql_orderby( $args, $accepted_fields, $default_order = 'ASC' ){
|
206 |
+
//First, ORDER BY
|
207 |
+
$orderby = array();
|
208 |
+
if(is_array($args['orderby'])){
|
209 |
+
//Clean orderby array so we only have accepted values
|
210 |
+
foreach( $args['orderby'] as $key => $field ){
|
211 |
+
if( !array_key_exists($field, $accepted_fields) ){
|
212 |
+
unset($args['orderby'][$key]);
|
213 |
+
}else{
|
214 |
+
$orderby[] = $accepted_fields[$field];
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}elseif( $args['orderby'] != '' && array_key_exists($args['orderby'], $accepted_fields) ){
|
218 |
+
$orderby[] = $accepted_fields[$args['orderby']];
|
219 |
+
}
|
220 |
+
//ORDER
|
221 |
+
//If order is an array, we'll go through the orderby array and match the order values (in order of array) with orderby values
|
222 |
+
//If orders don't match up, or it's not ASC/DESC, the default events search in EM settings/options page will be used.
|
223 |
+
foreach($orderby as $i => $field){
|
224 |
+
$orderby[$i] .= ' ';
|
225 |
+
if(is_array($args['order'])){
|
226 |
+
if( in_array($args['order'][$i], array('ASC','DESC')) ){
|
227 |
+
$orderby[$i] .= $args['order'][$i];
|
228 |
+
}else{
|
229 |
+
$orderby[$i] .= $default_order;
|
230 |
+
}
|
231 |
+
}else{
|
232 |
+
$orderby[$i] .= ( in_array($args['order'], array('ASC','DESC')) ) ? $args['order'] : $default_order;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
|
237 |
/**
|
238 |
* Save an array into this class.
|
285 |
}
|
286 |
return $types;
|
287 |
}
|
288 |
+
|
289 |
+
function get_fields( $inverted_array=false ){
|
290 |
+
if( is_array($this->fields) ){
|
291 |
+
$return = array();
|
292 |
+
foreach($this->fields as $fieldName => $fieldArray){
|
293 |
+
if($inverted_array){
|
294 |
+
$return[$fieldArray['name']] = $fieldName;
|
295 |
+
}else{
|
296 |
+
$return[$fieldName] = $fieldArray['name'];
|
297 |
+
}
|
298 |
+
}
|
299 |
+
return $return;
|
300 |
+
}
|
301 |
+
return array();
|
302 |
+
}
|
303 |
|
304 |
/**
|
305 |
* Sanitize text before inserting into database
|
events-manager.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Events Manager
|
4 |
-
Version: 3.0.
|
5 |
Plugin URI: http://davidebenini.it/wordpress-plugins/events-manager/
|
6 |
Description: Manage events specifying precise spatial data (Location, Town, Province, etc).
|
7 |
Author: Davide Benini, Marcus Sykes
|
@@ -86,7 +86,7 @@ if( is_admin() ){
|
|
86 |
|
87 |
|
88 |
// Setting constants
|
89 |
-
define('EM_VERSION', 3.
|
90 |
define('EM_CATEGORIES_TABLE', 'em_categories'); //TABLE NAME
|
91 |
define('EM_EVENTS_TABLE','em_events'); //TABLE NAME
|
92 |
define('EM_RECURRENCE_TABLE','dbem_recurrence'); //TABLE NAME
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Events Manager
|
4 |
+
Version: 3.0.5
|
5 |
Plugin URI: http://davidebenini.it/wordpress-plugins/events-manager/
|
6 |
Description: Manage events specifying precise spatial data (Location, Town, Province, etc).
|
7 |
Author: Davide Benini, Marcus Sykes
|
86 |
|
87 |
|
88 |
// Setting constants
|
89 |
+
define('EM_VERSION', 3.05); //self expanatory
|
90 |
define('EM_CATEGORIES_TABLE', 'em_categories'); //TABLE NAME
|
91 |
define('EM_EVENTS_TABLE','em_events'); //TABLE NAME
|
92 |
define('EM_RECURRENCE_TABLE','dbem_recurrence'); //TABLE NAME
|
events.php
CHANGED
@@ -16,7 +16,7 @@ function em_content($content) {
|
|
16 |
//TODO any loop should put the current $EM_Event etc. into the global variable
|
17 |
if ( isset( $_REQUEST['calendar_day'] ) && $_REQUEST['calendar_day'] != '' ) {
|
18 |
//Events for a specific day
|
19 |
-
$events = EM_Events::get( array('
|
20 |
if ( count($events) > 1 || get_option('dbem_display_calendar_day_single') == 1 ) {
|
21 |
$content = EM_Events::output($events);
|
22 |
} else {
|
@@ -37,7 +37,7 @@ function em_content($content) {
|
|
37 |
if (get_option ( 'dbem_display_calendar_in_events_page' )){
|
38 |
$content = EM_Calendar::get( array('full'=>1) );
|
39 |
}else{
|
40 |
-
$content = EM_Events::output
|
41 |
}
|
42 |
}
|
43 |
//If disable rewrite flag is on, then we need to add a placeholder here
|
16 |
//TODO any loop should put the current $EM_Event etc. into the global variable
|
17 |
if ( isset( $_REQUEST['calendar_day'] ) && $_REQUEST['calendar_day'] != '' ) {
|
18 |
//Events for a specific day
|
19 |
+
$events = EM_Events::get( array( 'scope'=>$_REQUEST['calendar_day'] ) );
|
20 |
if ( count($events) > 1 || get_option('dbem_display_calendar_day_single') == 1 ) {
|
21 |
$content = EM_Events::output($events);
|
22 |
} else {
|
37 |
if (get_option ( 'dbem_display_calendar_in_events_page' )){
|
38 |
$content = EM_Calendar::get( array('full'=>1) );
|
39 |
}else{
|
40 |
+
$content = EM_Events::output( array( 'scope' => $scope ) );
|
41 |
}
|
42 |
}
|
43 |
//If disable rewrite flag is on, then we need to add a placeholder here
|
install.php
CHANGED
@@ -221,7 +221,10 @@ function em_add_options() {
|
|
221 |
'dbem_rsvp_enabled'=> true,
|
222 |
'dbem_categories_enabled'=> true,
|
223 |
'dbem_disable_title_rewrites'=> false,
|
224 |
-
'dbem_title_html' => '<h2>#_PAGETITLE</h2>'
|
|
|
|
|
|
|
225 |
);
|
226 |
|
227 |
foreach($dbem_options as $key => $value){
|
221 |
'dbem_rsvp_enabled'=> true,
|
222 |
'dbem_categories_enabled'=> true,
|
223 |
'dbem_disable_title_rewrites'=> false,
|
224 |
+
'dbem_title_html' => '<h2>#_PAGETITLE</h2>',
|
225 |
+
'dbem_events_default_orderby' => 'start_date',
|
226 |
+
'dbem_events_default_order' => 'ASC',
|
227 |
+
'dbem_events_default_limit' => 10
|
228 |
);
|
229 |
|
230 |
foreach($dbem_options as $key => $value){
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://davidebenini.it
|
|
4 |
Tags: events, manager, calendar, gigs, concert, maps, geotagging, rsvp
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 3.0.1
|
7 |
-
Stable tag: 3.0.
|
8 |
|
9 |
Manage events and display them in your blog. Includes recurring events, location management, calendar, Google map integration, RSVP.
|
10 |
|
@@ -110,6 +110,15 @@ At this stage, Events Manager is only available in English and Italian. Yet, the
|
|
110 |
|
111 |
== Change Log ==
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
= 3.0.4 =
|
114 |
* Title rewriting workaround for themes where main menus are broken on events pages
|
115 |
* Added option to show lists on calendar days regardless of whether there is only one event on that day.
|
4 |
Tags: events, manager, calendar, gigs, concert, maps, geotagging, rsvp
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 3.0.1
|
7 |
+
Stable tag: 3.0.5
|
8 |
|
9 |
Manage events and display them in your blog. Includes recurring events, location management, calendar, Google map integration, RSVP.
|
10 |
|
110 |
|
111 |
== Change Log ==
|
112 |
|
113 |
+
= 3.0.5 =
|
114 |
+
* Fixed 12pm bug
|
115 |
+
* Re-added #_LOCATIONPAGEURL (although officially it's depreciated)
|
116 |
+
* Added default order by settings in options page
|
117 |
+
* Added default event list limits in options page
|
118 |
+
* Added orderby attribute for shortcode
|
119 |
+
* scope attribute now also allows searching between dates, e.g. "2010-01-01,2010-01-31"
|
120 |
+
* Fixed booking email reporting bug
|
121 |
+
|
122 |
= 3.0.4 =
|
123 |
* Title rewriting workaround for themes where main menus are broken on events pages
|
124 |
* Added option to show lists on calendar days regardless of whether there is only one event on that day.
|