Calendar - Version 1.2.3

Version Description

Download this release

Release Info

Developer KieranOShea
Plugin Icon 128x128 Calendar
Version 1.2.3
Comparing to
See all releases

Code changes from version 1.2.2 to 1.2.3

Files changed (3) hide show
  1. calendar.php +383 -562
  2. calendar.pot +4 -0
  3. readme.txt +3 -3
calendar.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.kieranoshea.com
5
  Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
6
  Author: Kieran O'Shea
7
  Author URI: http://www.kieranoshea.com
8
- Version: 1.2.2
9
  */
10
 
11
  /* Copyright 2008 Kieran O'Shea (email : kieran@kieranoshea.com)
@@ -34,12 +34,20 @@ define('WP_CALENDAR_TABLE', $table_prefix . 'calendar');
34
  define('WP_CALENDAR_CONFIG_TABLE', $table_prefix . 'calendar_config');
35
  define('WP_CALENDAR_CATEGORIES_TABLE', $table_prefix . 'calendar_categories');
36
 
 
 
 
 
37
  // Create a master category for Calendar and its sub-pages
38
  add_action('admin_menu', 'calendar_menu');
39
 
40
  // Enable the ability for the calendar to be loaded from pages
41
  add_filter('the_content','calendar_insert');
42
 
 
 
 
 
43
  // Add the function that puts style information in the header
44
  add_action('wp_head', 'calendar_wp_head');
45
 
@@ -57,11 +65,14 @@ function deal_with_deleted_user($id)
57
  {
58
  global $wpdb;
59
 
60
- // This wouldn't work unless the database was up to date. Lets check.
61
- check_calendar();
62
-
63
  // Do the query
64
- $wpdb->get_results("UPDATE ".WP_CALENDAR_TABLE." SET event_author=".$wpdb->get_var("SELECT MIN(ID) FROM ".$wpdb->prefix."users",0,0)." WHERE event_author=".$id);
 
 
 
 
 
 
65
  }
66
 
67
  // Function to add the calendar style into the header
@@ -69,23 +80,15 @@ function calendar_wp_head()
69
  {
70
  global $wpdb;
71
 
72
- // If the calendar isn't installed or upgraded this won't work
73
- check_calendar();
74
-
75
- $styles = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='calendar_style'");
76
- if (!empty($styles))
77
  {
78
- foreach ($styles as $style)
79
- {
80
  echo '<style type="text/css">
81
- <!--
82
  ';
83
- echo $style->config_value.'
84
  ';
85
- echo '//-->
86
- </style>
87
  ';
88
- }
89
  }
90
  }
91
 
@@ -94,9 +97,6 @@ function calendar_menu()
94
  {
95
  global $wpdb;
96
 
97
- // We make use of the Calendar tables so we must have installed Calendar
98
- check_calendar();
99
-
100
  // Set admin as the only one who can use Calendar for security
101
  $allowed_group = 'manage_options';
102
 
@@ -146,6 +146,26 @@ function calendar_insert($content)
146
  return $content;
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  // Function to check what version of Calendar is installed and install if needed
150
  function check_calendar()
151
  {
@@ -187,6 +207,7 @@ function check_calendar()
187
  padding:5px;
188
  width:150px;
189
  z-index:100;
 
190
  }
191
  .calendar-table {
192
  border:none;
@@ -261,31 +282,6 @@ function check_calendar()
261
  font-size:0.75em;
262
  text-align:center;
263
  }
264
- .event-title {
265
- text-align:center;
266
- font-weight:bold;
267
- font-size:1.2em;
268
- }
269
- .event-title-break {
270
- width:96%;
271
- margin-left:2%;
272
- margin-right:2%;
273
- margin-top:5px;
274
- margin-bottom:5px;
275
- text-align:center;
276
- height:1px;
277
- background-color:#000000;
278
- }
279
- .event-content-break {
280
- width:96%;
281
- margin-left:2%;
282
- margin-right:2%;
283
- margin-top:5px;
284
- margin-bottom:5px;
285
- text-align:center;
286
- height:1px;
287
- background-color:#000000;
288
- }
289
  .calendar-date-switcher {
290
  height:25px;
291
  text-align:center;
@@ -307,6 +303,36 @@ function check_calendar()
307
  margin-top:10px;
308
  padding:5px;
309
  border:1px solid #D6DED5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  }";
311
 
312
 
@@ -320,7 +346,7 @@ function check_calendar()
320
  $wp_calendar_config_version_number_exists = false;
321
 
322
  // Determine the calendar version
323
- $tables = $wpdb->get_results("show tables;");
324
  foreach ( $tables as $table )
325
  {
326
  foreach ( $table as $value )
@@ -371,7 +397,9 @@ function check_calendar()
371
  event_time TIME ,
372
  event_recur CHAR(1) ,
373
  event_repeats INT(3) ,
374
- event_author BIGINT(20) UNSIGNED,
 
 
375
  PRIMARY KEY (event_id)
376
  )";
377
  $wpdb->get_results($sql);
@@ -395,19 +423,10 @@ function check_calendar()
395
  $wpdb->get_results($sql);
396
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming_days', config_value=7";
397
  $wpdb->get_results($sql);
398
-
399
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_version', config_value='1.2'";
400
  $wpdb->get_results($sql);
401
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
402
  $wpdb->get_results($sql);
403
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED";
404
- $wpdb->get_results($sql);
405
- $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_category=1";
406
- $wpdb->get_results($sql);
407
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT";
408
- $wpdb->get_results($sql);
409
- $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_link=''";
410
- $wpdb->get_results($sql);
411
  $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
412
  category_id INT(11) NOT NULL AUTO_INCREMENT,
413
  category_name VARCHAR(30) NOT NULL ,
@@ -446,18 +465,13 @@ function check_calendar()
446
  $wpdb->get_results($sql);
447
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming_days', config_value=7";
448
  $wpdb->get_results($sql);
449
-
450
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_version', config_value='1.2'";
451
  $wpdb->get_results($sql);
452
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
453
  $wpdb->get_results($sql);
454
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED";
455
- $wpdb->get_results($sql);
456
- $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_category=1";
457
- $wpdb->get_results($sql);
458
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT";
459
  $wpdb->get_results($sql);
460
- $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_link=''";
461
  $wpdb->get_results($sql);
462
  $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
463
  category_id INT(11) NOT NULL AUTO_INCREMENT,
@@ -475,13 +489,9 @@ function check_calendar()
475
  $wpdb->get_results($sql);
476
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
477
  $wpdb->get_results($sql);
478
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED";
479
- $wpdb->get_results($sql);
480
- $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_category=1";
481
- $wpdb->get_results($sql);
482
- $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT";
483
  $wpdb->get_results($sql);
484
- $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_link=''";
485
  $wpdb->get_results($sql);
486
  $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
487
  category_id INT(11) NOT NULL AUTO_INCREMENT,
@@ -512,9 +522,9 @@ function wp_events_display_list()
512
  <tr>
513
  <th class="manage-column" scope="col"><?php _e('ID','calendar') ?></th>
514
  <th class="manage-column" scope="col"><?php _e('Title','calendar') ?></th>
515
- <th class="manage-column" scope="col"><?php _e('Description','calendar') ?></th>
516
  <th class="manage-column" scope="col"><?php _e('Start Date','calendar') ?></th>
517
  <th class="manage-column" scope="col"><?php _e('End Date','calendar') ?></th>
 
518
  <th class="manage-column" scope="col"><?php _e('Recurs','calendar') ?></th>
519
  <th class="manage-column" scope="col"><?php _e('Repeats','calendar') ?></th>
520
  <th class="manage-column" scope="col"><?php _e('Author','calendar') ?></th>
@@ -530,17 +540,18 @@ function wp_events_display_list()
530
  $class = ($class == 'alternate') ? '' : 'alternate';
531
  ?>
532
  <tr class="<?php echo $class; ?>">
533
- <th scope="row"><?php echo $event->event_id; ?></th>
534
- <td><?php echo $event->event_title; ?></td>
535
- <td><?php echo $event->event_desc; ?></td>
536
- <td><?php echo $event->event_begin; ?></td>
537
- <td><?php echo $event->event_end; ?></td>
538
  <td>
539
  <?php
540
  // Interpret the DB values into something human readable
541
  if ($event->event_recur == 'S') { echo __('Never','calendar'); }
542
  else if ($event->event_recur == 'W') { echo __('Weekly','calendar'); }
543
- else if ($event->event_recur == 'M') { echo __('Monthly','calendar'); }
 
544
  else if ($event->event_recur == 'Y') { echo __('Yearly','calendar'); }
545
  ?>
546
  </td>
@@ -549,18 +560,18 @@ function wp_events_display_list()
549
  // Interpret the DB values into something human readable
550
  if ($event->event_recur == 'S') { echo __('N/A','calendar'); }
551
  else if ($event->event_repeats == 0) { echo __('Forever','calendar'); }
552
- else if ($event->event_repeats > 0) { echo $event->event_repeats.' '.__('Times','calendar'); }
553
  ?>
554
  </td>
555
  <td><?php $e = get_userdata($event->event_author); echo $e->display_name; ?></td>
556
  <?php
557
- $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
558
  $this_cat = $wpdb->get_row($sql);
559
  ?>
560
- <td style="background-color:<?php echo $this_cat->category_colour;?>;"><?php echo $this_cat->category_name; ?></td>
561
  <?php unset($this_cat); ?>
562
- <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?page=calendar&amp;action=edit&amp;event_id=<?php echo $event->event_id;?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
563
- <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?page=calendar&amp;action=delete&amp;event_id=<?php echo $event->event_id;?>" class="delete" onclick="return confirm('<?php _e('Are you sure you want to delete this event?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
564
  </tr>
565
  <?php
566
  }
@@ -614,9 +625,9 @@ function wp_events_edit_form($mode='add', $event_id=false)
614
 
615
  ?>
616
  <div id="pop_up_cal" style="position:absolute;margin-left:150px;visibility:hidden;background-color:white;layer-background-color:white;z-index:1;"></div>
617
- <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=calendar">
618
  <input type="hidden" name="action" value="<?php echo $mode; ?>">
619
- <input type="hidden" name="event_id" value="<?php echo $event_id; ?>">
620
 
621
  <div id="linkadvanceddiv" class="postbox">
622
  <div style="float: left; width: 98%; clear: both;" class="inside">
@@ -624,11 +635,11 @@ function wp_events_edit_form($mode='add', $event_id=false)
624
  <tr>
625
  <td><legend><?php _e('Event Title','calendar'); ?></legend></td>
626
  <td><input type="text" name="event_title" class="input" size="40" maxlength="30"
627
- value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_title); ?>" /></td>
628
  </tr>
629
  <tr>
630
  <td style="vertical-align:top;"><legend><?php _e('Event Description','calendar'); ?></legend></td>
631
- <td><textarea name="event_desc" class="input" rows="5" cols="50"><?php if ( !empty($data) ) echo htmlspecialchars($data->event_desc); ?></textarea></td>
632
  </tr>
633
  <tr>
634
  <td><legend><?php _e('Event Category','calendar'); ?></legend></td>
@@ -639,7 +650,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
639
  $cats = $wpdb->get_results($sql);
640
  foreach($cats as $cat)
641
  {
642
- echo '<option value="'.$cat->category_id.'"';
643
  if (!empty($data))
644
  {
645
  if ($data->event_category == $cat->category_id)
@@ -647,7 +658,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
647
  echo 'selected="selected"';
648
  }
649
  }
650
- echo '>'.$cat->category_name.'</option>
651
  ';
652
  }
653
  ?>
@@ -656,12 +667,13 @@ function wp_events_edit_form($mode='add', $event_id=false)
656
  </tr>
657
  <tr>
658
  <td><legend><?php _e('Event Link (Optional)','calendar'); ?></legend></td>
659
- <td><input type="text" name="event_link" class="input" size="40" value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_link); ?>" /></td>
660
  </tr>
661
  <tr>
662
  <td><legend><?php _e('Start Date','calendar'); ?></legend></td>
663
  <td> <script type="text/javascript">
664
  var cal_begin = new CalendarPopup('pop_up_cal');
 
665
  function unifydates() {
666
  document.forms['quoteform'].event_end.value = document.forms['quoteform'].event_begin.value;
667
  }
@@ -670,11 +682,11 @@ function wp_events_edit_form($mode='add', $event_id=false)
670
  value="<?php
671
  if ( !empty($data) )
672
  {
673
- echo htmlspecialchars($data->event_begin);
674
  }
675
  else
676
  {
677
- echo date("Y-m-d");
678
  }
679
  ?>" /> <a href="#" onClick="cal_begin.select(document.forms['quoteform'].event_begin,'event_begin_anchor','yyyy-MM-dd'); return false;" name="event_begin_anchor" id="event_begin_anchor"><?php _e('Select Date','calendar'); ?></a>
680
  </td>
@@ -685,6 +697,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
685
  function check_and_print() {
686
  unifydates();
687
  var cal_end = new CalendarPopup('pop_up_cal');
 
688
  var newDate = new Date();
689
  newDate.setFullYear(document.forms['quoteform'].event_begin.value.split('-')[0],document.forms['quoteform'].event_begin.value.split('-')[1]-1,document.forms['quoteform'].event_begin.value.split('-')[2]);
690
  newDate.setDate(newDate.getDate()-1);
@@ -696,11 +709,11 @@ function wp_events_edit_form($mode='add', $event_id=false)
696
  value="<?php
697
  if ( !empty($data) )
698
  {
699
- echo htmlspecialchars($data->event_end);
700
  }
701
  else
702
  {
703
- echo date("Y-m-d");
704
  }
705
  ?>" /> <a href="#" onClick="check_and_print(); return false;" name="event_end_anchor" id="event_end_anchor"><?php _e('Select Date','calendar'); ?></a>
706
  </td>
@@ -717,14 +730,14 @@ function wp_events_edit_form($mode='add', $event_id=false)
717
  }
718
  else
719
  {
720
- echo date("H:i",strtotime(htmlspecialchars($data->event_time)));
721
  }
722
  }
723
  else
724
  {
725
- echo date("H:i");
726
  }
727
- ?>" /> <?php _e('Optional, set blank if not required.','calendar'); ?> <?php _e('Current time difference from GMT is ','calendar'); echo get_option('gmt_offset'); _e(' hour(s)'); ?>
728
  </td>
729
  </tr>
730
  <tr>
@@ -755,14 +768,19 @@ function wp_events_edit_form($mode='add', $event_id=false)
755
  {
756
  $selected_y = 'selected="selected"';
757
  }
 
 
 
 
758
  ?>
759
  <?php _e('Repeats for','calendar'); ?>
760
  <input type="text" name="event_repeats" class="input" size="1" value="<?php echo $repeats; ?>" />
761
  <select name="event_recur" class="input">
762
- <option class="input" <?php echo $selected_s; ?> value="S">None</option>
763
- <option class="input" <?php echo $selected_w; ?> value="W">Weeks</option>
764
- <option class="input" <?php echo $selected_m; ?> value="M">Months</option>
765
- <option class="input" <?php echo $selected_y; ?> value="Y">Years</option>
 
766
  </select><br />
767
  <?php _e('Entering 0 means forever. Where the recurrance interval is left at none, the event will not reoccur.','calendar'); ?>
768
  </td>
@@ -820,10 +838,6 @@ $edit = $create = $save = $delete = false;
820
  $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
821
  $event_id = !empty($_REQUEST['event_id']) ? $_REQUEST['event_id'] : '';
822
 
823
-
824
- // Lets see if this is first run and create us a table if it is!
825
- check_calendar();
826
-
827
  // Deal with adding an event to the database
828
  if ( $action == 'add' )
829
  {
@@ -837,20 +851,6 @@ if ( $action == 'add' )
837
  $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
838
  $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
839
 
840
- // Deal with the fools who have left magic quotes turned on
841
- if ( ini_get('magic_quotes_gpc') )
842
- {
843
- $title = stripslashes($title);
844
- $desc = stripslashes($desc);
845
- $begin = stripslashes($begin);
846
- $end = stripslashes($end);
847
- $time = stripslashes($time);
848
- $recur = stripslashes($recur);
849
- $repeats = stripslashes($repeats);
850
- $category = stripslashes($category);
851
- $linky = stripslashes($linky);
852
- }
853
-
854
  // Perform some validation on the submitted dates - this checks for valid years and months
855
  $date_format_one = '/^([0-9]{4})-([0][1-9])-([0-3][0-9])$/';
856
  $date_format_two = '/^([0-9]{4})-([1][0-2])-([0-3][0-9])$/';
@@ -899,6 +899,18 @@ if ( $action == 'add' )
899
  if (preg_match($time_format_one,$time) || preg_match($time_format_two,$time) || $time == '')
900
  {
901
  $time_ok = 1;
 
 
 
 
 
 
 
 
 
 
 
 
902
  }
903
  else
904
  {
@@ -917,19 +929,20 @@ if ( $action == 'add' )
917
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','calendar'); ?></p></div>
918
  <?php
919
  }
920
- // The title must be at least one character in length and no more than 30 - no non-standard characters allowed
921
- if (preg_match('/^[a-zA-Z0-9]{1}[a-zA-Z0-9[:space:]]{0,29}$/',$title))
922
  {
923
  $title_ok =1;
924
  }
925
  else
926
  {
927
  ?>
928
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 30 characters in length and contain no punctuation. Spaces are allowed but the title must not start with one.','calendar'); ?></p></div>
929
  <?php
930
  }
931
- // We run some checks on recurrance
932
- if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y')))
 
933
  {
934
  $recurring_ok = 1;
935
  }
@@ -943,7 +956,7 @@ if ( $action == 'add' )
943
  {
944
  $sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
945
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
946
- . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "', event_author=".$current_user->ID.", event_category=".mysql_escape_string($category).", event_link='".mysql_escape_string($linky)."'";
947
 
948
  $wpdb->get_results($sql);
949
 
@@ -990,20 +1003,6 @@ elseif ( $action == 'edit_save' )
990
  $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
991
  $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
992
  $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
993
-
994
- // Deal with the fools who have left magic quotes turned on
995
- if ( ini_get('magic_quotes_gpc') )
996
- {
997
- $title = stripslashes($title);
998
- $desc = stripslashes($desc);
999
- $begin = stripslashes($begin);
1000
- $end = stripslashes($end);
1001
- $time = stripslashes($time);
1002
- $recur = stripslashes($recur);
1003
- $repeats = stripslashes($repeats);
1004
- $category = stripslashes($category);
1005
- $linky = stripslashes($linky);
1006
- }
1007
 
1008
  if ( empty($event_id) )
1009
  {
@@ -1061,6 +1060,18 @@ elseif ( $action == 'edit_save' )
1061
  if (preg_match($time_format_one,$time) || preg_match($time_format_two,$time) || $time == '')
1062
  {
1063
  $time_ok = 1;
 
 
 
 
 
 
 
 
 
 
 
 
1064
  }
1065
  else
1066
  {
@@ -1079,19 +1090,20 @@ elseif ( $action == 'edit_save' )
1079
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','calendar'); ?></p></div>
1080
  <?php
1081
  }
1082
- // The title must be at least one character in length and no more than 30 - no non-standard characters allowed
1083
- if (preg_match('/^[a-zA-Z0-9]{1}[a-zA-Z0-9[:space:]]{0,29}$/',$title))
1084
  {
1085
  $title_ok =1;
1086
  }
1087
  else
1088
  {
1089
  ?>
1090
- <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 30 characters in length and contain no punctuation. Spaces are allowed but the title must not start with one.','calendar'); ?></p></div>
1091
  <?php
1092
  }
1093
- // We run some checks on recurrance
1094
- if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y')))
 
1095
  {
1096
  $recurring_ok = 1;
1097
  }
@@ -1101,11 +1113,11 @@ elseif ( $action == 'edit_save' )
1101
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
1102
  <?php
1103
  }
1104
- if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok && $recurring_ok == 1)
1105
  {
1106
  $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
1107
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
1108
- . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "', event_author=".$current_user->ID . ", event_category=".mysql_escape_string($category).", event_link='".mysql_escape_string($linky)."' WHERE event_id='" . mysql_escape_string($event_id) . "'";
1109
 
1110
  $wpdb->get_results($sql);
1111
 
@@ -1217,9 +1229,6 @@ function edit_calendar_config()
1217
  {
1218
  global $wpdb, $initial_style;
1219
 
1220
- // We can't use this page unless Calendar is installed/upgraded
1221
- check_calendar();
1222
-
1223
  if (isset($_POST['permissions']) && isset($_POST['style']))
1224
  {
1225
  if ($_POST['permissions'] == 'subscriber') { $new_perms = 'read'; }
@@ -1301,7 +1310,7 @@ function edit_calendar_config()
1301
  {
1302
  foreach ($configs as $config)
1303
  {
1304
- $allowed_group = $config->config_value;
1305
  }
1306
  }
1307
 
@@ -1310,7 +1319,7 @@ function edit_calendar_config()
1310
  {
1311
  foreach ($configs as $config)
1312
  {
1313
- $calendar_style = $config->config_value;
1314
  }
1315
  }
1316
  $configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_author'");
@@ -1378,7 +1387,7 @@ function edit_calendar_config()
1378
  {
1379
  foreach ($configs as $config)
1380
  {
1381
- $upcoming_days = $config->config_value;
1382
  }
1383
  }
1384
  $configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_categories'");
@@ -1436,7 +1445,7 @@ function edit_calendar_config()
1436
 
1437
  <div class="wrap">
1438
  <h2><?php _e('Calendar Options','calendar'); ?></h2>
1439
- <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=calendar-config">
1440
  <div id="linkadvanceddiv" class="postbox">
1441
  <div style="float: left; width: 98%; clear: both;" class="inside">
1442
  <table cellpadding="5" cellspacing="5">
@@ -1514,9 +1523,6 @@ function manage_categories()
1514
  {
1515
  global $wpdb;
1516
 
1517
- // Calendar must be installed and upgraded before this will work
1518
- check_calendar();
1519
-
1520
  ?>
1521
  <style type="text/css">
1522
  <!--
@@ -1545,12 +1551,14 @@ function manage_categories()
1545
  .private {
1546
  color: #e64f69;
1547
  }
1548
- //-->
 
1549
  </style>
1550
  <?php
1551
  // We do some checking to see what we're doing
1552
  if (isset($_POST['mode']) && $_POST['mode'] == 'add')
1553
  {
 
1554
  $sql = "INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='".mysql_escape_string($_POST['category_name'])."', category_colour='".mysql_escape_string($_POST['category_colour'])."'";
1555
  $wpdb->get_results($sql);
1556
  echo "<div class=\"updated\"><p><strong>".__('Category added successfully','calendar')."</strong></p></div>";
@@ -1570,19 +1578,19 @@ function manage_categories()
1570
  ?>
1571
  <div class="wrap">
1572
  <h2><?php _e('Edit Category','calendar'); ?></h2>
1573
- <form name="catform" id="catform" class="wrap" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=calendar-categories">
1574
  <input type="hidden" name="mode" value="edit" />
1575
- <input type="hidden" name="category_id" value="<?php echo $cur_cat->category_id ?>" />
1576
  <div id="linkadvanceddiv" class="postbox">
1577
  <div style="float: left; width: 98%; clear: both;" class="inside">
1578
  <table cellpadding="5" cellspacing="5">
1579
  <tr>
1580
  <td><legend><?php _e('Category Name','calendar'); ?>:</legend></td>
1581
- <td><input type="text" name="category_name" class="input" size="30" maxlength="30" value="<?php echo $cur_cat->category_name ?>" /></td>
1582
  </tr>
1583
  <tr>
1584
  <td><legend><?php _e('Category Colour (Hex format)','calendar'); ?>:</legend></td>
1585
- <td><input type="text" name="category_colour" class="input" size="10" maxlength="7" value="<?php echo $cur_cat->category_colour ?>" /></td>
1586
  </tr>
1587
  </table>
1588
  </div>
@@ -1595,6 +1603,7 @@ function manage_categories()
1595
  }
1596
  else if (isset($_POST['mode']) && isset($_POST['category_id']) && isset($_POST['category_name']) && isset($_POST['category_colour']) && $_POST['mode'] == 'edit')
1597
  {
 
1598
  $sql = "UPDATE " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='".mysql_escape_string($_POST['category_name'])."', category_colour='".mysql_escape_string($_POST['category_colour'])."' WHERE category_id=".mysql_escape_string($_POST['category_id']);
1599
  $wpdb->get_results($sql);
1600
  echo "<div class=\"updated\"><p><strong>".__('Category edited successfully','calendar')."</strong></p></div>";
@@ -1606,7 +1615,7 @@ function manage_categories()
1606
 
1607
  <div class="wrap">
1608
  <h2><?php _e('Add Category','calendar'); ?></h2>
1609
- <form name="catform" id="catform" class="wrap" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=calendar-categories">
1610
  <input type="hidden" name="mode" value="add" />
1611
  <input type="hidden" name="category_id" value="">
1612
  <div id="linkadvanceddiv" class="postbox">
@@ -1652,10 +1661,10 @@ function manage_categories()
1652
  $class = ($class == 'alternate') ? '' : 'alternate';
1653
  ?>
1654
  <tr class="<?php echo $class; ?>">
1655
- <th scope="row"><?php echo $category->category_id; ?></th>
1656
- <td><?php echo $category->category_name; ?></td>
1657
- <td style="background-color:<?php echo $category->category_colour; ?>;">&nbsp;</td>
1658
- <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?page=calendar-categories&amp;mode=edit&amp;category_id=<?php echo $category->category_id;?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
1659
  <?php
1660
  if ($category->category_id == 1)
1661
  {
@@ -1664,7 +1673,7 @@ function manage_categories()
1664
  else
1665
  {
1666
  ?>
1667
- <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?page=calendar-categories&amp;mode=delete&amp;category_id=<?php echo $category->category_id;?>" class="delete" onclick="return confirm('<?php echo __('Are you sure you want to delete this category?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
1668
  <?php
1669
  }
1670
  ?>
@@ -1687,55 +1696,33 @@ function manage_categories()
1687
  }
1688
  }
1689
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1690
  // Function to return a prefix which will allow the correct
1691
  // placement of arguments into the query string.
1692
  function permalink_prefix()
1693
  {
1694
  // Get the permalink structure from WordPress
1695
- $p_link = get_permalink();
 
 
 
 
 
1696
 
1697
- // Work out what the real URL we are viewing is
1698
- $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
1699
- $protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")).$s;
1700
- $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
1701
- $real_link = $protocol.'://'.$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
1702
-
1703
- // Now use all of that to get the correctly craft the Calendar link prefix
1704
- if (strstr($p_link, '?') && $p_link == $real_link)
1705
- {
1706
- $link_part = $p_link.'&';
1707
- }
1708
- else if ($p_link == $real_link)
1709
- {
1710
- $link_part = $p_link.'?';
1711
- }
1712
- else if (strstr($real_link, '?'))
1713
- {
1714
- if (isset($_GET['month']) && isset($_GET['yr']))
1715
- {
1716
- $new_tail = split("&", $real_link);
1717
- foreach ($new_tail as $item)
1718
- {
1719
- if (!strstr($item, 'month') && !strstr($item, 'yr'))
1720
- {
1721
- $link_part .= $item.'&';
1722
- }
1723
- }
1724
- if (!strstr($link_part, '?'))
1725
- {
1726
- $new_tail = split("month", $link_part);
1727
- $link_part = $new_tail[0].'?'.$new_tail[1];
1728
- }
1729
- }
1730
- else
1731
- {
1732
- $link_part = $real_link.'&';
1733
- }
1734
- }
1735
- else
1736
- {
1737
- $link_part = $real_link.'?';
1738
- }
1739
 
1740
  return $link_part;
1741
  }
@@ -1748,13 +1735,13 @@ function next_link($cur_year,$cur_month)
1748
 
1749
  if ($cur_month == 12)
1750
  {
1751
- return '<a href="' . permalink_prefix() . 'month=jan&yr=' . $next_year . '">'.__('Next','calendar').' &raquo;</a>';
1752
  }
1753
  else
1754
  {
1755
  $next_month = $cur_month + 1;
1756
  $month = $mod_rewrite_months[$next_month];
1757
- return '<a href="' . permalink_prefix() . 'month='.$month.'&yr=' . $cur_year . '">'.__('Next','calendar').' &raquo;</a>';
1758
  }
1759
  }
1760
 
@@ -1766,13 +1753,13 @@ function prev_link($cur_year,$cur_month)
1766
 
1767
  if ($cur_month == 1)
1768
  {
1769
- return '<a href="' . permalink_prefix() . 'month=dec&yr='. $last_year .'">&laquo; '.__('Prev','calendar').'</a>';
1770
  }
1771
  else
1772
  {
1773
  $next_month = $cur_month - 1;
1774
  $month = $mod_rewrite_months[$next_month];
1775
- return '<a href="' . permalink_prefix() . 'month='.$month.'&yr=' . $cur_year . '">&laquo; '.__('Prev','calendar').'</a>';
1776
  }
1777
  }
1778
 
@@ -1780,9 +1767,6 @@ function prev_link($cur_year,$cur_month)
1780
  function upcoming_events()
1781
  {
1782
  global $wpdb;
1783
-
1784
- // This function cannot be called unless calendar is up to date
1785
- check_calendar();
1786
 
1787
  // Find out if we should be displaying upcoming events
1788
  $display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming'",0,0);
@@ -1795,11 +1779,11 @@ function upcoming_events()
1795
 
1796
  while ($day_count < $future_days+1)
1797
  {
1798
- list($y,$m,$d) = split("-",date("Y-m-d",mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))));
1799
- $events = grab_events($y,$m,$d);
1800
  usort($events, "time_cmp");
1801
  if (count($events) != 0) {
1802
- $output .= '<li>'.date(get_option('date_format'),mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))).'<ul>';
1803
  }
1804
  foreach($events as $event)
1805
  {
@@ -1807,9 +1791,9 @@ function upcoming_events()
1807
  $time_string = ' '.__('all day','calendar');
1808
  }
1809
  else {
1810
- $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime($event->event_time));
1811
  }
1812
- $output .= '<li>'.draw_widget_event($event).$time_string.'</li>';
1813
  }
1814
  if (count($events) != 0) {
1815
  $output .= '</ul></li>';
@@ -1819,9 +1803,9 @@ function upcoming_events()
1819
 
1820
  if ($output != '')
1821
  {
1822
- $visual = '<li class="upcoming-events"><h2>'.__('Upcoming Events','calendar').'</h2><ul>';
1823
  $visual .= $output;
1824
- $visual .= '</ul></li>';
1825
  return $visual;
1826
  }
1827
  }
@@ -1832,16 +1816,13 @@ function todays_events()
1832
  {
1833
  global $wpdb;
1834
 
1835
- // This function cannot be called unless calendar is up to date
1836
- check_calendar();
1837
-
1838
  // Find out if we should be displaying todays events
1839
  $display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_todays'",0,0);
1840
 
1841
  if ($display == 'true')
1842
  {
1843
- $output = '<li class="todays-events"><h2>'.__('Today\'s Events','calendar').'</h2><ul>';
1844
- $events = grab_events(date("Y"),date("m"),date("d"));
1845
  usort($events, "time_cmp");
1846
  foreach($events as $event)
1847
  {
@@ -1849,11 +1830,11 @@ function todays_events()
1849
  $time_string = ' '.__('all day','calendar');
1850
  }
1851
  else {
1852
- $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime($event->event_time));
1853
  }
1854
- $output .= '<li>'.draw_widget_event($event).$time_string.'</li>';
1855
  }
1856
- $output .= '</ul></li>';
1857
  if (count($events) != 0)
1858
  {
1859
  return $output;
@@ -1879,94 +1860,11 @@ function draw_events($events)
1879
  // Now process the events
1880
  foreach($events as $event)
1881
  {
1882
- $output .= draw_event($event);
1883
  }
1884
  return $output;
1885
  }
1886
 
1887
- // Widget todays events
1888
- function todays_events_widget() {
1889
- global $wpdb;
1890
-
1891
- // This function cannot be called unless calendar is up to date
1892
- check_calendar();
1893
-
1894
- // Find out if we should be displaying todays events
1895
- $display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_todays'",0,0);
1896
-
1897
- if ($display == 'true')
1898
- {
1899
- $output = '<ul>';
1900
- $events = grab_events(date("Y"),date("m"),date("d"));
1901
- usort($events, "time_cmp");
1902
- foreach($events as $event)
1903
- {
1904
- if ($event->event_time == '00:00:00') {
1905
- $time_string = ' '.__('all day','calendar');
1906
- }
1907
- else {
1908
- $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime($event->event_time));
1909
- }
1910
- $output .= '<li>'.draw_widget_event($event).$time_string.'</li>';
1911
- }
1912
- $output .= '</ul>';
1913
- if (count($events) != 0)
1914
- {
1915
- return $output;
1916
- }
1917
- }
1918
- }
1919
-
1920
- // Widget upcoming events
1921
- function upcoming_events_widget() {
1922
- global $wpdb;
1923
-
1924
- // This function cannot be called unless calendar is up to date
1925
- check_calendar();
1926
-
1927
- // Find out if we should be displaying upcoming events
1928
- $display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming'",0,0);
1929
-
1930
- if ($display == 'true')
1931
- {
1932
- // Get number of days we should go into the future
1933
- $future_days = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming_days'",0,0);
1934
- $day_count = 1;
1935
-
1936
- while ($day_count < $future_days+1)
1937
- {
1938
- list($y,$m,$d) = split("-",date("Y-m-d",mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))));
1939
- $events = grab_events($y,$m,$d);
1940
- usort($events, "time_cmp");
1941
- if (count($events) != 0) {
1942
- $output .= '<li>'.date(get_option('date_format'),mktime($day_count*24,0,0,date("m"),date("d"),date("Y"))).'<ul>';
1943
- }
1944
- foreach($events as $event)
1945
- {
1946
- if ($event->event_time == '00:00:00') {
1947
- $time_string = ' '.__('all day','calendar');
1948
- }
1949
- else {
1950
- $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime($event->event_time));
1951
- }
1952
- $output .= '<li>'.draw_widget_event($event).$time_string.'</li>';
1953
- }
1954
- if (count($events) != 0) {
1955
- $output .= '</ul></li>';
1956
- }
1957
- $day_count = $day_count+1;
1958
- }
1959
-
1960
- if ($output != '')
1961
- {
1962
- $visual = '<ul>';
1963
- $visual .= $output;
1964
- $visual .= '</ul>';
1965
- return $visual;
1966
- }
1967
- }
1968
- }
1969
-
1970
  // The widget to show todays events in the sidebar
1971
  function widget_init_calendar_today() {
1972
  // Check for required functions
@@ -1977,7 +1875,7 @@ function widget_init_calendar_today() {
1977
  extract($args);
1978
  $the_title = get_option('calendar_today_widget_title');
1979
  $widget_title = empty($the_title) ? __('Today\'s Events','calendar') : $the_title;
1980
- $the_events = todays_events_widget();
1981
  if ($the_events != '') {
1982
  echo $before_widget;
1983
  echo $before_title . $widget_title . $after_title;
@@ -2013,7 +1911,7 @@ function widget_init_calendar_upcoming() {
2013
  extract($args);
2014
  $the_title = get_option('calendar_upcoming_widget_title');
2015
  $widget_title = empty($the_title) ? __('Upcoming Events','calendar') : $the_title;
2016
- $the_events = upcoming_events_widget();
2017
  if ($the_events != '') {
2018
  echo $before_widget;
2019
  echo $before_title . $widget_title . $after_title;
@@ -2045,9 +1943,6 @@ function draw_event($event)
2045
  {
2046
  global $wpdb;
2047
 
2048
- // Calendar must be updated to run this function
2049
- check_calendar();
2050
-
2051
  // Before we do anything we want to know if we
2052
  // should display the author and/or show categories.
2053
  // We check for this later
@@ -2056,81 +1951,38 @@ function draw_event($event)
2056
 
2057
  if ($show_cat == 'true')
2058
  {
2059
- $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
2060
  $cat_details = $wpdb->get_row($sql);
2061
- $style = "background-color:".$cat_details->category_colour.";";
2062
  }
2063
 
2064
- $header_details .= '<div class="event-title">'.$event->event_title.'</div><div class="event-title-break"></div>';
 
2065
  if ($event->event_time != "00:00:00")
2066
  {
2067
- $header_details .= '<strong>'.__('Time','calendar').':</strong> ' . date(get_option('time_format'), strtotime($event->event_time)) . '<br />';
2068
  }
2069
  if ($display_author == 'true')
2070
  {
2071
- $e = get_userdata($event->event_author);
2072
  $header_details .= '<strong>'.__('Posted by', 'calendar').':</strong> '.$e->display_name.'<br />';
2073
  }
2074
  if ($display_author == 'true' || $event->event_time != "00:00:00")
2075
  {
2076
- $header_details .= '<div class="event-content-break"></div>';
2077
  }
2078
- if ($event->event_link != '') { $linky = $event->event_link; }
2079
  else { $linky = '#'; }
2080
 
2081
- $details = '<br />
2082
- * <span class="calnk" nowrap="nowrap"><a href="'.$linky.'" style="'.$style.'">' . $event->event_title . '<span style="'.$style.'">' . $header_details . '' . $event->event_desc . '</span></a></span>';
2083
-
2084
- return $details;
2085
- }
2086
-
2087
- // Draw an event but customise the HTML for use in the widget
2088
- function draw_widget_event($event)
2089
- {
2090
- global $wpdb;
2091
-
2092
- // Calendar must be updated to run this function
2093
- check_calendar();
2094
-
2095
- // Before we do anything we want to know if we
2096
- // should display the author and/or show categories.
2097
- // We check for this later
2098
- $display_author = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_author'",0,0);
2099
- $show_cat = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='enable_categories'",0,0);
2100
-
2101
- if ($show_cat == 'true')
2102
- {
2103
- $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".$event->event_category;
2104
- $cat_details = $wpdb->get_row($sql);
2105
- $style = "background-color:".$cat_details->category_colour.";";
2106
- }
2107
-
2108
- $header_details .= '<div class="event-title">'.$event->event_title.'</div><div class="event-title-break"></div>';
2109
- if ($event->event_time != "00:00:00")
2110
- {
2111
- $header_details .= '<strong>'.__('Time','calendar').':</strong> ' . date(get_option('time_format'), strtotime($event->event_time)) . '<br />';
2112
- }
2113
- if ($display_author == 'true')
2114
- {
2115
- $e = get_userdata($event->event_author);
2116
- $header_details .= '<strong>'.__('Posted by','calendar').':</strong> '.$e->display_name.'<br />';
2117
- }
2118
- if ($display_author == 'true' || $event->event_time != "00:00:00")
2119
- {
2120
- $header_details .= '<div class="event-content-break"></div>';
2121
- }
2122
- if ($event->event_link != '') { $linky = $event->event_link; }
2123
- else { $linky = '#'; }
2124
-
2125
- $details = '<span class="calnk" nowrap="nowrap"><a href="'.$linky.'">' . $event->event_title . '<span style="'.$style.'">' . $header_details . '' . $event->event_desc . '</span></a></span>';
2126
 
2127
  return $details;
2128
  }
2129
 
2130
  // Grab all events for the requested date from calendar
2131
- function grab_events($y,$m,$d)
2132
  {
2133
- global $wpdb;
2134
 
2135
  $arr_events = array();
2136
 
@@ -2158,8 +2010,11 @@ function grab_events($y,$m,$d)
2158
  */
