My Calendar - Version 1.1.0

Version Description

  • Fixed some problems with Upcoming Events past events not scrolling off; hopefully all!
  • Fixed some problems with fuzzy interpretations of the numbers of past/future events displayed in Upcoming Events.
  • Added Bi-weekly events
  • Added restrictions so that admin level users can edit any events but other users can only edit their own events
  • Removed character restrictions on event titles
  • Revised default stylesheet
Download this release

Release Info

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

Code changes from version 1.0.2 to 1.1.0

date-utilities.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
 
3
-
4
  function my_calendar_add_date($givendate,$day=0,$mth=0,$yr=0) {
5
  $cd = strtotime($givendate);
6
  $newdate = date('Y-m-d', mktime(date('h',$cd),date('i',$cd), date('s',$cd), date('m',$cd)+$mth,date('d',$cd)+$day, date('Y',$cd)+$yr));
@@ -44,6 +43,16 @@ function my_calendar_datetime_cmp($a, $b) {
44
  return ( $event_dt_a < $event_dt_b ) ? -1 : 1;
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
47
  function my_calendar_timediff_cmp($a, $b) {
48
  $event_dt_a = strtotime($a->event_begin .' '. $a->event_time);
49
  $event_dt_b = strtotime($b->event_begin .' '. $b->event_time);
1
  <?php
2
 
 
3
  function my_calendar_add_date($givendate,$day=0,$mth=0,$yr=0) {
4
  $cd = strtotime($givendate);
5
  $newdate = date('Y-m-d', mktime(date('h',$cd),date('i',$cd), date('s',$cd), date('m',$cd)+$mth,date('d',$cd)+$day, date('Y',$cd)+$yr));
43
  return ( $event_dt_a < $event_dt_b ) ? -1 : 1;
44
  }
45
 
46
+ // reverse Function to compare datetime in event objects
47
+ function my_calendar_reverse_datetime_cmp($b, $a) {
48
+ $event_dt_a = strtotime($a->event_begin .' '. $a->event_time);
49
+ $event_dt_b = strtotime($b->event_begin .' '. $b->event_time);
50
+ if ($event_dt_a == $event_dt_b ) {
51
+ return 0;
52
+ }
53
+ return ( $event_dt_a < $event_dt_b ) ? -1 : 1;
54
+ }
55
+
56
  function my_calendar_timediff_cmp($a, $b) {
57
  $event_dt_a = strtotime($a->event_begin .' '. $a->event_time);
58
  $event_dt_b = strtotime($b->event_begin .' '. $b->event_time);
images/event-details.png CHANGED
Binary file
my-calendar-event-manager.php CHANGED
@@ -14,7 +14,7 @@ if ( get_option('ko_calendar_imported') != 'true' ) {
14
  _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar');
15
  echo "</p>";
16
  ?>
17
- <form method="post" action="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=my-calendar-config">
18
  <div>
19
  <input type="hidden" name="import" value="true" />
20
  <input type="submit" value="Import from Calendar" name="import-calendar" class="button-primary" />
@@ -45,20 +45,28 @@ if ($_GET['action'] == 'edit') {
45
  check_my_calendar();
46
 
47
  if ($_GET['action'] == 'delete') {
48
- $sql = "SELECT event_title FROM " . MY_CALENDAR_TABLE . " WHERE event_id=" . (int) $_GET['event_id'];
49
  $result = $wpdb->get_results($sql);
50
- ?>
51
- <div class="error">
52
- <p><strong><?php _e('Delete Event','my-calendar'); ?>:</strong> <?php _e('Are you sure you want to delete this event?','my-calendar'); ?></p>
53
- <form action="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar" method="post">
54
- <div>
55
- <input type="hidden" value="delete" name="action" />
56
- <input type="hidden" value="<?php echo (int) $_GET['event_id']; ?>" name="event_id" />
57
- <input type="submit" name="submit" class="button-primary" value="<?php _e('Delete','my-calendar'); echo " &quot;".$result[0]->event_title."&quot;"; ?>" />
58
- </div>
59
- </form>
60
- </div>
61
- <?php
 
 
 
 
 
 
 
 
62
  }
63
 
64
  // Deal with adding an event to the database
@@ -152,15 +160,16 @@ if ( $action == 'add' ) {
152
  <?php
153
  }
154
  // The title must be at least one character in length and no more than 60 - only basic punctuation is allowed
155
- if (preg_match('/^[a-zA-Z0-9\'\"]{1}[a-zA-Z0-9[:space:][.,;:()\'\"]{0,60}$/',$title)) {
 
156
  $title_ok =1;
157
  } else {
158
  ?>
159
- <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 60 characters in length. Some punctuation characters may not be allowed.','my-calendar'); ?></p></div>
160
  <?php
161
  }
162
  // We run some checks on recurrance
163
- if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y' || $recur == 'D'))) {
164
  $recurring_ok = 1;
165
  } else {
166
  ?>
@@ -239,6 +248,9 @@ if ( $action == 'add' ) {
239
  $event_state = !empty($_POST['event_state']) ? $_POST['event_state'] : '';
240
  $event_postcode = !empty($_POST['event_postcode']) ? $_POST['event_postcode'] : '';
241
  $event_country = !empty($_POST['event_country']) ? $_POST['event_country'] : '';
 
 
 
242
 
243
 
244
  // Deal with the fools who have left magic quotes turned on
@@ -259,6 +271,7 @@ if ( $action == 'add' ) {
259
  $event_state = stripslashes($event_state);
260
  $event_postcode = stripslashes($event_postcode);
261
  $event_country = stripslashes($event_country);
 
262
  }
263
 
264
  if ( empty($event_id) ) {
@@ -318,15 +331,16 @@ if ( $action == 'add' ) {
318
  <?php
319
  }
320
  // The title must be at least one character in length and no more than 60 - no non-standard characters allowed
321
- if (preg_match('/^[a-zA-Z0-9\'\"]{1}[a-zA-Z0-9[:space:][.,;:()\'\"]{0,60}$/',$title)) {
 
322
  $title_ok =1;
323
  } else {
324
  ?>
325
- <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 60 characters in length. Some punctuation characters may not be allowed.','my-calendar'); ?></p></div>
326
  <?php
327
  }
328
  // We run some checks on recurrance
329
- if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y' || $recur == 'D' ))) {
330
  $recurring_ok = 1;
331
  } else {
332
  ?>
@@ -342,7 +356,6 @@ if ( $action == 'add' ) {
342
  event_time='" . mysql_real_escape_string($time) . "',
343
  event_recur='" . mysql_real_escape_string($recur) . "',
344
  event_repeats='" . mysql_real_escape_string($repeats) . "',
345
- event_author=".$current_user->ID . ",
346
  event_category=".mysql_real_escape_string($category).",
347
  event_link='".mysql_real_escape_string($linky)."',
348
  event_label='".mysql_real_escape_string($event_label)."',
@@ -387,9 +400,17 @@ if ( $action == 'add' ) {
387
  $users_entries->event_state = $event_state;
388
  $users_entries->event_postcode = $event_postcode;
389
  $users_entries->event_country = $event_country;
 
390
  $error_with_saving = 1;
391
  }
392
  }
 
 
 
 
 
 
 
393
  } elseif ( $action == 'delete' ) {
394
  // Deal with deleting an event from the database
395
 
@@ -475,8 +496,10 @@ function jd_events_edit_form($mode='add', $event_id=false) {
475
  // Deal with possibility that form was submitted but not saved due to error - recover user's entries here
476
  $data = $users_entries;
477
  }
478
-
 
479
  ?>
 
480
  <div id="poststuff" class="jd-my-calendar">
481
  <div class="postbox">
482
  <h3><?php if ($mode == "add") { _e('Add an Event','my-calendar'); } else { _e('Edit Event'); } ?></h3>
@@ -485,6 +508,7 @@ function jd_events_edit_form($mode='add', $event_id=false) {
485
  <div>
486
  <input type="hidden" name="action" value="<?php echo $mode; ?>" />
487
  <input type="hidden" name="event_id" value="<?php echo $event_id; ?>" />
 
488
  </div>
489
  <fieldset>
490
  <legend><?php _e('Enter your Event Information','my-calendar'); ?></legend>
@@ -547,9 +571,11 @@ function jd_events_edit_form($mode='add', $event_id=false) {
547
  if ($data->event_recur == "S") {
548
  $selected_s = 'selected="selected"';
549
  } else if ($data->event_recur == "D") {
550
- $selected_d = 'selected="selected"';
551
  } else if ($data->event_recur == "W") {
552
  $selected_w = 'selected="selected"';
 
 
553
  } else if ($data->event_recur == "M") {
554
  $selected_m = 'selected="selected"';
555
  } else if ($data->event_recur == "Y") {
@@ -559,11 +585,12 @@ function jd_events_edit_form($mode='add', $event_id=false) {
559
  <p>
560
  <label for="event_repeats"><?php _e('Repeats for','my-calendar'); ?></label> <input type="text" name="event_repeats" id="event_repeats" class="input" size="1" value="<?php echo $repeats; ?>" />
561
  <label for="event_recur"><?php _e('Units','my-calendar'); ?></label> <select name="event_recur" class="input" id="event_recur">
562
- <option class="input" <?php echo $selected_s; ?> value="S">Does not recur</option>
563
- <option class="input" <?php echo $selected_d; ?> value="D">Days</option>
564
- <option class="input" <?php echo $selected_w; ?> value="W">Weeks</option>
565
- <option class="input" <?php echo $selected_m; ?> value="M">Months</option>
566
- <option class="input" <?php echo $selected_y; ?> value="Y">Years</option>
 
567
  </select><br />
568
  <?php _e('Entering 0 means forever, if a unit is selected. If the recurrance unit is left at "Does not recur," the event will not reoccur.','my-calendar'); ?>
569
  </p>
@@ -629,6 +656,7 @@ function jd_events_display_list() {
629
  $class = '';
630
  foreach ( $events as $event ) {
631
  $class = ($class == 'alternate') ? '' : 'alternate';
 
632
  ?>
633
  <tr class="<?php echo $class; ?>">
634
  <th scope="row"><?php echo $event->event_id; ?></th>
@@ -642,6 +670,7 @@ function jd_events_display_list() {
642
  if ($event->event_recur == 'S') { _e('Never','my-calendar'); }
643
  else if ($event->event_recur == 'D') { _e('Daily','my-calendar'); }
644
  else if ($event->event_recur == 'W') { _e('Weekly','my-calendar'); }
 
645
  else if ($event->event_recur == 'M') { _e('Monthly','my-calendar'); }
646
  else if ($event->event_recur == 'Y') { _e('Yearly','my-calendar'); }
647
  ?>
@@ -654,14 +683,18 @@ function jd_events_display_list() {
654
  else if ($event->event_repeats > 0) { echo $event->event_repeats.' '.__('Times','my-calendar'); }
655
  ?>
656
  </td>
657
- <td><?php $e = get_userdata($event->event_author); echo $e->display_name; ?></td>
658
  <?php
659
  $sql = "SELECT * FROM " . MY_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
660
  $this_cat = $wpdb->get_row($sql);
661
  ?>
662
  <td style="background-color:<?php echo $this_cat->category_color;?>;"><?php echo $this_cat->category_name; ?></td>
663
  <?php unset($this_cat); ?>
664
- <td><a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;action=edit&amp;event_id=<?php echo $event->event_id;?>" class='edit'><?php echo __('Edit','my-calendar'); ?></a> &middot; <a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;action=delete&amp;event_id=<?php echo $event->event_id;?>" class="delete"><?php echo __('Delete','my-calendar'); ?></a></td> </tr>
 
 
 
 
665
  <?php
666
  }
667
  ?>
14
  _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar');
15
  echo "</p>";
16
  ?>
17
+ <form method="post" action="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar-config">
18
  <div>
19
  <input type="hidden" name="import" value="true" />
20
  <input type="submit" value="Import from Calendar" name="import-calendar" class="button-primary" />
45
  check_my_calendar();
46
 
47
  if ($_GET['action'] == 'delete') {
48
+ $sql = "SELECT event_title, event_author FROM " . MY_CALENDAR_TABLE . " WHERE event_id=" . (int) $_GET['event_id'];
49
  $result = $wpdb->get_results($sql);
50
+ if ( mc_can_edit_event( $result[1] ) ) {
51
+ ?>
52
+ <div class="error">
53
+ <p><strong><?php _e('Delete Event','my-calendar'); ?>:</strong> <?php _e('Are you sure you want to delete this event?','my-calendar'); ?></p>
54
+ <form action="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar" method="post">
55
+ <div>
56
+ <input type="hidden" value="delete" name="action" />
57
+ <input type="hidden" value="<?php echo (int) $_GET['event_id']; ?>" name="event_id" />
58
+ <input type="submit" name="submit" class="button-primary" value="<?php _e('Delete','my-calendar'); echo " &quot;".$result[0]->event_title."&quot;"; ?>" />
59
+ </div>
60
+ </form>
61
+ </div>
62
+ <?php
63
+ } else {
64
+ ?>
65
+ <div class="error">
66
+ <p><strong><?php _e('You do not have permission to delete that event.','my-calendar'); ?></strong></p>
67
+ </div>
68
+ <?php
69
+ }
70
  }
71
 
72
  // Deal with adding an event to the database
160
  <?php
161
  }
162
  // The title must be at least one character in length and no more than 60 - only basic punctuation is allowed
163
+ $title_length = strlen($title);
164
+ if ( $title_length > 1 && $title_length <= 60 ) {
165
  $title_ok =1;
166
  } else {
167
  ?>
168
+ <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 60 characters in length.','my-calendar'); ?></p></div>
169
  <?php
170
  }
171
  // We run some checks on recurrance
172
+ if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'B' || $recur == 'M' || $recur == 'Y' || $recur == 'D'))) {
173
  $recurring_ok = 1;
174
  } else {
175
  ?>
248
  $event_state = !empty($_POST['event_state']) ? $_POST['event_state'] : '';
249
  $event_postcode = !empty($_POST['event_postcode']) ? $_POST['event_postcode'] : '';
250
  $event_country = !empty($_POST['event_country']) ? $_POST['event_country'] : '';
251
+ $event_author = !empty($_POST['event_author']) ? $_POST['event_author'] : '';
252
+
253
+ if ( mc_can_edit_event( $event_author ) ) {
254
 
255
 
256
  // Deal with the fools who have left magic quotes turned on
271
  $event_state = stripslashes($event_state);
272
  $event_postcode = stripslashes($event_postcode);
273
  $event_country = stripslashes($event_country);
274
+ $event_author = stripslashes($event_author);
275
  }
276
 
277
  if ( empty($event_id) ) {
331
  <?php
332
  }
333
  // The title must be at least one character in length and no more than 60 - no non-standard characters allowed
334
+ $title_length = strlen($title);
335
+ if ( $title_length > 1 && $title_length <= 60 ) {
336
  $title_ok =1;
337
  } else {
338
  ?>
339
+ <div class="error"><p><strong><?php _e('Error','my-calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 60 characters in length.','my-calendar'); ?></p></div>
340
  <?php
341
  }
342
  // We run some checks on recurrance
343
+ if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'B' || $recur == 'M' || $recur == 'Y' || $recur == 'D' ))) {
344
  $recurring_ok = 1;
345
  } else {
346
  ?>
356
  event_time='" . mysql_real_escape_string($time) . "',
357
  event_recur='" . mysql_real_escape_string($recur) . "',
358
  event_repeats='" . mysql_real_escape_string($repeats) . "',
 
359
  event_category=".mysql_real_escape_string($category).",
360
  event_link='".mysql_real_escape_string($linky)."',
361
  event_label='".mysql_real_escape_string($event_label)."',
400
  $users_entries->event_state = $event_state;
401
  $users_entries->event_postcode = $event_postcode;
402
  $users_entries->event_country = $event_country;
403
+ $users_entries->event_author = $event_author;
404
  $error_with_saving = 1;
405
  }
406
  }
407
+ } else {
408
+ ?>
409
+ <div class="error">
410
+ <p><strong><?php _e('You do not have sufficient permissions to edit that event.','my-calendar'); ?></strong></p>
411
+ </div>
412
+ <?php
413
+ }
414
  } elseif ( $action == 'delete' ) {
415
  // Deal with deleting an event from the database
416
 
496
  // Deal with possibility that form was submitted but not saved due to error - recover user's entries here
497
  $data = $users_entries;
498
  }
499
+ global $user_ID;
500
+ get_currentuserinfo();
501
  ?>
502
+
503
  <div id="poststuff" class="jd-my-calendar">
504
  <div class="postbox">
505
  <h3><?php if ($mode == "add") { _e('Add an Event','my-calendar'); } else { _e('Edit Event'); } ?></h3>
508
  <div>
509
  <input type="hidden" name="action" value="<?php echo $mode; ?>" />
510
  <input type="hidden" name="event_id" value="<?php echo $event_id; ?>" />
511
+ <input type="hidden" name="event_author" value="<?php echo $user_ID; ?>" />
512
  </div>
513
  <fieldset>
514
  <legend><?php _e('Enter your Event Information','my-calendar'); ?></legend>
571
  if ($data->event_recur == "S") {
572
  $selected_s = 'selected="selected"';
573
  } else if ($data->event_recur == "D") {
574
+ $selected_d = 'selected="selected"';
575
  } else if ($data->event_recur == "W") {
576
  $selected_w = 'selected="selected"';
577
+ } else if ($data->event_recur == "B") {
578
+ $selected_b = 'selected="selected"';
579
  } else if ($data->event_recur == "M") {
580
  $selected_m = 'selected="selected"';
581
  } else if ($data->event_recur == "Y") {
585
  <p>
586
  <label for="event_repeats"><?php _e('Repeats for','my-calendar'); ?></label> <input type="text" name="event_repeats" id="event_repeats" class="input" size="1" value="<?php echo $repeats; ?>" />
587
  <label for="event_recur"><?php _e('Units','my-calendar'); ?></label> <select name="event_recur" class="input" id="event_recur">
588
+ <option class="input" <?php echo $selected_s; ?> value="S"><?php _e('Does not recur','my-calendar'); ?></option>
589
+ <option class="input" <?php echo $selected_d; ?> value="D"><?php _e('Daily','my-calendar'); ?></option>
590
+ <option class="input" <?php echo $selected_w; ?> value="W"><?php _e('Weekly','my-calendar'); ?></option>
591
+ <option class="input" <?php echo $selected_b; ?> value="B"><?php _e('Bi-weekly','my-calendar'); ?></option>
592
+ <option class="input" <?php echo $selected_m; ?> value="M"><?php _e('Monthly','my-calendar'); ?></option>
593
+ <option class="input" <?php echo $selected_y; ?> value="Y"><?php _e('Annually','my-calendar'); ?></option>
594
  </select><br />
595
  <?php _e('Entering 0 means forever, if a unit is selected. If the recurrance unit is left at "Does not recur," the event will not reoccur.','my-calendar'); ?>
596
  </p>
656
  $class = '';
657
  foreach ( $events as $event ) {
658
  $class = ($class == 'alternate') ? '' : 'alternate';
659
+ $author = get_userdata($event->event_author);
660
  ?>
661
  <tr class="<?php echo $class; ?>">
662
  <th scope="row"><?php echo $event->event_id; ?></th>
670
  if ($event->event_recur == 'S') { _e('Never','my-calendar'); }
671
  else if ($event->event_recur == 'D') { _e('Daily','my-calendar'); }
672
  else if ($event->event_recur == 'W') { _e('Weekly','my-calendar'); }
673
+ else if ($event->event_recur == 'B') { _e('Bi-Weekly','my-calendar'); }
674
  else if ($event->event_recur == 'M') { _e('Monthly','my-calendar'); }
675
  else if ($event->event_recur == 'Y') { _e('Yearly','my-calendar'); }
676
  ?>
683
  else if ($event->event_repeats > 0) { echo $event->event_repeats.' '.__('Times','my-calendar'); }
684
  ?>
685
  </td>
686
+ <td><?php echo $author->display_name; ?></td>
687
  <?php
688
  $sql = "SELECT * FROM " . MY_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
689
  $this_cat = $wpdb->get_row($sql);
690
  ?>
691
  <td style="background-color:<?php echo $this_cat->category_color;?>;"><?php echo $this_cat->category_name; ?></td>
692
  <?php unset($this_cat); ?>
693
+ <td>
694
+ <?php if ( mc_can_edit_event( $event->event_author ) ) { ?>
695
+ <a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;action=edit&amp;event_id=<?php echo $event->event_id;?>" class='edit'><?php echo __('Edit','my-calendar'); ?></a> &middot; <a href="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar&amp;action=delete&amp;event_id=<?php echo $event->event_id;?>" class="delete"><?php echo __('Delete','my-calendar'); ?></a></td>
696
+ <?php } else { echo "Not editable."; } ?>
697
+ </tr>
698
  <?php
699
  }
700
  ?>
my-calendar-settings.php CHANGED
@@ -142,7 +142,7 @@ function edit_my_calendar_config() {
142
  <div class="postbox">
143
  <h3><?php _e('Calendar Settings','my-calendar'); ?></h3>
144
  <div class="inside">
145
- <form name="my-calendar" id="my-calendar" method="post" action="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=my-calendar-config">
146
  <fieldset>
147
  <legend><?php _e('Primary Calendar Options','my-calendar'); ?></legend>
148
  <p>
@@ -206,7 +206,7 @@ if ( get_option('ko_calendar_imported') != 'true' ) {
206
  _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar');
207
  echo "</p>";
208
  ?>
209
- <form method="post" action="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=my-calendar-config">
210
  <div>
211
  <input type="hidden" name="import" value="true" />
212
  <input type="submit" value="Import from Calendar" name="import-calendar" class="button-primary" />
142
  <div class="postbox">
143
  <h3><?php _e('Calendar Settings','my-calendar'); ?></h3>
144
  <div class="inside">
145
+ <form name="my-calendar" id="my-calendar" method="post" action="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar-config">
146
  <fieldset>
147
  <legend><?php _e('Primary Calendar Options','my-calendar'); ?></legend>
148
  <p>
206
  _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar');
207
  echo "</p>";
208
  ?>
209
+ <form method="post" action="<?php bloginfo('wpurl'); ?>/wp-admin/admin.php?page=my-calendar-config">
210
  <div>
211
  <input type="hidden" name="import" value="true" />
212
  <input type="submit" value="Import from Calendar" name="import-calendar" class="button-primary" />
my-calendar-widgets.php CHANGED
@@ -106,11 +106,11 @@ function init_my_calendar_upcoming() {
106
  ?>
107
  <p>
108
  <label for="my_calendar_upcoming_title"><?php _e('Title','my-calendar'); ?>:</label><br />
109
- <input class="widefat" type="text" id="my_calendar_upcoming_title" name="my_calendar_upcoming_title" value="<?php echo $widget_title; ?>"/>
110
  </p>
111
  <p>
112
  <label for="my_calendar_upcoming_template"><?php _e('Template','my-calendar'); ?></label><br />
113
- <textarea class="widefat" rows="8" cols="20" id="my_calendar_upcoming_template" name="my_calendar_upcoming_template"><?php echo stripcslashes($widget_template); ?></textarea>
114
  </p>
115
  <fieldset>
116
  <legend><?php _e('Widget Options','my-calendar'); ?></legend>
@@ -121,12 +121,12 @@ function init_my_calendar_upcoming() {
121
  </select>
122
  </p>
123
  <p>
124
- <input type="text" id="display_upcoming_events" name="display_upcoming_events" value="<?php echo $upcoming_events ?>" size="1" maxlength="2" /> <label for="display_upcoming_events"><?php _e('events into the future;','my-calendar'); ?></label><br />
125
- <input type="text" id="display_past_events" name="display_past_events" value="<?php echo $past_events ?>" size="1" maxlength="2" /> <label for="display_past_events"><?php _e('events from the past','my-calendar'); ?></label>
126
  </p>
127
  <p>
128
- <input type="text" id="display_upcoming_days" name="display_upcoming_days" value="<?php echo $upcoming_days ?>" size="1" maxlength="2" /> <label for="display_upcoming_days"><?php _e('days into the future;','my-calendar'); ?></label><br />
129
- <input type="text" id="display_past_days" name="display_past_days" value="<?php echo $past_days ?>" size="1" maxlength="2" /> <label for="display_past_days"><?php _e('days from the past','my-calendar'); ?></label>
130
  </p>
131
  </fieldset>
132
  <?php
@@ -145,7 +145,7 @@ function my_calendar_upcoming_events() {
145
  check_my_calendar();
146
  $template = get_option('my_calendar_upcoming_template');
147
  $display_upcoming_type = get_option('display_upcoming_type');
148
-
149
 
150
  // Get number of days we should go into the future
151
  $future_days = get_option('display_upcoming_days');
@@ -162,7 +162,7 @@ function my_calendar_upcoming_events() {
162
  list($y,$m,$d) = split("-",date("Y-m-d",mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))));
163
  $events = my_calendar_grab_events( $y,$m,$d );
164
 
165
- usort($events, "my_calendar_time_cmp");
166
  foreach($events as $event) {
167
  $event_details = event_as_array($event);
168
  $output .= "<li>".jd_draw_widget_event($event_details,$template)."</li>";
@@ -170,32 +170,50 @@ function my_calendar_upcoming_events() {
170
  $day_count = $day_count+1;
171
  }
172
  } else {
173
- $events = mc_get_all_events( ); // grab all events WITHIN reasonable proximity
174
- usort($events, "my_calendar_timediff_cmp");// sort all events by proximity to current date
175
- for ($i=0;$i<=($past_events+$future_events);$i++) {
 
 
 
176
  if ($events[$i]) {
177
- $near_events[] = $events[$i]; // split off a number of events equal to the past + future settings
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
- }
180
 
181
  $events = $near_events;
182
- usort($events, "my_calendar_datetime_cmp"); // sort split events by date
183
-
184
- foreach($events as $event) {
185
- $event_details = event_as_array($event);
186
- $today = date('Y').'-'.date('m').'-'.date('d');
187
  $date = date('Y-m-d',strtotime($event_details['date']));
188
- if (my_calendar_date_comp($date,$today)===true) {
189
  $class = "past-event";
190
  } else {
191
  $class = "future-event";
192
  }
193
- if (my_calendar_date_equal($date,$today)) {
194
  $class = "today";
195
- }
196
  $output .= "<li class=\"$class\">".jd_draw_widget_event($event_details,$template)."</li>\n";
197
  }
198
  $day_count = $day_count+1;
 
 
 
199
  }
200
 
201
  if ($output != '') {
@@ -217,7 +235,7 @@ function my_calendar_todays_events() {
217
  if (count($events) != 0) {
218
  $output = "<ul>";
219
  }
220
- usort($events, "my_calendar_time_cmp");
221
  foreach($events as $event) {
222
  $event_details = event_as_array($event);
223
 
106
  ?>
107
  <p>
108
  <label for="my_calendar_upcoming_title"><?php _e('Title','my-calendar'); ?>:</label><br />
109
+ <input class="widefat" type="text" id="my_calendar_upcoming_title" name="my_calendar_upcoming_title" value="<?php if(isset($_POST['my_calendar_upcoming_title'])){echo strip_tags($_POST['my_calendar_upcoming_title']); } else { echo $widget_title; } ?>"/>
110
  </p>
111
  <p>
112
  <label for="my_calendar_upcoming_template"><?php _e('Template','my-calendar'); ?></label><br />
113
+ <textarea class="widefat" rows="8" cols="20" id="my_calendar_upcoming_template" name="my_calendar_upcoming_template"><?php if(isset($_POST['my_calendar_upcoming_template'])){echo stripcslashes($_POST['my_calendar_upcoming_template']); } else { echo stripcslashes($widget_template); } ?></textarea>
114
  </p>
115
  <fieldset>
116
  <legend><?php _e('Widget Options','my-calendar'); ?></legend>
121
  </select>
122
  </p>
123
  <p>
124
+ <input type="text" id="display_upcoming_events" name="display_upcoming_events" value="<?php if(isset($_POST['display_upcoming_events'])){echo $_POST['display_upcoming_events']; } else { echo $upcoming_events; } ?>" size="1" maxlength="2" /> <label for="display_upcoming_events"><?php _e('events into the future;','my-calendar'); ?></label><br />
125
+ <input type="text" id="display_past_events" name="display_past_events" value="<?php if(isset($_POST['display_past_events'])){echo $_POST['display_past_events']; } else { echo $past_events; } ?>" size="1" maxlength="2" /> <label for="display_past_events"><?php _e('events from the past','my-calendar'); ?></label>
126
  </p>
127
  <p>
128
+ <input type="text" id="display_upcoming_days" name="display_upcoming_days" value="<?php if(isset($_POST['display_upcoming_days'])){echo $_POST['display_upcoming_days']; } else { echo $upcoming_days; } ?>" size="1" maxlength="2" /> <label for="display_upcoming_days"><?php _e('days into the future;','my-calendar'); ?></label><br />
129
+ <input type="text" id="display_past_days" name="display_past_days" value="<?php if(isset($_POST['display_past_days'])){echo $_POST['display_past_days']; } else { echo $past_days; } ?>" size="1" maxlength="2" /> <label for="display_past_days"><?php _e('days from the past','my-calendar'); ?></label>
130
  </p>
131
  </fieldset>
132
  <?php
145
  check_my_calendar();
146
  $template = get_option('my_calendar_upcoming_template');
147
  $display_upcoming_type = get_option('display_upcoming_type');
148
+ $today = date('Y').'-'.date('m').'-'.date('d');
149
 
150
  // Get number of days we should go into the future
151
  $future_days = get_option('display_upcoming_days');
162
  list($y,$m,$d) = split("-",date("Y-m-d",mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))));
163
  $events = my_calendar_grab_events( $y,$m,$d );
164
 
165
+ @usort($events, "my_calendar_time_cmp");
166
  foreach($events as $event) {
167
  $event_details = event_as_array($event);
168
  $output .= "<li>".jd_draw_widget_event($event_details,$template)."</li>";
170
  $day_count = $day_count+1;
171
  }
172
  } else {
173
+ $events = mc_get_all_events(); // grab all events WITHIN reasonable proximity
174
+ $past = 1;
175
+ $future = 1;
176
+ @usort( $events, "my_calendar_timediff_cmp" );// sort all events by proximity to current date
177
+ $count = count($events);
178
+ for ( $i=0;$i<=$count;$i++ ) {
179
  if ($events[$i]) {
180
+ if ( ( $past<=$past_events && $future<=$future_events ) ) {
181
+ $near_events[] = $events[$i]; // if neither limit is reached, split off freely
182
+ } else if ( $past <= $past_events && ( my_calendar_date_comp( $events[$i]->event_begin,$today ) ) ) {
183
+ $near_events[] = $events[$i]; // split off another past event
184
+ } else if ( $future <= $future_events && ( !my_calendar_date_comp( $events[$i]->event_begin,$today ) ) ) {
185
+ $near_events[] = $events[$i]; // split off another future event
186
+ }
187
+ if ( my_calendar_date_comp( $events[$i]->event_begin,$today ) ) {
188
+ $past++;
189
+ } elseif ( my_calendar_date_equal( $events[$i]->event_begin,$today ) ) {
190
+ $present = 1;
191
+ } else {
192
+ $future++;
193
+ }
194
  }
195
+ }
196
 
197
  $events = $near_events;
198
+ @usort( $events, "my_calendar_datetime_cmp" ); // sort split events by date
199
+ if ( is_array( $events ) ) {
200
+ foreach( $events as $event ) {
201
+ $event_details = event_as_array( $event );
 
202
  $date = date('Y-m-d',strtotime($event_details['date']));
203
+ if (my_calendar_date_comp( $date,$today )===true) {
204
  $class = "past-event";
205
  } else {
206
  $class = "future-event";
207
  }
208
+ if ( my_calendar_date_equal( $date,$today ) ) {
209
  $class = "today";
210
+ }
211
  $output .= "<li class=\"$class\">".jd_draw_widget_event($event_details,$template)."</li>\n";
212
  }
213
  $day_count = $day_count+1;
214
+ } else {
215
+ $output .= "<li class=\"no-events\">".__('There are no events currently scheduled.','my-calendar')."</li>\n";
216
+ }
217
  }
218
 
219
  if ($output != '') {
235
  if (count($events) != 0) {
236
  $output = "<ul>";
237
  }
238
+ @usort($events, "my_calendar_time_cmp");
239
  foreach($events as $event) {
240
  $event_details = event_as_array($event);
241
 
my-calendar.php CHANGED
@@ -5,7 +5,7 @@ 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.0.2
9
  */
10
  /* Copyright 2009 Joe Dolson (email : joe@joedolson.com)
11
 
@@ -160,14 +160,13 @@ jQuery(document).ready(function($) {
160
  ';
161
  }
162
  if ($_GET['page']=='my-calendar-categories') {
163
- ?>
164
- <script type=\"text/javascript\">
165
- //<![CDATA[
166
- //jQuery(document).ready(function($) {
167
- //$('#category_color').colorpicker({ flat: true });
168
- //]]>
169
- </script>
170
- <?php
171
  }
172
  }
173
  function my_calendar_add_display_javascript() {
@@ -307,10 +306,17 @@ function check_my_calendar() {
307
 
308
  // default styles will go into the options table on a new install
309
  $initial_style = "
310
- #jd-calendar caption {
311
- margin-top:-8px;
312
- background:#f6f6f6;
313
- border:1px solid #ddd;
 
 
 
 
 
 
 
314
  font-weight:700;
315
  padding:2px 0;
316
  }
@@ -329,12 +335,21 @@ width:60px;
329
  height:70px;
330
  padding:2px!important;
331
  }
332
-
 
 
 
 
 
 
 
333
  #jd-calendar h3 {
334
- font-size:1em;
 
335
  font-weight:700;
336
  margin:3px 0;
337
  padding:0;
 
338
  }
339
  #jd-calendar h3 img {
340
  vertical-align: bottom;
@@ -348,17 +363,16 @@ vertical-align: middle;
348
  font-size:1.2em;
349
  margin:0;
350
  }
351
-
352
  #jd-calendar .calendar-event .details {
353
  position:absolute;
354
- width:300px;
355
- background:#cae0f5;
356
  color:#000;
357
- border:1px solid;
358
  -moz-border-radius:10px;
359
- -moz-box-shadow:4px 4px 12px #777;
360
- -webkit-box-shadow:4px 4px 12px #777;
361
- box-shadow:4px 4px 12px #777;
362
  padding:5px;
363
  z-index: 3;
364
  }
@@ -390,7 +404,11 @@ border:1px solid #c3d3d3;
390
  }
391
 
392
  #jd-calendar .current-day {
393
- background:#ffd;
 
 
 
 
394
  }
395
 
396
  #jd-calendar td span {
@@ -408,8 +426,8 @@ padding:0;
408
  }
409
 
410
  #jd-calendar .weekend {
411
- font-weight:700;
412
- background:#fdd;
413
  }
414
 
415
  #jd-calendar th {
@@ -417,8 +435,21 @@ font-size:.8em;
417
  text-transform:uppercase;
418
  padding:2px 4px 2px 0;
419
  }
420
-
421
- .category-icon {
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  margin-right:5px;
423
  margin-bottom:5px;
424
  vertical-align:middle;
@@ -464,10 +495,10 @@ clear:left;
464
  background: #fff;
465
  }
466
  #jd-calendar {
467
- padding: 5px;
468
  -moz-border-radius: 5px;
469
  -webkit-border-radius: 5px;
470
  border-radius: 5px;
 
471
  }
472
  #jd-calendar img {
473
  border: none;
@@ -477,13 +508,12 @@ margin-right: 5px;
477
  vertical-align: top;
478
  }
479
  .my-calendar-nav {
480
- height:1em;
 
481
  }
482
 
483
  #jd-calendar .my-calendar-nav ul {
484
  list-style-type:none;
485
- height:2.2em;
486
- border-bottom:1px solid #ccc;
487
  margin:0;
488
  padding:0;
489
  }
@@ -501,20 +531,39 @@ my-calendar-nav .my-calendar-next {
501
  text-align:right;
502
  }
503
 
504
- .my-calendar-nav li a {
505
  display:block;
506
- background:#eee;
507
- border:1px solid #ddd;
508
  -moz-border-radius:5px 5px 0 0;
509
  -webkit-border-radius:5px 5px 0 0;
510
  border-radius:5px 5px 0 0;
511
  border-bottom:none;
512
  text-align:center;
513
  padding:1px 20px;
 
514
  }
515
 
516
- .my-calendar-nav li a:hover {
517
- background:#fff;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  }";
519
 
520
  $default_template = "<strong>{date}</strong> &#8211; {link_title}<br /><span>{time}, {category}</span>";
@@ -573,7 +622,7 @@ $default_template = "<strong>{date}</strong> &#8211; {link_title}<br /><span>{ti
573
  add_option('display_upcoming_days',7);
574
  add_option('my_calendar_version','1.0');
575
  add_option('display_upcoming_type','false');
576
- add_option('display_my_calendar_upcoming_events',3);
577
  add_option('display_past_days',0);
578
  add_option('display_past_events',2);
579
  add_option('my_calendar_use_styles','false');
@@ -859,6 +908,16 @@ global $wpdb;
859
  $arr_events[]=${$i};
860
  }
861
  break;
 
 
 
 
 
 
 
 
 
 
862
  case "M":
863
  for ($i=$numback;$i<=$numforward;$i++) {
864
  $begin = my_calendar_add_date($orig_begin,0,$i,0);
@@ -886,9 +945,9 @@ global $wpdb;
886
  $event_begin = $event->event_begin;
887
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
888
  $nDays = get_option('display_past_events');
889
- $fDays = get_option('display_my_calendar_upcoming_events');
890
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
891
- if (my_calendar_date_comp( $event_begin, my_calendar_add_date($this_date,-($nDays),0,0) )) {
892
  $diff = jd_date_diff_precise(strtotime($event_begin));
893
  $diff_days = $diff/(86400);
894
  $days = explode(".",$diff_days);
@@ -924,10 +983,10 @@ global $wpdb;
924
  $event_begin = $event->event_begin;
925
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
926
  $nDays = get_option('display_past_events');
927
- $fDays = get_option('display_my_calendar_upcoming_events');
928
 
929
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
930
- if (my_calendar_date_comp( $event_begin, my_calendar_add_date($this_date,-($nDays*7),0,0) )) {
931
  $diff = jd_date_diff_precise(strtotime($event_begin));
932
  $diff_weeks = $diff/(86400*7);
933
  $weeks = explode(".",$diff_weeks);
@@ -941,7 +1000,7 @@ global $wpdb;
941
  ${$realStart}->event_begin = $this_date;
942
  $arr_events[] = ${$realStart};
943
  }
944
- }
945
 
946
  } else {
947
  $realDays = -($nDays);
@@ -959,14 +1018,53 @@ global $wpdb;
959
  }
960
  break;
961
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
962
  case "M":
963
  $event_begin = $event->event_begin;
964
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
965
  $nDays = get_option('display_past_events');
966
- $fDays = get_option('display_my_calendar_upcoming_events');
967
 
968
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
969
- if (my_calendar_date_comp( $event_begin, my_calendar_add_date($this_date,-($nDays),0,0) )) {
970
  $diff = jd_date_diff_precise(strtotime($event_begin));
971
  $diff_days = $diff/(86400*30);
972
  $days = explode(".",$diff_days);
@@ -1002,10 +1100,10 @@ global $wpdb;
1002
  $event_begin = $event->event_begin;
1003
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
1004
  $nDays = get_option('display_past_events');
1005
- $fDays = get_option('display_my_calendar_upcoming_events');
1006
 
1007
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
1008
- if (my_calendar_date_comp( $event_begin, my_calendar_add_date($this_date,-($nDays),0,0) )) {
1009
  $diff = jd_date_diff_precise(strtotime($event_begin));
1010
  $diff_days = $diff/(86400*365);
1011
  $days = explode(".",$diff_days);
@@ -1171,7 +1269,73 @@ function my_calendar_grab_events($y,$m,$d,$category=null) {
1171
  }
1172
  }
1173
 
1174
- /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1175
  Weekly - well isn't this fun! We need to scan all weekly events, find what day they fell on
1176
  and see if that matches the current day. If it does, we check to see if the repeats are 0.
1177
  If they are, display the event, if not, we fast forward from the original day in week blocks
@@ -1180,10 +1344,8 @@ function my_calendar_grab_events($y,$m,$d,$category=null) {
1180
 
1181
  // The weekly events that never stop recurring
1182
  $events = $wpdb->get_results("SELECT * FROM " . MY_CALENDAR_TABLE . " WHERE $select_category event_recur = 'W' AND '$date' >= event_begin AND event_repeats = 0 ORDER BY event_id");
1183
- if (!empty($events))
1184
- {
1185
- foreach($events as $event)
1186
- {
1187
  // This is going to get complex so lets setup what we would place in for
1188
  // an event so we can drop it in with ease
1189
 
@@ -1208,7 +1370,7 @@ function my_calendar_grab_events($y,$m,$d,$category=null) {
1208
 
1209
  }
1210
  }
1211
-
1212
  // The weekly events that have a limit on how many times they occur
1213
  $events = $wpdb->get_results("SELECT * FROM " . MY_CALENDAR_TABLE . " WHERE $select_category event_recur = 'W' AND '$date' >= event_begin AND event_repeats != 0 AND (event_repeats*7) >= (TO_DAYS('$date') - TO_DAYS(event_end)) ORDER BY event_id");
1214
  if (!empty($events)) {
@@ -1585,4 +1747,20 @@ function my_calendar_is_odd( $int ) {
1585
  return( $int & 1 );
1586
  }
1587
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1588
  ?>
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.1.0
9
  */
10
  /* Copyright 2009 Joe Dolson (email : joe@joedolson.com)
11
 
160
  ';
161
  }
162
  if ($_GET['page']=='my-calendar-categories') {
163
+ /*
164
+ <script type=\"text/javascript\">
165
+ //<![CDATA[
166
+ //jQuery(document).ready(function($) {
167
+ //$('#category_color').colorpicker({ flat: true });
168
+ //]]>
169
+ */
 
170
  }
171
  }
172
  function my_calendar_add_display_javascript() {
306
 
307
  // default styles will go into the options table on a new install
308
  $initial_style = "
309
+ #jd-calendar * {
310
+ margin: 0;
311
+ padding: 0;
312
+ line-height: 1.5;
313
+ color: #000;
314
+ background: #fff;
315
+ }
316
+ #jd-calendar caption, #jd-calendar .my-calendar-date-switcher {
317
+ background: #edf7ff;
318
+ border: 1px solid #a9e3ff;
319
+ margin: 0;
320
  font-weight:700;
321
  padding:2px 0;
322
  }
335
  height:70px;
336
  padding:2px!important;
337
  }
338
+ #jd-calendar th {
339
+ text-align: center;
340
+ padding: 5px 0!important;
341
+ letter-spacing: 1px;
342
+ }
343
+ #jd-calendar th abbr {
344
+ border-bottom: none;
345
+ }
346
  #jd-calendar h3 {
347
+ font-size:.9em;
348
+ font-family: Arial, Verdana, sans-serif;
349
  font-weight:700;
350
  margin:3px 0;
351
  padding:0;
352
+ width: 100%;
353
  }
354
  #jd-calendar h3 img {
355
  vertical-align: bottom;
363
  font-size:1.2em;
364
  margin:0;
365
  }
 
366
  #jd-calendar .calendar-event .details {
367
  position:absolute;
368
+ width:50%;
369
+ background: #edf7ff;
370
  color:#000;
371
+ border:1px solid #9b5;
372
  -moz-border-radius:10px;
373
+ -moz-box-shadow:3px 3px 6px #777;
374
+ -webkit-box-shadow:3px 3px 6px #777;
375
+ box-shadow:3px 3px 6px #777;
376
  padding:5px;
377
  z-index: 3;
378
  }
404
  }
405
 
406
  #jd-calendar .current-day {
407
+ background:#ffb;
408
+ }
409
+ #jd-calendar .current-day span {
410
+ color: #000;
411
+ background: #eee;
412
  }
413
 
414
  #jd-calendar td span {
426
  }
427
 
428
  #jd-calendar .weekend {
429
+ background:#bd7;
430
+ color: #000;
431
  }
