Event List - Version 0.1.1

Version Description

(2012-09-24) =

  • fixed an issue with additional quotes after adding or editing an event
  • fixed saving of wrong date when adding a new event
  • fixed sorting of events when more events are at the same day
  • added validation of data before saving to database
Download this release

Release Info

Developer mibuthu
Plugin Icon 128x128 Event List
Version 0.1.1
Comparing to
See all releases

Code changes from version 0.1.0 to 0.1.1

Files changed (5) hide show
  1. event-list.php +2 -2
  2. js/admin.js +3 -3
  3. php/admin.php +31 -31
  4. php/db.php +71 -56
  5. readme.txt +9 -2
event-list.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Event List
4
  Plugin URI: http://wordpress.org/extend/plugins/event-list/
5
  Description: Manage your events and show them in a list view on your site.
6
- Version: 0.1.0
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
@@ -89,4 +89,4 @@ function on_el_widgets() {
89
  return register_widget( 'event_list_widget' );
90
  }
91
  */
92
- ?>
3
  Plugin Name: Event List
4
  Plugin URI: http://wordpress.org/extend/plugins/event-list/
5
  Description: Manage your events and show them in a list view on your site.
6
+ Version: 0.1.1
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
89
  return register_widget( 'event_list_widget' );
90
  }
91
  */