2159
 
2160
 
2161
- // Deal with forever recurring year events
2162
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0 ORDER BY event_id");
 
 
 
2163
 
2164
  if (!empty($events))
2165
  {
@@ -2191,47 +2046,18 @@ function grab_events($y,$m,$d)
2191
  }
2192
  }
2193
  }
2194
-
2195
- // Now the ones that happen a finite number of times
2196
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (EXTRACT(YEAR FROM '$date')-EXTRACT(YEAR FROM event_begin)) <= event_repeats ORDER BY event_id");
2197
- if (!empty($events))
2198
- {
2199
- foreach($events as $event)
2200
- {
2201
- // This is going to get complex so lets setup what we would place in for
2202
- // an event so we can drop it in with ease
2203
-
2204
- // Technically we don't care about the years, but we need to find out if the
2205
- // event spans the turn of a year so we can deal with it appropriately.
2206
- $year_begin = date('Y',strtotime($event->event_begin));
2207
- $year_end = date('Y',strtotime($event->event_end));
2208
-
2209
- if ($year_begin == $year_end)
2210
- {
2211
- if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) &&
2212
- date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
2213
- {
2214
- array_push($arr_events, $event);
2215
- }
2216
- }
2217
- else if ($year_begin < $year_end)
2218
- {
2219
- if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) ||
2220
- date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
2221
- {
2222
- array_push($arr_events, $event);
2223
- }
2224
- }
2225
- }
2226
- }
2227
 