432
 
433
  #jd-calendar th {
435
  text-transform:uppercase;
436
  padding:2px 4px 2px 0;
437
  }
438
+ #jd-calendar .category-key {
439
+ background: #edf7ff;
440
+ border: 1px solid #a9e3ff;
441
+ padding: 5px;
442
+ margin: 5px 0;
443
+ }
444
+ #jd-calendar .category-key ul {
445
+ list-style-type: none;
446
+ margin: 0;
447
+ padding: 0;
448
+ }
449
+ #jd-calendar .category-key li {
450
+ margin: 2px 10px;
451
+ }
452
+ #jd-calendar .category-icon {
453
  margin-right:5px;
454
  margin-bottom:5px;
455
  vertical-align:middle;
495
  background: #fff;
496
  }
497
  #jd-calendar {
 
498
  -moz-border-radius: 5px;
499
  -webkit-border-radius: 5px;
500
  border-radius: 5px;
501
+ position: relative;
502
  }
503
  #jd-calendar img {
504
  border: none;
508
  vertical-align: top;
509
  }
510
  .my-calendar-nav {
511
+ height: 2.25em;
512
+ border-bottom: 1px solid #ac6;
513
  }
514
 
515
  #jd-calendar .my-calendar-nav ul {
516
  list-style-type:none;
 
 