92
+ ?>
js/admin.js CHANGED
@@ -3,7 +3,7 @@ jQuery(document).ready(function( $ ) {
3
  // $(".datepicker").datepick({
4
  // dateFormat: 'yyyy-mm-dd',
5
  // onSelect: function(dates) {
6
- // if ($("#multi").is(':checked')) {
7
  // check the end day is greater
8
  // if ($("#start_date").val() > $("#end_date").val()) {
9
  // $("#end_date").val($("#start_date").val());
@@ -20,10 +20,10 @@ jQuery(document).ready(function( $ ) {
20
  $("#end_date_row").hide();
21
  }
22
  else {
23
- $("#multi").attr('checked', true);
24
  }
25
 
26
- $("#multi").click(function() {
27
  if (this.checked) {
28
  $("#end_date").val($("#start_date").val());
29
  $("#end_date_row").fadeIn();
3
  // $(".datepicker").datepick({
4
  // dateFormat: 'yyyy-mm-dd',
5
  // onSelect: function(dates) {
6
+ // if ($("#multiday").is('checked')) {
7
  // check the end day is greater
8
  // if ($("#start_date").val() > $("#end_date").val()) {
9
  // $("#end_date").val($("#start_date").val());
20
  $("#end_date_row").hide();
21
  }
22
  else {
23
+ $("#multiday").attr('checked', true);
24
  }
25
 
26
+ $("#multiday").click(function() {
27
  if (this.checked) {
28
  $("#end_date").val($("#start_date").val());
29
  $("#end_date_row").fadeIn();
php/admin.php CHANGED
@@ -15,12 +15,12 @@ class el_admin {
15
  <div class="wrap nosubsub" style="padding-bottom:15px">
16
  <div id="icon-edit-pages" class="icon32"><br /></div><h2>Event List</h2>
17
  </div>';
18
-
19
  // is there POST data to deal with?
20
- if ($_POST) {
21
- el_db::update_event($_POST);
22
  }
23
-
24
  $out .= '<div class="wrap">';
25
 
26
  if( !isset( $_GET['action'] ) ) {
@@ -43,7 +43,7 @@ class el_admin {
43
  $out .= '</div>';
44
  echo $out;
45
  }
46
-
47
  public static function show_new() {
48
  $out = '<div class="wrap">
49
  <div class="wrap nosubsub" style="padding-bottom:15px">
@@ -53,7 +53,7 @@ class el_admin {
53
  $out .= '</div>';
54
  echo $out;
55
  }
56
-
57
  private static function show_edit() {
58
  $out = '<div class="wrap">
59
  <div class="wrap nosubsub" style="padding-bottom:15px">
@@ -63,7 +63,7 @@ class el_admin {
63
  $out .= '</div>';
64
  echo $out;
65
  }
66
-
67
  public static function show_settings () {
68
  if (!current_user_can('manage_options')) {
69
  wp_die( __('You do not have sufficient permissions to access this page.') );
@@ -129,7 +129,7 @@ class el_admin {
129
  </div>';
130
  echo $out;
131
  }
132
-
133
  public static function show_about() {
134
  $out = '<div class="wrap">
135
  <div class="wrap nosubsub" style="padding-bottom:15px">
@@ -144,7 +144,7 @@ class el_admin {
144
  </div>';
145
  echo $out;
146
  }
147
-
148
  public static function embed_admin_js() {
149
  echo '<script type="text/javascript" src="'.EL_URL.'/js/admin.js"></script>';
150
  }
@@ -170,10 +170,10 @@ class el_admin {
170
  $out .= '<a href="?page=el_admin_new" class="button-primary" style="float:right;">New Event</a>
171
  <table class="widefat" style="margin-top:10px;">
172
  <thead>
173
- <tr><th class="event_date">Date</th><th class="event_location">Event</th><th class="event_details" colspan="2">Event Details</th></tr>
174
  </thead>';
175
 
176
- if ( !empty( $events ) ) {
177
  foreach ( $events as $event ) {
178
  $out .= '<tr><td class="event_date">';
179
  $out .= self::format_date( $event->start_date, $event->end_date).'<br />';
@@ -193,18 +193,18 @@ class el_admin {
193
  <td colspan="10" style="text-align:center;">No events found in this range.</td>
194
  </tr>';
195
  }
196
-
197
  $out .= "</table>";
198
  return $out;
199
  }
200
-
201
  private static function edit_event() {
202
  $copy = false;
203
  $new = false;
204
  if( isset( $_GET['id'] ) ) {
205
  // existing event
206
  $event = el_db::get_event( $_GET['id'] );
207
- if ( isset( $_GET['action'] ) && $_GET['action'] == 'copy' ) {
208
  // copy of existing event
209
  $start_date = date('Y-m-d');
210
  $end_date = date('Y-m-d');
@@ -230,7 +230,7 @@ class el_admin {
230
  $out .= '<table class="form-table">
231
  <tr>
232
  <th><label>Start Date (required)</label></th>
233
- <td><input type="text" class="text datepicker form-required" name="start_date" id="start_date" value="'.$start_date.'" /> <label><input type="checkbox" id="multi" /> Multiple Day Event</label></td>
234
  </tr>
235
  <tr id="end_date_row">
236
  <th><label>End Date</label></th>
@@ -275,7 +275,7 @@ class el_admin {
275
  $end_array = explode("-", $end_date);
276
  $end_date = mktime(0,0,0,$end_array[1],$end_array[2],$end_array[0]);
277
  $out = '';
278
-
279
  if ($start_date == $end_date) {
280
  if ($start_array[2] == "00") {
281
  $start_date = mktime(0,0,0,$start_array[1],15,$start_array[0]);
@@ -285,7 +285,7 @@ class el_admin {
285
  $out .= '<span style="white-space:nowrap;">' . date("M j, Y", $start_date) . "</span>";
286
  return $out;
287
  }
288
-
289
  if ($start_array[0] == $end_array[0]) {
290
  if ($start_array[1] == $end_array[1]) {
291
  $out .= '<span style="white-space:nowrap;">' . date("M j", $start_date) . "-" . date("j, Y", $end_date) . "</span>";
@@ -293,13 +293,13 @@ class el_admin {
293
  }
294
  $out .= '<span style="white-space:nowrap;">' . date("M j", $start_date) . "-" . date("M j, Y", $end_date) . "</span>";
295
  return $out;
296
-
297
  }
298
-
299
  $out .= '<span style="white-space:nowrap;">' . date("M j, Y", $start_date) . "-" . date("M j, Y", $end_date) . "</span>";
300
  return $out;
301
  }
302
-
303
  private static function create_tabs( $current = 'general' ) {
304
  $tabs = array( 'general' => 'General settings', 'comment_list' => 'Comment-list settings', 'comment_form' => 'Comment-form settings',
305
  'comment_form_html' => 'Comment-form html code', 'comment_html' => 'Comment html code' );
@@ -311,7 +311,7 @@ class el_admin {
311
  $out .= '</h3>';
312
  return $out;
313
  }
314
-
315
  // $desc_pos specifies where the descpription will be displayed.
316
  // available options: 'right' ... description will be displayed on the right side of the option (standard value)
317
  // 'newline' ... description will be displayed below the option
@@ -357,7 +357,7 @@ class el_admin {
357
  }
358
  return $out;
359
  }
360
-
361
  private static function show_checkbox( $name, $value, $caption ) {
362
  $out = '
363
  <label for="'.$name.'">
@@ -382,18 +382,18 @@ class el_admin {
382
  <textarea name="'.$name.'" id="'.$name.'" rows="20" class="large-text code">'.$value.'</textarea>';
383
  return $out;
384
  }
385
-
386
  // function to truncate and shorten html text
387
  private static function truncate( $maxLength, $html ) {
388
  $printedLength = 0;
389
  $position = 0;
390
  $tags = array();
391
-
392
  $out = '';
393
-
394
  while ($printedLength < $maxLength && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) {
395
  list($tag, $tagPosition) = $match[0];
396
-
397
  // Print text leading up to the tag.
398
  $str = substr($html, $position, $tagPosition - $position);
399
  if ($printedLength + strlen($str) > $maxLength) {
@@ -401,10 +401,10 @@ class el_admin {
401
  $printedLength = $maxLength;
402
  break;
403
  }
404
-
405
  $out .= $str;
406
  $printedLength += strlen($str);
407
-
408
  if ($tag[0] == '&') {
409
  // Handle the entity.
410
  $out .= $tag;
@@ -430,11 +430,11 @@ class el_admin {
430
  $tags[] = $tagName;
431
  }
432
  }
433
-
434
  // Continue after the tag.
435
  $position = $tagPosition + strlen($tag);
436
  }
437
-
438
  // Print any remaining text.
439
  if ($printedLength < $maxLength && $position < strlen($html)) {
440
  $out .= substr($html, $position, $maxLength - $printedLength);
@@ -450,4 +450,4 @@ class el_admin {
450
  return $out;
451
  }
452
  }
453
- ?>
15
  <div class="wrap nosubsub" style="padding-bottom:15px">
16
  <div id="icon-edit-pages" class="icon32"><br /></div><h2>Event List</h2>
17
  </div>';
18
+
19
  // is there POST data to deal with?
20
+ if( !empty( $_POST ) ) {
21
+ el_db::update_event( $_POST );
22
  }
23
+
24
  $out .= '<div class="wrap">';
25
 
26
  if( !isset( $_GET['action'] ) ) {
43
  $out .= '</div>';
44
  echo $out;
45
  }
46
+
47
  public static function show_new() {
48
  $out = '<div class="wrap">
49
  <div class="wrap nosubsub" style="padding-bottom:15px">
53
  $out .= '</div>';
54
  echo $out;
55
  }
56
+
57
  private static function show_edit() {
58
  $out = '<div class="wrap">
59
  <div class="wrap nosubsub" style="padding-bottom:15px">
63
  $out .= '</div>';
64
  echo $out;
65
  }
66
+
67
  public static function show_settings () {
68
  if (!current_user_can('manage_options')) {
69
  wp_die( __('You do not have sufficient permissions to access this page.') );
129
  </div>';
130
  echo $out;
131
  }
132
+
133
  public static function show_about() {
134
  $out = '<div class="wrap">
135
  <div class="wrap nosubsub" style="padding-bottom:15px">
144
  </div>';
145
  echo $out;
146
  }
147
+
148
  public static function embed_admin_js() {
149
  echo '<script type="text/javascript" src="'.EL_URL.'/js/admin.js"></script>';
150
  }
170
  $out .= '<a href="?page=el_admin_new" class="button-primary" style="float:right;">New Event</a>
171
  <table class="widefat" style="margin-top:10px;">
172
  <thead>
173
+ <tr><th class="event_date">Date</th><th class="event_location">Event</th><th class="event_details">Details</th><th class="event_buttons">Actions</tr>
174
  </thead>';
175
 
176
+ if ( !empty( $events ) ) {
177
  foreach ( $events as $event ) {
178
  $out .= '<tr><td class="event_date">';
179
  $out .= self::format_date( $event->start_date, $event->end_date).'<br />';
193
  <td colspan="10" style="text-align:center;">No events found in this range.</td>
194
  </tr>';
195
  }
196
+
197
  $out .= "</table>";
198
  return $out;
199
  }
200
+
201
  private static function edit_event() {
202
  $copy = false;
203
  $new = false;
204
  if( isset( $_GET['id'] ) ) {
205
  // existing event
206
  $event = el_db::get_event( $_GET['id'] );
207
+ if( isset( $_GET['action'] ) && $_GET['action'] == 'copy' ) {
208
  // copy of existing event
209
  $start_date = date('Y-m-d');
210
  $end_date = date('Y-m-d');
230
  $out .= '<table class="form-table">
231
  <tr>
232
  <th><label>Start Date (required)</label></th>
233
+ <td><input type="text" class="text datepicker form-required" name="start_date" id="start_date" value="'.$start_date.'" /> <label><input type="checkbox" name="multiday" id="multiday" value="1" /> Multiple Day Event</label></td>
234
  </tr>
235
  <tr id="end_date_row">
236
  <th><label>End Date</label></th>
275
  $end_array = explode("-", $end_date);
276
  $end_date = mktime(0,0,0,$end_array[1],$end_array[2],$end_array[0]);
277
  $out = '';
278
+
279
  if ($start_date == $end_date) {
280
  if ($start_array[2] == "00") {
281
  $start_date = mktime(0,0,0,$start_array[1],15,$start_array[0]);
285
  $out .= '<span style="white-space:nowrap;">' . date("M j, Y", $start_date) . "</span>";
286
  return $out;
287
  }
288
+
289
  if ($start_array[0] == $end_array[0]) {
290
  if ($start_array[1] == $end_array[1]) {
291
  $out .= '<span style="white-space:nowrap;">' . date("M j", $start_date) . "-" . date("j, Y", $end_date) . "</span>";
293
  }
294
  $out .= '<span style="white-space:nowrap;">' . date("M j", $start_date) . "-" . date("M j, Y", $end_date) . "</span>";
295
  return $out;
296
+
297
  }
298
+
299
  $out .= '<span style="white-space:nowrap;">' . date("M j, Y", $start_date) . "-" . date("M j, Y", $end_date) . "</span>";
300
  return $out;
301
  }
302
+
303
  private static function create_tabs( $current = 'general' ) {
304
  $tabs = array( 'general' => 'General settings', 'comment_list' => 'Comment-list settings', 'comment_form' => 'Comment-form settings',
305
  'comment_form_html' => 'Comment-form html code', 'comment_html' => 'Comment html code' );
311
  $out .= '</h3>';
312
  return $out;
313
  }
314
+
315
  // $desc_pos specifies where the descpription will be displayed.
316
  // available options: 'right' ... description will be displayed on the right side of the option (standard value)
317
  // 'newline' ... description will be displayed below the option
357
  }
358
  return $out;
359
  }
360
+
361
  private static function show_checkbox( $name, $value, $caption ) {
362
  $out = '
363
  <label for="'.$name.'">
382
  <textarea name="'.$name.'" id="'.$name.'" rows="20" class="large-text code">'.$value.'</textarea>';
383
  return $out;
384
  }
385
+
386
  // function to truncate and shorten html text
387
  private static function truncate( $maxLength, $html ) {
388
  $printedLength = 0;
389
  $position = 0;
390
  $tags = array();
391
+
392
  $out = '';
393
+
394
  while ($printedLength < $maxLength && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) {
395
  list($tag, $tagPosition) = $match[0];
396
+
397
  // Print text leading up to the tag.
398
  $str = substr($html, $position, $tagPosition - $position);
399
  if ($printedLength + strlen($str) > $maxLength) {
401
  $printedLength = $maxLength;
402
  break;
403
  }
404
+
405
  $out .= $str;
406
  $printedLength += strlen($str);
407
+
408
  if ($tag[0] == '&') {
409
  // Handle the entity.
410
  $out .= $tag;
430
  $tags[] = $tagName;
431
  }
432
  }
433
+
434
  // Continue after the tag.
435
  $position = $tagPosition + strlen($tag);
436
  }
437
+
438
  // Print any remaining text.
439
  if ($printedLength < $maxLength && $position < strlen($html)) {
440
  $out .= substr($html, $position, $maxLength - $printedLength);
450
  return $out;
451
  }
452
  }
453
+ ?>
php/db.php CHANGED
@@ -23,10 +23,10 @@ class el_db {
23
  history text,
24
  PRIMARY KEY (id) )
25
  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
26
-
27
  require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
28
  dbDelta( $sql );
29
-
30
  // el_options::set( 'el_db_version', self::VERSION );
31
  // }
32
  }
@@ -35,10 +35,10 @@ class el_db {
35
  global $wpdb;
36
  return $wpdb->prefix.self::TABLE_NAME;
37
  }
38
-
39
  public static function get_events( $date_range='all' ) {
40
  global $wpdb;
41
-
42
  // set date for data base query
43
  if( $date_range === 'all' ) {
44
  // get all events
@@ -54,16 +54,16 @@ class el_db {
54
  $range_start = $date_range.'-01-01';
55
  $range_end = $date_range.'-12-31';
56
  }
57
- $sql = 'SELECT * FROM '.self::table_name().' WHERE (end_date >= "'.$range_start.'" AND start_date <= "'.$range_end.'") ORDER BY start_date';
58
  return $wpdb->get_results( $sql );
59
  }
60
-
61
  public static function get_event( $id ) {
62
  global $wpdb;
63
  $sql = 'SELECT * FROM '.self::table_name().' WHERE id = '.$id.' LIMIT 1';
64
  return $wpdb->get_row( $sql );
65
  }
66
-
67
  public static function get_event_date( $event ) {
68
  global $wpdb;
69
  if( $event === 'first' ) {
@@ -85,20 +85,44 @@ class el_db {
85
  }
86
  return $date;
87
  }
88
-
89
  public static function update_event( $event_data ) {
90
  global $wpdb;
91
- self::remove_wp_magic_quotes();
92
- $current_user = wp_get_current_user();
93
-
94
- $sqldata = array( 'pub_user' => $current_user->ID,
95
- 'pub_date' => date( "Y-m-d H:i:s" ),
96
- 'start_date' => $event_data['start_date'],
97
- 'end_date' => $event_data['end_date'],
98
- 'time' => $event_data['time'],
99
- 'title' => $event_data['title'],
100
- 'location' => $event_data['location'],
101
- 'details' => $event_data['details'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  $sqltypes = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' );
103
 
104
  if( isset( $event_data['id'] ) ) { // update event
@@ -108,60 +132,51 @@ class el_db {
108
  $wpdb->insert( self::table_name(), $sqldata, $sqltypes );
109
  }
110
  }
111
-
112
  public static function delete_event( $event_id ) {
113
  global $wpdb;
114
- $wpdb->query( 'DELETE FROM '.self::table_name().' WHERE id = "'.$event_id.'"' );
115
- }
116
-
117
- public static function remove_wp_magic_quotes() {
118
- $_GET = stripslashes_deep($_GET);
119
- $_POST = stripslashes_deep($_POST);
120
- $_COOKIE = stripslashes_deep($_COOKIE);
121
- $_REQUEST = stripslashes_deep($_REQUEST);
122
  }
123
-
124
- public static function extract_date( $date, $format ) {
125
-
126
- if( $date == "0000-00-00" || !$date ) return false;
127
-
128
- $dateArray = explode( "-", $date );
129
- $date = mktime( 0, 0, 0, $dateArray[1] ,$dateArray[2] ,$dateArray[0] );
130
-
131
- // special for day set to "00"
132
- if( $dateArray[2] == "00" ) {
133
- if( $format == "d" ) {
134
- return "00";
135
- }
136
- else {
137
- $date = mktime(0,0,0,$dateArray[1],15,$dateArray[0]);
138
- }
139
  }
140
-
141
- return date( $format, $date );
 
 
142
  }
143
-
144
  public static function html_calendar_nav() {
145
  $first_year = self::get_event_date( 'first' );
146
  $last_year = self::get_event_date( 'last' );
147
-
148
- if ( is_admin() ) {
149
  $url = "?page=el_admin_main&";
150
  }
151
- else if ( get_option( 'permalink_structure' ) ) {
152
  $url = "?";
153
  }
154
  else {
155
  $existing = "?";
156
- foreach ( $_GET as $k => $v ) {
157
- if ( $k != "ytd" && $k != "event_id" ) $existing .= $k . "=" . $v . "&";
158
  }
159
  $url = $existing;
160
  }
161
-
162
  // Calendar Navigation
163
  $out = '<div id="eventlist_nav">';
164
- if ( isset( $_GET['ytd'] ) || isset( $_GET['event_id'] ) ) {
165
  $out .= '<a href="'.$url.'">Upcoming</a>';
166
  }
167
  else {
@@ -177,7 +192,7 @@ class el_db {
177
  }
178
  }
179
  $out .= '</div><br />';
180
-
181
  // Title (only if event details are viewed)
182
  if( isset( $_GET['event_id'] ) ) {
183
  $out .= '<h2>Event Information:</h2>';
@@ -185,4 +200,4 @@ class el_db {
185
  return $out;
186
  }
187
  }
188
- ?>
23
  history text,
24
  PRIMARY KEY (id) )
25
  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
26
+
27
  require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
28
  dbDelta( $sql );
29
+
30
  // el_options::set( 'el_db_version', self::VERSION );
31
  // }
32
  }
35
  global $wpdb;
36
  return $wpdb->prefix.self::TABLE_NAME;
37
  }
38
+
39
  public static function get_events( $date_range='all' ) {
40
  global $wpdb;
41
+
42
  // set date for data base query
43
  if( $date_range === 'all' ) {
44
  // get all events
54
  $range_start = $date_range.'-01-01';
55
  $range_end = $date_range.'-12-31';
56
  }
57
+ $sql = 'SELECT * FROM '.self::table_name().' WHERE (end_date >= "'.$range_start.'" AND start_date <= "'.$range_end.'") ORDER BY start_date ASC, time ASC, end_date ASC';
58
  return $wpdb->get_results( $sql );
59
  }
60
+
61
  public static function get_event( $id ) {
62
  global $wpdb;
63
  $sql = 'SELECT * FROM '.self::table_name().' WHERE id = '.$id.' LIMIT 1';
64
  return $wpdb->get_row( $sql );
65
  }
66
+
67
  public static function get_event_date( $event ) {
68
  global $wpdb;
69
  if( $event === 'first' ) {
85
  }
86
  return $date;
87
  }
88
+
89
  public static function update_event( $event_data ) {
90
  global $wpdb;
91
+ // prepare and validate sqldata
92
+ $sqldata = array();
93
+ //pub_user
94
+ $sqldata['pub_user'] = wp_get_current_user()->ID;
95
+ //pub_date
96
+ $sqldata['pub_date'] = date( "Y-m-d H:i:s" );
97
+ //start_date
98
+ if( !isset( $event_data['start_date']) ) { return false; }
99
+ $start_timestamp = 0;
100
+ $sqldata['start_date'] = self::extract_date( $event_data['start_date'], "Y-m-d", $start_timestamp );
101
+ if( false === $sqldata['start_date'] ) { return false; }
102
+ //end_date
103
+ if( !isset( $event_data['end_date']) ) { return false; }
104
+ if( isset( $event_data['multiday'] ) && "1" === $event_data['multiday'] ) {
105
+ $end_timestamp = 0;
106
+ $sqldata['end_date'] = self::extract_date( $event_data['end_date'], "Y-m-d", $end_timestamp );
107
+ if( false === $sqldata['end_date'] ) { $sqldata['end_date'] = $sqldata['start_date']; }
108
+ elseif( $end_timestamp < $start_timestamp ) { $sqldata['end_date'] = $sqldata['start_date']; }
109
+ }
110
+ else {
111
+ $sqldata['end_date'] = $sqldata['start_date'];
112
+ }
113
+ //time
114
+ if( !isset( $event_data['time'] ) ) { $sqldata['time'] = ''; }
115
+ else { $sqldata['time'] = $event_data['time']; }
116
+ //title
117
+ if( !isset( $event_data['title'] ) || $event_data['title'] === '' ) { return false; }
118
+ $sqldata['title'] = stripslashes( $event_data['title'] );
119
+ //location
120
+ if( !isset( $event_data['location'] ) ) { $sqldata['location'] = ''; }
121
+ else { $sqldata['location'] = stripslashes ($event_data['location'] ); }
122
+ //details
123
+ if( !isset( $event_data['details'] ) ) { $sqldata['details'] = ''; }
124
+ else { $sqldata['details'] = stripslashes ($event_data['details'] ); }
125
+ //types for sql data
126
  $sqltypes = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' );
127
 
128
  if( isset( $event_data['id'] ) ) { // update event
132
  $wpdb->insert( self::table_name(), $sqldata, $sqltypes );
133
  }
134
  }
135
+
136
  public static function delete_event( $event_id ) {
137
  global $wpdb;
138
+ $wpdb->query( $wpdb->prepare( 'DELETE FROM '.self::table_name().' WHERE id = "'.$event_id.'"' ) );
 
 
 
 
 
 
 
139
  }
140
+
141
+ public static function extract_date( $datestring, $ret_format, &$ret_timestamp=NULL, &$ret_datearray=NULL ) {
142
+ $date_array = date_parse( $datestring );
143
+ if( !empty( $date_array['errors']) ) {
144
+ return false;
145
+ }
146
+ if( false === checkdate( $date_array['month'], $date_array['day'], $date_array['year'] ) ) {
147
+ return false;
148
+ }
149
+ $timestamp = mktime( 0, 0, 0, $date_array['month'], $date_array['day'], $date_array['year'] );
150
+ if( isset( $ret_timestamp ) ) {
151
+ $ret_timestamp = $timestamp;
 
 
 
 
152
  }
153
+ if( isset( $ret_datearray ) ) {
154
+ $ret_datearray = $date_array;
155
+ }
156
+ return date( $ret_format, $timestamp );
157
  }
158
+
159
  public static function html_calendar_nav() {
160
  $first_year = self::get_event_date( 'first' );
161
  $last_year = self::get_event_date( 'last' );
162
+
163
+ if( is_admin() ) {
164
  $url = "?page=el_admin_main&";
165
  }
166
+ else if( get_option( 'permalink_structure' ) ) {
167
  $url = "?";
168
  }
169
  else {
170
  $existing = "?";
171
+ foreach( $_GET as $k => $v ) {
172
+ if( $k != "ytd" && $k != "event_id" ) $existing .= $k . "=" . $v . "&";
173
  }
174
  $url = $existing;
175
  }
176
+
177
  // Calendar Navigation
178
  $out = '<div id="eventlist_nav">';
179
+ if( isset( $_GET['ytd'] ) || isset( $_GET['event_id'] ) ) {
180
  $out .= '<a href="'.$url.'">Upcoming</a>';
181
  }
182
  else {
192
  }
193
  }
194
  $out .= '</div><br />';
195
+
196
  // Title (only if event details are viewed)
197
  if( isset( $_GET['event_id'] ) ) {
198
  $out .= '<h2>Event Information:</h2>';
200
  return $out;
201
  }
202
  }
203
+ ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: event, events, list, listview, calendar, schedule, shortcode, page, category, categories, admin, attribute, widget, sidebar
5
  Requires at least: 3.3
6
  Tested up to: 3.4.2
7
- Stable tag: 0.1.0
8
  Plugin URI: http://wordpress.org/extend/plugins/event-list
9
  Licence: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -23,7 +23,7 @@ There are also admin sites available to access the plugin-settings and to manage
23
  * a duplicate function for events
24
  * an possibility to view past events by year
25
 
26
- The event list can be placed in any page or post on your Wordpress site. Just include the following short code where you want the calendar to appear:
27
 
28
  ‘[event-list]’
29
 
@@ -53,6 +53,13 @@ not available yet
53
 
54
  == Changelog ==
55
 
 
 
 
 
 
 
 
56
  = 0.1.0 (2012-09-08) =
57
 
58
  * Initial release
4
  Tags: event, events, list, listview, calendar, schedule, shortcode, page, category, categories, admin, attribute, widget, sidebar
5
  Requires at least: 3.3
6
  Tested up to: 3.4.2
7
+ Stable tag: 0.1.1
8
  Plugin URI: http://wordpress.org/extend/plugins/event-list
9
  Licence: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
23
  * a duplicate function for events
24
  * an possibility to view past events by year
25
 
26
+ The event list can be placed in any page or post on your Wordpress site. Just include the following short code where you want the calendar to appear:
27
 
28
  ‘[event-list]’
29
 
53
 
54
  == Changelog ==
55
 
56
+ = 0.1.1 (2012-09-24) =
57
+
58
+ * fixed an issue with additional quotes after adding or editing an event
59
+ * fixed saving of wrong date when adding a new event
60
+ * fixed sorting of events when more events are at the same day
61
+ * added validation of data before saving to database
62
+
63
  = 0.1.0 (2012-09-08) =
64
 
65
  * Initial release