2228
  /*
2229
  The monthly code - just as easy because as long as the day of the month is correct, then we
2230
  show the event
2231
  */
2232
 
2233
- // The monthly events that never stop recurring
2234
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0 ORDER BY event_id");
 
 
 
2235
  if (!empty($events))
2236
  {
2237
  foreach($events as $event)
@@ -2244,7 +2070,7 @@ function grab_events($y,$m,$d)
2244
  $month_begin = date('m',strtotime($event->event_begin));
2245
  $month_end = date('m',strtotime($event->event_end));
2246
 
2247
- if ($month_begin == $month_end)
2248
  {
2249
  if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
2250
  date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
@@ -2252,7 +2078,7 @@ function grab_events($y,$m,$d)
2252
  array_push($arr_events, $event);
2253
  }
2254
  }
2255
- else if ($month_begin < $month_end)
2256
  {
2257
  if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
2258
  date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
@@ -2264,38 +2090,72 @@ function grab_events($y,$m,$d)
2264
  }
2265
 
2266
 
2267
- // Now the ones that happen a finite number of times
2268
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM event_begin))) <= event_repeats ORDER BY event_id");
2269
- if (!empty($events))
2270
- {
2271
- foreach($events as $event)
2272
- {
2273
- // This is going to get complex so lets setup what we would place in for
2274
- // an event so we can drop it in with ease
2275
-
2276
- // Technically we don't care about the years or months, but we need to find out if the
2277
- // event spans the turn of a year or month so we can deal with it appropriately.
2278
- $month_begin = date('m',strtotime($event->event_begin));
2279
- $month_end = date('m',strtotime($event->event_end));
2280
 
2281
- if ($month_begin == $month_end)
2282
- {
2283
- if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
2284
- date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
2285
- {
2286
- array_push($arr_events, $event);
2287
- }
2288
- }
2289
- else if ($month_begin < $month_end)
2290
- {
2291
- if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
2292
- date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
2293
- {
2294
- array_push($arr_events, $event);
2295
- }
2296
- }
2297
- }
2298
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2299
 
2300
 
2301
  /*
@@ -2305,8 +2165,11 @@ function grab_events($y,$m,$d)
2305
  until the number is exhausted. If the date we arrive at is in the future, display the event.
2306
  */
2307
 
2308
- // The weekly events that never stop recurring
2309
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats = 0 ORDER BY event_id");
 
 
 
2310
  if (!empty($events))
2311
  {
2312
  foreach($events as $event)
@@ -2347,63 +2210,51 @@ function grab_events($y,$m,$d)
2347
 
2348
  }
2349
  }