517
  margin:0;
518
  padding:0;
519
  }
531
  text-align:right;
532
  }
533
 
534
+ #jd-calendar .my-calendar-nav li a {
535
  display:block;
536
+ background:#fff;
537
+ border:1px solid #9b5;
538
  -moz-border-radius:5px 5px 0 0;
539
  -webkit-border-radius:5px 5px 0 0;
540
  border-radius:5px 5px 0 0;
541
  border-bottom:none;
542
  text-align:center;
543
  padding:1px 20px;
544
+ color: #243f82;
545
  }
546
 
547
+ #jd-calendar .my-calendar-nav li a:hover {
548
+ background:#a9e3ff;
549
+ color:#000;
550
+ border: 1px solid #243f82;
551
+ border-bottom: none;
552
+ }
553
+ #jd-calendar .my-calendar-next {
554
+ margin-left: 1px;
555
+ }
556
+ #jd-calendar .day-without-date {
557
+ background: #fafafa;
558
+ }
559
+ #upcoming-events .past-event {
560
+ color: #777;
561
+ }
562
+ #upcoming-events .today {
563
+ color: #111;
564
+ }
565
+ #upcoming-events .future-event {
566
+ color: #555;
567
  }";
568
 
569
  $default_template = "<strong>{date}</strong> &#8211; {link_title}<br /><span>{time}, {category}</span>";
