My Calendar - Version 1.10.6

Version Description

  • Revised template tags so the description tags are run through wpautop(), and added _raw versions which are not.
  • Fixed a bug in URL generation so that URLs with ports are correctly constructed.
  • Fixed a bug iin Print output which did not allow restriction to multiple categories
  • Added option to use {date} in previous/next navigation links to indicate what date set is being navigated to.
Download this release

Release Info

Developer joedolson
Plugin Icon 128x128 My Calendar
Version 1.10.6
Comparing to
See all releases

Code changes from version 1.9.8 to 1.10.6

mc-print.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .my-calendar-header, h3 img, .mc-toggle, .mc_edit_links, #mc-export,.longdesc, .shortdesc , .mc-print { display: none; }
2
+ table { border: 1px solid #ddd; border-collapse: collapse; margin: 0 auto;}
3
+ th { text-align:center; background: #f6f6f6; border: 1px solid #ddd; width: 130px; text-transform:uppercase; }
4
+ td { border: 1px solid #ddd; font-size: 12px; vertical-align: top;}
5
+ .details {border-bottom: 1px solid #ddd; color: #444; margin-bottom: 2px;}
6
+ .details a { display: none; }
7
+ h3 { font-size: 1.1em; margin: 2px 0 5px;}
8
+ p {margin: 2px 0; padding: 1px 0; line-height: 1.2; }
9
+ caption { font-size: 1.4em; padding: 3px 0; }
10
+ abbr { border: none;}
11
+ a { text-decoration: none; color: #f00}
12
+ .mc-date { font-weight: 700; font-size: 1.2em; padding: 2px 4px; line-height: 1; margin-left: 3px; float: right; background: #f9f9f9; position: relative; top: -1px; right: -1px; border-left: 1px solid #ddd; border-bottom: 1px solid #ddd}
13
+ .return { width: 910px; margin: 10px auto;}
mc-styles.css CHANGED
@@ -91,12 +91,19 @@ font-size: .9em;
91
  }
92
  .clonedInput {margin-bottom: 10px;border-bottom: 1px solid #ddd;}
93
  #my-calendar .apply {
94
- float: right;
95
- padding: 15px 15px 0;
96
- border-radius: 5px;
97
  box-shadow: 2px 2px 3px #aaa;
98
  background: #ffd;
99
- width: 200px;
 
 
 
 
 
 
 
100
  }
101
  #my-calendar .apply legend {background: #ffd;padding: 2px 0;}
102
  #my-calendar .apply .warning {
@@ -117,4 +124,6 @@ column-gap: 20px;
117
  }
118
  .event_image {float:right;}
119
  .event_image img {margin-top: 2px;}
120
- .mc_support {font-family:'Courier New';background:#fff;padding:5px;}
 
 
91
  }
92
  .clonedInput {margin-bottom: 10px;border-bottom: 1px solid #ddd;}
93
  #my-calendar .apply {
94
+ padding: 1px 5px 0;
95
+ margin: 0 -5px;
96
+ border-radius: 3px;
97
  box-shadow: 2px 2px 3px #aaa;
98
  background: #ffd;
99
+ }
100
+ #my-calendar .apply ul {
101
+ -moz-column-count: 3;
102
+ -moz-column-gap: 20px;
103
+ -webkit-column-count: 3;
104
+ -webkit-column-gap: 20px;
105
+ column-count: 3;
106
+ column-gap: 20px;
107
  }
108
  #my-calendar .apply legend {background: #ffd;padding: 2px 0;}
109
  #my-calendar .apply .warning {
124
  }
125
  .event_image {float:right;}
126
  .event_image img {margin-top: 2px;}
127
+ .mc_support {font-family:'Courier New';background:#fff;padding:5px;}
128
+ .jd-my-calendar .button-primary { position: absolute; top: 10px; right: 20px;}
129
+ .template-editor, .style-editor { width: 98%; }
my-calendar-behaviors.php CHANGED
@@ -88,7 +88,7 @@ my_calendar_check_db();
88
  <label for="calendar-javascript"><?php _e('Edit the jQuery scripts for My Calendar in Calendar format','my-calendar'); ?></label><br /><textarea id="calendar-javascript" name="mc_caljs" rows="8" cols="80"><?php echo $mc_caljs; ?></textarea>
89
  </p>
90
  <p>
91
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
92
  </p>
93
  </fieldset>
94
 
@@ -119,7 +119,7 @@ my_calendar_check_db();
119
  <label for="list-javascript"><?php _e('Edit the jQuery scripts for My Calendar in List format','my-calendar'); ?></label><br /><textarea id="list-javascript" name="mc_listjs" rows="8" cols="80"><?php echo $mc_listjs; ?></textarea>
120
  </p>
121
  <p>
122
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
123
  </p>
124
  </fieldset>
125
 
@@ -150,7 +150,7 @@ my_calendar_check_db();
150
  <label for="mini-javascript"><?php _e('Edit the jQuery scripts for My Calendar in Mini Calendar format','my-calendar'); ?></label><br /><textarea id="mini-javascript" name="mc_minijs" rows="8" cols="80"><?php echo $mc_minijs; ?></textarea>
151
  </p>
152
  <p>
153
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
154
  </p>
155
  </fieldset>
156
 
@@ -181,7 +181,7 @@ my_calendar_check_db();
181
  <label for="ajax-javascript"><?php _e('Edit the jQuery scripts for My Calendar AJAX navigation','my-calendar'); ?></label><br /><textarea id="ajax-javascript" name="mc_ajaxjs" rows="8" cols="80"><?php echo $mc_ajaxjs; ?></textarea>
182
  </p>
183
  <p>
184
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
185
  </p>
186
  </fieldset>
187
  <?php
@@ -201,7 +201,9 @@ my_calendar_check_db();
201
  echo '</div>';
202
  }
203
  ?>
204
-
 
 
205
  </form>
206
  </div>
207
  </div>
88
  <label for="calendar-javascript"><?php _e('Edit the jQuery scripts for My Calendar in Calendar format','my-calendar'); ?></label><br /><textarea id="calendar-javascript" name="mc_caljs" rows="8" cols="80"><?php echo $mc_caljs; ?></textarea>
89
  </p>
90
  <p>
91
+ <input type="submit" name="save" class="button-secondary" value="<?php _e('Save','my-calendar'); ?>" />
92
  </p>
93
  </fieldset>
94
 
119
  <label for="list-javascript"><?php _e('Edit the jQuery scripts for My Calendar in List format','my-calendar'); ?></label><br /><textarea id="list-javascript" name="mc_listjs" rows="8" cols="80"><?php echo $mc_listjs; ?></textarea>
120
  </p>
121
  <p>
122
+ <input type="submit" name="save" class="button-secondary" value="<?php _e('Save','my-calendar'); ?>" />
123
  </p>
124
  </fieldset>
125
 
150
  <label for="mini-javascript"><?php _e('Edit the jQuery scripts for My Calendar in Mini Calendar format','my-calendar'); ?></label><br /><textarea id="mini-javascript" name="mc_minijs" rows="8" cols="80"><?php echo $mc_minijs; ?></textarea>
151
  </p>
152
  <p>
153
+ <input type="submit" name="save" class="button-secondary" value="<?php _e('Save','my-calendar'); ?>" />
154
  </p>
155
  </fieldset>
156
 
181
  <label for="ajax-javascript"><?php _e('Edit the jQuery scripts for My Calendar AJAX navigation','my-calendar'); ?></label><br /><textarea id="ajax-javascript" name="mc_ajaxjs" rows="8" cols="80"><?php echo $mc_ajaxjs; ?></textarea>
182
  </p>
183
  <p>
184
+ <input type="submit" name="save" class="button-secondary" value="<?php _e('Save','my-calendar'); ?>" />
185
  </p>
186
  </fieldset>
187
  <?php
201
  echo '</div>';
202
  }
203
  ?>
204
+ <p>
205
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?>" />
206
+ </p>
207
  </form>
208
  </div>
209
  </div>
my-calendar-core.php CHANGED
@@ -16,8 +16,10 @@ function my_calendar_add_feed() {
16
  if ( get_option('mc_show_ical') == 'true' ) {
17
  add_feed( 'my-calendar-ics', 'my_calendar_ical' );
18
  }
19
-
20
- if ( get_option('mc_show_rss') == 'true' || get_option('mc_show_ical') == 'true' ) {
 
 
21
  add_action('generate_rewrite_rules', 'mc_rewrite_rules');
22
  $wp_rewrite->flush_rules();
23
  }
@@ -181,8 +183,8 @@ function my_calendar_write_js() {
181
  add_action( 'in_plugin_update_message-my-calendar/my-calendar.php', 'mc_plugin_update_message' );
182
  function mc_plugin_update_message() {
183
  global $mc_version;
184
- define('PLUGIN_README_URL', 'http://svn.wp-plugins.org/my-calendar/trunk/readme.txt');
185
- $response = wp_remote_get( PLUGIN_README_URL, array ('user-agent' => 'WordPress/My Calendar' . $mc_version . '; ' . get_bloginfo( 'url' ) ) );
186
  if ( ! is_wp_error( $response ) || is_array( $response ) ) {
187
  $data = $response['body'];
188
  $bits=explode('== Upgrade Notice ==',$data);
@@ -220,7 +222,9 @@ function mc_footer_js() {
220
 
221
  $list_js = stripcslashes( get_option( 'mc_listjs' ) );
222
  $cal_js = stripcslashes( get_option( 'mc_caljs' ) );
 
223
  $mini_js = stripcslashes( get_option( 'mc_minijs' ) );
 
224
  $ajax_js = stripcslashes( get_option( 'mc_ajaxjs' ) );
225
 
226
  $this_post = $wp_query->get_queried_object();
@@ -269,7 +273,11 @@ function mc_get_current_url() {
269
  if ( !empty($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
270
  $pageURL .= "://";
271
  if ( !empty( $_SERVER['SERVER_PORT']) && $_SERVER["SERVER_PORT"] != "80") {
272
- $pageURL .= $_SERVER["HTTP_HOST"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 
 
 
 
273
  } else {
274
  $pageURL .= $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
275
  }
@@ -336,20 +344,31 @@ function check_my_calendar() {
336
  if ( version_compare( $current_version, "1.9.0", "<" ) ) { $upgrade_path[] = "1.9.0"; }
337
  if ( version_compare( $current_version, "1.9.1", "<" ) ) { $upgrade_path[] = "1.9.1"; }
338
  if ( version_compare( $current_version, "1.9.3", "<" ) ) { $upgrade_path[] = "1.9.3"; }
 
339
  }
340
  // having determined upgrade path, assign new version number
341
  update_option( 'mc_version' , $mc_version );
342
  // Now we've determined what the current install is or isn't
343
  if ( $new_install == true ) {
344
- //add default settings
345
  mc_default_settings();
346
  $sql = "INSERT INTO " . MY_CALENDAR_CATEGORIES_TABLE . " SET category_id=1, category_name='General', category_color='#ffffff', category_icon='event.png'";
347
  $wpdb->query($sql);
348
- }
 
 
 
349
  // switch for different upgrade paths
350
  foreach ($upgrade_path as $upgrade) {
351
  switch ($upgrade) {
352
  // only upgrade db on most recent version
 
 
 
 
 
 
 
353
  case '1.9.3':
354
  update_option( 'mc_draggable', 1 );
355
  break;
@@ -1183,6 +1202,22 @@ $plugins_string
1183
  </form>";
1184
  }
1185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1186
  // Filters -- these are filters applied on My Calendar elements, which you can use to modify output.
1187
  // Base values are empty unless otherwise specified.
1188
  // The actual filters are in the places they belong, but these are here for documentation.
16
  if ( get_option('mc_show_ical') == 'true' ) {
17
  add_feed( 'my-calendar-ics', 'my_calendar_ical' );
18
  }
19
+ if ( get_option('mc_show_print') == 'true' ) {
20
+ add_feed( 'my-calendar-print', 'my_calendar_print' );
21
+ }
22
+ if ( get_option('mc_show_rss') == 'true' || get_option('mc_show_ical') == 'true' || get_option('mc_show_print') == true ) {
23
  add_action('generate_rewrite_rules', 'mc_rewrite_rules');
24
  $wp_rewrite->flush_rules();
25
  }
183
  add_action( 'in_plugin_update_message-my-calendar/my-calendar.php', 'mc_plugin_update_message' );
184
  function mc_plugin_update_message() {
185
  global $mc_version;
186
+ define('MC_PLUGIN_README_URL', 'http://svn.wp-plugins.org/my-calendar/trunk/readme.txt');
187
+ $response = wp_remote_get( MC_PLUGIN_README_URL, array ('user-agent' => 'WordPress/My Calendar' . $mc_version . '; ' . get_bloginfo( 'url' ) ) );
188
  if ( ! is_wp_error( $response ) || is_array( $response ) ) {
189
  $data = $response['body'];
190
  $bits=explode('== Upgrade Notice ==',$data);
222
 
223
  $list_js = stripcslashes( get_option( 'mc_listjs' ) );
224
  $cal_js = stripcslashes( get_option( 'mc_caljs' ) );
225
+ if ( get_option('mc_open_uri') == 'true') { $cal_js = str_replace('e.preventDefault();','',$cal_js); }
226
  $mini_js = stripcslashes( get_option( 'mc_minijs' ) );
227
+ if ( get_option('mc_open_day_uri') == 'true') { $mini_js = str_replace('e.preventDefault();','',$mini_js); }
228
  $ajax_js = stripcslashes( get_option( 'mc_ajaxjs' ) );
229
 
230
  $this_post = $wp_query->get_queried_object();
273
  if ( !empty($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
274
  $pageURL .= "://";
275
  if ( !empty( $_SERVER['SERVER_PORT']) && $_SERVER["SERVER_PORT"] != "80") {
276
+ if ( strpos( $_SERVER["HTTP_HOST"], $_SERVER["SERVER_PORT"] ) === FALSE ) {
277
+ $pageURL .= $_SERVER["HTTP_HOST"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
278
+ } else {
279
+ $pageURL .= $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
280
+ }
281
  } else {
282
  $pageURL .= $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
283
  }
344
  if ( version_compare( $current_version, "1.9.0", "<" ) ) { $upgrade_path[] = "1.9.0"; }
345
  if ( version_compare( $current_version, "1.9.1", "<" ) ) { $upgrade_path[] = "1.9.1"; }
346
  if ( version_compare( $current_version, "1.9.3", "<" ) ) { $upgrade_path[] = "1.9.3"; }
347
+ if ( version_compare( $current_version, "1.10.0", "<" ) ) { $upgrade_path[] = "1.10.0"; }
348
  }
349
  // having determined upgrade path, assign new version number
350
  update_option( 'mc_version' , $mc_version );
351
  // Now we've determined what the current install is or isn't
352
  if ( $new_install == true ) {
353
+ //add default settings
354
  mc_default_settings();
355
  $sql = "INSERT INTO " . MY_CALENDAR_CATEGORIES_TABLE . " SET category_id=1, category_name='General', category_color='#ffffff', category_icon='event.png'";
356
  $wpdb->query($sql);
357
+ } else {
358
+ // clear cache so updates are immediately available
359
+ mc_delete_cache();
360
+ }
361
  // switch for different upgrade paths
362
  foreach ($upgrade_path as $upgrade) {
363
  switch ($upgrade) {
364
  // only upgrade db on most recent version
365
+ case '1.10.0':
366
+ upgrade_db();
367
+ update_option( 'mc_caching_enabled','true' );
368
+ update_option( 'mc_week_caption',"The week's events" );
369
+ update_option( 'mc_show_print','false' );
370
+ update_option( 'mc_db_version','1.10.0' );
371
+ break;
372
  case '1.9.3':
373
  update_option( 'mc_draggable', 1 );
374
  break;
1202
  </form>";
1203
  }
1204
 
1205
+ // Actions -- these are action hooks attached to My Calendar events, usable to add additional actions during those events.
1206
+ // Actions are only performed after their respective My Calendar events have been successfully completed.
1207
+ // If there are errors in the My Calendar event, the action hook will not fire.
1208
+ /*
1209
+ mc_save_event
1210
+ Performed when an event is added, updated, or copied. Arguments are the action taken ('edit','copy','add') and
1211
+ and an array of the processed event data
1212
+
1213
+ mc_delete_event
1214
+ Performed when an event is deleted. Argument is the event_id.
1215
+
1216
+ mc_mass_delete_events
1217
+ Performed when events are deleted en masse. Argument is an array of event_ids deleted.
1218
+
1219
+ */
1220
+
1221
  // Filters -- these are filters applied on My Calendar elements, which you can use to modify output.
1222
  // Base values are empty unless otherwise specified.
1223
  // The actual filters are in the places they belong, but these are here for documentation.
my-calendar-event-manager.php CHANGED
@@ -82,6 +82,7 @@ function mc_convert( $object, $edit=false ) {
82
  'event_fifth_week'=>$object->event_fifth_week,
83
  'event_holiday'=>$object->event_holiday,
84
  'event_group_id'=>$object->event_group_id,
 
85
  // floats
86
  'event_longitude'=>$object->event_longitude,
87
  'event_latitude'=>$object->event_latitude,
@@ -122,17 +123,13 @@ $action = !empty($_POST['event_action']) ? $_POST['event_action'] : '';
122
  $event_id = !empty($_POST['event_id']) ? $_POST['event_id'] : '';
123
 
124
  if ( isset( $_GET['mode'] ) ) {
125
- if ( $_GET['mode'] == 'edit' ) {
126
- $action = "edit";
127
  $event_id = (int) $_GET['event_id'];
128
  }
129
- if ( $_GET['mode'] == 'copy' ) {
130
- $action = "copy";
131
- $event_id = (int) $_GET['event_id'];
132
- }
133
  }
134
 
135
- // Lets see if this is first run and create us a table if it is!
136
  check_my_calendar();
137
 
138
  if ( !empty($_POST['mass_delete']) ) {
@@ -141,14 +138,15 @@ if ( !empty($_POST['mass_delete']) ) {
141
  $events = $_POST['mass_delete'];
142
  $sql = 'DELETE FROM ' . my_calendar_table() . ' WHERE event_id IN (';
143
  $i=0;
 
144
  foreach ($events as $value) {
145
  $value = (int) $value;
146
  $ea = "SELECT event_author FROM " . my_calendar_table() . " WHERE event_id = $value";
147
  $result = $wpdb->get_results( $ea, ARRAY_A );
148
- $total = count($events);
149
-
150
  if ( mc_can_edit_event( $result[0]['event_author'] ) ) {
151
  $sql .= mysql_real_escape_string($value).',';
 
152
  $i++;
153
  }
154
  }
@@ -157,6 +155,8 @@ if ( !empty($_POST['mass_delete']) ) {
157
  $result = $wpdb->query($sql);
158
  if ( $result !== 0 && $result !== false ) {
159
  mc_delete_cache();
 
 
160
  $message = "<div class='updated'><p>".sprintf(__('%1$d events deleted successfully out of %2$d selected','my-calendar'), $i, $total )."</p></div>";
161
  } else {
162
  $message = "<div class='error'><p><strong>".__('Error','my-calendar').":</strong>".__('Your events have not been deleted. Please investigate.','my-calendar')."</p></div>";
@@ -193,8 +193,7 @@ if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'delete' ) {
193
  }
194
  }
195
 
196
-
197
- // Approve and show an Event ...by Roland
198
  if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'approve' ) {
199
  if ( current_user_can( get_option( 'mc_event_approve_perms' ) ) ) {
200
  $sql = "UPDATE " . my_calendar_table() . " SET event_approved = 1 WHERE event_id=" . (int) $_GET['event_id'];
@@ -244,7 +243,7 @@ if ( isset( $_POST['event_action'] ) ) {
244
  // mc_split_event creates the other newevents, my_calendar_save creates this one (only if proceed is true)
245
  $events = mc_split_event( (int) $_POST['event_id'], $mc_output[2]['event_begin'] );
246
  }
247
- $response = my_calendar_save($action,$mc_output,(int) $_POST['event_id']);
248
  }
249
  echo $response;
250
  }
@@ -302,7 +301,6 @@ if ( get_site_option('mc_multisite') == 2 ) {
302
  <?php
303
  }
304
 
305
-
306
  function my_calendar_save( $action,$output,$event_id=false ) {
307
  global $wpdb,$event_author;
308
  $proceed = $output[0];
@@ -312,7 +310,7 @@ global $wpdb,$event_author;
312
  $add = $output[2]; // add format here
313
  $formats = array(
314
  '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',
315
- '%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d',
316
  '%f','%f'
317
  );
318
  $result = $wpdb->insert(
@@ -323,7 +321,9 @@ global $wpdb,$event_author;
323
  if ( !$result ) {
324
  $message = "<div class='error'><p><strong>". __('Error','my-calendar') .":</strong> ". __('I\'m sorry! I couldn\'t add that event to the database.','my-calendar') . "</p></div>";
325
  } else {
326
- // Call mail function
 
 
327
  $sql = "SELECT * FROM ". my_calendar_table()." JOIN " . my_calendar_categories_table() . " ON (event_category=category_id) WHERE event_id = ".$wpdb->insert_id;
328
  $event = $wpdb->get_results($sql);
329
  $event_start_ts = strtotime( $event[0]->event_begin . ' ' . $event[0]->event_time );
@@ -339,7 +339,7 @@ global $wpdb,$event_author;
339
  $update = $output[2];
340
  $formats = array(
341
  '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',
342
- '%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d',
343
  '%f','%f'
344
  );
345
  //$wpdb->show_errors();
@@ -355,6 +355,8 @@ global $wpdb,$event_author;
355
  } else if ( $result === 0 ) {
356
  $message = "<div class='updated'><p>".__('Nothing was changed in that update.','my-calendar')."</p></div>";
357
  } else {
 
 
358
  $message = "<div class='updated'><p>".__('Event updated successfully','my-calendar')."</p></div>";
359
  mc_delete_cache();
360
  }
@@ -372,12 +374,14 @@ global $wpdb,$event_author;
372
  $instance = date('Y-m-d',strtotime($_POST['event_instance']) );
373
  mc_split_event( $event_id, $instance );
374
  }
375
- $sql = "DELETE FROM " . my_calendar_table() . " WHERE event_id='" . mysql_real_escape_string($event_id) . "'";
376
  $wpdb->query($sql);
377
- $sql = "SELECT event_id FROM " . my_calendar_table() . " WHERE event_id='" . mysql_real_escape_string($event_id) . "'";
378
  $result = $wpdb->get_results($sql);
379
  if ( empty($result) || empty($result[0]->event_id) ) {
380
- mc_delete_cache();
 
 
381
  return "<div class='updated'><p>".__('Event deleted successfully','my-calendar')."</p></div>";
382
  } else {
383
  $message = "<div class='error'><p><strong>".__('Error','my-calendar').":</strong>".__('Despite issuing a request to delete, the event still remains in the database. Please investigate.','my-calendar')."</p></div>";
@@ -394,7 +398,7 @@ global $wpdb,$users_entries;
394
  if ( intval($event_id) != $event_id ) {
395
  return "<div class=\"error\"><p>".__('Sorry! That\'s an invalid event key.','my-calendar')."</p></div>";
396
  } else {
397
- $data = $wpdb->get_results("SELECT * FROM " . my_calendar_table() . " WHERE event_id='" . mysql_real_escape_string($event_id) . "' LIMIT 1");
398
  if ( empty($data) ) {
399
  return "<div class=\"error\"><p>".__("Sorry! We couldn't find an event with that ID.",'my-calendar')."</p></div>";
400
  }
@@ -430,10 +434,10 @@ function jd_events_edit_form($mode='add', $event_id=false) {
430
  }
431
  echo ($message != '')?"<div class='error'><p>$message</p></div>":'';
432
  ?>
433
- <form id="my-calendar" method="post" action="<?php echo admin_url('admin.php?page=my-calendar'); ?>">
434
  <?php my_calendar_print_form_fields($data,$mode,$event_id); ?>
435
  <p>
436
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Event','my-calendar'); ?> &raquo;" />
437
  </p>
438
  </form>
439
 
@@ -454,7 +458,7 @@ function my_calendar_print_form_fields( $data,$mode,$event_id ) {
454
  $user = get_userdata($user_ID);
455
  $mc_input_administrator = (get_option('mc_input_options_administrators')=='true' && current_user_can('manage_options'))?true:false;
456
  $mc_input = get_option('mc_input_options');
457
- ?>
458
  <div>
459
  <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" />
460
  <input type="hidden" name="event_group_id" value="<?php if ( !empty( $data->event_group_id ) ) { echo $data->event_group_id; } else { mc_group_id(); } ?>" />
@@ -466,6 +470,9 @@ function my_calendar_print_form_fields( $data,$mode,$event_id ) {
466
  <div id="poststuff" class="jd-my-calendar">
467
  <div class="postbox">
468
  <div class="inside">
 
 
 
469
  <?php
470
  if ( !empty( $_GET['date'] ) && $data->event_recur != 'S' ) {
471
  $date = date_i18n( get_option('mc_date_format'),strtotime($_GET['date']) );
@@ -593,7 +600,10 @@ function my_calendar_print_form_fields( $data,$mode,$event_id ) {
593
  <div class="postbox">
594
  <div class="inside">
595
  <fieldset><legend><?php _e('Event Date and Time','my-calendar'); ?></legend>
596
- <p><em><?php _e('Enter the beginning and ending information for this occurrence of the event.','my-calendar'); ?></em></p>
 
 
 
597
  <div id="event1" class="clonedInput">
598
  <?php
599
  if ( !empty($data) ) {
@@ -1113,6 +1123,7 @@ if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) {
1113
  $event_image = esc_url_raw( $_POST['event_image'] );
1114
  $event_fifth_week = !empty($_POST['event_fifth_week']) ? 1 : 0;
1115
  $event_holiday = !empty($_POST['event_holiday']) ? 1 : 0;
 
1116
  // get group id: if multiple events submitted, auto group OR if event being submitted is already part of a group; otherwise zero.
1117
  $group_id_submitted = (int) $_POST['event_group_id'];
1118
  $event_group_id = ( ( is_array($_POST['event_begin']) && count($_POST['event_begin'])>1 ) || mc_event_is_grouped( $group_id_submitted) )?$group_id_submitted:0;
@@ -1248,6 +1259,7 @@ if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) {
1248
  'event_fifth_week'=>$event_fifth_week,
1249
  'event_holiday'=>$event_holiday,
1250
  'event_group_id'=>$event_group_id,
 
1251
  // floats
1252
  'event_longitude'=>$event_longitude,
1253
  'event_latitude'=>$event_latitude
@@ -1289,6 +1301,7 @@ if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) {
1289
  $users_entries->event_holiday = $event_holiday;
1290
  $users_entries->event_flagged = 0;
1291
  $users_entries->event_group_id = $event_group_id;
 
1292
  $proceed = false;
1293
  }
1294
  $data = array($proceed, $users_entries, $submit,$errors);
82
  'event_fifth_week'=>$object->event_fifth_week,
83
  'event_holiday'=>$object->event_holiday,
84
  'event_group_id'=>$object->event_group_id,
85
+ 'event_span'=>$object->event_span,
86
  // floats
87
  'event_longitude'=>$object->event_longitude,
88
  'event_latitude'=>$object->event_latitude,
123
  $event_id = !empty($_POST['event_id']) ? $_POST['event_id'] : '';
124
 
125
  if ( isset( $_GET['mode'] ) ) {
126
+ $action = $_GET['mode'];
127
+ if ( $action == 'edit' || $action == 'copy' ) {
128
  $event_id = (int) $_GET['event_id'];
129
  }
 
 
 
 
130
  }
131
 
132
+ // Check whether My Calendar is up to date and installed.
133
  check_my_calendar();
134
 
135
  if ( !empty($_POST['mass_delete']) ) {
138
  $events = $_POST['mass_delete'];
139
  $sql = 'DELETE FROM ' . my_calendar_table() . ' WHERE event_id IN (';
140
  $i=0;
141
+ $deleted = array();
142
  foreach ($events as $value) {
143
  $value = (int) $value;
144
  $ea = "SELECT event_author FROM " . my_calendar_table() . " WHERE event_id = $value";
145
  $result = $wpdb->get_results( $ea, ARRAY_A );
146
+ $total = count($events);
 
147
  if ( mc_can_edit_event( $result[0]['event_author'] ) ) {
148
  $sql .= mysql_real_escape_string($value).',';
149
+ $deleted[] = $value;
150
  $i++;
151
  }
152
  }
155
  $result = $wpdb->query($sql);
156
  if ( $result !== 0 && $result !== false ) {
157
  mc_delete_cache();
158
+ // argument: array of event IDs
159
+ do_action( 'mc_mass_delete_events', $deleted );
160
  $message = "<div class='updated'><p>".sprintf(__('%1$d events deleted successfully out of %2$d selected','my-calendar'), $i, $total )."</p></div>";
161
  } else {
162
  $message = "<div class='error'><p><strong>".__('Error','my-calendar').":</strong>".__('Your events have not been deleted. Please investigate.','my-calendar')."</p></div>";
193
  }
194
  }
195
 
196
+ // Approve and show an Event ...originally by Roland
 
197
  if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'approve' ) {
198
  if ( current_user_can( get_option( 'mc_event_approve_perms' ) ) ) {
199
  $sql = "UPDATE " . my_calendar_table() . " SET event_approved = 1 WHERE event_id=" . (int) $_GET['event_id'];
243
  // mc_split_event creates the other newevents, my_calendar_save creates this one (only if proceed is true)
244
  $events = mc_split_event( (int) $_POST['event_id'], $mc_output[2]['event_begin'] );
245
  }
246
+ $response = my_calendar_save($action,$mc_output,(int) $_POST['event_id']);
247
  }
248
  echo $response;
249
  }
301
  <?php
302
  }
303
 
 
304
  function my_calendar_save( $action,$output,$event_id=false ) {
305
  global $wpdb,$event_author;
306
  $proceed = $output[0];
310
  $add = $output[2]; // add format here
311
  $formats = array(
312
  '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',
313
+ '%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d',
314
  '%f','%f'
315
  );
316
  $result = $wpdb->insert(
321
  if ( !$result ) {
322
  $message = "<div class='error'><p><strong>". __('Error','my-calendar') .":</strong> ". __('I\'m sorry! I couldn\'t add that event to the database.','my-calendar') . "</p></div>";
323
  } else {
324
+ // do an action using the $action and processed event data
325
+ do_action( 'mc_save_event', $action, $add );
326
+ // Call mail function
327
  $sql = "SELECT * FROM ". my_calendar_table()." JOIN " . my_calendar_categories_table() . " ON (event_category=category_id) WHERE event_id = ".$wpdb->insert_id;
328
  $event = $wpdb->get_results($sql);
329
  $event_start_ts = strtotime( $event[0]->event_begin . ' ' . $event[0]->event_time );
339
  $update = $output[2];
340
  $formats = array(
341
  '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',
342
+ '%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d',
343
  '%f','%f'
344
  );
345
  //$wpdb->show_errors();
355
  } else if ( $result === 0 ) {
356
  $message = "<div class='updated'><p>".__('Nothing was changed in that update.','my-calendar')."</p></div>";
357
  } else {
358
+ // do an action using the $action and processed event data
359
+ do_action( 'mc_save_event', $action, $add );
360
  $message = "<div class='updated'><p>".__('Event updated successfully','my-calendar')."</p></div>";
361
  mc_delete_cache();
362
  }
374
  $instance = date('Y-m-d',strtotime($_POST['event_instance']) );
375
  mc_split_event( $event_id, $instance );
376
  }
377
+ $sql = "DELETE FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'";
378
  $wpdb->query($sql);
379
+ $sql = "SELECT event_id FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'";
380
  $result = $wpdb->get_results($sql);
381
  if ( empty($result) || empty($result[0]->event_id) ) {
382
+ mc_delete_cache();
383
+ // do an action using the event_id
384
+ do_action( 'mc_delete_event', $event_id );
385
  return "<div class='updated'><p>".__('Event deleted successfully','my-calendar')."</p></div>";
386
  } else {
387
  $message = "<div class='error'><p><strong>".__('Error','my-calendar').":</strong>".__('Despite issuing a request to delete, the event still remains in the database. Please investigate.','my-calendar')."</p></div>";
398
  if ( intval($event_id) != $event_id ) {
399
  return "<div class=\"error\"><p>".__('Sorry! That\'s an invalid event key.','my-calendar')."</p></div>";
400
  } else {
401
+ $data = $wpdb->get_results("SELECT * FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "' LIMIT 1");
402
  if ( empty($data) ) {
403
  return "<div class=\"error\"><p>".__("Sorry! We couldn't find an event with that ID.",'my-calendar')."</p></div>";
404
  }
434
  }
435
  echo ($message != '')?"<div class='error'><p>$message</p></div>":'';
436
  ?>
437
+ <form id="my-calendar" method="post" class="jd-my-calendar" action="<?php echo admin_url('admin.php?page=my-calendar'); ?>">
438
  <?php my_calendar_print_form_fields($data,$mode,$event_id); ?>
439
  <p>
440
+ <input type="submit" name="save" class="button-secondary" value="<?php _e('Save Event','my-calendar'); ?>" />
441
  </p>
442
  </form>
443
 
458
  $user = get_userdata($user_ID);
459
  $mc_input_administrator = (get_option('mc_input_options_administrators')=='true' && current_user_can('manage_options'))?true:false;
460
  $mc_input = get_option('mc_input_options');
461
+ ?>
462
  <div>
463
  <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" />
464
  <input type="hidden" name="event_group_id" value="<?php if ( !empty( $data->event_group_id ) ) { echo $data->event_group_id; } else { mc_group_id(); } ?>" />
470
  <div id="poststuff" class="jd-my-calendar">
471
  <div class="postbox">
472
  <div class="inside">
473
+ <p>
474
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Event','my-calendar'); ?>" />
475
+ </p>
476
  <?php
477
  if ( !empty( $_GET['date'] ) && $data->event_recur != 'S' ) {
478
  $date = date_i18n( get_option('mc_date_format'),strtotime($_GET['date']) );
600
  <div class="postbox">
601
  <div class="inside">
602
  <fieldset><legend><?php _e('Event Date and Time','my-calendar'); ?></legend>
603
+ <p>
604
+ <input type="checkbox" value="1" id="event_span" name="event_span"<?php if ( !empty($data) && $data->event_span == '1' ) { echo " checked=\"checked\""; } else if ( !empty($data) && $data->event_link_expires == '0' ) { echo ""; } else if ( get_option( 'mc_event_span' ) == 'true' ) { echo " checked=\"checked\""; } ?> /> <label for="event_span"><?php _e('This is a multi-day event.','my-calendar'); ?></label>
605
+ </p>
606
+ <p class="note"><em><?php _e('Enter the beginning and ending information for this occurrence of the event.','my-calendar'); ?> <?php _e('If this is a multi-day event, it will create a single event with multiple times/dates; otherwise this will create separate events for each occurrence.','my-calendar'); ?></em></p>
607
  <div id="event1" class="clonedInput">
608
  <?php
609
  if ( !empty($data) ) {
1123
  $event_image = esc_url_raw( $_POST['event_image'] );
1124
  $event_fifth_week = !empty($_POST['event_fifth_week']) ? 1 : 0;
1125
  $event_holiday = !empty($_POST['event_holiday']) ? 1 : 0;
1126
+ $event_span = !empty($_POST['event_span']) ? 1 : 0;
1127
  // get group id: if multiple events submitted, auto group OR if event being submitted is already part of a group; otherwise zero.
1128
  $group_id_submitted = (int) $_POST['event_group_id'];
1129
  $event_group_id = ( ( is_array($_POST['event_begin']) && count($_POST['event_begin'])>1 ) || mc_event_is_grouped( $group_id_submitted) )?$group_id_submitted:0;
1259
  'event_fifth_week'=>$event_fifth_week,
1260
  'event_holiday'=>$event_holiday,
1261
  'event_group_id'=>$event_group_id,
1262
+ 'event_span'=>$event_span,
1263
  // floats
1264
  'event_longitude'=>$event_longitude,
1265
  'event_latitude'=>$event_latitude
1301
  $users_entries->event_holiday = $event_holiday;
1302
  $users_entries->event_flagged = 0;
1303
  $users_entries->event_group_id = $event_group_id;
1304
+ $users_entries->event_span = $event_span;
1305
  $proceed = false;
1306
  }
1307
  $data = array($proceed, $users_entries, $submit,$errors);
my-calendar-events.php CHANGED
@@ -17,18 +17,25 @@ global $wpdb;
17
  $date = date('Y', time()+($offset)).'-'.date('m', time()+($offset)).'-'.date('d', time()+($offset));
18
  $arr_events = array();
19
  if (!empty($events)) {
 
20
  foreach( array_keys($events) as $key) {
21
  $event =& $events[$key];
22
- $event_occurrences = mc_increment_event( $event );
23
- $arr_events = array_merge( $arr_events, $event_occurrences );
24
- }
 
 
 
 
 
25
  }
26
  return $arr_events;
27
  }
28
 
29
- function mc_get_rss_events() {
30
  global $wpdb;
31
- $events = $wpdb->get_results("SELECT *,event_begin as event_original_begin FROM " . MY_CALENDAR_TABLE . " JOIN " . MY_CALENDAR_CATEGORIES_TABLE . " ON (event_category=category_id) ORDER BY event_added DESC LIMIT 0,15" );
 
32
  foreach ( array_keys($events) as $key ) {
33
  $event =& $events[$key];
34
  $output[] = $event;
@@ -321,12 +328,9 @@ function my_calendar_grab_events($y,$m,$d,$category=null,$ltype='',$lvalue='') {
321
  }
322
 
323
  function mc_check_cache($y, $m, $d, $category, $ltype, $lvalue) {
324
- $caching = true;
325
  if ( $caching == true ) {
326
  $cache = get_transient('mc_cache');
327
- //if ( $category == null ) { $category = 'all'; }
328
- //if ( $ltype == '' ) { $ltype = 'all'; }
329
- //if ( $lvalue == '' ) { $lvalue = 'all'; }
330
  $value = $cache[$y][$m][$d][$category][$ltype][$lvalue];
331
  if ( $value ) { return $value; } else { return false; }
332
  } else {
@@ -335,17 +339,24 @@ function mc_check_cache($y, $m, $d, $category, $ltype, $lvalue) {
335
  }
336
 
337
  function mc_create_cache($arr_events, $y, $m, $d, $category, $ltype, $lvalue) {
338
- $caching = true;
339
  if ( $arr_events == false ) { $arr_events = 'empty'; }
340
  if ( $caching == true ) {
341
- $cache = get_transient('mc_cache');
342
- //if ( $category == null ) { $category = 'all'; }
343
- //if ( $ltype == '' ) { $ltype = 'all'; }
344
- //if ( $lvalue == '' ) { $lvalue = 'all'; }
 
 
345
  $cache[$y][$m][$d][$category][$ltype][$lvalue] = $arr_events;
346
  set_transient( 'mc_cache',$cache, 60*60*48 );
347
  }
348
- //delete_option('mc_cache');
 
 
 
 
 
349
  }
350
 
351
  function mc_delete_cache() {
@@ -641,14 +652,15 @@ function mc_increment_event( $event, $instance='', $object=true ) {
641
 
642
  for ($realStart;$realStart<=$realFinish;$realStart++) { // jump forward to near present.
643
  $this_date = my_calendar_add_date($event_begin,($realStart*7),0,0);
644
- $this_end = my_calendar_add_date($event_end,($realStart*7),0,0);
645
  if ( my_calendar_date_comp( $event->event_begin,$this_date ) ) {
646
  ${$realStart} = clone($event);
647
  ${$realStart}->event_begin = $this_date;
648
  $this_event_start = strtotime("$this_date $event->event_time");
649
  $this_event_end = strtotime("$this_end $event->event_endtime");
 
650
  ${$realStart}->event_start_ts = $this_event_start;
651
- ${$realStart}->event_end_ts = $this_event_end;
652
  $arr_events[] = ${$realStart};
653
  }
654
  }
@@ -664,6 +676,7 @@ function mc_increment_event( $event, $instance='', $object=true ) {
664
  ${$realDays}->event_end = $this_end;
665
  $this_event_start = strtotime("$this_date $event->event_time");
666
  $this_event_end = strtotime("$this_end $event->event_endtime");
 
667
  ${$realDays}->event_start_ts = $this_event_start;
668
  ${$realDays}->event_end_ts = $this_event_end;
669
  $arr_events[] = ${$realDays};
@@ -691,6 +704,7 @@ function mc_increment_event( $event, $instance='', $object=true ) {
691
  ${$realStart}->event_end = $this_end;
692
  $this_event_start = strtotime("$this_date $event->event_time");
693
  $this_event_end = strtotime("$this_end $event->event_endtime");
 
694
  ${$realStart}->event_start_ts = $this_event_start;
695
  ${$realStart}->event_end_ts = $this_event_end;
696
  $arr_events[] = ${$realStart};
@@ -708,6 +722,7 @@ function mc_increment_event( $event, $instance='', $object=true ) {
708
  ${$realDays}->event_end = $this_end;
709
  $this_event_start = strtotime("$this_date $event->event_time");
710
  $this_event_end = strtotime("$this_end $event->event_endtime");
 
711
  ${$realDays}->event_start_ts = $this_event_start;
712
  ${$realDays}->event_end_ts = $this_event_end;
713
  $arr_events[] = ${$realDays};
@@ -736,6 +751,7 @@ function mc_increment_event( $event, $instance='', $object=true ) {
736
  ${$realStart}->event_begin = $this_date;
737
  $this_event_start = strtotime("$this_date $event->event_time");
738
  $this_event_end = strtotime("$this_end $event->event_endtime");
 
739
  ${$realStart}->event_start_ts = $this_event_start;
740
  ${$realStart}->event_end_ts = $this_event_end;
741
  $arr_events[] = ${$realStart};
@@ -753,6 +769,7 @@ function mc_increment_event( $event, $instance='', $object=true ) {
753
  ${$realDays}->event_end = $this_end;
754
  $this_event_start = strtotime("$this_date $event->event_time");
755
  $this_event_end = strtotime("$this_end $event->event_endtime");
 
756
  ${$realDays}->event_start_ts = $this_event_start;
757
  ${$realDays}->event_end_ts = $this_event_end;
758
  $arr_events[] = ${$realDays};
@@ -823,6 +840,7 @@ function mc_increment_event( $event, $instance='', $object=true ) {
823
  ${$realStart}->event_end = $end;
824
  $this_event_start = strtotime("$begin $event->event_time");
825
  $this_event_end = strtotime("$end $event->event_endtime");
 
826
  ${$realStart}->event_start_ts = $this_event_start;
827
  ${$realStart}->event_end_ts = $this_event_end;
828
  $arr_events[]=${$realStart};
@@ -879,6 +897,7 @@ function mc_increment_event( $event, $instance='', $object=true ) {
879
  ${$realDays}->event_end = $end;
880
  $this_event_start = strtotime("$begin $event->event_time");
881
  $this_event_end = strtotime("$end $event->event_endtime");
 
882
  ${$realDays}->event_start_ts = $this_event_start;
883
  ${$realDays}->event_end_ts = $this_event_end;
884
  $arr_events[]=${$realDays};
17
  $date = date('Y', time()+($offset)).'-'.date('m', time()+($offset)).'-'.date('d', time()+($offset));
18
  $arr_events = array();
19
  if (!empty($events)) {
20
+ $groups = array();
21
  foreach( array_keys($events) as $key) {
22
  $event =& $events[$key];
23
+ if ( !in_array( $event->event_group_id, $groups ) ) {
24
+ $event_occurrences = mc_increment_event( $event );
25
+ $arr_events = array_merge( $arr_events, $event_occurrences );
26
+ if ( $event->event_span == 1 ) {
27
+ //$groups[] = $event->event_group_id;
28
+ }
29
+ }
30
+ }
31
  }
32
  return $arr_events;
33
  }
34
 
35
+ function mc_get_rss_events( $cat_id=false) {
36
  global $wpdb;
37
+ if ( $cat_id ) { $cat = "WHERE event_category = $cat_id"; } else { $cat = ''; }
38
+ $events = $wpdb->get_results("SELECT *,event_begin as event_original_begin FROM " . MY_CALENDAR_TABLE . " JOIN " . MY_CALENDAR_CATEGORIES_TABLE . " ON (event_category=category_id) $cat ORDER BY event_added DESC LIMIT 0,15" );
39
  foreach ( array_keys($events) as $key ) {
40
  $event =& $events[$key];
41
  $output[] = $event;
328
  }
329
 
330
  function mc_check_cache($y, $m, $d, $category, $ltype, $lvalue) {
331
+ $caching = ( get_option('mc_caching_enabled') == 'true' )?true:false;
332
  if ( $caching == true ) {
333
  $cache = get_transient('mc_cache');
 
 
 
334
  $value = $cache[$y][$m][$d][$category][$ltype][$lvalue];
335
  if ( $value ) { return $value; } else { return false; }
336
  } else {
339
  }
340
 
341
  function mc_create_cache($arr_events, $y, $m, $d, $category, $ltype, $lvalue) {
342
+ $caching = ( get_option('mc_caching_enabled') == 'true' )?true:false;
343
  if ( $arr_events == false ) { $arr_events = 'empty'; }
344
  if ( $caching == true ) {
345
+ $before = memory_get_usage();
346
+ $ret = get_transient('mc_cache');
347
+ $after = memory_get_usage();
348
+ $mem_limit = mc_allocated_memory( $before, $after );
349
+ if ( $mem_limit ) { mc_delete_cache(); }
350
+ $cache = get_transient('mc_cache');
351
  $cache[$y][$m][$d][$category][$ltype][$lvalue] = $arr_events;
352
  set_transient( 'mc_cache',$cache, 60*60*48 );
353
  }
354
+ }
355
+
356
+ function mc_allocated_memory($before, $after) {
357
+ $size = ($after - $before);
358
+ // limits cache to occupying 2000 KB of PHP memory.
359
+ if ( $size/1024 > 2000 ) { return true; } else { return false; }
360
  }
361
 
362
  function mc_delete_cache() {
652
 
653
  for ($realStart;$realStart<=$realFinish;$realStart++) { // jump forward to near present.
654
  $this_date = my_calendar_add_date($event_begin,($realStart*7),0,0);
655
+ $this_end = my_calendar_add_date($event_end,($realStart*7),0,0);
656
  if ( my_calendar_date_comp( $event->event_begin,$this_date ) ) {
657
  ${$realStart} = clone($event);
658
  ${$realStart}->event_begin = $this_date;
659
  $this_event_start = strtotime("$this_date $event->event_time");
660
  $this_event_end = strtotime("$this_end $event->event_endtime");
661
+ ${$realStart}->event_end = date('Y-m-d',$this_event_end);
662
  ${$realStart}->event_start_ts = $this_event_start;
663
+ ${$realStart}->event_end_ts = $this_event_end;
664
  $arr_events[] = ${$realStart};
665
  }
666
  }
676
  ${$realDays}->event_end = $this_end;
677
  $this_event_start = strtotime("$this_date $event->event_time");
678
  $this_event_end = strtotime("$this_end $event->event_endtime");
679
+ ${$realStart}->event_end = date('Y-m-d',$this_event_end);
680
  ${$realDays}->event_start_ts = $this_event_start;
681
  ${$realDays}->event_end_ts = $this_event_end;
682
  $arr_events[] = ${$realDays};
704
  ${$realStart}->event_end = $this_end;
705
  $this_event_start = strtotime("$this_date $event->event_time");
706
  $this_event_end = strtotime("$this_end $event->event_endtime");
707
+ ${$realStart}->event_end = date('Y-m-d',$this_event_end);
708
  ${$realStart}->event_start_ts = $this_event_start;
709
  ${$realStart}->event_end_ts = $this_event_end;
710
  $arr_events[] = ${$realStart};
722
  ${$realDays}->event_end = $this_end;
723
  $this_event_start = strtotime("$this_date $event->event_time");
724
  $this_event_end = strtotime("$this_end $event->event_endtime");
725
+ ${$realStart}->event_end = date('Y-m-d',$this_event_end);
726
  ${$realDays}->event_start_ts = $this_event_start;
727
  ${$realDays}->event_end_ts = $this_event_end;
728
  $arr_events[] = ${$realDays};
751
  ${$realStart}->event_begin = $this_date;
752
  $this_event_start = strtotime("$this_date $event->event_time");
753
  $this_event_end = strtotime("$this_end $event->event_endtime");
754
+ ${$realStart}->event_end = date('Y-m-d',$this_event_end);
755
  ${$realStart}->event_start_ts = $this_event_start;
756
  ${$realStart}->event_end_ts = $this_event_end;
757
  $arr_events[] = ${$realStart};
769
  ${$realDays}->event_end = $this_end;
770
  $this_event_start = strtotime("$this_date $event->event_time");
771
  $this_event_end = strtotime("$this_end $event->event_endtime");
772
+ ${$realDays}->event_end = date('Y-m-d',$this_event_end);
773
  ${$realDays}->event_start_ts = $this_event_start;
774
  ${$realDays}->event_end_ts = $this_event_end;
775
  $arr_events[] = ${$realDays};
840
  ${$realStart}->event_end = $end;
841
  $this_event_start = strtotime("$begin $event->event_time");
842
  $this_event_end = strtotime("$end $event->event_endtime");
843
+ ${$realStart}->event_end = date('Y-m-d',$this_event_end);
844
  ${$realStart}->event_start_ts = $this_event_start;
845
  ${$realStart}->event_end_ts = $this_event_end;
846
  $arr_events[]=${$realStart};
897
  ${$realDays}->event_end = $end;
898
  $this_event_start = strtotime("$begin $event->event_time");
899
  $this_event_end = strtotime("$end $event->event_endtime");
900
+ ${$realDays}->event_end = date('Y-m-d',$this_event_end);
901
  ${$realDays}->event_start_ts = $this_event_start;
902
  ${$realDays}->event_end_ts = $this_event_end;
903
  $arr_events[]=${$realDays};
my-calendar-export.php CHANGED
@@ -39,6 +39,7 @@ DTSTAMP:{ical_start}
39
  ORGANIZER;CN={host}:MAILTO:{host_email}
40
  DTSTART:{ical_start}
41
  DTEND:{ical_end}
 
42
  URL;VALUE=URI:{link}
43
  DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{ical_desc}
44
  END:VEVENT
39
  ORGANIZER;CN={host}:MAILTO:{host_email}
40
  DTSTART:{ical_start}
41
  DTEND:{ical_end}
42
+ CATEGORIES:{category}
43
  URL;VALUE=URI:{link}
44
  DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{ical_desc}
45
  END:VEVENT
my-calendar-group-manager.php CHANGED
@@ -167,7 +167,7 @@ global $wpdb,$users_entries;
167
  if ( intval($event_id) != $event_id ) {
168
  return "<div class=\"error\"><p>".__('Sorry! That\'s an invalid event key.','my-calendar')."</p></div>";
169
  } else {
170
- $data = $wpdb->get_results("SELECT * FROM " . my_calendar_table() . " WHERE event_id='" . mysql_real_escape_string($event_id) . "' LIMIT 1");
171
  if ( empty($data) ) {
172
  return "<div class=\"error\"><p>".__("Sorry! We couldn't find an event with that ID.",'my-calendar')."</p></div>";
173
  }
@@ -210,7 +210,7 @@ function mc_group_form( $group_id, $type='break' ) {
210
  $query = "SELECT event_id, event_begin, event_time FROM ".my_calendar_table()." WHERE event_group_id = $group_id";
211
  $results = $wpdb->get_results($query);
212
  if ( $type == 'apply' ) {
213
- $warning = (!mc_compare_group_members($group_id))?"<p class='warning'>".__('<strong>NOTE:</strong> The group editable fields for the events in this group do not match','my-calendar')."</p>":'<p>'.__('The group editable fields in for the events in this group match.','my-calendar').'</p>';
214
  } else {
215
  $warning = '';
216
  }
@@ -224,9 +224,9 @@ function mc_group_form( $group_id, $type='break' ) {
224
  $group .= "<ul>";
225
  $checked = ( $type=='apply' )?' checked="checked"':'';
226
  foreach ( $results as $result ) {
227
- $date = date_i18n( get_option('mc_date_format'), strtotime( $result->event_begin ) );
228
- $time = date_i18n( get_option('mc_time_format'), strtotime( $result->event_time ) );
229
- $group .= "<li><input type='checkbox' name='$type"."[]' value='$result->event_id' id='$type$result->event_id'$checked /> <label for='break$result->event_id'><a href='#event$result->event_id'>#$result->event_id</a>: $date, $time</label></li>\n";
230
  }
231
  $group .= "<li><input type='checkbox' class='selectall' id='$type'$checked /> <label for='$type'><b>".__('Check/Uncheck all','my-calendar')."</b></label></li>\n</ul>";
232
  $group .= ($type == 'apply')?"</fieldset>":'';
@@ -257,7 +257,7 @@ function jd_groups_edit_form( $mode='edit', $event_id=false, $group_id=false ) {
257
  <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-groups&amp;mode=edit&amp;event_id=$event_id&amp;group_id=$group_id"); ?>">
258
  <?php my_calendar_print_group_fields($data,$mode,$event_id, $group_id); ?>
259
  <p>
260
- <input type="submit" name="save" class="button-primary" value="<?php _e('Edit Event Group','my-calendar'); ?> &raquo;" />
261
  </p>
262
  </form>
263
 
@@ -282,20 +282,28 @@ function my_calendar_print_group_fields( $data,$mode,$event_id,$group_id='' ) {
282
  <div id="poststuff" class="jd-my-calendar">
283
  <div class="postbox">
284
  <div class="inside">
 
 
 
285
  <fieldset>
286
  <legend><?php _e('Enter your Event Information','my-calendar'); ?></legend>
 
 
 
287
  <?php
288
  $apply = mc_group_form( $group_id, 'apply' );
289
  echo $apply;
290
- ?>
 
291
  <p>
292
- <label for="event_title"><?php _e('Event Title','my-calendar'); ?><span><?php _e('(required)','my-calendar'); ?></span></label> <input type="text" id="event_title" name="event_title" class="input" size="60" value="<?php if ( !empty($data) ) echo stripslashes(esc_attr($data->event_title)); ?>" />
293
  </p>
 
294
  <?php if ($mc_input['event_desc'] == 'on' || $mc_input_administrator ) { ?>
295
  <p id="group_description">
296
- <?php if ( !empty($data) ) { $description = stripslashes(esc_attr($data->event_desc)); } else { $description = ''; } ?>
297
- <label for="content"><?php _e('Event Description (<abbr title="hypertext markup language">HTML</abbr> allowed)','my-calendar'); ?></label><br /><?php if ( $mc_input['event_use_editor'] == 'on' ) { the_editor( $description ); } else { ?><textarea id="content" name="content" class="event_desc" rows="5" cols="80"><?php echo $description; ?></textarea><?php if ( $mc_input['event_use_editor'] == 'on' ) { ?></div><?php } } ?>
298
- </p>
299
  <?php } ?>
300
  <?php
301
  // If the editor is enabled, shouldn't display the image uploader.
@@ -513,6 +521,7 @@ if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) {
513
  $location_preset = !empty($_POST['location_preset']) ? $_POST['location_preset'] : '';
514
  $event_open = !empty($_POST['event_open']) ? $_POST['event_open'] : '2';
515
  $event_image = esc_url_raw( $_POST['event_image'] );
 
516
  // set location
517
  if ($location_preset != 'none') {
518
  $sql = "SELECT * FROM " . my_calendar_locations_table() . " WHERE location_id = $location_preset";
@@ -585,6 +594,7 @@ if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) {
585
  'event_zoom'=>$event_zoom,
586
  'event_open'=>$event_open,
587
  'event_host'=>$host,
 
588
  // floats
589
  'event_longitude'=>$event_longitude,
590
  'event_latitude'=>$event_latitude
@@ -613,6 +623,7 @@ if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) {
613
  $users_entries->event_open = $event_open;
614
  $users_entries->event_short = $short;
615
  $users_entries->event_image = $event_image;
 
616
  $proceed = false;
617
  }
618
  $data = array($proceed, $users_entries, $submit,$errors);
167
  if ( intval($event_id) != $event_id ) {
168
  return "<div class=\"error\"><p>".__('Sorry! That\'s an invalid event key.','my-calendar')."</p></div>";
169
  } else {
170
+ $data = $wpdb->get_results("SELECT * FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "' LIMIT 1");
171
  if ( empty($data) ) {
172
  return "<div class=\"error\"><p>".__("Sorry! We couldn't find an event with that ID.",'my-calendar')."</p></div>";
173
  }
210
  $query = "SELECT event_id, event_begin, event_time FROM ".my_calendar_table()." WHERE event_group_id = $group_id";
211
  $results = $wpdb->get_results($query);
212
  if ( $type == 'apply' ) {
213
+ $warning = (!mc_compare_group_members($group_id))?"<p class='warning'>".__('<strong>NOTE:</strong> The group editable fields for the events in this group do not match','my-calendar')."</p>":'<p>'.__('The group editable fields for the events in this group match.','my-calendar').'</p>';
214
  } else {
215
  $warning = '';
216
  }
224
  $group .= "<ul>";
225
  $checked = ( $type=='apply' )?' checked="checked"':'';
226
  foreach ( $results as $result ) {
227
+ $date = date_i18n( 'D, j M, Y', strtotime( $result->event_begin ) );
228
+ $time = date_i18n( 'g:i a', strtotime( $result->event_time ) );
229
+ $group .= "<li><input type='checkbox' name='$type"."[]' value='$result->event_id' id='$type$result->event_id'$checked /> <label for='break$result->event_id'><a href='#event$result->event_id'>#$result->event_id</a>: $date; $time</label></li>\n";
230
  }
231
  $group .= "<li><input type='checkbox' class='selectall' id='$type'$checked /> <label for='$type'><b>".__('Check/Uncheck all','my-calendar')."</b></label></li>\n</ul>";
232
  $group .= ($type == 'apply')?"</fieldset>":'';
257
  <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-groups&amp;mode=edit&amp;event_id=$event_id&amp;group_id=$group_id"); ?>">
258
  <?php my_calendar_print_group_fields($data,$mode,$event_id, $group_id); ?>
259
  <p>
260
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Edit Event Group','my-calendar'); ?>" />
261
  </p>
262
  </form>
263
 
282
  <div id="poststuff" class="jd-my-calendar">
283
  <div class="postbox">
284
  <div class="inside">
285
+ <p>
286
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Edit Event Group','my-calendar'); ?>" />
287
+ </p>
288
  <fieldset>
289
  <legend><?php _e('Enter your Event Information','my-calendar'); ?></legend>
290
+ <p>
291
+ <label for="event_title"><?php _e('Event Title','my-calendar'); ?><span><?php _e('(required)','my-calendar'); ?></span></label> <input type="text" id="event_title" name="event_title" class="input" size="60" value="<?php if ( !empty($data) ) echo stripslashes(esc_attr($data->event_title)); ?>" />
292
+ </p>
293
  <?php
294
  $apply = mc_group_form( $group_id, 'apply' );
295
  echo $apply;
296
+ ?>
297
+ <?php if ( $data->event_repeats == 0 && $data->event_recur == 'S' ) { ?>
298
  <p>
299
+ <input type="checkbox" value="1" id="event_span" name="event_span"<?php if ( !empty($data) && $data->event_span == '1' ) { echo " checked=\"checked\""; } else if ( !empty($data) && $data->event_link_expires == '0' ) { echo ""; } else if ( get_option( 'mc_event_span' ) == 'true' ) { echo " checked=\"checked\""; } ?> /> <label for="event_span"><?php _e('Selected dates are a single multi-day event.','my-calendar'); ?></label>
300
  </p>
301
+ <?php } ?>
302
  <?php if ($mc_input['event_desc'] == 'on' || $mc_input_administrator ) { ?>
303
  <p id="group_description">
304
+ <?php if ( !empty($data) ) { $description = $data->event_desc; } else { $description = ''; } ?>
305
+ <label for="content"><?php _e('Event Description (<abbr title="hypertext markup language">HTML</abbr> allowed)','my-calendar'); ?></label><br /><?php if ( $mc_input['event_use_editor'] == 'on' ) { the_editor( stripslashes($description) ); } else { ?><textarea id="content" name="content" class="event_desc" rows="5" cols="80"><?php echo stripslashes(esc_attr($description)); ?></textarea><?php if ( $mc_input['event_use_editor'] == 'on' ) { ?></div><?php } } ?>
306
+ </p>
307
  <?php } ?>
308
  <?php
309
  // If the editor is enabled, shouldn't display the image uploader.
521
  $location_preset = !empty($_POST['location_preset']) ? $_POST['location_preset'] : '';
522
  $event_open = !empty($_POST['event_open']) ? $_POST['event_open'] : '2';
523
  $event_image = esc_url_raw( $_POST['event_image'] );
524
+ $event_span = !empty($_POST['event_span']) ? 1 : 0;
525
  // set location
526
  if ($location_preset != 'none') {
527
  $sql = "SELECT * FROM " . my_calendar_locations_table() . " WHERE location_id = $location_preset";
594
  'event_zoom'=>$event_zoom,
595
  'event_open'=>$event_open,
596
  'event_host'=>$host,
597
+ 'event_span'=>$event_span,
598
  // floats
599
  'event_longitude'=>$event_longitude,
600
  'event_latitude'=>$event_latitude
623
  $users_entries->event_open = $event_open;
624
  $users_entries->event_short = $short;
625
  $users_entries->event_image = $event_image;
626
+ $users_entries->event_span = $event_span;
627
  $proceed = false;
628
  }
629
  $data = array($proceed, $users_entries, $submit,$errors);
my-calendar-help.php CHANGED
@@ -120,6 +120,12 @@ global $wp_plugin_dir;
120
  <dt><code>{endtime}</code></dt>
121
  <dd><?php _e('Displays the time at which the event ends.','my-calendar'); ?></dd>
122
 
 
 
 
 
 
 
123
  <dt><code>{author}</code></dt>
124
  <dd><?php _e('Displays the WordPress author who posted the event.','my-calendar'); ?></dd>
125
 
@@ -129,11 +135,11 @@ global $wp_plugin_dir;
129
  <dt><code>{host_email}</code></dt>
130
  <dd><?php _e('Displays the email address of the person assigned as host for the event.','my-calendar'); ?></dd>
131
 
132
- <dt><code>{shortdesc}</code></dt>
133
- <dd><?php _e('Displays the short version of the event description.','my-calendar'); ?></dd>
134
 
135
- <dt><code>{description}</code></dt>
136
- <dd><?php _e('Displays the description of the event.','my-calendar'); ?></dd>
137
 
138
  <dt><code>{image}</code></dt>
139
  <dd><?php _e('Image associated with the event.','my-calendar'); ?></dd>
120
  <dt><code>{endtime}</code></dt>
121
  <dd><?php _e('Displays the time at which the event ends.','my-calendar'); ?></dd>
122
 
123
+ <dt><code>{daterange}</code></dt>
124
+ <dd><?php _e('Displays the beginning date to the end date for events. Does not show end date if same as start date.','my-calendar'); ?></dd>
125
+
126
+ <dt><code>{multidate}</code></dt>
127
+ <dd><?php _e('For multi-day events displays an unordered list of dates and times for events in this group. Otherwise, beginning date/time.','my-calendar'); ?></dd>
128
+
129
  <dt><code>{author}</code></dt>
130
  <dd><?php _e('Displays the WordPress author who posted the event.','my-calendar'); ?></dd>
131
 
135
  <dt><code>{host_email}</code></dt>
136
  <dd><?php _e('Displays the email address of the person assigned as host for the event.','my-calendar'); ?></dd>
137
 
138
+ <dt><code>{shortdesc}</code>/<code>{shortdesc_raw}</code></dt>
139
+ <dd><?php _e('Displays the short version of the event description./Displays short description without converting paragraphs.','my-calendar'); ?></dd>
140
 
141
+ <dt><code>{description}</code>/<code>{description_raw}</code></dt>
142
+ <dd><?php _e('Displays the description of the event./Displays description without converting paragraphs.','my-calendar'); ?></dd>
143
 
144
  <dt><code>{image}</code></dt>
145
  <dd><?php _e('Image associated with the event.','my-calendar'); ?></dd>
my-calendar-ical.php CHANGED
@@ -15,7 +15,8 @@ ORGANIZER;CN={host}:MAILTO:{host_email}
15
  DTSTART:{ical_start}
16
  DTEND:{ical_end}
17
  URL;VALUE=URI:{link}
18
- DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{ical_desc}
 
19
  END:VEVENT";
20
  // add ICAL headers
21
  $output = 'BEGIN:VCALENDAR
@@ -26,7 +27,6 @@ PRODID:-//Accessible Web Design//My Calendar//http://www.mywpcal.com//v'.$mc_ver
26
  $d = date( 't',mktime( 0,0,0,$m,1,$y ) );
27
  for ( $i=1;$i<=$d;$i++ ) {
28
  $events = my_calendar_grab_events( $y,$m,$i );
29
-
30
  if ( is_array($events) && !empty($events) ) {
31
  foreach ( array_keys($events) as $key) {
32
  $event =& $events[$key];
@@ -35,13 +35,10 @@ PRODID:-//Accessible Web Design//My Calendar//http://www.mywpcal.com//v'.$mc_ver
35
  $output .= jd_draw_template($array,$template,'ical');
36
  }
37
  }
38
- } else {
39
- //$array = event_as_array($events);
40
- //$output .= jd_draw_template($array,$template,'ical');
41
  }
42
  }
43
  $output .= "\nEND:VCALENDAR";
44
- $output = preg_replace("~(?<!\r)\n~","\r\n",$output);
45
  header("Content-Type: text/calendar");
46
  header("Pragma: no-cache");
47
  header("Expires: 0");
15
  DTSTART:{ical_start}
16
  DTEND:{ical_end}
17
  URL;VALUE=URI:{link}
18
+ DESCRIPTION:{ical_desc}
19
+ CATEGORIES:{category}
20
  END:VEVENT";
21
  // add ICAL headers
22
  $output = 'BEGIN:VCALENDAR
27
  $d = date( 't',mktime( 0,0,0,$m,1,$y ) );
28
  for ( $i=1;$i<=$d;$i++ ) {
29
  $events = my_calendar_grab_events( $y,$m,$i );
 
30
  if ( is_array($events) && !empty($events) ) {
31
  foreach ( array_keys($events) as $key) {
32
  $event =& $events[$key];
35
  $output .= jd_draw_template($array,$template,'ical');
36
  }
37
  }
 
 
 
38
  }
39
  }
40
  $output .= "\nEND:VCALENDAR";
41
+ $output = html_entity_decode(preg_replace("~(?<!\r)\n~","\r\n",$output));
42
  header("Content-Type: text/calendar");
43
  header("Pragma: no-cache");
44
  header("Expires: 0");
my-calendar-install.php CHANGED
@@ -169,6 +169,7 @@ $initial_db = "CREATE TABLE " . my_calendar_table() . " (
169
  event_zoom INT(2) NOT NULL DEFAULT '14',
170
  event_group INT(1) NOT NULL DEFAULT '0',
171
  event_group_id INT(11) NOT NULL DEFAULT '0',
 
172
  event_approved INT(1) NOT NULL DEFAULT '1',
173
  event_flagged INT(1) NOT NULL DEFAULT '0',
174
  event_holiday INT(1) NOT NULL DEFAULT '$event_holiday',
@@ -367,12 +368,15 @@ global $default_template, $initial_listjs, $initial_caljs, $initial_minijs, $ini
367
  add_option('mc_css_file','refresh.css');
368
  add_option('mc_show_rss','false');
369
  add_option('mc_show_ical','false');
 
370
  add_option('mc_time_format',get_option('time_format'));
371
  add_option( 'mc_widget_defaults',$defaults);
372
  add_option( 'mc_show_weekends','true' );
373
  add_option( 'mc_uri','' );
374
  add_option( 'mc_show_event_vcal','false' );
375
  add_option( 'mc_draggable',0 );
 
 
376
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
377
  dbDelta($initial_db);
378
  dbDelta($initial_cat_db);
169
  event_zoom INT(2) NOT NULL DEFAULT '14',
170
  event_group INT(1) NOT NULL DEFAULT '0',
171
  event_group_id INT(11) NOT NULL DEFAULT '0',
172
+ event_span INT(1) NOT NULL DEFAULT '0',
173
  event_approved INT(1) NOT NULL DEFAULT '1',
174
  event_flagged INT(1) NOT NULL DEFAULT '0',
175
  event_holiday INT(1) NOT NULL DEFAULT '$event_holiday',
368
  add_option('mc_css_file','refresh.css');
369
  add_option('mc_show_rss','false');
370
  add_option('mc_show_ical','false');
371
+ add_option('mc_show_print','false');
372
  add_option('mc_time_format',get_option('time_format'));
373
  add_option( 'mc_widget_defaults',$defaults);
374
  add_option( 'mc_show_weekends','true' );
375
  add_option( 'mc_uri','' );
376
  add_option( 'mc_show_event_vcal','false' );
377
  add_option( 'mc_draggable',0 );
378
+ add_option( 'mc_caching_enabled','true' );
379
+ add_option( 'mc_week_caption',"The week's events" );
380
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
381
  dbDelta($initial_db);
382
  dbDelta($initial_cat_db);
my-calendar-limits.php CHANGED
@@ -1,9 +1,10 @@
1
  <?php
2
  function mc_select_category($category, $type='event', $group='events' ) {
 
3
  global $wpdb;
4
  $select_category = '';
5
  $data = ($group=='category')?'category_id':'event_category';
6
- if ( isset( $_GET['mcat'] ) ) { $category = (int) $_GET['mcat']; }
7
  if ( $category == 'all' || strpos( $category, "all" ) !== false ) {
8
  return '';
9
  } else {
@@ -17,6 +18,7 @@ global $wpdb;
17
  $i = 1;
18
  foreach ($categories as $key) {
19
  if ( is_numeric($key) ) {
 
20
  if ($i == 1) {
21
  $select_category .= ($type=='all')?" WHERE (":' (';
22
  }
@@ -28,6 +30,7 @@ global $wpdb;
28
  }
29
  $i++;
30
  } else {
 
31
  $cat = $wpdb->get_row("SELECT category_id FROM " . my_calendar_categories_table() . " WHERE category_name = '$key'");
32
  $category_id = $cat->category_id;
33
  if ($i == 1) {
@@ -59,8 +62,6 @@ global $wpdb;
59
  }
60
  }
61
 
62
-
63
-
64
  function mc_limit_string($type='',$ltype='',$lvalue='') {
65
  global $user_ID;
66
  $user_settings = get_option('mc_user_settings');
@@ -76,7 +77,7 @@ global $user_ID;
76
  }
77
  } else if ( $ltype !='' && $lvalue != '' ) {
78
  $location_type = $ltype;
79
- $current_location = $lvalue;
80
  }
81
  } else {
82
  $current_location = urldecode($_GET['loc']);
@@ -99,13 +100,8 @@ global $user_ID;
99
  }
100
  }
101
  if ($current_location != 'all' && $current_location != '') {
102
- //if ($select_category == "") {
103
  $limit_string = "$location_type='$current_location'";
104
  $limit_string .= ($type=='all')?' AND':"";
105
- //} else {
106
- // $limit_string = "AND $location_type='$current_location'";
107
- // $limit_string .= ($type=='all')?'':'';
108
- //}
109
  }
110
  }
111
  return $limit_string;
1
  <?php
2
  function mc_select_category($category, $type='event', $group='events' ) {
3
+ $category = urldecode($category);
4
  global $wpdb;
5
  $select_category = '';
6
  $data = ($group=='category')?'category_id':'event_category';
7
+ if ( isset( $_GET['mcat'] ) ) { $category = $_GET['mcat']; }
8
  if ( $category == 'all' || strpos( $category, "all" ) !== false ) {
9
  return '';
10
  } else {
18
  $i = 1;
19
  foreach ($categories as $key) {
20
  if ( is_numeric($key) ) {
21
+ $key = (int) $key;
22
  if ($i == 1) {
23
  $select_category .= ($type=='all')?" WHERE (":' (';
24
  }
30
  }
31
  $i++;
32
  } else {
33
+ $key = esc_sql($key);
34
  $cat = $wpdb->get_row("SELECT category_id FROM " . my_calendar_categories_table() . " WHERE category_name = '$key'");
35
  $category_id = $cat->category_id;
36
  if ($i == 1) {
62
  }
63
  }
64
 
 
 
65
  function mc_limit_string($type='',$ltype='',$lvalue='') {
66
  global $user_ID;
67
  $user_settings = get_option('mc_user_settings');
77
  }
78
  } else if ( $ltype !='' && $lvalue != '' ) {
79
  $location_type = $ltype;
80
+ $current_location = esc_sql( $lvalue );
81
  }
82
  } else {
83
  $current_location = urldecode($_GET['loc']);
100
  }
101
  }
102
  if ($current_location != 'all' && $current_location != '') {
 
103
  $limit_string = "$location_type='$current_location'";
104
  $limit_string .= ($type=='all')?' AND':"";
 
 
 
 
105
  }
106
  }
107
  return $limit_string;
my-calendar-output.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  // Used to draw multiple events
3
  function my_calendar_draw_events($events, $type, $process_date) {
 
4
  // We need to sort arrays of objects by time
5
  if ( is_array($events) ) {
6
  usort($events, "my_calendar_time_cmp");
@@ -144,10 +145,12 @@ jQuery(document).ready(function($) {
144
  $templates = get_option('mc_templates');
145
  $title_template = ($templates['title'] == '' )?'{title}':$templates['title'];
146
  $mytitle = jd_draw_template($data,$title_template);
147
- $toggle = ($type == 'calendar')?" <a href='#' class='mc-toggle'><img src='".MY_CALENDAR_DIRECTORY."/images/event-details.png' alt='".__('Event Details','my-calendar')."' /></a>":'';
 
148
  $current_date = date_i18n($date_format,strtotime($process_date));
149
  $event_date = ($type == 'single')?$current_date.', ':'';
150
- $header_details .= ($type != 'list' && $type != 'single')?"<h3 class='event-title summary'>$image".$mytitle."$toggle</h3>\n":'';
 
151
  $title = apply_filters( 'mc_before_event_title','',$event );
152
  $title .= ($type == 'single' )?"<h2 class='event-title summary'>$image $mytitle</h2>\n":'';
153
  $title .= apply_filters( 'mc_after_event_title','',$event );
@@ -262,6 +265,9 @@ jQuery(document).ready(function($) {
262
  }
263
  $status = ($status != '')?"<p>$status</p>":'';
264
  $return = ($type == 'single')?"<p><a href='".get_option('mc_uri')."'>".__('View full calendar','my-calendar')."</a></p>":'';
 
 
 
265
  if ($event_link != '') {
266
  $is_external = mc_external_link( $event_link );
267
  $link_template = ( isset($templates['link']))?$templates['link']:'{title}';
@@ -302,6 +308,8 @@ jQuery(document).ready(function($) {
302
  } else {
303
  $edit = '';
304
  }
 
 
305
  $details .= $edit;
306
  $details .= apply_filters('mc_after_event','',$event);
307
  $details .= "</div><!--ends .details--></div>";
@@ -327,7 +335,7 @@ jQuery(document).ready(function($) {
327
  }
328
  }
329
 
330
- function mc_build_date_switcher( $type='calendar' ) {
331
  global $wpdb;
332
  $current_url = mc_get_current_url();
333
  $date_switcher = "";
@@ -335,7 +343,10 @@ $current_url = mc_get_current_url();
335
  <form action="'.$current_url.'" method="get"><div>';
336
  $qsa = array();
337
  parse_str($_SERVER['QUERY_STRING'],$qsa);
 
338
  foreach ($qsa as $name => $argument) {
 
 
339
  if ($name != 'month' && $name != 'yr' && $name != 'dy' ) {
340
  $date_switcher .= '<input type="hidden" name="'.$name.'" value="'.$argument.'" />';
341
  }
@@ -381,15 +392,61 @@ $current_url = mc_get_current_url();
381
  return $date_switcher;
382
  }
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  // Actually do the printing of the calendar
385
  function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='month',$ltype='',$lvalue='') {
386
  global $wpdb, $wp_plugin_url;
387
  $my_calendar_body = '';
388
  $args = array('name'=>$name,'format'=>$format,'category'=>$category,'showkey'=>$showkey,'shownav'=>$shownav,'toggle'=>$toggle,'time'=>$time,'ltype'=>$ltype,'lvalue'=>$lvalue);
389
  $my_calendar_body .= apply_filters('mc_before_calendar','',$args);
 
 
390
  $format = ( mc_is_mobile() )?'list':$format;
391
  $date_format = ( get_option('mc_date_format') != '' )?get_option('mc_date_format'):get_option('date_format');
392
-
393
  if ( $format != 'mini' && $toggle == 'yes' ) {
394
  $format_toggle = "<div class='mc-format'>";
395
  $current_url = mc_get_current_url();
@@ -453,8 +510,8 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
453
  // Carry on with the script
454
  $offset = (60*60*get_option('gmt_offset'));
455
  // If we don't pass arguments we want a calendar that is relevant to today
456
- $c_m = 0;
457
- if ( isset($_GET['dy']) ) {
458
  $c_day = (int) $_GET['dy'];
459
  } else {
460
  if ($time == 'week' ) {
@@ -467,7 +524,7 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
467
  $c_day = 1;
468
  }
469
  }
470
- if ( isset($_GET['month']) ) {
471
  $c_month = (int) $_GET['month'];
472
  if ( !isset($_GET['dy']) ) { $c_day = 1; }
473
  } else {
@@ -475,12 +532,11 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
475
  $c_month = ($c_m == 0)?date("m",time()+($offset)):date("m",strtotime( $xnow.' -1 month'));
476
  }
477
 
478
- if ( isset($_GET['yr']) ) {
479
  $c_year = (int) $_GET['yr'];
480
  } else {
481
  $c_year = date("Y",time()+($offset));
482
- }
483
-
484
  // Years get funny if we exceed 3000, so we use this check
485
  if ( !($c_year <= 3000 && $c_year >= 0)) {
486
  // No valid year causes the calendar to default to today
@@ -488,14 +544,16 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
488
  $c_month = date("m",time()+($offset));
489
  $c_day = date("d",time()+($offset));
490
  }
 
 
491
  $anchor = (get_option('ajax_javascript') == '1' )?'#jd-calendar':'';
492
  if ($shownav == 'yes') {
493
  $pLink = my_calendar_prev_link($c_year,$c_month,$c_day,$format,$time);
494
  $nLink = my_calendar_next_link($c_year,$c_month,$c_day,$format,$time);
495
- $prevLink = mc_build_url( array( 'yr'=>$pLink['yr'],'month'=>$pLink['month'],'dy'=>$pLink['day'] ),array() );
496
- $nextLink = mc_build_url( array( 'yr'=>$nLink['yr'],'month'=>$nLink['month'],'dy'=>$nLink['day'] ),array() );
497
- $previous_link = apply_filters('mc_previous_link',' <li class="my-calendar-prev"><a id="prevMonth" href="' . $prevLink . $anchor .'" rel="nofollow">&laquo; '.$pLink['label'].'</a></li>',$pLink);
498
- $next_link = apply_filters('mc_previous_link',' <li class="my-calendar-next"><a id="nextMonth" href="' . $nextLink . $anchor .'" rel="nofollow">'.$nLink['label'].' &raquo;</a></li>',$nLink);
499
  $mc_nav = '
500
  <div class="my-calendar-nav">
501
  <ul>
@@ -506,7 +564,8 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
506
  } else {
507
  $mc_nav = '';
508
  }
509
- $my_calendar_body .= "<div id=\"jd-calendar\" class=\"$format $time\">";
 
510
  if ( $time == 'day' ) {
511
  $dayclass = strtolower(date_i18n('D',mktime (0,0,0,$c_month,$c_day,$c_year)));
512
  $grabbed_events = my_calendar_grab_events($c_year,$c_month,$c_day,$category,$ltype,$lvalue);
@@ -525,7 +584,7 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
525
  $events_class = " has-events$class";
526
  }
527
  $class = '';
528
- $my_calendar_body .= $mc_nav."\n"."<h3 class='mc-single".$class."'>".date_i18n( $date_format,strtotime("$c_year-$c_month-$c_day")).'</h3><div id="mc-day" class="'.$dayclass.' '.(date("Ymd", mktime (0,0,0,$c_month,$c_day,$c_year))==date_i18n("Ymd",time()+$offset)?'current-day':'day-with-date').$events_class.'">'."\n";
529
  $process_date = date_i18n("Y-m-d",strtotime("$c_year-$c_month-$c_day"));
530
  if ( count($grabbed_events) > 0 ) {
531
  foreach ( array_keys($grabbed_events) as $key ) {
@@ -574,25 +633,26 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
574
  <div class="my-calendar-header">';
575
  // We want to know if we should display the date switcher
576
  if ( $time != 'week' && $time != 'day' ) {
577
- $my_calendar_body .= ( $mc_display_jump == 'true' )?mc_build_date_switcher( $format ):'';
578
  }
579
  // The header of the calendar table and the links.
580
  $my_calendar_body .= "$mc_nav\n$format_toggle\n</div>";
581
  $my_calendar_body .= "\n<table class=\"my-calendar-table\">\n";
582
- $caption_heading = ($time != 'week')?$current_date_header.$caption_text:__('The week\'s events','my-calendar').$caption_text;
 
583
  $my_calendar_body .= "<caption class=\"my-calendar-$time\">".$caption_heading."</caption>\n";
584
  } else {
585
  // determine which header text to show depending on number of months displayed;
586
  if ( $time != 'week' && $time != 'day' ) {
587
  $list_heading = ($num_months <= 1)?__('Events in','my-calendar').' '.$current_date_header.$caption_text."\n":$current_month_header.'&ndash;'.$through_month_header.$caption_text;
588
  } else {
589
- $list_heading = __('This week\'s events','my-calendar');
590
  }
591
  $my_calendar_body .= "<h3 class=\"my-calendar-$time\">$list_heading</h3>\n";
592
  $my_calendar_body .= '<div class="my-calendar-header">';
593
  // We want to know if we should display the date switcher
594
  if ( $time != 'week' && $time != 'day' ) {
595
- $my_calendar_body .= ( $mc_display_jump == 'true' )?mc_build_date_switcher( $format ):'';
596
  }
597
  $my_calendar_body .= "$mc_nav\n$format_toggle\n</div>";
598
  }
@@ -675,7 +735,9 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
675
  }
676
  $events_class = " has-events$addclass$class";
677
  if ($format == 'mini') {
678
- $element = 'a href="#"';
 
 
679
  $close = 'a';
680
  $trigger = ' trigger';
681
  } else {
@@ -697,8 +759,11 @@ function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='mo
697
  $week_format = (get_option('mc_week_format')=='')?'M j, \'y':get_option('mc_week_format');
698
  $week_date_format = date_i18n($week_format,strtotime( "$c_year-$c_month-$thisday" ) );
699
  $thisday_heading = ($time == 'week')?"<small>$week_date_format</small>":$thisday;
 
 
 
700
  if ( ( $is_weekend && get_option('mc_show_weekends') == 'true' ) || !$is_weekend ) {
701
- $my_calendar_body .= "\n".'<td class="'.$dayclass.' '.$class.' '.(date("Ymd", mktime (0,0,0,$c_month,$thisday,$c_year))==date_i18n("Ymd",time()+$offset)?'current-day':'day-with-date').$events_class.'">'."\n <$element class='mc-date".$class."'>".$thisday_heading."</$close>". my_calendar_draw_events($grabbed_events, $format, $process_date)."</td>";
702
  }
703
  } else {
704
  if ( !isset($now) ) { $now = 1; }
@@ -852,44 +917,53 @@ $ical
852
  }
853
  }
854
 
 
 
 
 
 
 
 
855
  // Configure the "Next" link in the calendar
856
  function my_calendar_next_link($cur_year,$cur_month,$cur_day,$format,$time='month') {
857
  $next_year = $cur_year + 1;
858
- $next_events = ( get_option( 'mc_next_events') == '' )?__("Next events",'my-calendar'):stripcslashes( get_option( 'mc_next_events') );
859
  $num_months = get_option('mc_show_months');
860
  $nYr = $cur_year;
861
  if ($num_months <= 1 || $format!="list" ) {
862
  if ($cur_month == 12) {
863
- $nMonth = 1;
864
- $nYr = $next_year;
865
  } else {
866
- $next_month = $cur_month + 1;
867
- $nMonth = $next_month;
868
- $nYr = $cur_year;
869
  }
870
  } else {
871
  $next_month = (($cur_month + $num_months) > 12)?(($cur_month + $num_months) - 12):($cur_month + $num_months);
872
  if ($cur_month >= (13-$num_months)) {
873
- $nMonth = $next_month;
874
- $nYr = $next_year;
875
  } else {
876
- $nMonth = $next_month;
877
- $nYr = $cur_year;
878
  }
879
  }
880
  $nDay = '';
 
 
881
  if ($time == 'week') {
882
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day"."+ 7 days" );
883
  $nDay = date('d',$nextdate);
884
  $nYr = date('Y',$nextdate);
885
  $nMonth = date('m',$nextdate);
 
 
886
  }
887
  if ( $time == 'day' ) {
888
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day"."+ 1 days" );
889
  $nDay = date('d',$nextdate);
890
  $nYr = date('Y',$nextdate);
891
- $nMonth = date('m',$nextdate);
 
 
892
  }
 
893
  $output = array('month'=>$nMonth,'yr'=>$nYr,'day'=>$nDay,'label'=>$next_events);
894
  return $output;
895
  }
@@ -897,41 +971,43 @@ function my_calendar_next_link($cur_year,$cur_month,$cur_day,$format,$time='mont
897
  // Configure the "Previous" link in the calendar
898
  function my_calendar_prev_link($cur_year,$cur_month,$cur_day,$format,$time='month') {
899
  $last_year = $cur_year - 1;
900
- $previous_events = ( get_option( 'mc_previous_events') == '' )?__("Previous events",'my-calendar'):stripcslashes( get_option( 'mc_previous_events') );
901
  $num_months = get_option('mc_show_months');
902
  $pYr = $cur_year;
903
  if ($num_months <= 1 || $format!="list" ) {
904
  if ($cur_month == 1) {
905
- $pMonth = 12;
906
- $pYr = $last_year;
907
- } else {
908
- $next_month = $cur_month - 1;
909
- $pMonth = $next_month;
910
- $pYr = $cur_year;
911
  }
912
  } else {
913
  $next_month = ($cur_month > $num_months)?($cur_month - $num_months):(($cur_month - $num_months) + 12);
914
  if ($cur_month <= $num_months) {
915
- $pMonth = $next_month;
916
- $pYr = $last_year;
917
  } else {
918
- $pMonth = $next_month;
919
- $pYr = $cur_year;
920
  }
921
  }
 
 
922
  $pDay = '';
923
  if ( $time == 'week' ) {
924
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day"."- 7 days" );
925
  $pDay = date('d',$prevdate);
926
  $pYr = date('Y',$prevdate);
927
  $pMonth = date('m',$prevdate);
 
 
928
  }
929
  if ( $time == 'day' ) {
930
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day"."- 1 days" );
931
  $pDay = date('d',$prevdate);
932
  $pYr = date('Y',$prevdate);
933
- $pMonth = date('m',$prevdate);
 
 
934
  }
 
935
  $output = array( 'month'=>$pMonth,'yr'=>$pYr,'day'=>$pDay,'label'=>$previous_events );
936
  return $output;
937
  }
@@ -950,7 +1026,10 @@ function my_calendar_categories_list($show='list',$context='public') {
950
  <div>";
951
  $qsa = array();
952
  parse_str($_SERVER['QUERY_STRING'],$qsa);
 
953
  foreach ($qsa as $name => $argument) {
 
 
954
  if ( $name != 'mcat' ) {
955
  $form .= ' <input type="hidden" name="'.$name.'" value="'.$argument.'" />'."\n";
956
  }
@@ -1116,8 +1195,10 @@ global $wpdb;
1116
  <div>
1117
  <input type='hidden' name='ltype' value='$ltype' />";
1118
  $qsa = array();
1119
- parse_str($_SERVER['QUERY_STRING'],$qsa);
1120
- foreach ($qsa as $name => $argument) {
 
 
1121
  if ($name != 'loc' && $name != 'ltype') {
1122
  $output .= ' <input type="hidden" name="'.$name.'" value="'.$argument.'" />'."\n";
1123
  }
@@ -1203,5 +1284,4 @@ global $user_ID;
1203
  }
1204
  return $gtz;
1205
  }
1206
-
1207
  ?>
1
  <?php
2
  // Used to draw multiple events
3
  function my_calendar_draw_events($events, $type, $process_date) {
4
+ if ( $type == 'mini' && get_option('mc_open_day_uri') == 'true' ) return;
5
  // We need to sort arrays of objects by time
6
  if ( is_array($events) ) {
7
  usort($events, "my_calendar_time_cmp");
145
  $templates = get_option('mc_templates');
146
  $title_template = ($templates['title'] == '' )?'{title}':$templates['title'];
147
  $mytitle = jd_draw_template($data,$title_template);
148
+ $toggle = ($type == 'calendar')?"-<a href='#' class='mc-toggle'><img src='".MY_CALENDAR_DIRECTORY."/images/event-details.png' alt='".__('Event Details','my-calendar')."' /></a>":'';
149
+ $toggle = (get_option('mc_open_uri')=='true')?'':$toggle;
150
  $current_date = date_i18n($date_format,strtotime($process_date));
151
  $event_date = ($type == 'single')?$current_date.', ':'';
152
+ if ( $event->event_span == 1 ) { $group_class = ' multidate group'.$event->event_group_id; } else { $group_class = ''; }
153
+ $header_details .= ($type != 'list' && $type != 'single')?"<h3 class='event-title summary$group_class'>$image".$mytitle."$toggle</h3>\n":'';
154
  $title = apply_filters( 'mc_before_event_title','',$event );
155
  $title .= ($type == 'single' )?"<h2 class='event-title summary'>$image $mytitle</h2>\n":'';
156
  $title .= apply_filters( 'mc_after_event_title','',$event );
265
  }
266
  $status = ($status != '')?"<p>$status</p>":'';
267
  $return = ($type == 'single')?"<p><a href='".get_option('mc_uri')."'>".__('View full calendar','my-calendar')."</a></p>":'';
268
+ // if we're opening in a new page, there's no reason to display any of that. Later, re-write this section to make this easier to skip.
269
+ if ( $type == 'calendar' && get_option('mc_open_uri') == 'true' && $time != 'day' ) $body_details = $description = $short = $status = '';
270
+
271
  if ($event_link != '') {
272
  $is_external = mc_external_link( $event_link );
273
  $link_template = ( isset($templates['link']))?$templates['link']:'{title}';
308
  } else {
309
  $edit = '';
310
  }
311
+ if ( $type == 'calendar' && get_option('mc_open_uri') == 'true' && $time != 'day' ) { $edit = ''; }
312
+
313
  $details .= $edit;
314
  $details .= apply_filters('mc_after_event','',$event);
315
  $details .= "</div><!--ends .details--></div>";
335
  }
336
  }
337
 
338
+ function mc_build_date_switcher( $type='calendar', $cid='all' ) {
339
  global $wpdb;
340
  $current_url = mc_get_current_url();
341
  $date_switcher = "";
343
  <form action="'.$current_url.'" method="get"><div>';
344
  $qsa = array();
345
  parse_str($_SERVER['QUERY_STRING'],$qsa);
346
+ if ( !isset( $_GET['cid'] ) ) { $date_switcher .= '<input type="hidden" name="cid" value="'.$cid.'" />'; }
347
  foreach ($qsa as $name => $argument) {
348
+ $name = esc_attr(strip_tags($name));
349
+ $argument = esc_attr(strip_tags($argument));
350
  if ($name != 'month' && $name != 'yr' && $name != 'dy' ) {
351
  $date_switcher .= '<input type="hidden" name="'.$name.'" value="'.$argument.'" />';
352
  }
392
  return $date_switcher;
393
  }
394
 
395
+ function my_calendar_print() {
396
+ global $wp_plugin_url;
397
+ $category=(isset($_GET['mcat']))?$_GET['mcat']:''; // these are all sanitized elsewhere
398
+ $time=(isset($_GET['time']))?$_GET['time']:'month';
399
+ $ltype=(isset($_GET['ltype']))?$_GET['ltype']:'';
400
+ $lvalue=(isset($_GET['lvalue']))?$_GET['lvalue']:'';
401
+ header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
402
+ echo '<!DOCTYPE html>
403
+ <!--[if IE 6]>
404
+ <html id="ie6" dir="'.get_bloginfo('text_direction').'" lang="'.get_bloginfo('language').'">
405
+ <![endif]-->
406
+ <!--[if IE 7]>
407
+ <html id="ie7" dir="'.get_bloginfo('text_direction').'" lang="'.get_bloginfo('language').'">
408
+ <![endif]-->
409
+ <!--[if IE 8]>
410
+ <html id="ie8" dir="'.get_bloginfo('text_direction').'" lang="'.get_bloginfo('language').'">
411
+ <![endif]-->
412
+ <!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
413
+ <html dir="'.get_bloginfo('text_direction').'" lang="'.get_bloginfo('language').'">
414
+ <!--<![endif]-->
415
+ <head>
416
+ <meta charset="'.get_bloginfo('charset').'" />
417
+ <meta name="viewport" content="width=device-width" />
418
+ <title>'.get_bloginfo('name').' - '.__('Calendar: Print View','my-calendar').'</title>
419
+ <meta name="generator" content="My Calendar for WordPress" />
420
+ <meta name="robots" content="noindex,nofollow" />';
421
+ if ( file_exists( get_stylesheet_directory() . '/mc-print.css' ) ) {
422
+ $stylesheet = get_stylesheet_directory_uri() . '/mc-print.css';
423
+ } else {
424
+ $stylesheet = $wp_plugin_url."/my-calendar/mc-print.css";
425
+ }
426
+ echo "
427
+ <!-- Copy mc-print.css to your theme directory if you wish to replace the default print styles -->
428
+ <link rel='stylesheet' href='$stylesheet' type='text/css' media='screen,print' />
429
+ </head>
430
+ <body>\n";
431
+ echo my_calendar('print','calendar',$category,'no','no','no',$time,$ltype,$lvalue);
432
+ $return_url = ( get_option('mc_uri') != '' )?get_option('mc_uri'):home_url();
433
+ echo "<p class='return'><a href='$return_url'>".__('Return to site','my-calendar')."</a></p>";
434
+ echo '
435
+ </body>
436
+ </html>';
437
+ }
438
+
439
  // Actually do the printing of the calendar
440
  function my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time='month',$ltype='',$lvalue='') {
441
  global $wpdb, $wp_plugin_url;
442
  $my_calendar_body = '';
443
  $args = array('name'=>$name,'format'=>$format,'category'=>$category,'showkey'=>$showkey,'shownav'=>$shownav,'toggle'=>$toggle,'time'=>$time,'ltype'=>$ltype,'lvalue'=>$lvalue);
444
  $my_calendar_body .= apply_filters('mc_before_calendar','',$args);
445
+ $main_class = ( $name !='' )?sanitize_title($name):'all';
446
+ $cid = ( isset( $_GET['cid'] ) )?esc_attr(strip_tags($_GET['cid'])):'all';
447
  $format = ( mc_is_mobile() )?'list':$format;
448
  $date_format = ( get_option('mc_date_format') != '' )?get_option('mc_date_format'):get_option('date_format');
449
+
450
  if ( $format != 'mini' && $toggle == 'yes' ) {
451
  $format_toggle = "<div class='mc-format'>";
452
  $current_url = mc_get_current_url();
510
  // Carry on with the script
511
  $offset = (60*60*get_option('gmt_offset'));
512
  // If we don't pass arguments we want a calendar that is relevant to today
513
+ $c_m = 0;
514
+ if ( isset($_GET['dy']) && $main_class == $cid ) {
515
  $c_day = (int) $_GET['dy'];
516
  } else {
517
  if ($time == 'week' ) {
524
  $c_day = 1;
525
  }
526
  }
527
+ if ( isset($_GET['month']) && $main_class == $cid ) {
528
  $c_month = (int) $_GET['month'];
529
  if ( !isset($_GET['dy']) ) { $c_day = 1; }
530
  } else {
532
  $c_month = ($c_m == 0)?date("m",time()+($offset)):date("m",strtotime( $xnow.' -1 month'));
533
  }
534
 
535
+ if ( isset($_GET['yr']) && $main_class == $cid ) {
536
  $c_year = (int) $_GET['yr'];
537
  } else {
538
  $c_year = date("Y",time()+($offset));
539
+ }
 
540
  // Years get funny if we exceed 3000, so we use this check
541
  if ( !($c_year <= 3000 && $c_year >= 0)) {
542
  // No valid year causes the calendar to default to today
544
  $c_month = date("m",time()+($offset));
545
  $c_day = date("d",time()+($offset));
546
  }
547
+ $mc_print_url = mc_build_url( array( 'time'=>$time,'ltype'=>$ltype,'lvalue'=>$lvalue,'mcat'=>$category,'yr'=>$c_year,'month'=>$c_month,'dy'=>$c_day, 'cid'=>'print' ), array(), mc_feed_base() . 'my-calendar-print' );
548
+
549
  $anchor = (get_option('ajax_javascript') == '1' )?'#jd-calendar':'';
550
  if ($shownav == 'yes') {
551
  $pLink = my_calendar_prev_link($c_year,$c_month,$c_day,$format,$time);
552
  $nLink = my_calendar_next_link($c_year,$c_month,$c_day,$format,$time);
553
+ $prevLink = mc_build_url( array( 'yr'=>$pLink['yr'],'month'=>$pLink['month'],'dy'=>$pLink['day'],'cid'=>$main_class ),array() );
554
+ $nextLink = mc_build_url( array( 'yr'=>$nLink['yr'],'month'=>$nLink['month'],'dy'=>$nLink['day'],'cid'=>$main_class ),array() );
555
+ $previous_link = apply_filters('mc_previous_link',' <li class="my-calendar-prev"><a id="prevMonth" href="' . $prevLink . $anchor .'" rel="nofollow">'.$pLink['label'].'</a></li>',$pLink);
556
+ $next_link = apply_filters('mc_next_link',' <li class="my-calendar-next"><a id="nextMonth" href="' . $nextLink . $anchor .'" rel="nofollow">'.$nLink['label'].'</a></li>',$nLink);
557
  $mc_nav = '
558
  <div class="my-calendar-nav">
559
  <ul>
564
  } else {
565
  $mc_nav = '';
566
  }
567
+ $my_calendar_body .= "<div id=\"jd-calendar\" class=\"$format $time $main_class\">";
568
+ if ( get_option( 'mc_show_print' ) == 'true' ) { $my_calendar_body .= "<p class='mc-print'><a href='$mc_print_url'>".__('Print View','my-calendar')."</a></p>"; }
569
  if ( $time == 'day' ) {
570
  $dayclass = strtolower(date_i18n('D',mktime (0,0,0,$c_month,$c_day,$c_year)));
571
  $grabbed_events = my_calendar_grab_events($c_year,$c_month,$c_day,$category,$ltype,$lvalue);
584
  $events_class = " has-events$class";
585
  }
586
  $class = '';
587
+ $my_calendar_body .= $mc_nav."\n"."<h3 class='mc-single".$class."'>".date_i18n( $date_format,strtotime("$c_year-$c_month-$c_day")).'</h3><div id="mc-day" class="'.$dayclass.' '.(date("Ymd", mktime (0,0,0,$c_month,$c_day,$c_year))==date("Ymd",time()+$offset)?'current-day':'day-with-date').$events_class.'">'."\n";
588
  $process_date = date_i18n("Y-m-d",strtotime("$c_year-$c_month-$c_day"));
589
  if ( count($grabbed_events) > 0 ) {
590
  foreach ( array_keys($grabbed_events) as $key ) {
633
  <div class="my-calendar-header">';
634
  // We want to know if we should display the date switcher
635
  if ( $time != 'week' && $time != 'day' ) {
636
+ $my_calendar_body .= ( $mc_display_jump == 'true' )?mc_build_date_switcher( $format, $main_class ):'';
637
  }
638
  // The header of the calendar table and the links.
639
  $my_calendar_body .= "$mc_nav\n$format_toggle\n</div>";
640
  $my_calendar_body .= "\n<table class=\"my-calendar-table\">\n";
641
+ $week_caption = stripslashes(get_option('mc_week_caption'));
642
+ $caption_heading = ($time != 'week')?$current_date_header.$caption_text:$week_caption.$caption_text;
643
  $my_calendar_body .= "<caption class=\"my-calendar-$time\">".$caption_heading."</caption>\n";
644
  } else {
645
  // determine which header text to show depending on number of months displayed;
646
  if ( $time != 'week' && $time != 'day' ) {
647
  $list_heading = ($num_months <= 1)?__('Events in','my-calendar').' '.$current_date_header.$caption_text."\n":$current_month_header.'&ndash;'.$through_month_header.$caption_text;
648
  } else {
649
+ $list_heading = stripslashes(get_option('mc_week_caption'));
650
  }
651
  $my_calendar_body .= "<h3 class=\"my-calendar-$time\">$list_heading</h3>\n";
652
  $my_calendar_body .= '<div class="my-calendar-header">';
653
  // We want to know if we should display the date switcher
654
  if ( $time != 'week' && $time != 'day' ) {
655
+ $my_calendar_body .= ( $mc_display_jump == 'true' )?mc_build_date_switcher( $format, $main_class ):'';
656
  }
657
  $my_calendar_body .= "$mc_nav\n$format_toggle\n</div>";
658
  }
735
  }
736
  $events_class = " has-events$addclass$class";
737
  if ($format == 'mini') {
738
+ $day_url = mc_build_url( array('yr'=>$c_year,'month'=>$c_month,'dy'=>$thisday), array('month','dy','yr','ltype','loc','mcat'), get_option( 'mc_day_uri' ) );
739
+ $link = ( get_option('mc_day_uri') != '' )?$day_url:'#';
740
+ $element = 'a href="'.$link.'"';
741
  $close = 'a';
742
  $trigger = ' trigger';
743
  } else {
759
  $week_format = (get_option('mc_week_format')=='')?'M j, \'y':get_option('mc_week_format');
760
  $week_date_format = date_i18n($week_format,strtotime( "$c_year-$c_month-$thisday" ) );
761
  $thisday_heading = ($time == 'week')?"<small>$week_date_format</small>":$thisday;
762
+ /* if ( $thisday == 19 || $thisday == 20 || $thisday == 21 ) {
763
+ echo 'Today: '.date_i18n("Y-m-d h:i",time()+$offset).' -- '.date("Y-m-d h:i", mktime (0,0,0,$c_month,$thisday,$c_year)).'<br />';
764
+ } */
765
  if ( ( $is_weekend && get_option('mc_show_weekends') == 'true' ) || !$is_weekend ) {
766
+ $my_calendar_body .= "\n".'<td class="'.$dayclass.' '.$class.' '.(date("Ymd", mktime (0,0,0,$c_month,$thisday,$c_year))==date("Ymd",time()+$offset)?'current-day':'day-with-date').$events_class.'">'."\n <$element class='mc-date".$class."'>".$thisday_heading."</$close>". my_calendar_draw_events($grabbed_events, $format, $process_date)."</td>";
767
  }
768
  } else {
769
  if ( !isset($now) ) { $now = 1; }
917
  }
918
  }
919
 
920
+ function mc_feed_base() {
921
+ global $wp_rewrite;
922
+ $base = home_url();
923
+ $base .= ( $wp_rewrite->using_permalinks() )?'/feed/':'?feed=';
924
+ return $base;
925
+ }
926
+
927
  // Configure the "Next" link in the calendar
928
  function my_calendar_next_link($cur_year,$cur_month,$cur_day,$format,$time='month') {
929
  $next_year = $cur_year + 1;
930
+ $next_events = ( get_option( 'mc_next_events') == '' )?__("Next events &raquo;",'my-calendar'):stripcslashes( get_option( 'mc_next_events') );
931
  $num_months = get_option('mc_show_months');
932
  $nYr = $cur_year;
933
  if ($num_months <= 1 || $format!="list" ) {
934
  if ($cur_month == 12) {
935
+ $nMonth = 1;$nYr = $next_year;
 
936
  } else {
937
+ $next_month = $cur_month + 1;$nMonth = $next_month; $nYr = $cur_year;
 
 
938
  }
939
  } else {
940
  $next_month = (($cur_month + $num_months) > 12)?(($cur_month + $num_months) - 12):($cur_month + $num_months);
941
  if ($cur_month >= (13-$num_months)) {
942
+ $nMonth = $next_month;$nYr = $next_year;
 
943
  } else {
944
+ $nMonth = $next_month;$nYr = $cur_year;
 
945
  }
946
  }
947
  $nDay = '';
948
+ if ( $nYr != $cur_year ) { $format = 'F, Y'; } else { $format = 'F'; }
949
+ $date = date_i18n($format,mktime( 0,0,0,$nMonth,1,$nYr ) );
950
  if ($time == 'week') {
951
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day"."+ 7 days" );
952
  $nDay = date('d',$nextdate);
953
  $nYr = date('Y',$nextdate);
954
  $nMonth = date('m',$nextdate);
955
+ if ( $nYr != $cur_year ) { $format = 'F j, Y'; } else { $format = 'F j'; }
956
+ $date = __('Week of ','my-calendar').date_i18n($format,mktime( 0,0,0,$nMonth,$nDay,$nYr ) );
957
  }
958
  if ( $time == 'day' ) {
959
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day"."+ 1 days" );
960
  $nDay = date('d',$nextdate);
961
  $nYr = date('Y',$nextdate);
962
+ $nMonth = date('m',$nextdate);
963
+ if ( $nYr != $cur_year ) { $format = 'F j, Y'; } else { $format = 'F j'; }
964
+ $date = date_i18n($format,mktime( 0,0,0,$nMonth,$nDay,$nYr ) );
965
  }
966
+ $next_events = str_replace( '{date}', $date, $next_events );
967
  $output = array('month'=>$nMonth,'yr'=>$nYr,'day'=>$nDay,'label'=>$next_events);
968
  return $output;
969
  }
971
  // Configure the "Previous" link in the calendar
972
  function my_calendar_prev_link($cur_year,$cur_month,$cur_day,$format,$time='month') {
973
  $last_year = $cur_year - 1;
974
+ $previous_events = ( get_option( 'mc_previous_events') == '' )?__("&laquo; Previous events",'my-calendar'):stripcslashes( get_option( 'mc_previous_events') );
975
  $num_months = get_option('mc_show_months');
976
  $pYr = $cur_year;
977
  if ($num_months <= 1 || $format!="list" ) {
978
  if ($cur_month == 1) {
979
+ $pMonth = 12;$pYr = $last_year;
980
+ } else {
981
+ $next_month = $cur_month - 1; $pMonth = $next_month; $pYr = $cur_year;
 
 
 
982
  }
983
  } else {
984
  $next_month = ($cur_month > $num_months)?($cur_month - $num_months):(($cur_month - $num_months) + 12);
985
  if ($cur_month <= $num_months) {
986
+ $pMonth = $next_month; $pYr = $last_year;
 
987
  } else {
988
+ $pMonth = $next_month; $pYr = $cur_year;
 
989
  }
990
  }
991
+ if ( $pYr != $cur_year ) { $format = 'F, Y'; } else { $format = 'F'; }
992
+ $date = date_i18n($format,mktime( 0,0,0,$pMonth,1,$pYr ) );
993
  $pDay = '';
994
  if ( $time == 'week' ) {
995
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day"."- 7 days" );
996
  $pDay = date('d',$prevdate);
997
  $pYr = date('Y',$prevdate);
998
  $pMonth = date('m',$prevdate);
999
+ if ( $pYr != $cur_year ) { $format = 'F j, Y'; } else { $format = 'F j'; }
1000
+ $date = __('Week of ','my-calendar').date_i18n($format,mktime( 0,0,0,$pMonth,$pDay,$pYr ) );
1001
  }
1002
  if ( $time == 'day' ) {
1003
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day"."- 1 days" );
1004
  $pDay = date('d',$prevdate);
1005
  $pYr = date('Y',$prevdate);
1006
+ $pMonth = date('m',$prevdate);
1007
+ if ( $pYr != $cur_year ) { $format = 'F j, Y'; } else { $format = 'F j'; }
1008
+ $date = date_i18n($format,mktime( 0,0,0,$pMonth,$pDay,$pYr ) );
1009
  }
1010
+ $previous_events = str_replace( '{date}', $date, $previous_events );
1011
  $output = array( 'month'=>$pMonth,'yr'=>$pYr,'day'=>$pDay,'label'=>$previous_events );
1012
  return $output;
1013
  }
1026
  <div>";
1027
  $qsa = array();
1028
  parse_str($_SERVER['QUERY_STRING'],$qsa);
1029
+ if ( !isset( $_GET['cid'] ) ) { $form .= '<input type="hidden" name="cid" value="'.$cid.'" />'; }
1030
  foreach ($qsa as $name => $argument) {
1031
+ $name = esc_attr(strip_tags($name));
1032
+ $argument = esc_attr(strip_tags($argument));
1033
  if ( $name != 'mcat' ) {
1034
  $form .= ' <input type="hidden" name="'.$name.'" value="'.$argument.'" />'."\n";
1035
  }
1195
  <div>
1196
  <input type='hidden' name='ltype' value='$ltype' />";
1197
  $qsa = array();
1198
+ if ( !isset( $_GET['cid'] ) ) { $output .= '<input type="hidden" name="cid" value="'.$cid.'" />'; }
1199
+ foreach ($qsa as $name => $argument) {
1200
+ $name = esc_attr(strip_tags($name));
1201
+ $argument = esc_attr(strip_tags($argument));
1202
  if ($name != 'loc' && $name != 'ltype') {
1203
  $output .= ' <input type="hidden" name="'.$name.'" value="'.$argument.'" />'."\n";
1204
  }
1284
  }
1285
  return $gtz;
1286
  }
 
1287
  ?>
my-calendar-rss.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  function my_calendar_rss() {
3
  // establish template
 
4
  $template = "\n<item>
5
  <title>{title}</title>
6
  <link>{link}</link>
@@ -40,16 +41,20 @@ $output = '<?xml version="1.0" encoding="'.get_bloginfo('charset').'"?>
40
  <lastBuildDate>'. mysql2date('D, d M Y H:i:s +0000', time()+$offset) .'</lastBuildDate>
41
  <atom:link href="'. mc_get_current_url() .'" rel="self" type="application/rss+xml" />';
42
 
43
- $events = mc_get_rss_events();
44
  if ( is_array( $events) ) {
45
  //print_r($events);
46
  }
47
- $before = 0;
48
- $after = 15;
49
  foreach ( array_keys($events) as $key ) {
50
- $event =& $events[$key];
51
- $array = event_as_array($event);
52
- $output .= jd_draw_template( $array, $template, 'rss' );
 
 
 
 
 
53
  }
54
  $output .= '</channel>
55
  </rss>';
1
  <?php
2
  function my_calendar_rss() {
3
  // establish template
4
+ if ( isset($_GET['mcat']) ) { $cat_id = (int) $_GET['mcat']; } else { $cat_id = false; }
5
  $template = "\n<item>
6
  <title>{title}</title>
7
  <link>{link}</link>
41
  <lastBuildDate>'. mysql2date('D, d M Y H:i:s +0000', time()+$offset) .'</lastBuildDate>
42
  <atom:link href="'. mc_get_current_url() .'" rel="self" type="application/rss+xml" />';
43
 
44
+ $events = mc_get_rss_events( $cat_id );
45
  if ( is_array( $events) ) {
46
  //print_r($events);
47
  }
48
+ $groups = array();
 
49
  foreach ( array_keys($events) as $key ) {
50
+ $event =& $events[$key];
51
+ if ( !in_array( $event->event_group_id, $groups ) ) {
52
+ $array = event_as_array($event);
53
+ $output .= jd_draw_template( $array, $template, 'rss' );
54
+ if ( $event->event_span == 1 ) {
55
+ $groups[] = $event->event_group_id;
56
+ }
57
+ }
58
  }
59
  $output .= '</channel>
60
  </rss>';
my-calendar-settings.php CHANGED
@@ -37,7 +37,7 @@ function my_calendar_import() {
37
  foreach ($cats as $key) {
38
  $name = mysql_real_escape_string($key['category_name']);
39
  $color = mysql_real_escape_string($key['category_colour']);
40
- $id = mysql_real_escape_string($key['category_id']);
41
  $catsql = "INSERT INTO " . my_calendar_categories_table() . " SET
42
  category_id='".$id."',
43
  category_name='".$name."',
@@ -73,19 +73,21 @@ function edit_my_calendar_config() {
73
  $mc_event_approve = ( !empty($_POST['mc_event_approve']) && $_POST['mc_event_approve']=='on')?'true':'false';
74
  $mc_event_approve_perms = $_POST['mc_event_approve_perms'];
75
  $mc_event_edit_perms = $_POST['mc_event_edit_perms'];
 
 
76
  update_option('mc_event_approve_perms',$mc_event_approve_perms);
77
  update_option('mc_event_approve',$mc_event_approve);
78
  update_option('mc_can_manage_events',$new_perms);
79
  update_option('mc_event_edit_perms',$mc_event_edit_perms);
 
80
 
81
  if ( get_site_option('mc_multisite') == 2 ) {
82
  $mc_current_table = (int) $_POST['mc_current_table'];
83
  update_option('mc_current_table',$mc_current_table);
84
  }
85
-
86
  echo "<div class='updated'><p><strong>".__('Permissions Settings saved','my-calendar').".</strong></p></div>";
87
  }
88
- // output
89
  if (isset($_POST['mc_show_months']) ) {
90
  $mc_title_template = $_POST['mc_title_template'];
91
  $mc_details_label = $_POST['mc_details_label'];
@@ -95,6 +97,9 @@ function edit_my_calendar_config() {
95
  $templates['label'] = $mc_details_label;
96
  $templates['link'] = $mc_link_label;
97
  update_option('mc_uri',$_POST['mc_uri'] );
 
 
 
98
  update_option('mc_skip_holidays_category',(int) $_POST['mc_skip_holidays_category']);
99
  update_option('mc_skip_holidays',( !empty($_POST['mc_skip_holidays']) && $_POST['mc_skip_holidays']=='on')?'true':'false');
100
  update_option('mc_templates',$templates);
@@ -119,6 +124,8 @@ function edit_my_calendar_config() {
119
  update_option('mc_no_fifth_week',( !empty($_POST['mc_no_fifth_week']) && $_POST['mc_no_fifth_week']=='on')?'true':'false');
120
  update_option('mc_show_rss',( !empty($_POST['mc_show_rss']) && $_POST['mc_show_rss']=='on')?'true':'false');
121
  update_option('mc_show_ical',( !empty($_POST['mc_show_ical']) && $_POST['mc_show_ical']=='on')?'true':'false');
 
 
122
  update_option('mc_default_sort',$_POST['mc_default_sort']);
123
  // styles (output)
124
  echo "<div class=\"updated\"><p><strong>".__('Output Settings saved','my-calendar').".</strong></p></div>";
@@ -156,8 +163,10 @@ function edit_my_calendar_config() {
156
  $mc_next_events = $_POST['mc_next_events'];
157
  $mc_event_open = $_POST['mc_event_open'];
158
  $mc_event_closed = $_POST['mc_event_closed'];
 
159
  $my_calendar_caption = $_POST['my_calendar_caption'];
160
  update_option('mc_notime_text',$mc_notime_text);
 
161
  update_option('mc_next_events',$mc_next_events);
162
  update_option('mc_previous_events',$mc_previous_events);
163
  update_option('mc_caption',$my_calendar_caption);
@@ -211,6 +220,7 @@ function edit_my_calendar_config() {
211
  $mc_details_label = $templates['label'];
212
  $mc_link_label = $templates['link'];
213
  $mc_uri = get_option('mc_uri');
 
214
  ?>
215
  <div class="wrap">
216
  <?php
@@ -225,7 +235,7 @@ check_akismet();
225
  <h3><?php _e('Calendar Management Settings','my-calendar'); ?></h3>
226
  <div class="inside">
227
  <form id="my-calendar-manage" method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>">
228
- <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>
229
  <fieldset>
230
  <legend><?php _e('Calendar Options: Management','my-calendar'); ?></legend>
231
  <ul>
@@ -255,6 +265,8 @@ check_akismet();
255
  </select><br />
256
  <em><?php _e('By default, only administrators may edit or delete any event. Other users may only edit or delete events which they authored.','my-calendar'); ?></em>
257
  </li>
 
 
258
  <?php if ( get_site_option('mc_multisite') == 2 && MY_CALENDAR_TABLE != MY_CALENDAR_GLOBAL_TABLE ) { ?>
259
  <li>
260
  <input type="radio" name="mc_current_table" id="mc0" value="0"<?php echo jd_option_selected(get_option('mc_current_table'),0); ?> /> <label for="mc0"><?php _e('Currently editing my local calendar','my-calendar'); ?></label>
@@ -268,7 +280,7 @@ check_akismet();
268
  </ul>
269
  </fieldset>
270
  <p>
271
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Approval Settings','my-calendar'); ?> &raquo;" />
272
  </p>
273
  </form>
274
  </div>
@@ -285,10 +297,10 @@ check_akismet();
285
  <label for="mc_notime_text"><?php _e('Label for events without a set time','my-calendar'); ?></label> <input type="text" id="mc_notime_text" name="mc_notime_text" value="<?php if ( get_option('mc_notime_text') == "") { _e('N/A','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_notime_text') ) ); } ?>" />
286
  </li>
287
  <li>
288
- <label for="mc_previous_events"><?php _e('Previous events link','my-calendar'); ?></label> <input type="text" id="mc_previous_events" name="mc_previous_events" value="<?php if ( get_option('mc_previous_events') == "") { _e('Previous Events','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_previous_events') ) ); } ?>" />
289
  </li>
290
  <li>
291
- <label for="mc_next_events"><?php _e('Next events link','my-calendar'); ?></label> <input type="text" id="mc_next_events" name="mc_next_events" value="<?php if ( get_option('mc_next_events') == "") { _e('Next Events','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_next_events') ) ); } ?>" />
292
  </li>
293
  <li>
294
  <label for="mc_event_open"><?php _e('If events are open','my-calendar'); ?></label> <input type="text" id="mc_event_open" name="mc_event_open" value="<?php if ( get_option('mc_event_open') == "") { _e('Registration is open','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_event_open') ) ); } ?>" />
@@ -297,12 +309,15 @@ check_akismet();
297
  <label for="mc_event_closed"><?php _e('If events are closed','my-calendar'); ?></label> <input type="text" id="mc_event_closed" name="mc_event_closed" value="<?php if ( get_option('mc_event_closed') == "") { _e('Registration is closed','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_event_closed') ) ); } ?>" />
298
  </li>
299
  <li>
 
 
 
300
  <label for="my_calendar_caption"><?php _e('Additional caption:','my-calendar'); ?></label> <input type="text" id="my_calendar_caption" name="my_calendar_caption" value="<?php echo esc_attr( stripslashes( get_option('mc_caption') ) ); ?>" /><br /><small><?php _e('The calendar caption is the text containing the displayed month and year in either list or calendar format. This text will be displayed following that existing text.','my-calendar'); ?></small>
301
  </li>
302
  </ul>
303
  </fieldset>
304
  <p>
305
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Custom Text Settings','my-calendar'); ?> &raquo;" />
306
  </p>
307
  </form>
308
  </div>
@@ -312,6 +327,7 @@ check_akismet();
312
  <div class="inside">
313
  <form id="my-calendar-output" method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>">
314
  <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>
 
315
  <fieldset>
316
  <legend><?php _e('Calendar Options: Customize the Output of your Calendar','my-calendar'); ?></legend>
317
  <fieldset>
@@ -322,6 +338,16 @@ check_akismet();
322
  <input type="text" name="mc_uri" id="mc_uri" size="40" value="<?php echo esc_url($mc_uri); ?>" /><br /><small><?php _e('Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.','my-calendar'); ?> <?php mc_guess_calendar(); ?></small>
323
  </li>
324
  <li>
 
 
 
 
 
 
 
 
 
 
325
  <label for="mc_time_format"><?php _e('Time format','my-calendar'); ?></label> <input type="text" id="mc_time_format" name="mc_time_format" value="<?php if ( get_option('mc_time_format') == "") { echo ''; } else { echo esc_attr( get_option( 'mc_time_format') ); } ?>" /> <?php _e('Current:','my-calendar'); ?> <?php if ( get_option('mc_time_format') == '') { echo date_i18n( get_option('time_format') ); } else { echo date_i18n( get_option('mc_time_format') ); } ?>
326
  </li>
327
  <li>
@@ -338,6 +364,9 @@ check_akismet();
338
  <input type="checkbox" id="mc_show_ical" name="mc_show_ical" <?php jd_cal_checkCheckbox('mc_show_ical','true'); ?> /> <label for="mc_show_ical"><?php _e('Show link to iCal format download.','my-calendar'); ?></label> <small><?php _e('iCal outputs events occurring in the current calendar month.','my-calendar'); ?></small>
339
  </li>
340
  <li>
 
 
 
341
  <input type="checkbox" id="mc_display_jump" name="mc_display_jump" <?php jd_cal_checkCheckbox('mc_display_jump','true'); ?> /> <label for="mc_display_jump"><?php _e('Display a jumpbox for changing month and year quickly?','my-calendar'); ?></label>
342
  </li>
343
  </ul>
@@ -349,7 +378,7 @@ check_akismet();
349
  <ul>
350
  <li>
351
  <input type="checkbox" id="mc_show_weekends" name="mc_show_weekends" <?php jd_cal_checkCheckbox('mc_show_weekends','true'); ?> /> <label for="mc_show_weekends"><?php _e('Show Weekends on Calendar','my-calendar'); ?></label>
352
- </li>
353
  </ul>
354
  <?php // End Grid Options // ?>
355
  </fieldset>
@@ -466,8 +495,8 @@ check_akismet();
466
  </fieldset>
467
  </fieldset>
468
  <p>
469
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Output Settings','my-calendar'); ?> &raquo;" />
470
- </p>
471
  </form>
472
  </div>
473
  </div>
@@ -500,7 +529,7 @@ check_akismet();
500
  </ul>
501
  </fieldset>
502
  <p>
503
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Input Settings','my-calendar'); ?> &raquo;" />
504
  </p>
505
  </form>
506
  </div>
@@ -524,7 +553,7 @@ check_akismet();
524
  <p class="notice"><strong>*</strong> <?php _e('Changes only effect input permissions. Public-facing calendars will be unchanged.','my-calendar'); ?></p>
525
  </fieldset>
526
  <p>
527
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Multisite Settings','my-calendar'); ?> &raquo;" />
528
  </p>
529
  </form>
530
  </div>
@@ -555,7 +584,7 @@ check_akismet();
555
  </ul>
556
  </fieldset>
557
  <p>
558
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Email Settings','my-calendar'); ?> &raquo;" />
559
  </p>
560
  </form>
561
  </div>
@@ -638,7 +667,7 @@ $locations .= stripslashes("$key,$value")."\n";
638
  </fieldset>
639
  </fieldset>
640
  <p>
641
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save User Settings','my-calendar'); ?> &raquo;" />
642
  </p>
643
  </form>
644
  <?php
37
  foreach ($cats as $key) {
38
  $name = mysql_real_escape_string($key['category_name']);
39
  $color = mysql_real_escape_string($key['category_colour']);
40
+ $id = (int) $key['category_id'];
41
  $catsql = "INSERT INTO " . my_calendar_categories_table() . " SET
42
  category_id='".$id."',
43
  category_name='".$name."',
73
  $mc_event_approve = ( !empty($_POST['mc_event_approve']) && $_POST['mc_event_approve']=='on')?'true':'false';
74
  $mc_event_approve_perms = $_POST['mc_event_approve_perms'];
75
  $mc_event_edit_perms = $_POST['mc_event_edit_perms'];
76
+ $mc_caching_enabled = ( !empty($_POST['mc_caching_enabled']) && $_POST['mc_caching_enabled']=='on')?'true':'false';
77
+
78
  update_option('mc_event_approve_perms',$mc_event_approve_perms);
79
  update_option('mc_event_approve',$mc_event_approve);
80
  update_option('mc_can_manage_events',$new_perms);
81
  update_option('mc_event_edit_perms',$mc_event_edit_perms);
82
+ update_option('mc_caching_enabled',$mc_caching_enabled);
83
 
84
  if ( get_site_option('mc_multisite') == 2 ) {
85
  $mc_current_table = (int) $_POST['mc_current_table'];
86
  update_option('mc_current_table',$mc_current_table);
87
  }
 
88
  echo "<div class='updated'><p><strong>".__('Permissions Settings saved','my-calendar').".</strong></p></div>";
89
  }
90
+ // output
91
  if (isset($_POST['mc_show_months']) ) {
92
  $mc_title_template = $_POST['mc_title_template'];
93
  $mc_details_label = $_POST['mc_details_label'];
97
  $templates['label'] = $mc_details_label;
98
  $templates['link'] = $mc_link_label;
99
  update_option('mc_uri',$_POST['mc_uri'] );
100
+ update_option('mc_open_uri',( !empty($_POST['mc_open_uri']) && $_POST['mc_open_uri']=='on' && get_option('mc_uri') != '')?'true':'false');
101
+ update_option('mc_day_uri',$_POST['mc_day_uri'] );
102
+ update_option('mc_open_day_uri',( !empty($_POST['mc_open_day_uri']) && $_POST['mc_open_day_uri']=='on' && get_option('mc_day_uri') != '')?'true':'false');
103
  update_option('mc_skip_holidays_category',(int) $_POST['mc_skip_holidays_category']);
104
  update_option('mc_skip_holidays',( !empty($_POST['mc_skip_holidays']) && $_POST['mc_skip_holidays']=='on')?'true':'false');
105
  update_option('mc_templates',$templates);
124
  update_option('mc_no_fifth_week',( !empty($_POST['mc_no_fifth_week']) && $_POST['mc_no_fifth_week']=='on')?'true':'false');
125
  update_option('mc_show_rss',( !empty($_POST['mc_show_rss']) && $_POST['mc_show_rss']=='on')?'true':'false');
126
  update_option('mc_show_ical',( !empty($_POST['mc_show_ical']) && $_POST['mc_show_ical']=='on')?'true':'false');
127
+ update_option('mc_show_print',( !empty($_POST['mc_show_print']) && $_POST['mc_show_print']=='on')?'true':'false');
128
+
129
  update_option('mc_default_sort',$_POST['mc_default_sort']);
130
  // styles (output)
131
  echo "<div class=\"updated\"><p><strong>".__('Output Settings saved','my-calendar').".</strong></p></div>";
163
  $mc_next_events = $_POST['mc_next_events'];
164
  $mc_event_open = $_POST['mc_event_open'];
165
  $mc_event_closed = $_POST['mc_event_closed'];
166
+ $mc_week_caption = $_POST['mc_week_caption'];
167
  $my_calendar_caption = $_POST['my_calendar_caption'];
168
  update_option('mc_notime_text',$mc_notime_text);
169
+ update_option('mc_week_caption',$mc_week_caption);
170
  update_option('mc_next_events',$mc_next_events);
171
  update_option('mc_previous_events',$mc_previous_events);
172
  update_option('mc_caption',$my_calendar_caption);
220
  $mc_details_label = $templates['label'];
221
  $mc_link_label = $templates['link'];
222
  $mc_uri = get_option('mc_uri');
223
+ $mc_day_uri = get_option('mc_day_uri');
224
  ?>
225
  <div class="wrap">
226
  <?php
235
  <h3><?php _e('Calendar Management Settings','my-calendar'); ?></h3>
236
  <div class="inside">
237
  <form id="my-calendar-manage" method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>">
238
+ <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>
239
  <fieldset>
240
  <legend><?php _e('Calendar Options: Management','my-calendar'); ?></legend>
241
  <ul>
265
  </select><br />
266
  <em><?php _e('By default, only administrators may edit or delete any event. Other users may only edit or delete events which they authored.','my-calendar'); ?></em>
267
  </li>
268
+ <li><input type="checkbox" id="mc_caching_enabled" name="mc_caching_enabled" <?php jd_cal_checkCheckbox('mc_caching_enabled','true'); ?> /> <label for="mc_caching_enabled"><?php _e('Enable caching.','my-calendar'); ?></label>
269
+ </li>
270
  <?php if ( get_site_option('mc_multisite') == 2 && MY_CALENDAR_TABLE != MY_CALENDAR_GLOBAL_TABLE ) { ?>
271
  <li>
272
  <input type="radio" name="mc_current_table" id="mc0" value="0"<?php echo jd_option_selected(get_option('mc_current_table'),0); ?> /> <label for="mc0"><?php _e('Currently editing my local calendar','my-calendar'); ?></label>
280
  </ul>
281
  </fieldset>
282
  <p>
283
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Management Settings','my-calendar'); ?>" />
284
  </p>
285
  </form>
286
  </div>
297
  <label for="mc_notime_text"><?php _e('Label for events without a set time','my-calendar'); ?></label> <input type="text" id="mc_notime_text" name="mc_notime_text" value="<?php if ( get_option('mc_notime_text') == "") { _e('N/A','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_notime_text') ) ); } ?>" />
298
  </li>
299
  <li>
300
+ <label for="mc_previous_events"><?php _e('Previous events link','my-calendar'); ?></label> <input type="text" id="mc_previous_events" name="mc_previous_events" value="<?php if ( get_option('mc_previous_events') == "") { _e('Previous Events','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_previous_events') ) ); } ?>" /> <?php _e('Use <code>{date}</code> to display the appropriate date in navigation.','my-calendar'); ?>
301
  </li>
302
  <li>
303
+ <label for="mc_next_events"><?php _e('Next events link','my-calendar'); ?></label> <input type="text" id="mc_next_events" name="mc_next_events" value="<?php if ( get_option('mc_next_events') == "") { _e('Next Events','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_next_events') ) ); } ?>" /> <?php _e('Use <code>{date}</code> to display the appropriate date in navigation.','my-calendar'); ?>
304
  </li>
305
  <li>
306
  <label for="mc_event_open"><?php _e('If events are open','my-calendar'); ?></label> <input type="text" id="mc_event_open" name="mc_event_open" value="<?php if ( get_option('mc_event_open') == "") { _e('Registration is open','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_event_open') ) ); } ?>" />
309
  <label for="mc_event_closed"><?php _e('If events are closed','my-calendar'); ?></label> <input type="text" id="mc_event_closed" name="mc_event_closed" value="<?php if ( get_option('mc_event_closed') == "") { _e('Registration is closed','my-calendar'); } else { echo esc_attr( stripslashes( get_option('mc_event_closed') ) ); } ?>" />
310
  </li>
311
  <li>
312
+ <label for="mc_week_caption"><?php _e('Week view caption:','my-calendar'); ?></label> <input type="text" id="mc_week_caption" name="mc_week_caption" value="<?php echo esc_attr( stripslashes( get_option('mc_week_caption') ) ); ?>" />
313
+ </li>
314
+ <li>
315
  <label for="my_calendar_caption"><?php _e('Additional caption:','my-calendar'); ?></label> <input type="text" id="my_calendar_caption" name="my_calendar_caption" value="<?php echo esc_attr( stripslashes( get_option('mc_caption') ) ); ?>" /><br /><small><?php _e('The calendar caption is the text containing the displayed month and year in either list or calendar format. This text will be displayed following that existing text.','my-calendar'); ?></small>
316
  </li>
317
  </ul>
318
  </fieldset>
319
  <p>
320
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Custom Text Settings','my-calendar'); ?>" />
321
  </p>
322
  </form>
323
  </div>
327
  <div class="inside">
328
  <form id="my-calendar-output" method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>">
329
  <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>
330
+ <p><input type="submit" name="save" class="button-primary" value="<?php _e('Save Output Settings','my-calendar'); ?>" /></p>
331
  <fieldset>
332
  <legend><?php _e('Calendar Options: Customize the Output of your Calendar','my-calendar'); ?></legend>
333
  <fieldset>
338
  <input type="text" name="mc_uri" id="mc_uri" size="40" value="<?php echo esc_url($mc_uri); ?>" /><br /><small><?php _e('Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.','my-calendar'); ?> <?php mc_guess_calendar(); ?></small>
339
  </li>
340
  <li>
341
+ <input type="checkbox" id="mc_open_uri" name="mc_open_uri" <?php jd_cal_checkCheckbox('mc_open_uri','true'); ?> /> <label for="mc_open_uri"><?php _e('Open calendar links in single event view','my-calendar'); ?></label> <small><?php _e('Replaces pop-up in grid view.','my-calendar'); ?></small>
342
+ </li>
343
+ <li>
344
+ <label for="mc_day_uri"><?php _e('<abbr title="Uniform resource locator">URL</abbr> for the single days events timeline.','my-calendar'); ?></label>
345
+ <input type="text" name="mc_day_uri" id="mc_day_uri" size="40" value="<?php echo esc_url($mc_day_uri); ?>" /><br /><small><?php _e('Can be any Page or Post with the <code>[my_calendar time="day"]</code> shortcode.','my-calendar'); ?> <?php mc_guess_calendar(); ?></small>
346
+ </li>
347
+ <li>
348
+ <input type="checkbox" id="mc_open_day_uri" name="mc_open_day_uri" <?php jd_cal_checkCheckbox('mc_open_day_uri','true'); ?> /> <label for="mc_open_day_uri"><?php _e('Open Mini calendar widget to daily view page (above)','my-calendar'); ?></label> <small><?php _e('Replaces pop-up in mini calendar','my-calendar'); ?></small>
349
+ </li>
350
+ <li>
351
  <label for="mc_time_format"><?php _e('Time format','my-calendar'); ?></label> <input type="text" id="mc_time_format" name="mc_time_format" value="<?php if ( get_option('mc_time_format') == "") { echo ''; } else { echo esc_attr( get_option( 'mc_time_format') ); } ?>" /> <?php _e('Current:','my-calendar'); ?> <?php if ( get_option('mc_time_format') == '') { echo date_i18n( get_option('time_format') ); } else { echo date_i18n( get_option('mc_time_format') ); } ?>
352
  </li>
353
  <li>
364
  <input type="checkbox" id="mc_show_ical" name="mc_show_ical" <?php jd_cal_checkCheckbox('mc_show_ical','true'); ?> /> <label for="mc_show_ical"><?php _e('Show link to iCal format download.','my-calendar'); ?></label> <small><?php _e('iCal outputs events occurring in the current calendar month.','my-calendar'); ?></small>
365
  </li>
366
  <li>
367
+ <input type="checkbox" id="mc_show_print" name="mc_show_print" <?php jd_cal_checkCheckbox('mc_show_print','true'); ?> /> <label for="mc_show_print"><?php _e('Show link to print-formatted view of calendar','my-calendar'); ?></label>
368
+ </li>
369
+ <li>
370
  <input type="checkbox" id="mc_display_jump" name="mc_display_jump" <?php jd_cal_checkCheckbox('mc_display_jump','true'); ?> /> <label for="mc_display_jump"><?php _e('Display a jumpbox for changing month and year quickly?','my-calendar'); ?></label>
371
  </li>
372
  </ul>
378
  <ul>
379
  <li>
380
  <input type="checkbox" id="mc_show_weekends" name="mc_show_weekends" <?php jd_cal_checkCheckbox('mc_show_weekends','true'); ?> /> <label for="mc_show_weekends"><?php _e('Show Weekends on Calendar','my-calendar'); ?></label>
381
+ </li>
382
  </ul>
383
  <?php // End Grid Options // ?>
384
  </fieldset>
495
  </fieldset>
496
  </fieldset>
497
  <p>
498
+ <input type="submit" name="save" class="button-secondary" value="<?php _e('Save Output Settings','my-calendar'); ?>" />
499
+ </p>
500
  </form>
501
  </div>
502
  </div>
529
  </ul>
530
  </fieldset>
531
  <p>
532
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Input Settings','my-calendar'); ?>" />
533
  </p>
534
  </form>
535
  </div>
553
  <p class="notice"><strong>*</strong> <?php _e('Changes only effect input permissions. Public-facing calendars will be unchanged.','my-calendar'); ?></p>
554
  </fieldset>
555
  <p>
556
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Multisite Settings','my-calendar'); ?>" />
557
  </p>
558
  </form>
559
  </div>
584
  </ul>
585
  </fieldset>
586
  <p>
587
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Email Settings','my-calendar'); ?>" />
588
  </p>
589
  </form>
590
  </div>
667
  </fieldset>
668
  </fieldset>
669
  <p>
670
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save User Settings','my-calendar'); ?>" />
671
  </p>
672
  </form>
673
  <?php
my-calendar-shortcodes.php CHANGED
@@ -15,7 +15,8 @@ function my_calendar_insert($atts) {
15
  ), $atts));
16
  if ( isset($_GET['format']) ) {
17
  $format = mysql_real_escape_string($_GET['format']);
18
- }
 
19
  return my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time, $ltype, $lvalue );
20
  }
21
 
15
  ), $atts));
16
  if ( isset($_GET['format']) ) {
17
  $format = mysql_real_escape_string($_GET['format']);
18
+ }
19
+ //apply_filters( 'mc_filter_calendar_name',$all_styles,$styles );
20
  return my_calendar($name,$format,$category,$showkey,$shownav,$toggle,$time, $ltype, $lvalue );
21
  }
22
 
my-calendar-styles.php CHANGED
@@ -163,7 +163,7 @@ my_calendar_check_db();
163
  echo "</optgroup>";
164
  ?>
165
  </select>
166
- <input type="submit" name="save" class="button-primary" value="<?php _e('Choose Style','my-calendar'); ?> &raquo;" />
167
  </p>
168
  </fieldset>
169
  </form>
@@ -192,10 +192,10 @@ my_calendar_check_db();
192
  <input type="checkbox" id="reset_styles" name="reset_styles" <?php if (mc_is_custom_style(get_option('mc_css_file'))) { echo "disabled='disabled'"; } ?> /> <label for="reset_styles"><?php _e('Restore My Calendar stylesheet','my-calendar'); ?></label> <input type="checkbox" id="use_styles" name="use_styles" <?php jd_cal_checkCheckbox('mc_use_styles','true'); ?> /> <label for="use_styles"><?php _e('Disable My Calendar Stylesheet','my-calendar'); ?></label>
193
  </p>
194
  <p>
195
- <label for="style"><?php _e('Edit the stylesheet for My Calendar','my-calendar'); ?></label><br /><textarea id="style" name="style" rows="30" cols="80"<?php if ( get_option('mc_use_styles') == 'true' ) { echo "disabled='disabled'"; } ?>><?php echo $my_calendar_style; ?></textarea>
196
  </p>
197
  <p>
198
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-calendar'); ?> &raquo;" />
199
  </p>
200
  </fieldset>
201
  </form>
163
  echo "</optgroup>";
164
  ?>
165
  </select>
166
+ <input type="submit" name="save" class="button-secondary" value="<?php _e('Choose Style','my-calendar'); ?>" />
167
  </p>
168
  </fieldset>
169
  </form>
192
  <input type="checkbox" id="reset_styles" name="reset_styles" <?php if (mc_is_custom_style(get_option('mc_css_file'))) { echo "disabled='disabled'"; } ?> /> <label for="reset_styles"><?php _e('Restore My Calendar stylesheet','my-calendar'); ?></label> <input type="checkbox" id="use_styles" name="use_styles" <?php jd_cal_checkCheckbox('mc_use_styles','true'); ?> /> <label for="use_styles"><?php _e('Disable My Calendar Stylesheet','my-calendar'); ?></label>
193
  </p>
194
  <p>
195
+ <label for="style"><?php _e('Edit the stylesheet for My Calendar','my-calendar'); ?></label><br /><textarea class="style-editor" id="style" name="style" rows="30" cols="80"<?php if ( get_option('mc_use_styles') == 'true' ) { echo "disabled='disabled'"; } ?>><?php echo $my_calendar_style; ?></textarea>
196
  </p>
197
  <p>
198
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Changes','my-calendar'); ?>" />
199
  </p>
200
  </fieldset>
201
  </form>
my-calendar-templates.php CHANGED
@@ -142,8 +142,8 @@ function event_as_array($event,$type='html') {
142
  $offset = get_option('gmt_offset'); // reset offset in hours
143
  $os = strtotime($event->event_begin .' '. $event->event_time);
144
  $oe = strtotime($real_end_date .' '. $endtime );
145
- $dtstart = date("Ymd\THi00", (mktime(date('H',$os),date('i',$os), date('s',$os), date('m',$os),date('d',$os), date('Y',$os) ) - ($offset*60*60) ) ).'Z';
146
- $dtend = date("Ymd\THi00", (mktime(date('H',$oe),date('i',$oe), date('s',$oe), date('m',$oe),date('d',$oe), date('Y',$oe) ) - ($offset*60*60) ) ).'Z';
147
  $details['ical_start'] = $dtstart;
148
  $details['ical_end'] = $dtend;
149
  $ical_link = mc_build_url( array('vcal'=>"mc_".$dateid."_".$id), array('month','dy','yr','ltype','loc','mcat','format'), get_option( 'mc_uri' ) );
@@ -152,8 +152,9 @@ function event_as_array($event,$type='html') {
152
  $details['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime($event->event_begin.' '.$event->event_time) );// hcal formatted
153
  $details['dtend'] = date( 'Y-m-d\TH:i:s', strtotime($real_end_date.' '.$endtime) ); //hcal formatted end
154
  $details['rssdate'] = date( 'D, d M Y H:i:s +0000', strtotime( $event->event_added ) );
155
- $details['date'] = $date;
156
  $details['enddate'] = $date_end;
 
157
  $details['cat_id'] = $event->event_category;
158
  $details['category'] = stripslashes($event->category_name);
159
  $details['title'] = stripcslashes($event->event_title);
@@ -176,7 +177,8 @@ function event_as_array($event,$type='html') {
176
  $event_open = '';
177
  }
178
 
179
- $details['description'] = stripslashes($event->event_desc);
 
180
  $details['link_title'] = ($details['link'] != '')?"<a href='".$event->event_link."'>".stripslashes($event->event_title)."</a>":stripslashes($event->event_title);
181
  $details['location'] = stripslashes($event->event_label);
182
  $details['street'] = stripslashes($event->event_street);
@@ -187,7 +189,8 @@ function event_as_array($event,$type='html') {
187
  $details['country'] = stripslashes($event->event_country);
188
  $details['hcard'] = stripslashes($hcard);
189
  $details['link_map'] = $map;
190
- $details['shortdesc'] = stripslashes($event->event_short);
 
191
  $details['event_open'] = $event_open;
192
  $details['icon'] = $category_icon;
193
  $details['icon_html'] = "<img src='$category_icon' class='mc-category-icon' alt='' />";
@@ -207,6 +210,10 @@ function event_as_array($event,$type='html') {
207
  $details['details'] = ( get_option( 'mc_uri' ) != '' )?"<a href='$details_link'>$details_label</a>":'';
208
  $details['dateid'] = $dateid;
209
  $details['id'] = $id;
 
 
 
 
210
  // RSS guid
211
  $details['region'] = $event->event_region;
212
  $details['guid'] =( get_option( 'mc_uri' ) != '')?"<guid isPermaLink='true'>$details_link</guid>":"<guid isPermalink='false'>$details_link</guid>";
@@ -215,9 +222,39 @@ function event_as_array($event,$type='html') {
215
  $ical_description = mc_newline_replace(strip_tags($event->event_desc));
216
  $details['ical_description'] = str_replace( "\r", "=0D=0A=", $event->event_desc );
217
  $details['ical_desc'] = $ical_description;
218
-
219
  $details = apply_filters( 'mc_filter_shortcodes',$details,$event );
220
-
221
  return $details;
222
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  ?>
142
  $offset = get_option('gmt_offset'); // reset offset in hours
143
  $os = strtotime($event->event_begin .' '. $event->event_time);
144
  $oe = strtotime($real_end_date .' '. $endtime );
145
+ $dtstart = date("Ymd\THi00", (mktime(date('H',$os),date('i',$os), date('s',$os), date('m',$os),date('d',$os), date('Y',$os) ) - ($offset*60*60) ) );
146
+ $dtend = date("Ymd\THi00", (mktime(date('H',$oe),date('i',$oe), date('s',$oe), date('m',$oe),date('d',$oe), date('Y',$oe) ) - ($offset*60*60) ) );
147
  $details['ical_start'] = $dtstart;
148
  $details['ical_end'] = $dtend;
149
  $ical_link = mc_build_url( array('vcal'=>"mc_".$dateid."_".$id), array('month','dy','yr','ltype','loc','mcat','format'), get_option( 'mc_uri' ) );
152
  $details['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime($event->event_begin.' '.$event->event_time) );// hcal formatted
153
  $details['dtend'] = date( 'Y-m-d\TH:i:s', strtotime($real_end_date.' '.$endtime) ); //hcal formatted end
154
  $details['rssdate'] = date( 'D, d M Y H:i:s +0000', strtotime( $event->event_added ) );
155
+ $details['date'] = ($event->event_span != 1)?$date:mc_event_date_span( $event->event_group_id, $event->event_span, 'simple', $date );
156
  $details['enddate'] = $date_end;
157
+ $details['daterange'] = ($date == $date_end)?$date:$date." <span>&ndash;</span> ".$date_end;
158
  $details['cat_id'] = $event->event_category;
159
  $details['category'] = stripslashes($event->category_name);
160
  $details['title'] = stripcslashes($event->event_title);
177
  $event_open = '';
178
  }
179
 
180
+ $details['description'] = wpautop(stripslashes($event->event_desc));
181
+ $details['description_raw'] = stripslashes($event->event_desc);
182
  $details['link_title'] = ($details['link'] != '')?"<a href='".$event->event_link."'>".stripslashes($event->event_title)."</a>":stripslashes($event->event_title);
183
  $details['location'] = stripslashes($event->event_label);
184
  $details['street'] = stripslashes($event->event_street);
189
  $details['country'] = stripslashes($event->event_country);
190
  $details['hcard'] = stripslashes($hcard);
191
  $details['link_map'] = $map;
192
+ $details['shortdesc'] = wpautop(stripslashes($event->event_short));
193
+ $details['shortdesc_raw'] = stripslashes($event->event_short);
194
  $details['event_open'] = $event_open;
195
  $details['icon'] = $category_icon;
196
  $details['icon_html'] = "<img src='$category_icon' class='mc-category-icon' alt='' />";
210
  $details['details'] = ( get_option( 'mc_uri' ) != '' )?"<a href='$details_link'>$details_label</a>":'';
211
  $details['dateid'] = $dateid;
212
  $details['id'] = $id;
213
+ $details['group'] = $event->event_group_id;
214
+ $details['event_span'] = $event->event_span;
215
+ $details['datespan'] = ($event->event_span != 1)?$date:mc_event_date_span( $event->event_group_id, $event->event_span, 'simple' );
216
+ $details['multidate'] = mc_event_date_span( $event->event_group_id, $event->event_span, 'complex', "<span class='fallback-date'>$date</span><span class='separator'>,</span> <span class='fallback-time'>$details[time]</span>" );
217
  // RSS guid
218
  $details['region'] = $event->event_region;
219
  $details['guid'] =( get_option( 'mc_uri' ) != '')?"<guid isPermaLink='true'>$details_link</guid>":"<guid isPermalink='false'>$details_link</guid>";
222
  $ical_description = mc_newline_replace(strip_tags($event->event_desc));
223
  $details['ical_description'] = str_replace( "\r", "=0D=0A=", $event->event_desc );
224
  $details['ical_desc'] = $ical_description;
 
225
  $details = apply_filters( 'mc_filter_shortcodes',$details,$event );
 
226
  return $details;
227
  }
228
+
229
+ function mc_event_date_span( $group_id, $event_span, $display='simple', $default='' ) {
230
+ global $wpdb;
231
+ $group_id = (int) $group_id;
232
+ if ( $group_id == 0 || $event_span != 1 ) return $default;
233
+ $sql = "SELECT event_begin, event_time, event_end, event_endtime FROM ".my_calendar_table()." WHERE event_group_id = $group_id ORDER BY event_begin ASC";
234
+ $dates = $wpdb->get_results( $sql );
235
+ $count = count($dates);
236
+ $last = $count - 1;
237
+ if ( $display == 'simple' ) {
238
+ $begin = $dates[0]->event_begin . ' ' . $dates[0]->event_time;
239
+ $end = $dates[$last]->event_end . ' ' . $dates[$last]->event_endtime;
240
+ $begin = date_i18n( get_option('mc_date_format'),strtotime( $begin ));
241
+ $end = date_i18n( get_option('mc_date_format'),strtotime( $end ));
242
+ $return = $begin . ' <span>&ndash;</span> ' . $end;
243
+ } else {
244
+ $return = "<ul class='multidate'>";
245
+ foreach ($dates as $date ) {
246
+ $begin = $date->event_begin . ' ' . $date->event_time;
247
+ $end = $date->event_end . ' ' . $date->event_endtime;
248
+ $bformat = "<span class='multidate-date'>".date_i18n( get_option('mc_date_format'),strtotime( $begin ) ).'</span> <span class="multidate-time">'.date_i18n( get_option('mc_time_format'), strtotime( $begin ) )."</span>";
249
+ $endtimeformat = ($date->event_endtime == '00:00:00')?'':' '.get_option('mc_time_format');
250
+ $eformat = ($date->event_begin != $date->event_end)?get_option('mc_date_format').$endtimeformat:$endtimeformat;
251
+ $span = ($eformat != '')?" <span>&ndash;</span> <span class='multidate-end'>":'';
252
+ $endspan = ($eformat != '')?"</span>":'';
253
+ $return .= "<li>$bformat".$span.date_i18n( $eformat,strtotime( $end ))."$endspan</li>";
254
+ }
255
+ $return .= "</ul>";
256
+ }
257
+ return $return;
258
+ }
259
+
260
  ?>
my-calendar-templating.php CHANGED
@@ -90,6 +90,12 @@ function edit_mc_templates() {
90
  <dt><code>{endtime}</code></dt>
91
  <dd><?php _e('Time at which the event ends.','my-calendar'); ?></dd>
92
 
 
 
 
 
 
 
93
  <dt><code>{author}</code></dt>
94
  <dd><?php _e('Author who posted the event.','my-calendar'); ?></dd>
95
 
@@ -183,10 +189,10 @@ function edit_mc_templates() {
183
  <input type="checkbox" id="mc_use_grid_template" name="mc_use_grid_template" value="1" <?php jd_cal_checkCheckbox('mc_use_grid_template',1); ?>/> <label for="mc_use_grid_template"><?php _e('Use this grid event template','my-calendar'); ?></label>
184
  </p>
185
  <p>
186
- <label for="mc_grid_template"><?php _e('Your custom template for events in the calendar grid output.','my-calendar'); ?></label><br /><textarea id="mc_grid_template" name="mc_grid_template" rows="12" cols="64"><?php echo $mc_grid_template; ?></textarea>
187
  </p>
188
  <p>
189
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Grid Template','my-calendar'); ?> &raquo;" />
190
  </p>
191
  </form>
192
  </div>
@@ -203,10 +209,10 @@ function edit_mc_templates() {
203
  <input type="checkbox" id="mc_use_list_template" name="mc_use_list_template" value="1" <?php jd_cal_checkCheckbox('mc_use_list_template',1); ?>/> <label for="mc_use_list_template"><?php _e('Use this list event template','my-calendar'); ?></label>
204
  </p>
205
  <p>
206
- <label for="mc_list_template"><?php _e('Your custom template for events in calendar list output.','my-calendar'); ?></label><br /><textarea id="mc_list_template" name="mc_list_template" rows="12" cols="64"><?php echo $mc_list_template; ?></textarea>
207
  </p>
208
  <p>
209
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save List Template','my-calendar'); ?> &raquo;" />
210
  </p>
211
  </form>
212
  </div>
@@ -223,10 +229,10 @@ function edit_mc_templates() {
223
  <input type="checkbox" id="mc_use_mini_template" name="mc_use_mini_template" value="1" <?php jd_cal_checkCheckbox('mc_use_mini_template',1); ?>/> <label for="mc_use_mini_template"><?php _e('Use this mini event template','my-calendar'); ?></label>
224
  </p>
225
  <p>
226
- <label for="mc_mini_template"><?php _e('Your custom template for events in sidebar/mini calendar output.','my-calendar'); ?></label><br /><textarea id="mc_mini_template" name="mc_mini_template" rows="12" cols="64"><?php echo $mc_mini_template; ?></textarea>
227
  </p>
228
  <p>
229
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Mini Template','my-calendar'); ?> &raquo;" />
230
  </p>
231
  </form>
232
  </div>
@@ -243,10 +249,10 @@ function edit_mc_templates() {
243
  <input type="checkbox" id="mc_use_details_template" name="mc_use_details_template" value="1" <?php jd_cal_checkCheckbox('mc_use_details_template',1); ?>/> <label for="mc_use_details_template"><?php _e('Use this details template','my-calendar'); ?></label>
244
  </p>
245
  <p>
246
- <label for="mc_details_template"><?php _e('Your custom template for events on the event details page.','my-calendar'); ?></label><br /><textarea id="mc_details_template" name="mc_details_template" rows="12" cols="64"><?php echo $mc_details_template; ?></textarea>
247
  </p>
248
  <p>
249
- <input type="submit" name="save" class="button-primary" value="<?php _e('Save Details Template','my-calendar'); ?> &raquo;" />
250
  </p>
251
  </form>
252
  </div>
90
  <dt><code>{endtime}</code></dt>
91
  <dd><?php _e('Time at which the event ends.','my-calendar'); ?></dd>
92
 
93
+ <dt><code>{daterange}</code></dt>
94
+ <dd><?php _e('Beginning date to end date; excludes end date if same as beginning.','my-calendar'); ?></dd>
95
+
96
+ <dt><code>{multidate}</code></dt>
97
+ <dd><?php _e('Multi-day events: an unordered list of dates/times. Otherwise, beginning date/time.','my-calendar'); ?></dd>
98
+
99
  <dt><code>{author}</code></dt>
100
  <dd><?php _e('Author who posted the event.','my-calendar'); ?></dd>
101
 
189
  <input type="checkbox" id="mc_use_grid_template" name="mc_use_grid_template" value="1" <?php jd_cal_checkCheckbox('mc_use_grid_template',1); ?>/> <label for="mc_use_grid_template"><?php _e('Use this grid event template','my-calendar'); ?></label>
190
  </p>
191
  <p>
192
+ <label for="mc_grid_template"><?php _e('Your custom template for events in the calendar grid output.','my-calendar'); ?></label><br /><textarea id="mc_grid_template" name="mc_grid_template" class="template-editor" rows="12" cols="76"><?php echo $mc_grid_template; ?></textarea>
193
  </p>
194
  <p>
195
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Grid Template','my-calendar'); ?>" />
196
  </p>
197
  </form>
198
  </div>
209
  <input type="checkbox" id="mc_use_list_template" name="mc_use_list_template" value="1" <?php jd_cal_checkCheckbox('mc_use_list_template',1); ?>/> <label for="mc_use_list_template"><?php _e('Use this list event template','my-calendar'); ?></label>
210
  </p>
211
  <p>
212
+ <label for="mc_list_template"><?php _e('Your custom template for events in calendar list output.','my-calendar'); ?></label><br /><textarea id="mc_list_template" name="mc_list_template" class="template-editor" rows="12" cols="76"><?php echo $mc_list_template; ?></textarea>
213
  </p>
214
  <p>
215
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save List Template','my-calendar'); ?>" />
216
  </p>
217
  </form>
218
  </div>
229
  <input type="checkbox" id="mc_use_mini_template" name="mc_use_mini_template" value="1" <?php jd_cal_checkCheckbox('mc_use_mini_template',1); ?>/> <label for="mc_use_mini_template"><?php _e('Use this mini event template','my-calendar'); ?></label>
230
  </p>
231
  <p>
232
+ <label for="mc_mini_template"><?php _e('Your custom template for events in sidebar/mini calendar output.','my-calendar'); ?></label><br /><textarea id="mc_mini_template" name="mc_mini_template" rows="12" cols="76" class="template-editor"><?php echo $mc_mini_template; ?></textarea>
233
  </p>
234
  <p>
235
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Mini Template','my-calendar'); ?>" />
236
  </p>
237
  </form>
238
  </div>
249
  <input type="checkbox" id="mc_use_details_template" name="mc_use_details_template" value="1" <?php jd_cal_checkCheckbox('mc_use_details_template',1); ?>/> <label for="mc_use_details_template"><?php _e('Use this details template','my-calendar'); ?></label>
250
  </p>
251
  <p>
252
+ <label for="mc_details_template"><?php _e('Your custom template for events on the event details page.','my-calendar'); ?></label><br /><textarea id="mc_details_template" name="mc_details_template" rows="12" cols="76" class="template-editor"><?php echo $mc_details_template; ?></textarea>
253
  </p>
254
  <p>
255
+ <input type="submit" name="save" class="button-primary" value="<?php _e('Save Details Template','my-calendar'); ?>" />
256
  </p>
257
  </form>
258
  </div>
my-calendar-widgets.php CHANGED
@@ -86,14 +86,15 @@ function widget($args, $instance) {
86
  $before = ($instance['my_calendar_upcoming_before']!='')?esc_attr($instance['my_calendar_upcoming_before']):3;
87
  $after = ($instance['my_calendar_upcoming_after']!='')?esc_attr($instance['my_calendar_upcoming_after']):3;
88
  $skip = ($instance['my_calendar_upcoming_skip']!='')?esc_attr($instance['my_calendar_upcoming_skip']):0;
 
89
  $type = esc_attr($instance['my_calendar_upcoming_type']);
90
  $order = esc_attr($instance['my_calendar_upcoming_order']);
91
  $the_category = ($instance['my_calendar_upcoming_category']=='')?'default':esc_attr($instance['my_calendar_upcoming_category']);
92
  $widget_link = ($instance['my_calendar_upcoming_linked']=='yes')?get_option('mc_uri'):'';
93
  $widget_title = empty($the_title) ? '' : $the_title;
94
  $widget_title = ($widget_link=='') ? $widget_title : "<a href='$widget_link'>$widget_title</a>";
95
- $widget_title = ($widget_title!='') ? $before_title . $widget_title . $after_title : '';
96
- $the_events = my_calendar_upcoming_events($before,$after,$type,$the_category,$the_template,$the_substitute, $order,$skip);
97
  if ($the_events != '') {
98
  echo $before_widget;
99
  echo $widget_title;
@@ -112,6 +113,7 @@ function form($instance) {
112
  $widget_category = esc_attr($instance['my_calendar_upcoming_category']);
113
  $widget_before = esc_attr($instance['my_calendar_upcoming_before']);
114
  $widget_after = esc_attr($instance['my_calendar_upcoming_after']);
 
115
  $widget_type = esc_attr($instance['my_calendar_upcoming_type']);
116
  $widget_order = esc_attr($instance['my_calendar_upcoming_order']);
117
  $widget_linked = esc_attr($instance['my_calendar_upcoming_linked']);
@@ -156,7 +158,9 @@ function form($instance) {
156
  <input type="text" id="<?php echo $this->get_field_id('my_calendar_upcoming_after'); ?>" name="<?php echo $this->get_field_name('my_calendar_upcoming_after'); ?>" value="<?php echo $widget_after; ?>" size="1" maxlength="3" /> <label for="<?php echo $this->get_field_id('my_calendar_upcoming_after'); ?>"><?php _e("$widget_type into the future;",'my-calendar'); ?></label><br />
157
  <input type="text" id="<?php echo $this->get_field_id('my_calendar_upcoming_before'); ?>" name="<?php echo $this->get_field_name('my_calendar_upcoming_before'); ?>" value="<?php echo $widget_before; ?>" size="1" maxlength="3" /> <label for="<?php echo $this->get_field_id('my_calendar_upcoming_after'); ?>"><?php _e("$widget_type from the past",'my-calendar'); ?></label>
158
  </p>
159
-
 
 
160
  <p>
161
  <label for="<?php echo $this->get_field_id('my_calendar_no_events_text'); ?>"><?php _e('Show this text if there are no events meeting your criteria:','my-calendar'); ?></label><br />
162
  <input class="widefat" type="text" id="<?php echo $this->get_field_id('my_calendar_no_events_text'); ?>" name="<?php echo $this->get_field_name('my_calendar_no_events_text'); ?>" value="<?php echo $widget_text; ?>" /></textarea>
@@ -176,6 +180,7 @@ function form($instance) {
176
  $instance['my_calendar_upcoming_category'] = strip_tags($new_instance['my_calendar_upcoming_category']);
177
  $instance['my_calendar_upcoming_before'] = strip_tags($new_instance['my_calendar_upcoming_before']);
178
  $instance['my_calendar_upcoming_after'] = strip_tags($new_instance['my_calendar_upcoming_after']);
 
179
  $instance['my_calendar_upcoming_type'] = strip_tags($new_instance['my_calendar_upcoming_type']);
180
  $instance['my_calendar_upcoming_order'] = strip_tags($new_instance['my_calendar_upcoming_order']);
181
  $instance['my_calendar_upcoming_linked'] = strip_tags($new_instance['my_calendar_upcoming_linked']);
@@ -186,7 +191,7 @@ function form($instance) {
186
  }
187
 
188
  // Widget upcoming events
189
- function my_calendar_upcoming_events($before='default',$after='default',$type='default',$category='default',$template='default',$substitute='',$order='asc',$skip=0 ) {
190
  global $wpdb,$default_template,$defaults;
191
  $output = '';
192
  $date_format = ( get_option('mc_date_format') != '' )?get_option('mc_date_format'):get_option('date_format');
@@ -241,7 +246,8 @@ function my_calendar_upcoming_events($before='default',$after='default',$type='d
241
  $skipping = false;
242
  foreach ( array_keys($temp_array) as $key ) {
243
  $details = $temp_array[$key];
244
- // if any event this date is in the holiday category, we are skipping
 
245
  if ( $details['cat_id'] == get_option('mc_skip_holidays_category') ) {
246
  $skipping = true;
247
  break;
@@ -268,7 +274,7 @@ function my_calendar_upcoming_events($before='default',$after='default',$type='d
268
  }
269
  } else {
270
  $events = mc_get_all_events($category); // grab all events within reasonable proximity
271
- $output .= mc_produce_upcoming_events( $events,$template,$before,$after,'list',$order,$skip );
272
  }
273
  if ($output != '') {
274
  $output = $header.$output.$footer;
@@ -277,8 +283,19 @@ function my_calendar_upcoming_events($before='default',$after='default',$type='d
277
  return stripcslashes( $no_event_text );
278
  }
279
  }
 
 
 
 
 
 
 
 
 
 
 
280
  // make this function time-sensitive, not date-sensitive.
281
- function mc_produce_upcoming_events($events,$template,$before=0,$after=10,$type='list',$order='asc',$skip=0) {
282
  $output = '';
283
  $near_events = array();
284
  $temp_array = array();
@@ -288,29 +305,44 @@ function mc_produce_upcoming_events($events,$template,$before=0,$after=10,$type=
288
  $today = date('Y',time()+($offset)).'-'.date('m',time()+($offset)).'-'.date('d',time()+($offset));
289
  @usort( $events, "my_calendar_timediff_cmp" );// sort all events by proximity to current date
290
  $count = count($events);
 
 
291
  for ( $i=0;$i<$count;$i++ ) {
292
  if ( is_object( $events[$i] ) ) {
 
293
  $beginning = $events[$i]->event_begin . ' ' . $events[$i]->event_time;
294
- // tiny improvement, I hope: if event ends on same day and has an end-time set, expire it after the end of the event.
 
 
 
 
295
  if ( $events[$i]->event_endtime != '00:00:00' && $events[$i]->event_endtime != null && $events[$i]->event_begin == $events[$i]->event_end ) {
296
  $beginning = $events[$i]->event_end . ' ' . $events[$i]->event_endtime;
 
 
 
 
 
 
297
  }
298
  $current = date('Y-m-d H:i',time()+$offset);
299
- if ($events[$i]) {
300
- if ( ( $past<=$before && $future<=$after ) ) {
301
- $near_events[] = $events[$i]; // if neither limit is reached, split off freely
302
- } else if ( $past <= $before && ( my_calendar_date_comp( $beginning,$current ) ) ) {
303
- $near_events[] = $events[$i]; // split off another past event
304
- } else if ( $future <= $after && ( !my_calendar_date_comp( $beginning,$current ) ) ) {
305
- $near_events[] = $events[$i]; // split off another future event
306
- }
307
- if ( my_calendar_date_comp( $beginning,$current ) ) {
308
- $past++;
309
- } elseif ( my_calendar_date_equal( $beginning,$current ) ) {
310
- $present = 1;
311
- } else {
312
- $future++;
313
- }
 
 
314
  if ($past > $before && $future > $after) {
315
  break;
316
  }
@@ -319,9 +351,19 @@ function mc_produce_upcoming_events($events,$template,$before=0,$after=10,$type=
319
  }
320
  $events = $near_events;
321
  @usort( $events, "my_calendar_datetime_cmp" ); // sort split events by date
 
 
 
 
 
 
 
 
 
322
  if ( is_array( $events ) ) {
323
  foreach( array_keys($events) as $key ) {
324
  $event =& $events[$key];
 
325
  $event_details = event_as_array( $event );
326
  if ( get_option( 'mc_event_approve' ) == 'true' ) {
327
  if ( $event->event_approved != 0 ) { $temp_array[] = $event_details; }
@@ -341,37 +383,41 @@ function mc_produce_upcoming_events($events,$template,$before=0,$after=10,$type=
341
  }
342
  // check each event, if we're skipping, only include the holiday events.
343
  $i = 0;
 
344
  foreach( reverse_array($temp_array, true, $order) as $details ) {
345
- $date = date('Y-m-d',strtotime($details['date']));
346
- if (my_calendar_date_comp( $date,$today )===true) {
347
- $class = "past-event";
348
- } else {
349
- $class = "future-event";
350
- }
351
- if ( my_calendar_date_equal( $date,$today ) ) {
352
- $class = "today";
353
- }
354
- if ($type == 'list') {
355
- $prepend = "<li class=\"$class\">";
356
- $append = "</li>\n";
357
- } else {
358
- $prepend = $append = '';
359
- }
360
- // if any event this date is in the holiday category, we are skipping
361
-
362
- if ( $i < $skip && $skip != 0 ) {
363
- $i++;
364
- } else {
365
- if ($skipping == true) {
366
- if ($details['cat_id'] == get_option('mc_skip_holidays_category') ) {
367
- $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);
 
 
 
 
368
  } else {
369
- if ( $details['skip_holiday'] == 'false' ) { // 'true' means "is canceled"
370
- $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);
371
- }
372
  }
373
- } else {
374
- $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);
 
375
  }
376
  }
377
  }
@@ -385,8 +431,9 @@ function mc_produce_upcoming_events($events,$template,$before=0,$after=10,$type=
385
 
386
  // Widget todays events
387
  function my_calendar_todays_events($category='default',$template='default',$substitute='') {
388
- $todays_cache = get_transient('mc_todays_cache');
389
- if ( is_array($todays_cache) && $todays_cache[$category] ) { return $todays_cache[$category]; }
 
390
  global $wpdb, $default_template;
391
  $output = '';
392
  $offset = (60*60*get_option('gmt_offset'));
@@ -403,39 +450,42 @@ if ( is_array($todays_cache) && $todays_cache[$category] ) { return $todays_cach
403
  $footer = "</ul>";
404
  $holiday_exists = false;
405
  @usort($events, "my_calendar_time_cmp");
 
406
  // quick loop through all events today to check for holidays
407
  if (is_array($events) ) {
408
  foreach( array_keys($events) as $key ) {
409
  $event =& $events[$key];
410
  if ( $event->event_category == get_option('mc_skip_holidays_category') ) { $holiday_exists = true; }
411
  }
412
-
413
  foreach( array_keys($events) as $key ) {
414
- $event =& $events[$key];
415
- $event_details = event_as_array($event);
416
- $date = date_i18n(get_option('mc_date_format'),time()+$offset);
417
-
418
- // correct displayed time to today
419
- $event_details['date'] = $date;
420
- $this_event = '';
421
- if ( $event->event_holiday == 0 ) {
422
- if ( get_option( 'mc_event_approve' ) == 'true' ) {
423
- if ( $event->event_approved != 0 ) {$this_event = "<li>".jd_draw_template($event_details,$template)."</li>";}
424
- } else {
425
- $this_event = "<li>".jd_draw_template($event_details,$template)."</li>";
426
  }
427
- } else {
428
- // if we found a holiday earlier, then we know there is one today.
429
- if ( !$holiday_exists || ( $holiday_exists && $event->event_category == get_option('mc_skip_holidays_category') ) ) {
430
  if ( get_option( 'mc_event_approve' ) == 'true' ) {
431
  if ( $event->event_approved != 0 ) {$this_event = "<li>".jd_draw_template($event_details,$template)."</li>";}
432
  } else {
433
  $this_event = "<li>".jd_draw_template($event_details,$template)."</li>";
434
  }
 
 
 
 
 
 
 
 
 
435
  }
 
436
  }
437
- $output .= apply_filters( 'mc_event_today',$this_event,$event );
438
-
439
  }
440
  if (count($events) != 0) {
441
  $return = $header.$output.$footer;
@@ -444,8 +494,8 @@ if ( is_array($todays_cache) && $todays_cache[$category] ) { return $todays_cach
444
  }
445
  $time = strtotime( date( 'Y-m-d H:m:s',time()+$offset ) ) - strtotime( date( 'Y-m-d',time()+$offset ) );
446
  $time_remaining = 24*60*60 - $time;
447
- $todays_cache[$category] = $return;
448
- set_transient( 'mc_todays_cache', $todays_cache, $time_remaining );
449
  } else {
450
  $return = stripcslashes( $no_event_text );
451
  }
86
  $before = ($instance['my_calendar_upcoming_before']!='')?esc_attr($instance['my_calendar_upcoming_before']):3;
87
  $after = ($instance['my_calendar_upcoming_after']!='')?esc_attr($instance['my_calendar_upcoming_after']):3;
88
  $skip = ($instance['my_calendar_upcoming_skip']!='')?esc_attr($instance['my_calendar_upcoming_skip']):0;
89
+ $show_today = ($instance['my_calendar_upcoming_show_today']=='no')?'no':'yes';
90
  $type = esc_attr($instance['my_calendar_upcoming_type']);
91
  $order = esc_attr($instance['my_calendar_upcoming_order']);
92
  $the_category = ($instance['my_calendar_upcoming_category']=='')?'default':esc_attr($instance['my_calendar_upcoming_category']);
93
  $widget_link = ($instance['my_calendar_upcoming_linked']=='yes')?get_option('mc_uri'):'';
94
  $widget_title = empty($the_title) ? '' : $the_title;
95
  $widget_title = ($widget_link=='') ? $widget_title : "<a href='$widget_link'>$widget_title</a>";
96
+ $widget_title = ($widget_title!='') ? $before_title . $widget_title . $after_title : '';
97
+ $the_events = my_calendar_upcoming_events($before,$after,$type,$the_category,$the_template,$the_substitute, $order,$skip, $show_today);
98
  if ($the_events != '') {
99
  echo $before_widget;
100
  echo $widget_title;
113
  $widget_category = esc_attr($instance['my_calendar_upcoming_category']);
114
  $widget_before = esc_attr($instance['my_calendar_upcoming_before']);
115
  $widget_after = esc_attr($instance['my_calendar_upcoming_after']);
116
+ $widget_show_today = esc_attr($instance['my_calendar_upcoming_show_today']);
117
  $widget_type = esc_attr($instance['my_calendar_upcoming_type']);
118
  $widget_order = esc_attr($instance['my_calendar_upcoming_order']);
119
  $widget_linked = esc_attr($instance['my_calendar_upcoming_linked']);
158
  <input type="text" id="<?php echo $this->get_field_id('my_calendar_upcoming_after'); ?>" name="<?php echo $this->get_field_name('my_calendar_upcoming_after'); ?>" value="<?php echo $widget_after; ?>" size="1" maxlength="3" /> <label for="<?php echo $this->get_field_id('my_calendar_upcoming_after'); ?>"><?php _e("$widget_type into the future;",'my-calendar'); ?></label><br />
159
  <input type="text" id="<?php echo $this->get_field_id('my_calendar_upcoming_before'); ?>" name="<?php echo $this->get_field_name('my_calendar_upcoming_before'); ?>" value="<?php echo $widget_before; ?>" size="1" maxlength="3" /> <label for="<?php echo $this->get_field_id('my_calendar_upcoming_after'); ?>"><?php _e("$widget_type from the past",'my-calendar'); ?></label>
160
  </p>
161
+ <p>
162
+ <input type="checkbox" id="<?php echo $this->get_field_id('my_calendar_upcoming_show_today'); ?>" name="<?php echo $this->get_field_name('my_calendar_upcoming_show_today'); ?>" value="yes"<?php echo ($widget_show_today =='yes' || $widget_show_today == '' )?' checked="checked"':''; ?> /> <label for="<?php echo $this->get_field_id('my_calendar_upcoming_show_today'); ?>"><?php _e("Include today's events",'my-calendar'); ?></label>
163
+ </p>
164
  <p>
165
  <label for="<?php echo $this->get_field_id('my_calendar_no_events_text'); ?>"><?php _e('Show this text if there are no events meeting your criteria:','my-calendar'); ?></label><br />
166
  <input class="widefat" type="text" id="<?php echo $this->get_field_id('my_calendar_no_events_text'); ?>" name="<?php echo $this->get_field_name('my_calendar_no_events_text'); ?>" value="<?php echo $widget_text; ?>" /></textarea>
180
  $instance['my_calendar_upcoming_category'] = strip_tags($new_instance['my_calendar_upcoming_category']);
181
  $instance['my_calendar_upcoming_before'] = strip_tags($new_instance['my_calendar_upcoming_before']);
182
  $instance['my_calendar_upcoming_after'] = strip_tags($new_instance['my_calendar_upcoming_after']);
183
+ $instance['my_calendar_upcoming_show_today'] = ($new_instance['my_calendar_upcoming_show_today']=='yes')?'yes':'no';
184
  $instance['my_calendar_upcoming_type'] = strip_tags($new_instance['my_calendar_upcoming_type']);
185
  $instance['my_calendar_upcoming_order'] = strip_tags($new_instance['my_calendar_upcoming_order']);
186
  $instance['my_calendar_upcoming_linked'] = strip_tags($new_instance['my_calendar_upcoming_linked']);
191
  }
192
 
193
  // Widget upcoming events
194
+ function my_calendar_upcoming_events($before='default',$after='default',$type='default',$category='default',$template='default',$substitute='',$order='asc',$skip=0, $show_today='yes' ) {
195
  global $wpdb,$default_template,$defaults;
196
  $output = '';
197
  $date_format = ( get_option('mc_date_format') != '' )?get_option('mc_date_format'):get_option('date_format');
246
  $skipping = false;
247
  foreach ( array_keys($temp_array) as $key ) {
248
  $details = $temp_array[$key];
249
+
250
+ // if any event this date is in the holiday category, we are skipping
251
  if ( $details['cat_id'] == get_option('mc_skip_holidays_category') ) {
252
  $skipping = true;
253
  break;
274
  }
275
  } else {
276
  $events = mc_get_all_events($category); // grab all events within reasonable proximity
277
+ $output .= mc_produce_upcoming_events( $events,$template,$before,$after,'list',$order,$skip,$show_today );
278
  }
279
  if ($output != '') {
280
  $output = $header.$output.$footer;
283
  return stripcslashes( $no_event_text );
284
  }
285
  }
286
+ function mc_span_time( $group_id ) {
287
+ global $wpdb;
288
+ $group_id = (int) $group_id;
289
+ $sql = "SELECT event_begin, event_time, event_end, event_endtime FROM ".my_calendar_table()." WHERE event_group_id = $group_id ORDER BY event_begin ASC";
290
+ $dates = $wpdb->get_results( $sql );
291
+ $count = count($dates);
292
+ $last = $count - 1;
293
+ $begin = $dates[0]->event_begin . ' ' . $dates[0]->event_time;
294
+ $end = $dates[$last]->event_end . ' ' . $dates[$last]->event_endtime;
295
+ return array( $begin, $end );
296
+ }
297
  // make this function time-sensitive, not date-sensitive.
298
+ function mc_produce_upcoming_events($events,$template,$before=0,$after=10,$type='list',$order='asc',$skip=0, $show_today='yes') {
299
  $output = '';
300
  $near_events = array();
301
  $temp_array = array();
305
  $today = date('Y',time()+($offset)).'-'.date('m',time()+($offset)).'-'.date('d',time()+($offset));
306
  @usort( $events, "my_calendar_timediff_cmp" );// sort all events by proximity to current date
307
  $count = count($events);
308
+ $skip = false;
309
+ $group = array();
310
  for ( $i=0;$i<$count;$i++ ) {
311
  if ( is_object( $events[$i] ) ) {
312
+ // if the beginning of an event is after the current time, it is in the future
313
  $beginning = $events[$i]->event_begin . ' ' . $events[$i]->event_time;
314
+ $date = date('Y-m-d', strtotime($beginning));
315
+ // if the end of an event is before the current time, it is in the past.
316
+ if ( $events[$i]->event_endtime == '00:00:00' ) { $endtime = $events[$i]->event_time; } else { $endtime = $events[$i]->event_endtime; }
317
+ $end = $events[$i]->event_end . ' ' . $endtime;
318
+ /* tiny improvement, I hope: if event ends on same day and has an end-time set, expire it after the end of the event.
319
  if ( $events[$i]->event_endtime != '00:00:00' && $events[$i]->event_endtime != null && $events[$i]->event_begin == $events[$i]->event_end ) {
320
  $beginning = $events[$i]->event_end . ' ' . $events[$i]->event_endtime;
321
+ } */
322
+ if ( $events[$i]->event_span == 1 ) {
323
+ // this is a multi-day event: treat each event as if it spanned the entire range of the group.
324
+ $span_time = mc_span_time($events[$i]->event_group_id);
325
+ $beginning = $span_time[0];
326
+ $end = $span_time[1];
327
  }
328
  $current = date('Y-m-d H:i',time()+$offset);
329
+ if ($events[$i]) {
330
+ if ( $events[$i]->event_group_id != 0 && $events[$i]->event_span == 1 && in_array( $events[$i]->event_group_id, $group ) || ( my_calendar_date_equal( $date,$today ) && $show_today == 'no' ) ) { $skip = true;
331
+ } else {
332
+ $group[] = $events[$i]->event_group_id; $skip=false;
333
+ }
334
+ if ( !$skip ) {
335
+ if ( ( $past<=$before && $future<=$after ) ) {
336
+ $near_events[] = $events[$i]; // if neither limit is reached, split off freely
337
+ } else if ( $past <= $before && ( my_calendar_date_comp( $beginning,$current ) ) ) {
338
+ $near_events[] = $events[$i]; // split off another past event
339
+ } else if ( $future <= $after && ( !my_calendar_date_comp( $end,$current ) ) ) {
340
+ $near_events[] = $events[$i]; // split off another future event
341
+ }
342
+ if ( my_calendar_date_comp( $beginning,$current ) ) { $past++;
343
+ } else if ( my_calendar_date_equal( $beginning,$current ) ) { $present = 1;
344
+ } else { $future++; }
345
+ }
346
  if ($past > $before && $future > $after) {
347
  break;
348
  }
351
  }
352
  $events = $near_events;
353
  @usort( $events, "my_calendar_datetime_cmp" ); // sort split events by date
354
+
355
+ // If there are more items in the list than there should be (which is possible, due to handling of current-day's events), pop them off.
356
+ $intended = $before + $after;
357
+ $actual = count($events);
358
+ if ( $actual > $intended ) {
359
+ for ( $i=0;$i<($actual-$intended);$i++ ) {
360
+ array_pop($events);
361
+ }
362
+ }
363
  if ( is_array( $events ) ) {
364
  foreach( array_keys($events) as $key ) {
365
  $event =& $events[$key];
366
+ //echo $event->event_title . " " . $event->event_group_id."<br />";
367
  $event_details = event_as_array( $event );
368
  if ( get_option( 'mc_event_approve' ) == 'true' ) {
369
  if ( $event->event_approved != 0 ) { $temp_array[] = $event_details; }
383
  }
384
  // check each event, if we're skipping, only include the holiday events.
385
  $i = 0;
386
+ $groups = array();
387
  foreach( reverse_array($temp_array, true, $order) as $details ) {
388
+ if ( !in_array( $details['group'], $groups ) ) {
389
+ $date = date('Y-m-d',strtotime($details['dtstart']));
390
+ $class = (my_calendar_date_comp( $date,$today )===true)?"past-event":"future-event";
391
+ if ( my_calendar_date_equal( $date,$today ) ) {
392
+ $class = "today";
393
+ }
394
+ if ( $details['event_span'] == 1 ) {
395
+ $class = "multiday";
396
+ }
397
+ if ($type == 'list') {
398
+ $prepend = "\n<li class=\"$class\">";
399
+ $append = "</li>\n";
400
+ } else {
401
+ $prepend = $append = '';
402
+ }
403
+ // if any event this date is in the holiday category, we are skipping
404
+ if ( $i < $skip && $skip != 0 ) {
405
+ $i++;
406
+ } else {
407
+ if ($skipping == true) {
408
+ if ($details['cat_id'] == get_option('mc_skip_holidays_category') ) {
409
+ $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);
410
+ } else {
411
+ if ( $details['skip_holiday'] == 'false' ) { // 'true' means "is canceled"
412
+ $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);
413
+ }
414
+ }
415
  } else {
416
+ $output .= apply_filters('mc_event_upcoming',"$prepend".jd_draw_template($details,$template,$type)."$append",$event);
 
 
417
  }
418
+ }
419
+ if ( $details['event_span'] == 1 ) {
420
+ $groups[] = $details['group'];
421
  }
422
  }
423
  }
431
 
432
  // Widget todays events
433
  function my_calendar_todays_events($category='default',$template='default',$substitute='') {
434
+ $caching = ( get_option('mc_caching_enabled') == 'true' )?true:false;
435
+ $todays_cache = ($caching)? get_transient('mc_todays_cache') :'';
436
+ if ( $caching && is_array($todays_cache) && $todays_cache[$category] ) { return $todays_cache[$category]; }
437
  global $wpdb, $default_template;
438
  $output = '';
439
  $offset = (60*60*get_option('gmt_offset'));
450
  $footer = "</ul>";
451
  $holiday_exists = false;
452
  @usort($events, "my_calendar_time_cmp");
453
+ $groups = array();
454
  // quick loop through all events today to check for holidays
455
  if (is_array($events) ) {
456
  foreach( array_keys($events) as $key ) {
457
  $event =& $events[$key];
458
  if ( $event->event_category == get_option('mc_skip_holidays_category') ) { $holiday_exists = true; }
459
  }
 
460
  foreach( array_keys($events) as $key ) {
461
+ $event =& $events[$key];
462
+ if ( !in_array( $event->event_group_id, $groups ) ) {
463
+ $event_details = event_as_array($event);
464
+ $date = date_i18n(get_option('mc_date_format'),time()+$offset);
465
+
466
+ // correct displayed time to today - necessary for recurring events, problematic with multi-day events
467
+ if ( $event_details['event_span'] != 1 ) {
468
+ $event_details['date'] = $date;
 
 
 
 
469
  }
470
+ $this_event = '';
471
+ if ( $event->event_holiday == 0 ) {
 
472
  if ( get_option( 'mc_event_approve' ) == 'true' ) {
473
  if ( $event->event_approved != 0 ) {$this_event = "<li>".jd_draw_template($event_details,$template)."</li>";}
474
  } else {
475
  $this_event = "<li>".jd_draw_template($event_details,$template)."</li>";
476
  }
477
+ } else {
478
+ // if we found a holiday earlier, then we know there is one today.
479
+ if ( !$holiday_exists || ( $holiday_exists && $event->event_category == get_option('mc_skip_holidays_category') ) ) {
480
+ if ( get_option( 'mc_event_approve' ) == 'true' ) {
481
+ if ( $event->event_approved != 0 ) {$this_event = "<li>".jd_draw_template($event_details,$template)."</li>";}
482
+ } else {
483
+ $this_event = "<li>".jd_draw_template($event_details,$template)."</li>";
484
+ }
485
+ }
486
  }
487
+ $output .= apply_filters( 'mc_event_today',$this_event,$event );
488
  }
 
 
489
  }
490
  if (count($events) != 0) {
491
  $return = $header.$output.$footer;
494
  }
495
  $time = strtotime( date( 'Y-m-d H:m:s',time()+$offset ) ) - strtotime( date( 'Y-m-d',time()+$offset ) );
496
  $time_remaining = 24*60*60 - $time;
497
+ $todays_cache[$category] = ($caching)?$return:'';
498
+ if ( $caching ) set_transient( 'mc_todays_cache', $todays_cache, $time_remaining );
499
  } else {
500
  $return = stripcslashes( $no_event_text );
501
  }
my-calendar.php CHANGED
@@ -5,9 +5,9 @@ Plugin URI: http://www.joedolson.com/articles/my-calendar/
5
  Description: Accessible WordPress event calendar plugin. Show events from multiple calendars on pages, in posts, or in widgets.
6
  Author: Joseph C Dolson
7
  Author URI: http://www.joedolson.com
8
- Version: 1.9.8
9
  */
10
- /* Copyright 2009-2011 Joe Dolson (email : joe@joedolson.com)
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@ Version: 1.9.8
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
  global $mc_version, $wpdb;
27
- $mc_version = '1.9.8';
28
 
29
  // Define the tables used in My Calendar
30
  define('MY_CALENDAR_TABLE', $wpdb->prefix . 'my_calendar');
@@ -122,6 +122,7 @@ function jd_show_support_box() {
122
  <div class="resources">
123
  <ul>
124
  <li><a href="<?php echo admin_url("admin.php?page=my-calendar-help"); ?>#get-support"><?php _e("Get Support",'my-calendar'); ?></a></li>
 
125
  <li><a href="<?php echo admin_url("admin.php?page=my-calendar-help"); ?>"><?php _e("My Calendar Help",'my-calendar'); ?></a></li>
126
  <li><strong><a href="http://www.joedolson.com/donate.php" rel="external"><?php _e("Make a Donation",'my-calendar'); ?></a></strong></li>
127
  <li><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
@@ -143,10 +144,10 @@ function jd_show_support_box() {
143
 
144
  // Function to deal with adding the calendar menus
145
  function my_calendar_menu() {
146
- global $wpdb;
147
  check_my_calendar();
148
  $allowed_group = ( get_option('mc_can_manage_events') == '' )?'manage_options':get_option('mc_can_manage_events');
149
- $icon_path = site_url().'/wp-content/plugins/'.basename(dirname(__FILE__)).'/images';
150
  if ( function_exists('add_object_page') ) {
151
  add_object_page(__('My Calendar','my-calendar'), __('My Calendar','my-calendar'), $allowed_group, 'my-calendar', 'edit_my_calendar',$icon_path.'/icon.png' );
152
  } else {
5
  Description: Accessible WordPress event calendar plugin. Show events from multiple calendars on pages, in posts, or in widgets.
6
  Author: Joseph C Dolson
7
  Author URI: http://www.joedolson.com
8
+ Version: 1.10.6
9
  */
10
+ /* Copyright 2009-2012 Joe Dolson (email : joe@joedolson.com)
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License as published by
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
  global $mc_version, $wpdb;
27
+ $mc_version = '1.10.6';
28
 
29
  // Define the tables used in My Calendar
30
  define('MY_CALENDAR_TABLE', $wpdb->prefix . 'my_calendar');
122
  <div class="resources">
123
  <ul>
124
  <li><a href="<?php echo admin_url("admin.php?page=my-calendar-help"); ?>#get-support"><?php _e("Get Support",'my-calendar'); ?></a></li>
125
+ <li><a href="http://www.joedolson.com/articles/bugs/"><?php _e("Report a bug",'my-calendar'); ?></a></li>
126
  <li><a href="<?php echo admin_url("admin.php?page=my-calendar-help"); ?>"><?php _e("My Calendar Help",'my-calendar'); ?></a></li>
127
  <li><strong><a href="http://www.joedolson.com/donate.php" rel="external"><?php _e("Make a Donation",'my-calendar'); ?></a></strong></li>
128
  <li><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
144
 
145
  // Function to deal with adding the calendar menus
146
  function my_calendar_menu() {
147
+ global $wpdb, $wp_plugin_url;
148
  check_my_calendar();
149
  $allowed_group = ( get_option('mc_can_manage_events') == '' )?'manage_options':get_option('mc_can_manage_events');
150
+ $icon_path = $wp_plugin_url.'/'.basename(dirname(__FILE__)).'/images';
151
  if ( function_exists('add_object_page') ) {
152
  add_object_page(__('My Calendar','my-calendar'), __('My Calendar','my-calendar'), $allowed_group, 'my-calendar', 'edit_my_calendar',$icon_path.'/icon.png' );
153
  } else {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: joedolson
4
  Donate link: http://www.joedolson.com/donate.php
5
  Tags: calendar, dates, times, events, scheduling, event manager
6
  Requires at least: 2.9.2
7
- Tested up to: 3.3
8
  Stable tag: trunk
9
 
10
  Accessible WordPress event calendar plugin. Show events from multiple calendars on pages, in posts, or in widgets.
@@ -80,6 +80,56 @@ New or updated translations are always appreciated. The translation files are in
80
 
81
  == Changelog ==
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  = 1.9.8 =
84
 
85
  * This is just a convenience update due to a warning appearing in 1.9.7 that I missed.
@@ -678,5 +728,6 @@ I can! Just not in person. I've written a User's Guide for My Calendar, which yo
678
 
679
  == Upgrade Notice ==
680
 
681
- - Version 1.9.7 squashes more bugs. No settings or functionality changes.
 
682
  - Version 1.9.0 incorporated many new event editing and management options and a refresh of My Calendar's styles and scripts. Some changes will require updated styles or scripts to work properly. Updated JavaScript and styles <em>will not be installed by default</em>, in order to avoid overwriting any custom changes, but you can update styles and scripts on their editing pages.
4
  Donate link: http://www.joedolson.com/donate.php
5
  Tags: calendar, dates, times, events, scheduling, event manager
6
  Requires at least: 2.9.2
7
+ Tested up to: 3.4-alpha
8
  Stable tag: trunk
9
 
10
  Accessible WordPress event calendar plugin. Show events from multiple calendars on pages, in posts, or in widgets.
80
 
81
  == Changelog ==
82
 
83
+ = 1.10.6 =
84
+
85
+ * Revised template tags so the description tags are run through wpautop(), and added _raw versions which are not.
86
+ * Fixed a bug in URL generation so that URLs with ports are correctly constructed.
87
+ * Fixed a bug iin Print output which did not allow restriction to multiple categories
88
+ * Added option to use {date} in previous/next navigation links to indicate what date set is being navigated to.
89
+
90
+ = 1.10.5 =
91
+
92
+ * I made a truly bone-headed error in the last update, and I'm not even going to say what. If you didn't notice it, lucky for you!
93
+
94
+ = 1.10.4 =
95
+
96
+ * In my rush to fix the security issue, I broke an aspect of the event navigation. Apologies for this! Now fixed.
97
+
98
+ = 1.10.3 =
99
+
100
+ * Incorrectly called wp_kses(). Apologies for the frequent updates!
101
+
102
+ = 1.10.2 =
103
+
104
+ * Critical security update. Please upgrade promptly. Big thank you to Dean Batha for the bug report.
105
+
106
+ = 1.10.1 =
107
+
108
+ * Bug fix: undeclared array in widget manager
109
+ * Renamed overly-generic constant.
110
+
111
+ = 1.10.0 =
112
+
113
+ * New feature: option to link dates in mini calendar to separate daily view instead of pop-up.
114
+ * New feature: no longer necessary to manually edit behaviors in order to open main calendar event titles to separate page.
115
+ * New feature: Ability to define grouped events as a single multi-day event and remove duplicates from events lists (upcoming events and today's events widgets)
116
+ * New feature: group-association classes assigned to multi-day events in grid display.
117
+ * New template tags: {daterange} and {multidate} for displaying a beginning and ending date range for a single event and for displaying each date in a multi-day event, respectively.
118
+ * Week-view calendar caption now editable.
119
+ * Added printable version.
120
+ * Submit buttons in forms are now duplicated at top and bottom of long editing sections, to improve usability.
121
+ * Minor style change to group editor to avoid group list colliding with editor textarea.
122
+ * Removed angle brackets from Previous/Next events links.
123
+ * Added custom action hooks for event save and event delete
124
+ * Added ability to prevent today's events from showing up in upcoming events listings.
125
+ * Added categories to iCal output.
126
+ * iCal should return times in local time, not in UTC.
127
+ * Bug fix: iCal output not correctly encoded
128
+ * Bug fix: mc_next_link filter did not exist.
129
+ * Bug fix: placed limit on maximum size of cached calendar data.
130
+ * Bug fix: Upcoming events list will no longer occasionally display more items than expected.
131
+ * Bug fix: menu icon not aware of custom content locations
132
+
133
  = 1.9.8 =
134
 
135
  * This is just a convenience update due to a warning appearing in 1.9.7 that I missed.
728
 
729
  == Upgrade Notice ==
730
 
731
+ - Version 1.10.2 is a CRITICAL SECURITY UPGRADE. Please upgrade promptly.
732
+ - Version 1.10.0 adds a printable view, multi-day events, and a few additional new options.
733
  - Version 1.9.0 incorporated many new event editing and management options and a refresh of My Calendar's styles and scripts. Some changes will require updated styles or scripts to work properly. Updated JavaScript and styles <em>will not be installed by default</em>, in order to avoid overwriting any custom changes, but you can update styles and scripts on their editing pages.
uninstall.php CHANGED
@@ -77,6 +77,9 @@ delete_option( 'mc_details' );
77
  delete_option( 'mc_widget_defaults' );
78
  delete_option( 'mc_default_sort' );
79
  delete_option( 'mc_show_event_vcal' );
 
 
 
80
  add_option( 'mc_uninstalled','true' );
81
  }
82
  ?>
77
  delete_option( 'mc_widget_defaults' );
78
  delete_option( 'mc_default_sort' );
79
  delete_option( 'mc_show_event_vcal' );
80
+ delete_option( 'mc_caching_enabled' );
81
+ delete_option( 'mc_week_caption' );
82
+ delete_option( 'mc_show_print' );
83
  add_option( 'mc_uninstalled','true' );
84
  }
85
  ?>