2350
-
2351
- // The weekly events that have a limit on how many times they occur
2352
- $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE 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");
2353
- if (!empty($events))
2354
- {
2355
- foreach($events as $event)
2356
- {
2357
- // This is going to get complex so lets setup what we would place in for
2358
- // an event so we can drop it in with ease
2359
-
2360
- // Now we are going to check to see what day the original event
2361
- // fell on and see if the current date is both after it and on
2362
- // the correct day. If it is, display the event!
2363
- $day_start_event = date('D',strtotime($event->event_begin));
2364
- $day_end_event = date('D',strtotime($event->event_end));
2365
- $current_day = date('D',strtotime($date));
2366
-
2367
- $plan = array();
2368
- $plan['Mon'] = 1;
2369
- $plan['Tue'] = 2;
2370
- $plan['Wed'] = 3;
2371
- $plan['Thu'] = 4;
2372
- $plan['Fri'] = 5;
2373
- $plan['Sat'] = 6;
2374
- $plan['Sun'] = 7;
2375
-
2376
- if ($plan[$day_start_event] > $plan[$day_end_event])
2377
- {
2378
- if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
2379
- {
2380
- array_push($arr_events, $event);
2381
- }
2382
- }
2383
- else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event]))
2384
- {
2385
- if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event]))
2386
- {
2387
- array_push($arr_events, $event);
2388
- }
2389
- }
2390
-
2391
- }
2392
- }
2393
 
2394
  return $arr_events;
2395
  }
2396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2397
 
2398
  // Actually do the printing of the calendar
2399
  // Compared to searching for and displaying events
2400
  // this bit is really rather easy!
2401
  function calendar()
2402
  {
2403
- global $wpdb;
2404
 
2405
- // First things first, make sure calendar is up to date
2406
- check_calendar();
2407
 
2408
  // Deal with the week not starting on a monday
2409
  if (get_option('start_of_week') == 0)
@@ -2422,13 +2273,13 @@ function calendar()
2422
  // If we don't pass arguments we want a calendar that is relevant to today
2423
  if (empty($_GET['month']) || empty($_GET['yr']))
2424
  {
2425
- $c_year = date("Y");
2426
- $c_month = date("m");
2427
- $c_day = date("d");
2428
  }
2429
 
2430
  // Years get funny if we exceed 3000, so we use this check
2431
- if ($_GET['yr'] <= 3000 && $_GET['yr'] >= 0)
2432
  {
2433
  // This is just plain nasty and all because of permalinks
2434
  // which are no longer used, this will be cleaned up soon
@@ -2451,22 +2302,22 @@ function calendar()
2451
  else if ($_GET['month'] == 'nov') { $t_month = 11; }
2452
  else if ($_GET['month'] == 'dec') { $t_month = 12; }
2453
  $c_month = $t_month;
2454
- $c_day = date("d");
2455
  }
2456
  // No valid month causes the calendar to default to today
2457
  else
2458
  {
2459
- $c_year = date("Y");
2460
- $c_month = date("m");
2461
- $c_day = date("d");
2462
  }
2463
  }
2464
  // No valid year causes the calendar to default to today
2465
  else
2466
  {
2467
- $c_year = date("Y");
2468
- $c_month = date("m");
2469
- $c_day = date("d");
2470
  }
2471
 
2472
  // Fix the days of the week if week start is not on a monday
@@ -2497,7 +2348,7 @@ function calendar()
2497
  {
2498
  $calendar_body .= '<tr>
2499
  <td colspan="7" class="calendar-date-switcher">
2500
- <form method="GET" action="'.$_SERVER['REQUEST_URI'].'">
2501
  ';
2502
  $qsa = array();
2503
  parse_str($_SERVER['QUERY_STRING'],$qsa);
@@ -2505,61 +2356,31 @@ function calendar()
2505
  {
2506
  if ($name != 'month' && $name != 'yr')
2507
  {
2508
- $calendar_body .= '<input type="hidden" name="'.$name.'" value="'.$argument.'" />
2509
  ';
2510
  }
2511
  }
2512
- function month_comparison($month)
2513
- {
2514
- $current_month = strtolower(date("M", time()));
2515
- if (isset($_GET['yr']) && isset($_GET['month']))
2516
- {
2517
- if ($month == $_GET['month'])
2518
- {
2519
- return ' selected="selected"';
2520
- }
2521
- }
2522
- elseif ($month == $current_month)
2523
- {
2524
- return ' selected="selected"';
2525
- }
2526
- }
2527
  // We build the months in the switcher
2528
  $calendar_body .= '
2529
  '.__('Month','calendar').': <select name="month" style="width:100px;">
2530
- <option value="jan"'.month_comparison('jan').'>'.__('January','calendar').'</option>
2531
- <option value="feb"'.month_comparison('feb').'>'.__('February','calendar').'</option>
2532
- <option value="mar"'.month_comparison('mar').'>'.__('March','calendar').'</option>
2533
- <option value="apr"'.month_comparison('apr').'>'.__('April','calendar').'</option>
2534
- <option value="may"'.month_comparison('may').'>'.__('May','calendar').'</option>
2535
- <option value="jun"'.month_comparison('jun').'>'.__('June','calendar').'</option>
2536
- <option value="jul"'.month_comparison('jul').'>'.__('July','calendar').'</option>
2537
- <option value="aug"'.month_comparison('aug').'>'.__('August','calendar').'</option>
2538
- <option value="sept"'.month_comparison('sept').'>'.__('September','calendar').'</option>
2539
- <option value="oct"'.month_comparison('oct').'>'.__('October','calendar').'</option>
2540
- <option value="nov"'.month_comparison('nov').'>'.__('November','calendar').'</option>
2541
- <option value="dec"'.month_comparison('dec').'>'.__('December','calendar').'</option>
2542
  </select>
2543
  '.__('Year','calendar').': <select name="yr" style="width:60px;">
2544
  ';
2545
 
2546
- // The year builder is string mania. If you can make sense of this,
2547
- // you know your PHP!
2548
- function year_comparison($year)
2549
- {
2550
- $current_year = strtolower(date("Y", time()));
2551
- if (isset($_GET['yr']) && isset($_GET['month']))
2552
- {
2553
- if ($year == $_GET['yr'])
2554
- {
2555
- return ' selected="selected"';
2556
- }
2557
- }
2558
- else if ($year == $current_year)
2559
- {
2560
- return ' selected="selected"';
2561
- }
2562
- }
2563
 
2564
  $past = 30;
2565
  $future = 30;
@@ -2567,27 +2388,27 @@ function calendar()
2567
  while ($past > 0)
2568
  {
2569
  $p .= ' <option value="';
2570
- $p .= date("Y",time())-$past;
2571
- $p .= '"'.year_comparison(date("Y",time())-$past).'>';
2572
- $p .= date("Y",time())-$past.'</option>
2573
  ';
2574
  $past = $past - 1;
2575
  }
2576
  while ($fut < $future)
2577
  {
2578
  $f .= ' <option value="';
2579
- $f .= date("Y",time())+$fut;
2580
- $f .= '"'.year_comparison(date("Y",time())+$fut).'>';
2581
- $f .= date("Y",time())+$fut.'</option>
2582
  ';
2583
  $fut = $fut + 1;
2584
  }
2585
  $calendar_body .= $p;
2586
- $calendar_body .= ' <option value="'.date("Y",time()).'"'.year_comparison(date("Y",time())).'>'.date("Y",time()).'</option>
2587
  ';
2588
  $calendar_body .= $f;
2589
  $calendar_body .= '</select>
2590
- <input type="submit" value="Go" />
2591
  </form>
2592
  </td>
2593
  </tr>
@@ -2649,24 +2470,24 @@ function calendar()
2649
  if (get_option('start_of_week') == 0)
2650
  {
2651
  // This bit of code is for styles believe it or not.
2652
- $grabbed_events = grab_events($c_year,$c_month,$i);
2653
  $no_events_class = '';
2654
  if (!count($grabbed_events))
2655
  {
2656
  $no_events_class = ' no-events';
2657
  }
2658
- $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd")?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<7&&$ii>1?'':'class="weekend"').'>'.$i++.'</span><span class="event">' . draw_events($grabbed_events) . '</span></td>
2659
  ';
2660
  }
2661
  else
2662
  {
2663
- $grabbed_events = grab_events($c_year,$c_month,$i);
2664
  $no_events_class = '';
2665
  if (!count($grabbed_events))
2666
  {
2667
  $no_events_class = ' no-events';
2668
  }
2669
- $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd")?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<6?'':'class="weekend"').'>'.$i++.'</span><span class="event">' . draw_events($grabbed_events) . '</span></td>
2670
  ';
2671
  }
2672
  }