622
  add_option('display_upcoming_days',7);
623
  add_option('my_calendar_version','1.0');
624
  add_option('display_upcoming_type','false');
625
+ add_option('display_upcoming_events',3);
626
  add_option('display_past_days',0);
627
  add_option('display_past_events',2);
628
  add_option('my_calendar_use_styles','false');
908
  $arr_events[]=${$i};
909
  }
910
  break;
911
+ case "B":
912
+ for ($i=$numback;$i<=$numforward;$i++) {
913
+ $begin = my_calendar_add_date($orig_begin,($i*14),0,0);
914
+ $end = my_calendar_add_date($orig_end,($i*14),0,0);
915
+ ${$i} = clone $event;
916
+ ${$i}->event_begin = $begin;
917
+ ${$i}->event_end = $end;
918
+ $arr_events[]=${$i};
919
+ }
920
+ break;
921
  case "M":
922
  for ($i=$numback;$i<=$numforward;$i++) {
923
  $begin = my_calendar_add_date($orig_begin,0,$i,0);
945
  $event_begin = $event->event_begin;
946
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
947
  $nDays = get_option('display_past_events');
948
+ $fDays = get_option('display_upcoming_events');
949
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
950
+ if (my_calendar_date_comp( $event_begin, my_calendar_add_date($today,-($nDays),0,0) )) {
951
  $diff = jd_date_diff_precise(strtotime($event_begin));
952
  $diff_days = $diff/(86400);
953
  $days = explode(".",$diff_days);
983
  $event_begin = $event->event_begin;
984
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
985
  $nDays = get_option('display_past_events');
986
+ $fDays = get_option('display_upcoming_events');
987
 
988
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
989
+ if (my_calendar_date_comp( $event_begin, my_calendar_add_date($today,-($nDays*7),0,0) )) {
990
  $diff = jd_date_diff_precise(strtotime($event_begin));
991
  $diff_weeks = $diff/(86400*7);
992
  $weeks = explode(".",$diff_weeks);
1000
  ${$realStart}->event_begin = $this_date;
1001
  $arr_events[] = ${$realStart};
1002
  }
1003
+ }
1004
 
1005
  } else {
1006
  $realDays = -($nDays);
1018
  }
1019
  break;
1020
 
1021
+ case "B":
1022
+ $event_begin = $event->event_begin;
1023
+ $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
1024
+ $nDays = get_option('display_past_events');
1025
+ $fDays = get_option('display_upcoming_events');
1026
+
1027
+ if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
1028
+ if (my_calendar_date_comp( $event_begin, my_calendar_add_date($today,-($nDays*14),0,0) )) {
1029
+ $diff = jd_date_diff_precise(strtotime($event_begin));
1030
+ $diff_weeks = $diff/(86400*14);
1031
+ $weeks = explode(".",$diff_weeks);
1032
+ $realStart = $weeks[0] - $nDays;
1033
+ $realFinish = $weeks[0] + $fDays;
1034
+
1035
+ for ($realStart;$realStart<=$realFinish;$realStart++) { // jump forward to near present.
1036
+ $this_date = my_calendar_add_date($event_begin,($realStart*14),0,0);
1037
+ if ( my_calendar_date_comp( $event->event_begin,$this_date ) ) {
1038
+ ${$realStart} = clone $event;
1039
+ ${$realStart}->event_begin = $this_date;
1040
+ $arr_events[] = ${$realStart};
1041
+ }
1042
+ }
1043
+
1044
+ } else {
1045
+ $realDays = -($nDays);
1046
+ for ($realDays;$realDays<=$fDays;$realDays++) { // for each event within plus or minus range, mod date and add to array.
1047
+ $this_date = my_calendar_add_date($event_begin,($realDays*14),0,0);
1048
+ if ( my_calendar_date_comp( $event->event_begin,$this_date ) ) {
1049
+ ${$realDays} = clone $event;
1050
+ ${$realDays}->event_begin = $this_date;
1051
+ $arr_events[] = ${$realDays};
1052
+ }
1053
+ }
1054
+ }
1055
+ } else {
1056
+ break;
1057
+ }
1058
+ break;
1059
+
1060
  case "M":