@@ -2700,8 +2521,8 @@ function calendar()
2700
  $calendar_body .= '</table>
2701
  ';
2702
 
2703
- // A little link to yours truely. See the README if you wish to remove this
2704
- $calendar_body .= '<div class="kjo-link" style="visibility:visible;display:block;"><p>'.__('Calendar developed and supported by ', 'calendar').'<a href="http://www.kieranoshea.com">Kieran O\'Shea</a></p></div>
2705
  ';
2706
 
2707
  // Phew! After that bit of string building, spit it all out.
5
  Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
6
  Author: Kieran O'Shea
7
  Author URI: http://www.kieranoshea.com
8
+ Version: 1.2.3
9
  */
10
 
11
  /* Copyright 2008 Kieran O'Shea (email : kieran@kieranoshea.com)
34
  define('WP_CALENDAR_CONFIG_TABLE', $table_prefix . 'calendar_config');
35
  define('WP_CALENDAR_CATEGORIES_TABLE', $table_prefix . 'calendar_categories');
36
 
37
+ // Check ensure calendar is installed and install it if not - required for
38
+ // the successful operation of most functions called from this point on
39
+ check_calendar();
40
+
41
  // Create a master category for Calendar and its sub-pages
42
  add_action('admin_menu', 'calendar_menu');
43
 
44
  // Enable the ability for the calendar to be loaded from pages
45
  add_filter('the_content','calendar_insert');
46
 
47
+ // Enable the ability for the lists to be loaded from pages
48
+ add_filter('the_content','upcoming_insert');
49
+ add_filter('the_content','todays_insert');
50
+
51
  // Add the function that puts style information in the header
52
  add_action('wp_head', 'calendar_wp_head');
53
 
65
  {
66
  global $wpdb;
67
 
 
 
 
68
  // Do the query
69
+ $wpdb->get_results("UPDATE ".WP_CALENDAR_TABLE." SET event_author=".$wpdb->get_var("SELECT MIN(ID) FROM ".$wpdb->prefix."users",0,0)." WHERE event_author=".mysql_escape_string($id));
70
+ }
71
+
72
+ // Function to provide time with WordPress offset, localy replaces time()
73
+ function ctwo()
74
+ {
75
+ return (time()+(3600*(get_option('gmt_offset'))));
76
  }
77
 
78
  // Function to add the calendar style into the header
80
  {
81
  global $wpdb;
82
 
83
+ $style = $wpdb->get_var("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='calendar_style'");
84
+ if ($style != '')
 
 
 
85
  {
 
 
86
  echo '<style type="text/css">
 
87
  ';
88
+ echo stripslashes($style).'
89
  ';
90
+ echo '</style>
 
91
  ';
 
92
  }
93
  }
94
 
97
  {
98
  global $wpdb;
99
 
 
 
 
100
  // Set admin as the only one who can use Calendar for security
101
  $allowed_group = 'manage_options';
102
 
146
  return $content;
147
  }
148
 
149
+ // Functions to allow the widgets to be inserted into posts and pages
150
+ function upcoming_insert($content)
151
+ {
152
+ if (preg_match('{UPCOMING_EVENTS}',$content))
153
+ {
154
+ $cal_output = '<span class="page-upcoming-events">'.upcoming_events().'</span>';
155
+ $content = str_replace('{UPCOMING_EVENTS}',$cal_output,$content);
156
+ }
157
+ return $content;
158
+ }
159
+ function todays_insert($content)
160
+ {
161
+ if (preg_match('{TODAYS_EVENTS}',$content))
162
+ {
163
+ $cal_output = '<span class="page-todays-events">'.todays_events().'</span>';
164
+ $content = str_replace('{TODAYS_EVENTS}',$cal_output,$content);
165
+ }
166
+ return $content;
167
+ }
168
+
169
  // Function to check what version of Calendar is installed and install if needed
170
  function check_calendar()
171
  {
207
  padding:5px;
208
  width:150px;
209
  z-index:100;
210
+ line-height:1.2em;
211
  }
212
  .calendar-table {
213
  border:none;
282
  font-size:0.75em;
283
  text-align:center;
284
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  .calendar-date-switcher {
286
  height:25px;
287
  text-align:center;
303
  margin-top:10px;
304
  padding:5px;
305
  border:1px solid #D6DED5;
306
+ }
307
+ .calnk a:hover span span.event-title {
308
+ padding:0;
309
+ text-align:center;
310
+ font-weight:bold;
311
+ font-size:1.2em;
312
+ }
313
+ .calnk a:hover span span.event-title-break {
314
+ width:96%;
315
+ text-align:center;
316
+ height:1px;
317
+ margin-top:5px;
318
+ margin-right:2%;
319
+ padding:0;
320
+ background-color:#000000;
321
+ }
322
+ .calnk a:hover span span.event-content-break {
323
+ width:96%;
324
+ text-align:center;
325
+ height:1px;
326
+ margin-top:5px;
327
+ margin-right:2%;
328
+ padding:0;
329
+ background-color:#000000;
330
+ }
331
+ .page-upcoming-events {
332
+ font-size:80%;
333
+ }
334
+ .page-todays-events {
335
+ font-size:80%;
336
  }";
337
 
338
 
346
  $wp_calendar_config_version_number_exists = false;
347
 
348
  // Determine the calendar version
349
+ $tables = $wpdb->get_results("show tables");
350
  foreach ( $tables as $table )
351
  {
352
  foreach ( $table as $value )
397
  event_time TIME ,
398
  event_recur CHAR(1) ,
399
  event_repeats INT(3) ,
400
+ event_author BIGINT(20) UNSIGNED ,
401
+ event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1 ,
402
+ event_link TEXT DEFAULT '' ,
403
  PRIMARY KEY (event_id)
404
  )";
405
  $wpdb->get_results($sql);
423
  $wpdb->get_results($sql);
424
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming_days', config_value=7";
425
  $wpdb->get_results($sql);
 
426
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_version', config_value='1.2'";
427
  $wpdb->get_results($sql);
428
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
429
  $wpdb->get_results($sql);
 
 
 
 
 
 
 
 
430
  $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
431
  category_id INT(11) NOT NULL AUTO_INCREMENT,
432
  category_name VARCHAR(30) NOT NULL ,
465
  $wpdb->get_results($sql);
466
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='display_upcoming_days', config_value=7";
467
  $wpdb->get_results($sql);
 
468
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='calendar_version', config_value='1.2'";
469
  $wpdb->get_results($sql);
470
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
471
  $wpdb->get_results($sql);
472
+ $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
 
 
 
 
473
  $wpdb->get_results($sql);
474
+ $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT DEFAULT ''";
475
  $wpdb->get_results($sql);
476
  $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
477
  category_id INT(11) NOT NULL AUTO_INCREMENT,
489
  $wpdb->get_results($sql);
490
  $sql = "INSERT INTO ".WP_CALENDAR_CONFIG_TABLE." SET config_item='enable_categories', config_value='false'";
491
  $wpdb->get_results($sql);
492
+ $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
 
 
 
 
493
  $wpdb->get_results($sql);
494
+ $sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT DEFAULT ''";
495
  $wpdb->get_results($sql);
496
  $sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
497
  category_id INT(11) NOT NULL AUTO_INCREMENT,
522
  <tr>
523
  <th class="manage-column" scope="col"><?php _e('ID','calendar') ?></th>
524
  <th class="manage-column" scope="col"><?php _e('Title','calendar') ?></th>
 
525
  <th class="manage-column" scope="col"><?php _e('Start Date','calendar') ?></th>
526
  <th class="manage-column" scope="col"><?php _e('End Date','calendar') ?></th>
527
+ <th class="manage-column" scope="col"><?php _e('Time','calendar') ?></th>
528
  <th class="manage-column" scope="col"><?php _e('Recurs','calendar') ?></th>
529
  <th class="manage-column" scope="col"><?php _e('Repeats','calendar') ?></th>
530
  <th class="manage-column" scope="col"><?php _e('Author','calendar') ?></th>
540
  $class = ($class == 'alternate') ? '' : 'alternate';
541
  ?>
542
  <tr class="<?php echo $class; ?>">
543
+ <th scope="row"><?php echo stripslashes($event->event_id); ?></th>
544
+ <td><?php echo stripslashes($event->event_title); ?></td>
545
+ <td><?php echo stripslashes($event->event_begin); ?></td>
546
+ <td><?php echo stripslashes($event->event_end); ?></td>
547
+ <td><?php if ($event->event_time == '00:00:00') { echo __('N/A','calendar'); } else { echo stripslashes($event->event_time); } ?></td>
548
  <td>
549
  <?php
550
  // Interpret the DB values into something human readable
551
  if ($event->event_recur == 'S') { echo __('Never','calendar'); }
552
  else if ($event->event_recur == 'W') { echo __('Weekly','calendar'); }
553
+ else if ($event->event_recur == 'M') { echo __('Monthly (date)','calendar'); }
554
+ else if ($event->event_recur == 'U') { echo __('Monthly (day)','calendar'); }
555
  else if ($event->event_recur == 'Y') { echo __('Yearly','calendar'); }
556
  ?>
557
  </td>
560
  // Interpret the DB values into something human readable
561
  if ($event->event_recur == 'S') { echo __('N/A','calendar'); }
562
  else if ($event->event_repeats == 0) { echo __('Forever','calendar'); }
563
+ else if ($event->event_repeats > 0) { echo stripslashes($event->event_repeats).' '.__('Times','calendar'); }
564
  ?>
565
  </td>
566
  <td><?php $e = get_userdata($event->event_author); echo $e->display_name; ?></td>
567
  <?php
568
+ $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".mysql_escape_string($event->event_category);
569
  $this_cat = $wpdb->get_row($sql);
570
  ?>
571
+ <td style="background-color:<?php echo stripslashes($this_cat->category_colour);?>;"><?php echo stripslashes($this_cat->category_name); ?></td>
572
  <?php unset($this_cat); ?>
573
+ <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar&amp;action=edit&amp;event_id=<?php echo stripslashes($event->event_id);?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
574
+ <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar&amp;action=delete&amp;event_id=<?php echo stripslashes($event->event_id);?>" class="delete" onclick="return confirm('<?php _e('Are you sure you want to delete this event?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
575
  </tr>
576
  <?php
577
  }
625
 
626
  ?>
627
  <div id="pop_up_cal" style="position:absolute;margin-left:150px;visibility:hidden;background-color:white;layer-background-color:white;z-index:1;"></div>
628
+ <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar">
629
  <input type="hidden" name="action" value="<?php echo $mode; ?>">
630
+ <input type="hidden" name="event_id" value="<?php echo stripslashes($event_id); ?>">
631
 
632
  <div id="linkadvanceddiv" class="postbox">
633
  <div style="float: left; width: 98%; clear: both;" class="inside">
635
  <tr>
636
  <td><legend><?php _e('Event Title','calendar'); ?></legend></td>
637
  <td><input type="text" name="event_title" class="input" size="40" maxlength="30"
638
+ value="<?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_title)); ?>" /></td>
639
  </tr>
640
  <tr>
641
  <td style="vertical-align:top;"><legend><?php _e('Event Description','calendar'); ?></legend></td>
642
+ <td><textarea name="event_desc" class="input" rows="5" cols="50"><?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_desc)); ?></textarea></td>
643
  </tr>
644
  <tr>
645
  <td><legend><?php _e('Event Category','calendar'); ?></legend></td>
650
  $cats = $wpdb->get_results($sql);
651
  foreach($cats as $cat)
652
  {
653
+ echo '<option value="'.stripslashes($cat->category_id).'"';
654
  if (!empty($data))
655
  {
656
  if ($data->event_category == $cat->category_id)
658
  echo 'selected="selected"';
659
  }
660
  }
661
+ echo '>'.stripslashes($cat->category_name).'</option>
662
  ';
663
  }
664
  ?>
667
  </tr>
668
  <tr>
669
  <td><legend><?php _e('Event Link (Optional)','calendar'); ?></legend></td>
670
+ <td><input type="text" name="event_link" class="input" size="40" value="<?php if ( !empty($data) ) echo htmlspecialchars(stripslashes($data->event_link)); ?>" /></td>
671
  </tr>
672
  <tr>
673
  <td><legend><?php _e('Start Date','calendar'); ?></legend></td>
674
  <td> <script type="text/javascript">
675
  var cal_begin = new CalendarPopup('pop_up_cal');
676
+ cal_begin.setWeekStartDay(<?php echo get_option('start_of_week'); ?>);
677
  function unifydates() {
678
  document.forms['quoteform'].event_end.value = document.forms['quoteform'].event_begin.value;
679
  }
682
  value="<?php
683
  if ( !empty($data) )
684
  {
685
+ echo htmlspecialchars(stripslashes($data->event_begin));
686
  }
687
  else
688
  {
689
+ echo date("Y-m-d",ctwo());
690
  }
691
  ?>" /> <a href="#" onClick="cal_begin.select(document.forms['quoteform'].event_begin,'event_begin_anchor','yyyy-MM-dd'); return false;" name="event_begin_anchor" id="event_begin_anchor"><?php _e('Select Date','calendar'); ?></a>
692
  </td>
697
  function check_and_print() {
698
  unifydates();
699
  var cal_end = new CalendarPopup('pop_up_cal');
700
+ cal_end.setWeekStartDay(<?php echo get_option('start_of_week'); ?>);
701
  var newDate = new Date();
702
  newDate.setFullYear(document.forms['quoteform'].event_begin.value.split('-')[0],document.forms['quoteform'].event_begin.value.split('-')[1]-1,document.forms['quoteform'].event_begin.value.split('-')[2]);
703
  newDate.setDate(newDate.getDate()-1);
709
  value="<?php
710
  if ( !empty($data) )
711
  {
712
+ echo htmlspecialchars(stripslashes($data->event_end));
713
  }
714
  else
715
  {
716
+ echo date("Y-m-d",ctwo());
717
  }
718
  ?>" /> <a href="#" onClick="check_and_print(); return false;" name="event_end_anchor" id="event_end_anchor"><?php _e('Select Date','calendar'); ?></a>
719
  </td>
730
  }
731
  else
732
  {
733
+ echo date("H:i",strtotime(htmlspecialchars(stripslashes($data->event_time))));
734
  }
735
  }
736
  else
737
  {
738
+ echo date("H:i",ctwo());
739
  }
740
+ ?>" /> <?php _e('Optional, set blank if not required.','calendar'); ?> <?php _e('Current time difference from GMT is ','calendar'); echo get_option('gmt_offset'); _e(' hour(s)','calendar'); ?>
741
  </td>
742
  </tr>
743
  <tr>
768
  {
769
  $selected_y = 'selected="selected"';
770
  }
771
+ else if ($data->event_recur == "U")
772
+ {
773
+ $selected_u = 'selected="selected"';
774
+ }
775
  ?>
776
  <?php _e('Repeats for','calendar'); ?>
777
  <input type="text" name="event_repeats" class="input" size="1" value="<?php echo $repeats; ?>" />
778
  <select name="event_recur" class="input">
779
+ <option class="input" <?php echo $selected_s; ?> value="S"><?php _e('None') ?></option>
780
+ <option class="input" <?php echo $selected_w; ?> value="W"><?php _e('Weeks') ?></option>
781
+ <option class="input" <?php echo $selected_m; ?> value="M"><?php _e('Months (date)') ?></option>
782
+ <option class="input" <?php echo $selected_u; ?> value="U"><?php _e('Months (day)') ?></option>
783
+ <option class="input" <?php echo $selected_y; ?> value="Y"><?php _e('Years') ?></option>
784
  </select><br />
785
  <?php _e('Entering 0 means forever. Where the recurrance interval is left at none, the event will not reoccur.','calendar'); ?>
786
  </td>
838
  $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
839
  $event_id = !empty($_REQUEST['event_id']) ? $_REQUEST['event_id'] : '';
840
 
 
 
 
 
841
  // Deal with adding an event to the database
842
  if ( $action == 'add' )
843
  {
851
  $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
852
  $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
853
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
854
  // Perform some validation on the submitted dates - this checks for valid years and months
855
  $date_format_one = '/^([0-9]{4})-([0][1-9])-([0-3][0-9])$/';
856
  $date_format_two = '/^([0-9]{4})-([1][0-2])-([0-3][0-9])$/';
899
  if (preg_match($time_format_one,$time) || preg_match($time_format_two,$time) || $time == '')
900
  {
901
  $time_ok = 1;
902
+ if ($time == '')
903
+ {
904
+ $time_to_use = '00:00:00';
905
+ }
906
+ else if ($time == '00:00')
907
+ {
908
+ $time_to_use = '00:00:01';
909
+ }
910
+ else
911
+ {
912
+ $time_to_use = $time;
913
+ }
914
  }
915
  else
916
  {
929
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','calendar'); ?></p></div>
930
  <?php
931
  }
932
+ // The title must be at least one character in length and no more than 30
933
+ if (preg_match('/^.{1,30}$/',$title))
934
  {
935
  $title_ok =1;
936
  }
937
  else
938
  {
939
  ?>
940
+ <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 30 characters in length','calendar'); ?></p></div>
941
  <?php
942
  }
943
+ // We run some checks on recurrance
944
+ $repeats = (int)$repeats;
945
+ if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y' || $recur == 'U')))
946
  {
947
  $recurring_ok = 1;
948
  }
956
  {
957
  $sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
958
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
959
+ . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time_to_use) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "', event_author=".$current_user->ID.", event_category=".mysql_escape_string($category).", event_link='".mysql_escape_string($linky)."'";
960
 
961
  $wpdb->get_results($sql);
962
 
1003
  $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
1004
  $category = !empty($_REQUEST['event_category']) ? $_REQUEST['event_category'] : '';
1005
  $linky = !empty($_REQUEST['event_link']) ? $_REQUEST['event_link'] : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1006
 
1007
  if ( empty($event_id) )
1008
  {
1060
  if (preg_match($time_format_one,$time) || preg_match($time_format_two,$time) || $time == '')
1061
  {
1062
  $time_ok = 1;
1063
+ if ($time == '')
1064
+ {
1065
+ $time_to_use = '00:00:00';
1066
+ }
1067
+ else if ($time == '00:00')
1068
+ {
1069
+ $time_to_use = '00:00:01';
1070
+ }
1071
+ else
1072
+ {
1073
+ $time_to_use = $time;
1074
+ }
1075
  }
1076
  else
1077
  {
1090
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The URL entered must either be prefixed with http:// or be completely blank','calendar'); ?></p></div>
1091
  <?php
1092
  }
1093
+ // The title must be at least one character in length and no more than 30
1094
+ if (preg_match('/^.{1,30}$/',$title))
1095
  {
1096
  $title_ok =1;
1097
  }
1098
  else
1099
  {
1100
  ?>
1101
+ <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The event title must be between 1 and 30 characters in length','calendar'); ?></p></div>
1102
  <?php
1103
  }
1104
+ // We run some checks on recurrance
1105
+ $repeats = (int)$repeats;
1106
+ if (($repeats == 0 && $recur == 'S') || (($repeats >= 0) && ($recur == 'W' || $recur == 'M' || $recur == 'Y' || $recur == 'U')))
1107
  {
1108
  $recurring_ok = 1;
1109
  }
1113
  <div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
1114
  <?php
1115
  }
1116
+ if ($start_date_ok == 1 && $end_date_ok == 1 && $time_ok == 1 && $url_ok == 1 && $title_ok == 1 && $recurring_ok == 1)
1117
  {
1118
  $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
1119
  . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
1120
+ . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time_to_use) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "', event_author=".$current_user->ID . ", event_category=".mysql_escape_string($category).", event_link='".mysql_escape_string($linky)."' WHERE event_id='" . mysql_escape_string($event_id) . "'";
1121
 
1122
  $wpdb->get_results($sql);
1123
 
1229
  {
1230
  global $wpdb, $initial_style;
1231
 
 
 
 
1232
  if (isset($_POST['permissions']) && isset($_POST['style']))
1233
  {
1234
  if ($_POST['permissions'] == 'subscriber') { $new_perms = 'read'; }
1310
  {
1311
  foreach ($configs as $config)
1312
  {
1313
+ $allowed_group = stripslashes($config->config_value);
1314
  }
1315
  }
1316
 
1319
  {
1320
  foreach ($configs as $config)
1321
  {
1322
+ $calendar_style = stripslashes($config->config_value);
1323
  }
1324
  }
1325
  $configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_author'");
1387
  {
1388
  foreach ($configs as $config)
1389
  {
1390
+ $upcoming_days = stripslashes($config->config_value);
1391
  }
1392
  }
1393
  $configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_categories'");
1445
 
1446
  <div class="wrap">
1447
  <h2><?php _e('Calendar Options','calendar'); ?></h2>
1448
+ <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-config">
1449
  <div id="linkadvanceddiv" class="postbox">
1450
  <div style="float: left; width: 98%; clear: both;" class="inside">
1451
  <table cellpadding="5" cellspacing="5">
1523
  {
1524
  global $wpdb;
1525
 
 
 
 
1526
  ?>
1527
  <style type="text/css">
1528
  <!--
1551
  .private {
1552
  color: #e64f69;
1553
  }
1554
+ //-->
1555
+
1556
  </style>
1557
  <?php
1558
  // We do some checking to see what we're doing
1559
  if (isset($_POST['mode']) && $_POST['mode'] == 'add')
1560
  {
1561
+ // Proceed with the save
1562
  $sql = "INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='".mysql_escape_string($_POST['category_name'])."', category_colour='".mysql_escape_string($_POST['category_colour'])."'";
1563
  $wpdb->get_results($sql);
1564
  echo "<div class=\"updated\"><p><strong>".__('Category added successfully','calendar')."</strong></p></div>";
1578
  ?>
1579
  <div class="wrap">
1580
  <h2><?php _e('Edit Category','calendar'); ?></h2>
1581
+ <form name="catform" id="catform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-categories">
1582
  <input type="hidden" name="mode" value="edit" />
1583
+ <input type="hidden" name="category_id" value="<?php echo stripslashes($cur_cat->category_id) ?>" />
1584
  <div id="linkadvanceddiv" class="postbox">
1585
  <div style="float: left; width: 98%; clear: both;" class="inside">
1586
  <table cellpadding="5" cellspacing="5">
1587
  <tr>
1588
  <td><legend><?php _e('Category Name','calendar'); ?>:</legend></td>
1589
+ <td><input type="text" name="category_name" class="input" size="30" maxlength="30" value="<?php echo stripslashes($cur_cat->category_name) ?>" /></td>
1590
  </tr>
1591
  <tr>
1592
  <td><legend><?php _e('Category Colour (Hex format)','calendar'); ?>:</legend></td>
1593
+ <td><input type="text" name="category_colour" class="input" size="10" maxlength="7" value="<?php echo stripslashes($cur_cat->category_colour) ?>" /></td>
1594
  </tr>
1595
  </table>
1596
  </div>
1603
  }
1604
  else if (isset($_POST['mode']) && isset($_POST['category_id']) && isset($_POST['category_name']) && isset($_POST['category_colour']) && $_POST['mode'] == 'edit')
1605
  {
1606
+ // Proceed with the save
1607
  $sql = "UPDATE " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='".mysql_escape_string($_POST['category_name'])."', category_colour='".mysql_escape_string($_POST['category_colour'])."' WHERE category_id=".mysql_escape_string($_POST['category_id']);
1608
  $wpdb->get_results($sql);
1609
  echo "<div class=\"updated\"><p><strong>".__('Category edited successfully','calendar')."</strong></p></div>";
1615
 
1616
  <div class="wrap">
1617
  <h2><?php _e('Add Category','calendar'); ?></h2>
1618
+ <form name="catform" id="catform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-categories">
1619
  <input type="hidden" name="mode" value="add" />
1620
  <input type="hidden" name="category_id" value="">
1621
  <div id="linkadvanceddiv" class="postbox">
1661
  $class = ($class == 'alternate') ? '' : 'alternate';
1662
  ?>
1663
  <tr class="<?php echo $class; ?>">
1664
+ <th scope="row"><?php echo stripslashes($category->category_id); ?></th>
1665
+ <td><?php echo stripslashes($category->category_name); ?></td>
1666
+ <td style="background-color:<?php echo stripslashes($category->category_colour); ?>;">&nbsp;</td>
1667
+ <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar-categories&amp;mode=edit&amp;category_id=<?php echo stripslashes($category->category_id);?>" class='edit'><?php echo __('Edit','calendar'); ?></a></td>
1668
  <?php
1669
  if ($category->category_id == 1)
1670
  {
1673
  else
1674
  {
1675
  ?>
1676
+ <td><a href="<?php echo bloginfo('wpurl') ?>/wp-admin/admin.php?page=calendar-categories&amp;mode=delete&amp;category_id=<?php echo stripslashes($category->category_id);?>" class="delete" onclick="return confirm('<?php echo __('Are you sure you want to delete this category?','calendar'); ?>')"><?php echo __('Delete','calendar'); ?></a></td>
1677
  <?php
1678
  }
1679
  ?>
1696
  }
1697
  }
1698
 
1699
+ // Function to indicate the number of the day passed, eg. 1st or 2nd Sunday
1700
+ function np_of_day($date)
1701
+ {
1702
+ $instance = 0;
1703
+ $dom = date('j',strtotime($date));
1704
+ if (($dom-7) <= 0) { $instance = 1; }
1705
+ else if (($dom-7) > 0 && ($dom-7) <= 7) { $instance = 2; }
1706
+ else if (($dom-7) > 7 && ($dom-7) <= 14) { $instance = 3; }
1707
+ else if (($dom-7) > 14 && ($dom-7) <= 21) { $instance = 4; }
1708
+ else if (($dom-7) > 21 && ($dom-7) < 28) { $instance = 5; }
1709
+ return $instance;
1710
+ }
1711
+
1712
  // Function to return a prefix which will allow the correct
1713
  // placement of arguments into the query string.
1714
  function permalink_prefix()
1715
  {
1716
  // Get the permalink structure from WordPress
1717
+ if (is_home()) {
1718
+ $p_link = get_bloginfo('url');
1719
+ if ($p_link[strlen($p_link)-1] != '/') { $p_link = $p_link.'/'; }
1720
+ } else {
1721
+ $p_link = get_permalink();
1722
+ }
1723
 
1724
+ // Based on the structure, append the appropriate ending
1725
+ if (!(strstr($p_link,'?'))) { $link_part = $p_link.'?'; } else { $link_part = $p_link.'&'; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1726
 
1727
  return $link_part;
1728
  }
1735
 
1736
  if ($cur_month == 12)
1737
  {
1738
+ return '<a href="' . permalink_prefix() . 'month=jan&amp;yr=' . $next_year . '">'.__('Next','calendar').' &raquo;</a>';
1739
  }
1740
  else
1741
  {
1742
  $next_month = $cur_month + 1;
1743
  $month = $mod_rewrite_months[$next_month];
1744
+ return '<a href="' . permalink_prefix() . 'month='.$month.'&amp;yr=' . $cur_year . '">'.__('Next','calendar').' &raquo;</a>';
1745
  }
1746
  }
1747
 
1753
 
1754
  if ($cur_month == 1)
1755
  {
1756
+ return '<a href="' . permalink_prefix() . 'month=dec&amp;yr='. $last_year .'">&laquo; '.__('Prev','calendar').'</a>';
1757
  }
1758
  else
1759
  {
1760
  $next_month = $cur_month - 1;
1761
  $month = $mod_rewrite_months[$next_month];
1762
+ return '<a href="' . permalink_prefix() . 'month='.$month.'&amp;yr=' . $cur_year . '">&laquo; '.__('Prev','calendar').'</a>';
1763
  }
1764
  }
1765
 
1767
  function upcoming_events()
1768
  {
1769
  global $wpdb;
 
 
 
1770
 
1771
  // Find out if we should be displaying upcoming events
1772
  $display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming'",0,0);
1779
 
1780
  while ($day_count < $future_days+1)
1781
  {
1782
+ list($y,$m,$d) = split("-",date("Y-m-d",mktime($day_count*24,0,0,date("m",ctwo()),date("d",ctwo()),date("Y",ctwo()))));
1783
+ $events = grab_events($y,$m,$d,'upcoming');
1784
  usort($events, "time_cmp");
1785
  if (count($events) != 0) {
1786
+ $output .= '<li>'.date_i18n(get_option('date_format'),mktime($day_count*24,0,0,date("m",ctwo()),date("d",ctwo()),date("Y",ctwo()))).'<ul>';
1787
  }
1788
  foreach($events as $event)
1789
  {
1791
  $time_string = ' '.__('all day','calendar');
1792
  }
1793
  else {
1794
+ $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime(stripslashes($event->event_time)));
1795
  }
1796
+ $output .= '<li>'.draw_event($event).$time_string.'</li>';
1797
  }
1798
  if (count($events) != 0) {
1799
  $output .= '</ul></li>';
1803
 
1804
  if ($output != '')
1805
  {
1806
+ $visual = '<ul>';
1807
  $visual .= $output;
1808
+ $visual .= '</ul>';
1809
  return $visual;
1810
  }
1811
  }
1816
  {
1817
  global $wpdb;
1818
 
 
 
 
1819
  // Find out if we should be displaying todays events
1820
  $display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_todays'",0,0);
1821
 
1822
  if ($display == 'true')
1823
  {
1824
+ $output = '<ul>';
1825
+ $events = grab_events(date("Y",ctwo()),date("m",ctwo()),date("d",ctwo()),'todays');
1826
  usort($events, "time_cmp");
1827
  foreach($events as $event)
1828
  {
1830
  $time_string = ' '.__('all day','calendar');
1831
  }
1832
  else {
1833
+ $time_string = ' '.__('at','calendar').' '.date(get_option('time_format'), strtotime(stripslashes($event->event_time)));
1834
  }
1835
+ $output .= '<li>'.draw_event($event).$time_string.'</li>';
1836
  }
1837
+ $output .= '</ul>';
1838
  if (count($events) != 0)
1839
  {
1840
  return $output;
1860
  // Now process the events
1861
  foreach($events as $event)
1862
  {
1863
+ $output .= '* '.draw_event($event).'<br />';
1864
  }
1865
  return $output;
1866
  }
1867
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1868
  // The widget to show todays events in the sidebar
1869
  function widget_init_calendar_today() {
1870
  // Check for required functions
1875
  extract($args);
1876
  $the_title = get_option('calendar_today_widget_title');
1877
  $widget_title = empty($the_title) ? __('Today\'s Events','calendar') : $the_title;
1878
+ $the_events = todays_events();
1879
  if ($the_events != '') {
1880
  echo $before_widget;
1881
  echo $before_title . $widget_title . $after_title;
1911
  extract($args);
1912
  $the_title = get_option('calendar_upcoming_widget_title');
1913
  $widget_title = empty($the_title) ? __('Upcoming Events','calendar') : $the_title;
1914
+ $the_events = upcoming_events();
1915
  if ($the_events != '') {
1916
  echo $before_widget;
1917
  echo $before_title . $widget_title . $after_title;
1943
  {
1944
  global $wpdb;
1945
 
 
 
 
1946
  // Before we do anything we want to know if we
1947
  // should display the author and/or show categories.
1948
  // We check for this later
1951
 
1952
  if ($show_cat == 'true')
1953
  {
1954
+ $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".mysql_escape_string($event->event_category);
1955
  $cat_details = $wpdb->get_row($sql);
1956
+ $style = "background-color:".stripslashes($cat_details->category_colour).";";
1957
  }
1958
 
1959
+ $header_details .= '<span class="event-title">'.stripslashes($event->event_title).'</span><br />
1960
+ <span class="event-title-break"></span><br />';
1961
  if ($event->event_time != "00:00:00")
1962
  {
1963
+ $header_details .= '<strong>'.__('Time','calendar').':</strong> ' . date(get_option('time_format'), strtotime(stripslashes($event->event_time))) . '<br />';
1964
  }
1965
  if ($display_author == 'true')
1966
  {
1967
+ $e = get_userdata(stripslashes($event->event_author));
1968
  $header_details .= '<strong>'.__('Posted by', 'calendar').':</strong> '.$e->display_name.'<br />';
1969
  }
1970
  if ($display_author == 'true' || $event->event_time != "00:00:00")
1971
  {
1972
+ $header_details .= '<span class="event-content-break"></span><br />';
1973
  }
1974
+ if ($event->event_link != '') { $linky = stripslashes($event->event_link); }
1975
  else { $linky = '#'; }
1976
 
1977
+ $details = '<span class="calnk"><a href="'.$linky.'" style="'.$style.'">' . stripslashes($event->event_title) . '<span style="'.$style.'">' . $header_details . '' . stripslashes($event->event_desc) . '</span></a></span>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1978
 
1979
  return $details;
1980
  }
1981
 
1982
  // Grab all events for the requested date from calendar
1983
+ function grab_events($y,$m,$d,$typing)
1984
  {
1985
+ global $wpdb,$tod_no,$cal_no;
1986
 
1987
  $arr_events = array();
1988
 
2010
  */