1061
  $event_begin = $event->event_begin;
1062
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
1063
  $nDays = get_option('display_past_events');
1064
+ $fDays = get_option('display_upcoming_events');
1065
 
1066
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
1067
+ if (my_calendar_date_comp( $event_begin, my_calendar_add_date($today,-($nDays),0,0) )) {
1068
  $diff = jd_date_diff_precise(strtotime($event_begin));
1069
  $diff_days = $diff/(86400*30);
1070
  $days = explode(".",$diff_days);
1100
  $event_begin = $event->event_begin;
1101
  $today = date('Y',time()+(60*60*$offset)).'-'.date('m',time()+(60*60*$offset)).'-'.date('d',time()+(60*60*$offset));
1102
  $nDays = get_option('display_past_events');
1103
+ $fDays = get_option('display_upcoming_events');
1104
 
1105
  if ( my_calendar_date_comp($event_begin, $today) ) { // compare first date against today's date
1106
+ if (my_calendar_date_comp( $event_begin, my_calendar_add_date($today,-($nDays),0,0) )) {
1107
  $diff = jd_date_diff_precise(strtotime($event_begin));
1108
  $diff_days = $diff/(86400*365);
1109
  $days = explode(".",$diff_days);
1269
  }
1270
  }
1271
 
1272
+ //bi-weekly events
1273
+ $events = $wpdb->get_results("SELECT * FROM " . MY_CALENDAR_TABLE . " WHERE $select_category event_recur = 'B' AND '$date' >= event_begin AND event_repeats = 0 ORDER BY event_id");
1274
+ if ( !empty( $events ) ) {
1275
+ foreach( $events as $event ) {
1276
+ // This is going to get complex so lets setup what we would place in for
1277
+ // an event so we can drop it in with ease
1278
+
1279
+ // Now we are going to check to see what day the original event
1280
+ // fell on and see if the current date is both after it and on
1281
+ // the correct day. If it is, display the event!
1282
+ $day_start_event = date('D',strtotime($event->event_begin));
1283
+ $day_end_event = date('D',strtotime($event->event_end));
1284
+ $current_day = date('D',strtotime($date));
1285
+ $current_date = date('Y-m-d',strtotime($date));
1286
+ $start_date = $event->event_begin;
1287
+
1288
+ $plan = array("Mon"=>1,"Tue"=>2,"Wed"=>3,"Thu"=>4,"Fri"=>5,"Sat"=>6,"Sun"=>7);
1289
+
1290
+ for ($n=0;$n<=$event->event_repeats;$n++) {
1291
+ if ( $current_date == my_calendar_add_date($start_date,(14*$n)) ) {
1292
+ if ($plan[$day_start_event] > $plan[$day_end_event]) {
1293
+ if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event])) {
1294
+ $arr_events[]=$event;
1295
+ }
1296
+ } else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event])) {
1297
+ if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event])) {
1298
+ $arr_events[]=$event;
1299
+ }
1300
+ }
1301
+ }
1302
+ }
1303
+
1304
+ }
1305
+ }
1306
+
1307
+ // The bi-weekly events that have a limit on how many times they occur
1308
+ $events = $wpdb->get_results("SELECT * FROM " . MY_CALENDAR_TABLE . " WHERE $select_category event_recur = 'B' AND '$date' >= event_begin AND event_repeats != 0 AND (event_repeats*14) >= (TO_DAYS('$date') - TO_DAYS(event_end)) ORDER BY event_id");
1309
+ if (!empty($events)) {
1310
+
1311
+ foreach($events as $event) {
1312
+ // Now we are going to check to see what day the original event
1313
+ // fell on and see if the current date is both after it and on
1314
+ // the correct day. If it is, display the event!
1315
+ $day_start_event = date('D',strtotime($event->event_begin));
1316
+ $day_end_event = date('D',strtotime($event->event_end));
1317
+ $current_day = date('D',strtotime($date));
1318
+ $current_date = date('Y-m-d',strtotime($date));
1319
+ $start_date = $event->event_begin;
1320
+
1321
+ $plan = array("Mon"=>1,"Tue"=>2,"Wed"=>3,"Thu"=>4,"Fri"=>5,"Sat"=>6,"Sun"=>7);
1322
+
1323
+ for ($n=0;$n<=$event->event_repeats;$n++) {
1324
+ if ( $current_date == my_calendar_add_date($start_date,(14*$n)) ) {
1325
+ if ($plan[$day_start_event] > $plan[$day_end_event]) {
1326
+ if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event])) {
1327
+ $arr_events[]=$event;
1328
+ }
1329
+ } else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event])) {
1330
+ if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event])) {
1331
+ $arr_events[]=$event;
1332
+ }
1333
+ }
1334
+ }
1335
+ }
1336
+ }
1337
+ }
1338
+ /*
1339
  Weekly - well isn't this fun! We need to scan all weekly events, find what day they fell on
1340
  and see if that matches the current day. If it does, we check to see if the repeats are 0.
1341
  If they are, display the event, if not, we fast forward from the original day in week blocks
1344
 
1345
  // The weekly events that never stop recurring
1346
  $events = $wpdb->get_results("SELECT * FROM " . MY_CALENDAR_TABLE . " WHERE $select_category event_recur = 'W' AND '$date' >= event_begin AND event_repeats = 0 ORDER BY event_id");
1347
+ if ( !empty( $events ) ) {
1348
+ foreach( $events as $event ) {
 
 
1349
  // This is going to get complex so lets setup what we would place in for
1350
  // an event so we can drop it in with ease
1351
 
1370
 
1371
  }
1372
  }
1373
+
1374
  // The weekly events that have a limit on how many times they occur
1375
  $events = $wpdb->get_results("SELECT * FROM " . MY_CALENDAR_TABLE . " WHERE $select_category event_recur = 'W' AND '$date' >= event_begin AND event_repeats != 0 AND (event_repeats*7) >= (TO_DAYS('$date') - TO_DAYS(event_end)) ORDER BY event_id");
1376
  if (!empty($events)) {
1747
  return( $int & 1 );
1748
  }
1749
 
1750
+
1751
+ function mc_can_edit_event($author_id) {
1752
+ global $user_ID;
1753
+ get_currentuserinfo();
1754
+ $user = get_userdata($user_ID);
1755
+
1756
+ if ($user->user_level == 10) {
1757
+ return true;
1758
+ } elseif ( $user_ID == $author_id ) {
1759
+ return true;
1760
+ } else {
1761
+ return false;
1762
+ }
1763
+ }
1764
+
1765
+
1766
  ?>
readme.txt CHANGED
@@ -58,6 +58,15 @@ Features:
58
 
59
  == Changelog ==
60
 
 
 
 
 
 
 
 
 
 
61
  = 1.0.2 =
62
 
63
  * Fixed problems with editing and deleting events or categories in multiblog installation
58
 
59
  == Changelog ==
60
 
61
+ = 1.1.0 =
62
+
63
+ * Fixed some problems with Upcoming Events past events not scrolling off; hopefully all!
64
+ * Fixed some problems with fuzzy interpretations of the numbers of past/future events displayed in Upcoming Events.
65
+ * Added Bi-weekly events
66
+ * Added restrictions so that admin level users can edit any events but other users can only edit their own events
67
+ * Removed character restrictions on event titles
68
+ * Revised default stylesheet
69
+
70
  = 1.0.2 =
71
 
72
  * Fixed problems with editing and deleting events or categories in multiblog installation