2011
 
2012
 
2013
+ // Deal with forever recurring year events unioned with those that have a limit
2014
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0
2015
+ UNION ALL
2016
+ SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (EXTRACT(YEAR FROM '$date')-EXTRACT(YEAR FROM event_begin)) <= event_repeats
2017
+ ORDER BY event_id");
2018
 
2019
  if (!empty($events))
2020
  {
2046
  }
2047
  }
2048
  }
2049
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2050
 
2051
  /*
2052
  The monthly code - just as easy because as long as the day of the month is correct, then we
2053
  show the event
2054
  */
2055
 
2056
+ // The monthly events that never stop recurring unioned with those that do
2057
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0
2058
+ UNION ALL
2059
+ SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM event_begin))) <= event_repeats
2060
+ ORDER BY event_id");
2061
  if (!empty($events))
2062
  {
2063
  foreach($events as $event)
2070
  $month_begin = date('m',strtotime($event->event_begin));
2071
  $month_end = date('m',strtotime($event->event_end));
2072
 
2073
+ if (($month_begin == $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
2074
  {
2075
  if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
2076
  date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
2078
  array_push($arr_events, $event);
2079
  }
2080
  }
2081
+ else if (($month_begin < $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
2082
  {
2083
  if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
2084
  date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
2090
  }
2091
 
2092
 
2093
+ /*
2094
+ The month of Sundays code - events that repeat on every nth instance of a day
2095
+ */
 
 
 
 
 
 
 
 
 
 
2096
 
2097
+ // The month of Sundays events that never stop recurring unioned with those that do
2098
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'U' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0
2099
+ UNION ALL
2100
+ SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'U' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM event_begin))) <= event_repeats
2101
+ ORDER BY event_id");
2102
+ if (!empty($events))
2103
+ {
2104
+ foreach($events as $event) {
2105
+ // Technically we don't care about the years or months, but we need to find out if the
2106
+ // event spans the turn of a year or month so we can deal with it appropriately.
2107
+
2108
+ // In addition we need to know if the instance is the same
2109
+ $month_begin = date('m',strtotime($event->event_begin));
2110
+ $month_end = date('m',strtotime($event->event_end));
2111
+
2112
+ // We also deal with days here so we assign numeric to each day
2113
+ $day_start_event = date('D',strtotime($event->event_begin));
2114
+ $day_end_event = date('D',strtotime($event->event_end));
2115
+ $current_day = date('D',strtotime($date));
2116
+ $orig_diff = strtotime($event->event_end) - strtotime($event->event_begin);
2117
+ $cur_strto = strtotime($date);
2118
+ $plan = array();
2119
+ $plan['Mon'] = 1;
2120
+ $plan['Tue'] = 2;
2121
+ $plan['Wed'] = 3;
2122
+ $plan['Thu'] = 4;
2123
+ $plan['Fri'] = 5;
2124
+ $plan['Sat'] = 6;
2125
+ $plan['Sun'] = 7;
2126
+
2127
+ if (($month_begin == $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
2128
+ {
2129
+ if (np_of_day($event->event_begin) == np_of_day($date) && $plan[$day_start_event] == $plan[$current_day])
2130
+ {
2131
+ if ($typing == 'calendar') { $cal_no[$event->event_id] = strtotime($date); }
2132
+ else if ($typing == 'upcoming') { $tod_no[$event->event_id] = strtotime($date); }
2133
+ else if ($typing == 'todays') { $tod_no[$event->event_id] = strtotime($date); }
2134
+ }
2135
+ if ($typing == 'calendar') { $week_no[$event->event_id] = $cal_no[$event->event_id]; }
2136
+ else if ($typing == 'upcoming') { $week_no[$event->event_id] = $tod_no[$event->event_id]; }
2137
+ else if ($typing == 'todays') { $week_no[$event->event_id] = $tod_no[$event->event_id]; }
2138
+
2139
+ if ((($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
2140
+ && ((np_of_day($event->event_begin) == np_of_day($date) && $plan[$day_start_event] == $plan[$current_day] && $cur_strto-$week_no[$event->event_id] <= $orig_diff )
2141
+ || (np_of_day($event->event_begin) == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)
2142
+ || (np_of_day($event->event_begin)+1 == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)))
2143
+ {
2144
+ array_push($arr_events, $event);
2145
+ }
2146
+ }
2147
+ else if (($month_begin < $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
2148
+ {
2149
+ if ((($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
2150
+ && ((np_of_day($event->event_begin) == np_of_day($date) && $plan[$day_start_event] == $plan[$current_day] && $cur_strto-$week_no[$event->event_id] <= $orig_diff )
2151
+ || (np_of_day($event->event_begin) == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)
2152
+ || (np_of_day($event->event_begin)+1 == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)))
2153
+ {
2154
+ array_push($arr_events, $event);
2155
+ }
2156
+ }
2157
+ }
2158
+ }
2159
 
2160
 
2161
  /*
2165
  until the number is exhausted. If the date we arrive at is in the future, display the event.
2166
  */
2167
 
2168
+ // The weekly events that never stop recurring unioned with those that do
2169
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats = 0
2170
+ UNION ALL
2171
+ SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats != 0 AND (event_repeats*7) >= (TO_DAYS('$date') - TO_DAYS(event_end))
2172
+ ORDER BY event_id");
2173
  if (!empty($events))
2174
  {
2175
  foreach($events as $event)
2210
 
2211
  }
2212
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2213
 
2214
  return $arr_events;
2215
  }
2216
 
2217
+ // Setup comparison functions for building the calendar later
2218
+ function calendar_month_comparison($month)
2219
+ {
2220
+ $current_month = strtolower(date("M", ctwo()));
2221
+ if (isset($_GET['yr']) && isset($_GET['month']))
2222
+ {
2223
+ if ($month == $_GET['month'])
2224
+ {
2225
+ return ' selected="selected"';
2226
+ }
2227
+ }
2228
+ elseif ($month == $current_month)
2229
+ {
2230
+ return ' selected="selected"';
2231
+ }
2232
+ }
2233
+ function calendar_year_comparison($year)
2234
+ {
2235
+ $current_year = strtolower(date("Y", ctwo()));
2236
+ if (isset($_GET['yr']) && isset($_GET['month']))
2237
+ {
2238
+ if ($year == $_GET['yr'])
2239
+ {
2240
+ return ' selected="selected"';
2241
+ }
2242
+ }
2243
+ else if ($year == $current_year)
2244
+ {
2245
+ return ' selected="selected"';
2246
+ }
2247
+ }
2248
 
2249
  // Actually do the printing of the calendar
2250
  // Compared to searching for and displaying events
2251
  // this bit is really rather easy!
2252
  function calendar()
2253
  {
2254
+ global $wpdb,$week_no;
2255
 
2256
+ // Clean up
2257
+ unset($week_no);
2258
 
2259
  // Deal with the week not starting on a monday
2260
  if (get_option('start_of_week') == 0)
2273
  // If we don't pass arguments we want a calendar that is relevant to today
2274
  if (empty($_GET['month']) || empty($_GET['yr']))
2275
  {
2276
+ $c_year = date("Y",ctwo());
2277
+ $c_month = date("m",ctwo());
2278
+ $c_day = date("d",ctwo());
2279
  }
2280
 
2281
  // Years get funny if we exceed 3000, so we use this check
2282
+ if ($_GET['yr'] <= 3000 && $_GET['yr'] >= 0 && (int)$_GET['yr'] != 0)
2283
  {
2284
  // This is just plain nasty and all because of permalinks
2285
  // which are no longer used, this will be cleaned up soon
2302
  else if ($_GET['month'] == 'nov') { $t_month = 11; }
2303
  else if ($_GET['month'] == 'dec') { $t_month = 12; }
2304
  $c_month = $t_month;
2305
+ $c_day = date("d",ctwo());
2306
  }
2307
  // No valid month causes the calendar to default to today
2308
  else
2309
  {
2310
+ $c_year = date("Y",ctwo());
2311
+ $c_month = date("m",ctwo());
2312
+ $c_day = date("d",ctwo());
2313
  }
2314
  }
2315
  // No valid year causes the calendar to default to today
2316
  else
2317
  {
2318
+ $c_year = date("Y",ctwo());
2319
+ $c_month = date("m",ctwo());
2320
+ $c_day = date("d",ctwo());
2321
  }
2322
 
2323
  // Fix the days of the week if week start is not on a monday
2348
  {
2349
  $calendar_body .= '<tr>
2350
  <td colspan="7" class="calendar-date-switcher">
2351
+ <form method="get" action="'.htmlspecialchars($_SERVER['REQUEST_URI']).'">
2352
  ';
2353
  $qsa = array();
2354
  parse_str($_SERVER['QUERY_STRING'],$qsa);
2356
  {
2357
  if ($name != 'month' && $name != 'yr')
2358
  {
2359
+ $calendar_body .= '<input type="hidden" name="'.strip_tags($name).'" value="'.strip_tags($argument).'" />
2360
  ';
2361
  }
2362
  }
2363
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2364
  // We build the months in the switcher
2365
  $calendar_body .= '
2366
  '.__('Month','calendar').': <select name="month" style="width:100px;">
2367
+ <option value="jan"'.calendar_month_comparison('jan').'>'.__('January','calendar').'</option>
2368
+ <option value="feb"'.calendar_month_comparison('feb').'>'.__('February','calendar').'</option>
2369
+ <option value="mar"'.calendar_month_comparison('mar').'>'.__('March','calendar').'</option>
2370
+ <option value="apr"'.calendar_month_comparison('apr').'>'.__('April','calendar').'</option>
2371
+ <option value="may"'.calendar_month_comparison('may').'>'.__('May','calendar').'</option>
2372
+ <option value="jun"'.calendar_month_comparison('jun').'>'.__('June','calendar').'</option>
2373
+ <option value="jul"'.calendar_month_comparison('jul').'>'.__('July','calendar').'</option>
2374
+ <option value="aug"'.calendar_month_comparison('aug').'>'.__('August','calendar').'</option>
2375
+ <option value="sept"'.calendar_month_comparison('sept').'>'.__('September','calendar').'</option>
2376
+ <option value="oct"'.calendar_month_comparison('oct').'>'.__('October','calendar').'</option>
2377
+ <option value="nov"'.calendar_month_comparison('nov').'>'.__('November','calendar').'</option>
2378
+ <option value="dec"'.calendar_month_comparison('dec').'>'.__('December','calendar').'</option>
2379
  </select>
2380
  '.__('Year','calendar').': <select name="yr" style="width:60px;">
2381
  ';
2382
 
2383
+ // The year builder is string mania. If you can make sense of this, you know your PHP!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2384
 
2385
  $past = 30;
2386
  $future = 30;
2388
  while ($past > 0)
2389
  {
2390
  $p .= ' <option value="';
2391
+ $p .= date("Y",ctwo())-$past;
2392
+ $p .= '"'.calendar_year_comparison(date("Y",ctwo())-$past).'>';
2393
+ $p .= date("Y",ctwo())-$past.'</option>
2394
  ';
2395
  $past = $past - 1;
2396
  }
2397
  while ($fut < $future)
2398
  {
2399
  $f .= ' <option value="';
2400
+ $f .= date("Y",ctwo())+$fut;
2401
+ $f .= '"'.calendar_year_comparison(date("Y",ctwo())+$fut).'>';
2402
+ $f .= date("Y",ctwo())+$fut.'</option>
2403
  ';
2404
  $fut = $fut + 1;
2405
  }
2406
  $calendar_body .= $p;
2407
+ $calendar_body .= ' <option value="'.date("Y",ctwo()).'"'.calendar_year_comparison(date("Y",ctwo())).'>'.date("Y",ctwo()).'</option>
2408
  ';
2409
  $calendar_body .= $f;
2410
  $calendar_body .= '</select>
2411
+ <input type="submit" value="'.__('Go','calendar').'" />
2412
  </form>
2413
  </td>
2414
  </tr>
2470
  if (get_option('start_of_week') == 0)
2471
  {
2472
  // This bit of code is for styles believe it or not.
2473
+ $grabbed_events = grab_events($c_year,$c_month,$i,'calendar');
2474
  $no_events_class = '';
2475
  if (!count($grabbed_events))
2476
  {
2477
  $no_events_class = ' no-events';
2478
  }
2479
+ $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<7&&$ii>1?'':'class="weekend"').'>'.$i++.'</span><span class="event"><br />' . draw_events($grabbed_events) . '</span></td>
2480
  ';
2481
  }
2482
  else
2483
  {
2484
+ $grabbed_events = grab_events($c_year,$c_month,$i,'calendar');
2485
  $no_events_class = '';
2486
  if (!count($grabbed_events))
2487
  {
2488
  $no_events_class = ' no-events';
2489
  }
2490
+ $calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'"><span '.($ii<6?'':'class="weekend"').'>'.$i++.'</span><span class="event"><br />' . draw_events($grabbed_events) . '</span></td>
2491
  ';
2492
  }
2493
  }
2521
  $calendar_body .= '</table>
2522
  ';
2523
 
2524
+ // A little link to yours truly. See the README if you wish to remove this
2525
+ $calendar_body .= '<div class="kjo-link" style="visibility:visible !important;display:block !important;"><p>'.__('Calendar developed and supported by ', 'calendar').'<a href="http://www.kieranoshea.com">Kieran O\'Shea</a></p></div>
2526
  ';
2527
 
2528
  // Phew! After that bit of string building, spit it all out.
calendar.pot CHANGED
@@ -496,6 +496,10 @@ msgstr ""
496
  msgid "Year"
497
  msgstr ""
498
 
 
 
 
 
499
  #: calendar.php:2683
500
  msgid "Category Key"
501
  msgstr ""
496
  msgid "Year"
497
  msgstr ""
498
 
499
+ #: calendar.php:2616
500
+ msgid "Go"
501
+ msgstr ""
502
+
503
  #: calendar.php:2683
504
  msgid "Category Key"
505
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: KieranOShea
3
  Donate link: http://www.kieranoshea.com
4
  Tags: calendar, dates, times, events
5
  Requires at least: 2.0
6
- Tested up to: 2.8
7
- Stable tag: 1.2.2
8
 
9
  A simple but effective Calendar plugin for WordPress that allows you to
10
  manage your events and appointments and display them to the world.
@@ -23,7 +23,7 @@ Features:
23
  * Events can display their author (optional)
24
  * Events can span more than one day
25
  * Multiple events per day possible
26
- * Events can repeat on a weekly, monthly or yearly basis
27
  * Repeats can occur indefinitely or a limited number of times
28
  * Easy to use events manager in admin dashboard
29
  * Sidebar function/Widget to show todays events
3
  Donate link: http://www.kieranoshea.com
4
  Tags: calendar, dates, times, events
5
  Requires at least: 2.0
6
+ Tested up to: 3.0
7
+ Stable tag: 1.2.3
8
 
9
  A simple but effective Calendar plugin for WordPress that allows you to
10
  manage your events and appointments and display them to the world.
23
  * Events can display their author (optional)
24
  * Events can span more than one day
25
  * Multiple events per day possible
26
+ * Events can repeat on a weekly, monthly (set numerical day), monthly (set textual day) or yearly basis
27
  * Repeats can occur indefinitely or a limited number of times
28
  * Easy to use events manager in admin dashboard
29
  * Sidebar function/Widget to show todays events