WordPress.org

Plugin Directory

Changeset 610194


Ignore:
Timestamp:
10/09/12 22:50:43 (19 months ago)
Author:
joedolson
Message:

Commit version 2.0.8. Bug fixes and performance improvements.

Location:
my-calendar/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • my-calendar/trunk/my-calendar-event-manager.php

    r604930 r610194  
    109109} 
    110110 
    111 if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'delete' ) { 
     111if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'delete' ) {  
    112112        $sql = "SELECT event_title, event_author FROM " . my_calendar_table() . " WHERE event_id=" . (int) $_GET['event_id']; 
    113113       $result = $mcdb->get_results( $sql, ARRAY_A ); 
    114114    if ( mc_can_edit_event( $result[0]['event_author'] ) ) { 
     115        if ( isset( $_GET['date'] ) ) { 
     116            $event_instance = (int) $_GET['date']; 
     117            $sql = "SELECT occur_begin FROM " . my_calendar_event_table() . " WHERE occur_id=" . $event_instance; 
     118            $inst = $mcdb->get_var( $sql ); 
     119            $instance_date = date('Y-m-d',strtotime($inst) ); 
     120        } else { 
     121            $instance_date = ''; 
     122        } 
    115123    ?> 
    116124        <div class="error"> 
     
    120128        <input type="hidden" value="delete" name="event_action" /> 
    121129        <?php if ( !empty( $_GET['date'] ) ) { ?>  
    122         <input type="hidden" name="event_instance" value="<?php echo (int) $_GET['date']; ?>" /> 
     130            <input type="hidden" name="event_instance" value="<?php echo (int) $_GET['date']; ?>" /> 
    123131        <?php } ?> 
    124132        <input type="hidden" value="<?php echo (int) $_GET['event_id']; ?>" name="event_id" /> 
    125         <input type="submit" name="submit" class="button-secondary delete" value="<?php _e('Delete','my-calendar'); echo " &quot;".stripslashes($result[0]['event_title'])."&quot;"; ?>" /> 
     133        <input type="submit" name="submit" class="button-secondary delete" value="<?php _e('Delete','my-calendar'); echo " &quot;".stripslashes( $result[0]['event_title'] )."&quot; ($instance_date)"; ?>" /> 
    126134        </form></p> 
    127135        </div> 
    128     <?php 
    129     } else { 
    130     ?> 
     136<?php } else { ?> 
    131137        <div class="error"> 
    132         <p><strong><?php _e('You do not have permission to delete that event.','my-calendar'); ?></strong></p> 
     138        <p><strong><?php _e( 'You do not have permission to delete that event.','my-calendar' ); ?></strong></p> 
    133139        </div> 
    134     <?php 
    135     } 
     140<?php } 
    136141} 
    137142 
     
    348353            $message = "<div class='error'><p><strong>".__('Error','my-calendar').":</strong>".__("You can't delete an event if you haven't submitted an event id",'my-calendar')."</p></div>"; 
    349354        } else { 
    350             $sql = "DELETE FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'"; 
    351             $delete_occurrences = "DELETE FROM ".my_calendar_event_table()." WHERE occur_event_id = ".(int) $event_id; 
    352             $delete = $mcdb->query($delete_occurrences);             
    353             $mcdb->query($sql); 
    354             $sql = "SELECT event_id FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'"; 
    355             $result = $mcdb->get_results($sql); 
     355            if ( empty( $_POST['event_instance'] ) ) { 
     356                $sql = "DELETE FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'"; 
     357                $delete_occurrences = "DELETE FROM ".my_calendar_event_table()." WHERE occur_event_id = ".(int) $event_id; 
     358                $delete = $mcdb->query($delete_occurrences);             
     359                $mcdb->query($sql); 
     360                $sql = "SELECT event_id FROM " . my_calendar_table() . " WHERE event_id='" . (int) $event_id . "'"; 
     361                $result = $mcdb->get_results($sql); 
     362            } else { 
     363                $delete = "DELETE FROM " . my_calendar_event_table(). " WHERE occur_id = ".(int) $_POST['event_instance']; 
     364                $result = $mcdb->get_results($delete); 
     365            } 
    356366            if ( empty($result) || empty($result[0]->event_id) ) { 
    357367                mc_delete_cache(); 
     
    428438     
    429439    $instance = ( isset($_GET['date'] ) )?(int) $_GET['date']:false; 
    430     if ( $instance ) { $ins = mc_get_instance_data( $instance ); $event_id = $ins->occur_event_id; $data = mc_get_event_core( $event_id ); $instance=false; } 
     440    if ( $instance ) { $ins = mc_get_instance_data( $instance ); $event_id = $ins->occur_event_id; $data = mc_get_event_core( $event_id );} 
    431441    ?> 
    432442 
     
    436446<?php if ( $mode == 'add' || $mode == 'copy' ) { $edit_args = ''; } else { 
    437447    $edit_args = "&amp;mode=$mode&amp;event_id=$event_id"; 
    438     if ( isset( $_GET['date'] ) && !empty($_GET['date']) ) { $date_id = (int) $_GET['date']; $edit_args .= "&amp;date=$date_id"; } 
    439 } ?> 
    440  
     448    if ( $instance ) { $edit_args .= "&amp;date=$instance"; } 
     449}  
     450?> 
    441451<form id="my-calendar" method="post" action="<?php echo admin_url('admin.php?page=my-calendar').$edit_args; ?>"> 
    442452 
     
    463473<?php 
    464474    if ( !empty( $_GET['date'] ) && $data->event_recur != 'S' ) { 
    465         $event = mc_get_event( $date_id ); 
     475        $event = mc_get_event( $instance ); 
    466476        $date = date_i18n( get_option('mc_date_format'),strtotime( $event->occur_begin ) ); 
    467477        $message = __("You are editing the <strong>$date</strong> instance of this event. Other instances of this event will not be changed.",'my-calendar'); 
    468         echo "<div><input type='hidden' name='event_instance' value='$date_id' /></div>"; 
     478        echo "<div><input type='hidden' name='event_instance' value='$instance' /></div>"; 
    469479        echo "<div class='message updated'><p>$message</p></div>"; 
    470480    } else if ( isset( $_GET['date'] ) && empty( $_GET['date'] ) ) { 
     
    603613                $event_end = esc_attr($data->event_end); 
    604614                if ( !empty($_GET['date'] ) ) { 
    605                     $event = mc_get_event( $date_id );               
     615                    $event = mc_get_event( $instance );                  
    606616                    $event_begin = date( 'Y-m-d', strtotime( $event->occur_begin ) ); 
    607617                    $event_end = date( 'Y-m-d', strtotime( $event->occur_end ) ); 
     
    619629                    } else { 
    620630                        echo date_i18n("h:i a",time()+$offset); 
    621                     }?>" /> <input type="checkbox" value="1" id="event_allday" name="event_allday"<?php if ( $data->event_time == '00:00:00' && $data->event_endtime == '00:00:00' ) { echo " checked=\"checked\""; } ?> /> <label for="event_allday"><?php _e('All day event','my-calendar'); ?></label> 
     631                    }?>" /> <input type="checkbox" value="1" id="event_allday" name="event_allday"<?php if ( !empty($data) && ( $data->event_time == '00:00:00' && $data->event_endtime == '00:00:00' ) ) { echo " checked=\"checked\""; } ?> /> <label for="event_allday"><?php _e('All day event','my-calendar'); ?></label> 
    622632            </p> 
    623633            <p> 
     
    940950    if ( $filter == '' ) { $filtered = ""; } else { $filtered = "<a href='".admin_url('admin.php?page=my-calendar')."'>".__('Clear filters','my-calendar')."</a>"; } 
    941951    $current = empty($_GET['paged']) ? 1 : intval($_GET['paged']); 
    942     $items_per_page = 50;    
     952    $items_per_page = ( get_option('mc_num_per_page') == '' )?50:get_option('mc_num_per_page');  
    943953    $events = $mcdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM " . my_calendar_table() . " $limit ORDER BY $sortbyvalue $sortbydirection LIMIT ".(($current-1)*$items_per_page).", ".$items_per_page ); 
    944954    $found_rows = $wpdb->get_col("SELECT FOUND_ROWS();"); 
     
    11761186        $event_span = (!empty($post['event_span']) && $event_group_id != 0 ) ? 1 : 0; 
    11771187        $event_hide_end = (!empty($post['event_hide_end']) ) ? 1 : 0; 
    1178             $event_hide_end = ( $time == '' || $time == '00:00:00' )?1:0; // hide end time automatically on all day events 
     1188        $event_hide_end = ( $time == '' || $time == '00:00:00' )?1:$event_hide_end; // hide end time automatically on all day events 
    11791189        // set location 
    11801190            if ($location_preset != 'none') { 
  • my-calendar/trunk/my-calendar-events.php

    r604930 r610194  
    133133                        OR DATE(occur_end) BETWEEN '$from 00:00:00' and '$to 23:59:59'  
    134134                        OR ( DATE('$from') BETWEEN DATE(occur_begin) AND DATE(occur_end) )  
    135                         OR ( DATE('$to') BETWEEN DATE(occur_begin) AND DATE(occur_end) ))"; 
     135                        OR ( DATE('$to') BETWEEN DATE(occur_begin) AND DATE(occur_end) ))  
     136                        ORDER BY occur_begin"; 
    136137    $events = $mcdb->get_results( $event_query ); 
    137138    if (!empty($events)) { 
  • my-calendar/trunk/my-calendar-install.php

    r598560 r610194  
    405405function mc_migrate_db() { 
    406406    global $wpdb, $initial_occur_db; 
    407     //require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
    408407    // this function migrates the DB from version 1.10.x to version 2.0. 
    409408    $tables = $wpdb->get_results("show tables;"); 
  • my-calendar/trunk/my-calendar-output.php

    r604930 r610194  
    11<?php 
    22// Used to draw multiple events 
     3function mc_holiday_limit( $events, $holidays ) { 
     4    foreach ( array_keys($events) as $key ) { 
     5        if ( !empty($holidays[$key]) ) { 
     6            foreach ( $events[$key] as $k => $event ) { 
     7                if ( $event->event_category != get_option('mc_skip_holidays_category') && $event->event_holiday == 1 ) { 
     8                    unset($events[$key][$k]); 
     9                } 
     10            } 
     11        }  
     12    } 
     13    return $events; 
     14} 
     15 
     16function mc_set_date_array( $events ) { 
     17    $event_array = array(); 
     18    foreach ( $events as $event ) { 
     19        $date = date( 'Y-m-d',strtotime($event->occur_begin) ); 
     20        $end = date( 'Y-m-d',strtotime($event->occur_end) ); 
     21        if ( $date != $end ) { 
     22            $start = strtotime($date); 
     23            $end = strtotime($end); 
     24            do { 
     25                $date = date('Y-m-d',$start); 
     26                $event_array[$date][] = $event;  
     27                $start = strtotime( "+1 day",$start );           
     28            } while ( $start <= $end );  
     29        } else { 
     30            $event_array[$date][] = $event;  
     31        } 
     32    } 
     33    return $event_array; 
     34} 
     35 
    336function my_calendar_draw_events($events, $type, $process_date, $time, $template='') { 
    437  if ( $type == 'mini' && ( get_option('mc_open_day_uri') == 'true' || get_option('mc_open_day_uri') == 'listanchor' || get_option('mc_open_day_uri') == 'calendaranchor' ) ) return true; 
    538  // We need to sort arrays of objects by time 
    639  if ( is_array($events) ) { 
    7  usort($events, "my_calendar_time_cmp"); 
    8  $temp_array = array(); 
     40 //usort($events, "my_calendar_time_cmp"); 
    941 $output_array = array(); 
    1042 $begin = $event_output = $end = ''; 
     
    1648        } 
    1749    } 
    18     foreach(array_keys($events) as $key) {  
    19         $event =& $events[$key]; 
    20         $temp_array[] = $event; 
    21     } 
    22      
    2350    // By default, skip no events. 
    2451    $skipping = false; 
    25     foreach(array_keys($temp_array) as $key) { 
    26         $event =& $temp_array[$key]; 
    27         // if any event this date is in the holiday category, we are skipping 
    28         if ( $event->event_category == get_option('mc_skip_holidays_category') ) { 
    29             $skipping = true; 
    30             break; 
    31         } 
    32     } 
    33     // check each event, if we're skipping, only include the holiday events. 
    34     $sum = 0; 
    35     foreach(array_keys($temp_array) as $key) { 
    36         $event =& $temp_array[$key];     
    37         if ($skipping == true) { 
    38             if ($event->event_category == get_option('mc_skip_holidays_category') ) { 
     52    foreach(array_keys($events) as $key ) { 
     53        $event =& $events[$key]; 
     54        $output_array[] = my_calendar_draw_event($event, $type, $process_date,$time,$template); 
     55    } 
     56    //} else { 
     57        /* foreach(array_keys($events) as $key ) { 
     58            $event =& $events[$key]; 
     59            $output_array[] = my_calendar_draw_event($event, $type, $process_date,$time,$template); 
     60        }        
     61        /*foreach(array_keys($temp_array) as $key) { 
     62            $event =& $temp_array[$key]; 
     63            // if any event this date is in the holiday category, we are skipping 
     64            if ( $event->event_category == get_option('mc_skip_holidays_category') ) { 
     65                $skipping = true; 
     66                break; 
     67            } 
     68        } 
     69        // check each event, if we're skipping, only include the holiday events. 
     70        $sum = 0; 
     71        foreach(array_keys($temp_array) as $key) { 
     72            $event =& $temp_array[$key];     
     73            if ($skipping == true) { 
     74                if ($event->event_category == get_option('mc_skip_holidays_category') ) { 
     75                    $output_array[] = my_calendar_draw_event($event, $type, $process_date,$time,$template); 
     76                } else { 
     77                    if ( $event->event_holiday == '0' ) { // '1' means "is canceled" 
     78                        $output_array[] = my_calendar_draw_event($event, $type, $process_date,$time,$template); 
     79                    } 
     80                } 
     81            } else { 
    3982                $output_array[] = my_calendar_draw_event($event, $type, $process_date,$time,$template); 
    40             } else { 
    41                 if ( $event->event_holiday == '0' ) { // '1' means "is canceled" 
    42                     $output_array[] = my_calendar_draw_event($event, $type, $process_date,$time,$template); 
    43                 } 
    44             } 
    45         } else { 
    46             $output_array[] = my_calendar_draw_event($event, $type, $process_date,$time,$template); 
    47         } 
    48     } 
     83            } 
     84        }*/ 
     85    //} 
    4986    if ( is_array($output_array) ) { 
    5087        foreach (array_keys($output_array) as $key) { 
     
    5289            $event_output .= $value; 
    5390        } 
    54     } 
     91    }    
    5592    if ( $event_output == '' ) { return; } 
    5693    if ($type == "mini" && count($events) > 0) { $end .= "</div>"; } 
     
    156193    } else {  
    157194        $wrap = $balance = '';  
    158     } 
    159      
     195    }    
    160196    //$toggle = ($type == 'calendar')?"&nbsp;<a href='#' class='mc-toggle'><img src='".MY_CALENDAR_DIRECTORY."/images/event-details.png' alt='".__('Event Details','my-calendar')."' /></a>":''; 
    161197    //$toggle =  (get_option('mc_open_uri')=='true')?'':$toggle; 
     
    344380        break; 
    345381    } 
    346      
    347382    if ( get_option( 'mc_event_approve' ) == 'true' ) { 
    348383        if ( $event->event_approved == 1 ) {     
     
    478513} 
    479514 
    480 function mc_date_array( $timestamp,$period ) { 
     515function mc_date_array( $timestamp, $period, $months=0 ) { 
    481516    switch ( $period ) { 
    482517        case "month": 
    483518                $first = date('N',$timestamp); $n = ( get_option('start_of_week')==1 )?$first-1:$first; 
    484             $from = date('Y-m-d',strtotime( "-$n days", $timestamp ) ); 
     519            $from = date( 'Y-m-d', strtotime( "-$n days", $timestamp ) ); 
    485520                $endtime = mktime(0,0,0,date('m',$timestamp),date('t',$timestamp),date('Y',$timestamp) ); 
     521            //  $endtime = strtotime("+$months months",$endtime); // this allows multiple months displayed. Will figure out splitting tables... 
    486522                $last = date('N', $endtime ); $n = ( get_option('start_of_week')==1 )?7-$last:6-$last; 
    487523            if ( $n == '-1' && date('N',$endtime ) == '7' ) { $n = 6; } 
     
    561597     
    562598    $date_format = ( get_option('mc_date_format') != '' )?get_option('mc_date_format'):get_option('date_format'); 
    563  
    564599    $format_toggle = mc_format_toggle( $format, $toggle ); 
    565600     
     
    647682        $n_month = str_pad( $n_month, 2, '0', STR_PAD_LEFT ); 
    648683        $p_month = str_pad( $p_month, 2, '0', STR_PAD_LEFT ); 
    649          
    650684        //echo "<p>Debug:<br />Day: $c_day<br />Month: $c_month<br />Year: $c_year<br />Date: ".date('Y-m-d',$current_date)."</p>"; 
    651  
     685        $num = get_option( 'mc_show_months' ) - 1; // the number set is how months to show; but this is how many *additional* months to show. 
    652686         
    653687        if ( $format == "list" && $time != 'week' ) { 
    654             $num = get_option( 'mc_show_months' ) - 1; // the number set is how months to show; but this value is how many *additional* months to show. 
    655688            if ( $num > 0 && $time != 'day' && $time != 'week' ) { 
    656689                $from = date( 'Y-m-d',mktime(0,0,0,$c_month,1,$c_year) ); 
    657690                    $next = strtotime( "+$num months",mktime(0,0,0,$c_month,1,$c_year ) ); 
    658691                    $last = date( 't',$next ); 
    659                 $to =date('Y-m',$next).'-'.$last; 
     692                $to = date( 'Y-m',$next ).'-'.$last; 
    660693            } else { 
    661694                $from = date( 'Y-m-d',mktime(0,0,0,$c_month,1,$c_year) ); 
    662                 $to = date( 'Y-m-d',mktime(0,0,0,$c_month,date('t',mktime(0,0,0,$c_month,1,$c_year) ),$c_year) ); 
     695                $to = date( 'Y-m-d',mktime(0,0,0,$c_month,date( 't',mktime(0,0,0,$c_month,1,$c_year) ),$c_year) ); 
    663696            } 
    664697            $this_dates = array( 'from'=>$from, 'to'=>$to );             
    665698        } else { 
    666             $this_dates = mc_date_array( $current_date, $time ); 
    667         } 
    668  
     699            $this_dates = mc_date_array( $current_date, $time, $num ); 
     700        } 
    669701        $from = $this_dates['from']; 
    670702        $to = $this_dates['to']; 
    671703        //echo "<pre>$num $from, $to ($c_month,$c_day,$c_year)</pre>"; 
     704 
    672705        $events = my_calendar_grab_events( $from, $to, $category, $ltype, $lvalue,'calendar',$author ); 
     706            if ( !get_option('mc_skip_holidays_category') || get_option('mc_skip_holidays_category') == '' ) {  
     707                $holidays = array(); 
     708            } else { 
     709                $holidays = my_calendar_grab_events( $from, $to, get_option('mc_skip_holidays_category'),$ltype, $lvalue, 'calendar', $author ); 
     710                $holiday_array = mc_set_date_array( $holidays ); 
     711            } 
    673712        // get events into an easily parseable set, keyed by date. 
    674         $event_array = array(); 
    675         if ( is_array($events) && !empty($events) ) { 
     713        if ( is_array( $events ) && !empty($events) ) { 
    676714            $no_events = false; 
    677             foreach ( $events as $event ) { 
    678                 $date = date( 'Y-m-d',strtotime($event->occur_begin) ); 
    679                 $end = date( 'Y-m-d',strtotime($event->occur_end) ); 
    680                 if ( $date != $end ) { 
    681                     $start = strtotime($date); 
    682                     $end = strtotime($end); 
    683                     do { 
    684                         $date = date('Y-m-d',$start); 
    685                         $event_array[$date][] = $event;  
    686                         $start = strtotime( "+1 day",$start );           
    687                     } while ( $start <= $end );  
    688                 } else { 
    689                     $event_array[$date][] = $event;  
    690                 } 
     715            $event_array = mc_set_date_array( $events ); 
     716            if ( is_array( $holidays ) && count($holidays) > 0 ) { 
     717                $event_array = mc_holiday_limit( $event_array, $holiday_array ); // if there are holidays, rejigger. 
    691718            } 
    692719        } else { 
     
    695722        // if convert to strings, can iterate using for with +86400 to get each day.  
    696723        // if use strtotime can do +1 day to get each date.      
    697          
     724 
    698725        // setup print link 
    699726        if ( get_option( 'mc_show_print' ) == 'true' ) { 
     
    734761            $from = $to = "$c_year-$c_month-$c_day"; 
    735762            //echo "<p>Debug: $from, $to, $category, $ltype, $lvalue, $author</p>"; 
    736             // Need to find a way for this to catch events which occur on this day, but neither start nor finish on it.... 
    737763            $events = my_calendar_grab_events($from,$to,$category,$ltype,$lvalue,'calendar',$author); 
     764            if ( !get_option('mc_skip_holidays_category') || get_option('mc_skip_holidays_category') == '' ) {  
     765                $holidays = array();     
     766            } else { 
     767                $holidays = my_calendar_grab_events( $from, $to, get_option('mc_skip_holidays_category'),$ltype, $lvalue, 'calendar', $author ); 
     768            } 
    738769            //echo "<pre>".print_r($events,1)."</pre>"; 
    739770            $events_class = mc_events_class( $events ); 
     
    741772            $mc_events = ''; 
    742773            if ( is_array($events) && count($events) > 0 ) { 
    743                 $mc_events .= my_calendar_draw_events($events, $format, $from, $time, $template); 
     774                if ( is_array($holidays) && count($holidays) > 0 ) { 
     775                    $mc_events .= my_calendar_draw_events($holidays, $format, $from, $time, $template ); 
     776                } else { 
     777                    $mc_events .= my_calendar_draw_events($events, $format, $from, $time, $template ); 
     778                } 
    744779            } else { 
    745780                $mc_events .= __( 'No events scheduled for today!','my-calendar'); 
     
    756791            $current_month_header = ( date('Y',$current_date) == date('Y',$through_date) )?date_i18n('F',$current_date):date_i18n('F Y',$current_date); 
    757792            $through_month_header = date_i18n('F Y', $through_date); 
    758              
     793         
    759794            // Adjust the days of the week if week start is not Monday 
    760795                $and = __("and",'my-calendar'); 
     
    813848                $start = strtotime($from); 
    814849                $end = strtotime($to); 
    815                 do {             
     850                do {     
     851                 
    816852                $date = date('Y-m-d',$start); 
    817853                $enddate = date('Y-m-d',$end ); 
     
    823859                        } 
    824860                        // date-based classes 
    825                         $monthclass = ( date('n',$start ) == $c_month )?'':'nextmonth'; 
     861                        $monthclass = ( date('n',$start ) == $c_month || $time != 'month' )?'':'nextmonth'; 
    826862                        $dateclass = mc_dateclass( time()+$offset, $start );     
    827863                        $dayclass = strtolower( date_i18n('D',$start) ); 
     
    831867                        $events = @$event_array[$date]; 
    832868                            if ( !empty($events) ) { 
    833                                 $event_output = my_calendar_draw_events($events, $format, $date, $time, $template); 
     869                                $event_output = my_calendar_draw_events($events, $format, $date, $time, $template, $holidays);                       
    834870                                if ( $event_output === true ) { $event_output = ' '; } 
    835871                                $events_class = ( $event_output != '' )?mc_events_class($events):'no-events'; 
     
    893929                                } 
    894930                            } 
     931 
    895932                        if ( date( 'N', $start ) ==  $end_of_week && $format != "list" ) { 
    896933                            $my_calendar_body .= "</tr>\n"; // end of 'is beginning of week' 
    897934                        } 
    898935                    } 
    899                     $start = strtotime( "+1 day",$start );           
     936                    $start = strtotime( "+1 day",$start );   
     937                     
    900938                } while ( $start <= $end );                  
    901939            } 
     
    11481186            $home = ''; // an empty string seems to work best; leaving it open. 
    11491187        } else { 
    1150             $home = get_permalink();         
     1188            $home = get_permalink();    // so, if the calendar is in a custom post type which is inserted in a page, this gets the post type's link.  
     1189                                        // I think that's actually what it should do, and am not inclined to fix it...have to think. 
    11511190        } 
    11521191    } 
  • my-calendar/trunk/my-calendar-settings.php

    r604930 r610194  
    88        define('KO_CALENDAR_CATS', $mcdb->prefix . 'calendar_categories'); 
    99        $events = $mcdb->get_results("SELECT * FROM " . KO_CALENDAR_TABLE, 'ARRAY_A'); 
    10         $sql = ""; 
     10        $event_ids = array(); 
    1111        foreach ($events as $key) { 
    12             $title = mysql_real_escape_string($key['event_title']); 
    13             $desc = mysql_real_escape_string($key['event_desc']); 
    14             $begin = mysql_real_escape_string($key['event_begin']); 
    15             $end = mysql_real_escape_string($key['event_end']); 
    16             $time = mysql_real_escape_string($key['event_time']); 
    17             $recur = mysql_real_escape_string($key['event_recur']); 
    18             $repeats = mysql_real_escape_string($key['event_repeats']); 
    19             $author = mysql_real_escape_string($key['event_author']); 
    20             $category = mysql_real_escape_string($key['event_category']); 
    21             $linky = mysql_real_escape_string($key['event_link']); 
    22             $sql = "INSERT INTO " . my_calendar_table() . " SET  
    23             event_title='" . ($title) . "',  
    24             event_desc='" . ($desc) . "',  
    25             event_begin='" . ($begin) . "',  
    26             event_end='" . ($end) . "',  
    27             event_time='" . ($time) . "',  
    28             event_recur='" . ($recur) . "',  
    29             event_repeats='" . ($repeats) . "',  
    30             event_author=".($author).",  
    31             event_category=".($category).",  
    32             event_link='".($linky)."'; 
    33             "; 
    34             $events_results = $mcdb->query($sql);        
    35         }    
     12            if ( $key['event_time'] == '00:00:00' ) { 
     13                $endtime = '00:00:00'; 
     14            } else { 
     15                $endtime = date('H:i:s',strtotime( "$key[event_time] +1 hour" ) ); 
     16            } 
     17            $data = array( 
     18                'event_title'=>$key['event_title'], 
     19                'event_desc'=>$key['event_desc'],  
     20                'event_begin'=>$key['event_begin'],  
     21                'event_end'=>$key['event_end'],  
     22                'event_time'=>$key['event_time'],  
     23                'event_endtime'=>$endtime, 
     24                'event_recur'=>$key['event_recur'],  
     25                'event_repeats'=>$key['event_repeats'],  
     26                'event_author'=>$key['event_author'],  
     27                'event_category'=>$key['event_category'], 
     28                'event_hide_end'=>1, 
     29                'event_link'=>( isset($key['event_link']) )?$key['event_link']:'' ); 
     30            $format = array( '%s','%s','%s','%s','%s','%s','%s','%d','%d','%d','%d','%s' ); 
     31            $update = $mcdb->insert( my_calendar_table(), $data, $format ); 
     32            $event_ids[] = $mcdb->insert_id; 
     33        } 
     34 
     35        foreach ( $event_ids as $value ) { // propagate event instances. 
     36                $sql = "SELECT event_begin, event_time, event_end, event_endtime FROM ".my_calendar_table()." WHERE event_id = $value"; 
     37                echo "$sql<br />"; 
     38                $event = $wpdb->get_results($sql); 
     39                $dates = array( 'event_begin'=>$event->event_begin,'event_end'=>$event->event_end,'event_time'=>$event->event_time,'event_endtime'=>$event->event_endtime ); 
     40                $event = mc_increment_event( $value, $dates );               
     41        } 
    3642        $cats = $mcdb->get_results("SELECT * FROM " . KO_CALENDAR_CATS, 'ARRAY_A');  
    3743        $catsql = ""; 
     
    6167} 
    6268 
     69function mc_drop_table( $table ) { 
     70    global $wpdb; 
     71    $sql = "DROP TABLE ".$table(); 
     72    $wpdb->query($sql); 
     73} 
     74 
    6375function edit_my_calendar_config() { 
    6476    global $wpdb,$default_user_settings; 
     
    6880    if (!empty($_POST)) { 
    6981        $nonce=$_REQUEST['_wpnonce']; 
    70         if (! wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed");   
     82        if (! wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed");  
     83        if ( isset($_POST['remigrate']) ) {  
     84            echo "<div class='updated fade'><ol>"; 
     85            echo "<li>".__('Dropping occurrences database table','my-calendar')."</li>"; 
     86            mc_drop_table( 'my_calendar_event_table' ); 
     87            sleep(1); 
     88            echo "<li>".__('Reinstalling occurrences database table.','my-calendar')."</li>"; 
     89            mc_upgrade_db();  
     90            sleep(1); 
     91            echo "<li>".__('Generating event occurrences.','my-calendar')."</li>"; 
     92            mc_migrate_db(); 
     93            echo "<li>".__('Event generation completed.','my-calendar')."</li>"; 
     94            echo "</ol></div>"; 
     95        } 
    7196    } 
    7297   if (isset($_POST['mc_manage'])) { 
     
    82107        update_option('mc_caching_enabled',$mc_caching_enabled); 
    83108        update_option('mc_default_sort',$_POST['mc_default_sort']); 
    84          
     109        update_option('mc_num_per_page',(int) $_POST['mc_num_per_page']); 
    85110         
    86111        if ( get_site_option('mc_multisite') == 2 ) { 
     
    269294    $mc_day_uri = get_option('mc_day_uri'); 
    270295    $mc_mini_uri = get_option('mc_mini_uri'); 
     296    $mc_num_per_page = ( get_option('mc_num_per_page') == '' )?50:get_option('mc_num_per_page'); 
    271297?>  
    272298 
    273     <div class="wrap jd-my-calendar" id="mc_settings"> 
     299<div class="wrap jd-my-calendar" id="mc_settings"> 
    274300<?php my_calendar_check_db();?> 
    275301    <div id="icon-options-general" class="icon32"><br /></div> 
     
    277303<div class="postbox-container" style="width: 70%"> 
    278304<div class="metabox-holder"> 
     305  <?php 
     306update_option( 'ko_calendar_imported','false' ); 
     307if (isset($_POST['import']) && $_POST['import'] == 'true') { 
     308    $nonce=$_REQUEST['_wpnonce']; 
     309    if (! wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed"); 
     310    my_calendar_import(); 
     311} 
     312if ( get_option( 'ko_calendar_imported' ) != 'true' ) { 
     313    if (function_exists('check_calendar')) { 
     314?> 
     315    <div class='import upgrade-db'> 
     316    <p> 
     317    <?php _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar'); ?> 
     318    </p> 
     319        <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
     320        <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>       
     321        <div> 
     322        <input type="hidden" name="import" value="true" /> 
     323        <input type="submit" value="<?php _e('Import from Calendar','my-calendar'); ?>" name="import-calendar" class="button-primary" /> 
     324        </div> 
     325        </form> 
     326    </div> 
     327<?php 
     328    } 
     329} 
     330?> 
    279331 
    280332<div class="ui-sortable meta-box-sortables">    
     
    336388    </select>    
    337389    </li> 
     390    <li> 
     391    <label for='mc_num_per_page'><?php _e('Number of events per page in admin events list','my-calendar'); ?></label> <input type='text' name='mc_num_per_page' id='mc_num_per_page' value='<?php echo $mc_num_per_page; ?>' /> 
     392    </li> 
    338393        <?php if ( get_site_option('mc_multisite') == 2 && MY_CALENDAR_TABLE != MY_CALENDAR_GLOBAL_TABLE ) { ?> 
    339394    <li> 
     
    348403        <?php } ?> 
    349404    <?php } ?> 
     405    <li><input type="checkbox" id="remigrate" name="remigrate" value="migrate" /> <label for="remigrate"><?php _e('Re-generate event occurrences table.','my-calendar'); ?></label> 
     406    </li> 
    350407    </ul> 
    351408    </fieldset> 
     
    838895    <?php _e('Only users with the ability to edit user accounts may modify user settings.','my-calendar'); ?> 
    839896<?php } ?> 
    840   <?php 
    841 //update_option( 'ko_calendar_imported','false' ); 
    842 if (isset($_POST['import']) && $_POST['import'] == 'true') { 
    843     $nonce=$_REQUEST['_wpnonce']; 
    844     if (! wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed"); 
    845     my_calendar_import(); 
    846 } 
    847 if ( get_option( 'ko_calendar_imported' ) != 'true' ) { 
    848     if (function_exists('check_calendar')) { 
    849     echo "<div class='import'>"; 
    850     echo "<p>"; 
    851     _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar'); 
    852     echo "</p>"; 
    853 ?> 
    854         <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
    855         <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>       
    856         <div> 
    857         <input type="hidden" name="import" value="true" /> 
    858         <input type="submit" value="<?php _e('Import from Calendar','my-calendar'); ?>" name="import-calendar" class="button-primary" /> 
    859         </div> 
    860         </form> 
    861 <?php 
    862     echo "</div>"; 
    863     } 
    864 } 
    865 ?> 
    866897    </div> 
    867898</div> 
    868899 
    869 <?php $mc_settings = apply_filters( 'mc_after_settings',$mc_settings ); echo $mc_settings; ?> 
     900<?php $mc_settings = apply_filters( 'mc_after_settings','' ); echo $mc_settings; ?> 
    870901 
    871902</div> 
  • my-calendar/trunk/my-calendar-templates.php

    r599338 r610194  
    11<?php 
    22function jd_draw_template($array,$template,$type='list') { 
     3    //$mtime = microtime( true); // DEBUG PERFORMANCE 
    34    //1st argument: array of details 
    45    //2nd argument: template to print details into 
    56    $template = stripcslashes($template);    
    6     foreach ($array as $key=>$value) { 
     7    foreach ( $array as $key=>$value ) { 
    78        if ( !is_object($value) ) { 
    8             if ($type != 'list') { 
    9                 if ( $key == 'link' && $value == '') { $value = ( get_option('mc_uri') != '' )?get_option('mc_uri'):get_bloginfo('url'); } 
    10                 if ( $key != 'guid') { $value = htmlentities($value); } 
    11             } 
    12             preg_match_all('/{'.$key.'\b(?>\s+(?:before="([^"]*)"|after="([^"]*)"|format="([^"]*)")|[^\s]+|\s+){0,2}}/', $template, $matches, PREG_PATTERN_ORDER ); 
    13             if ( $matches ) { 
    14                 $before = @$matches[1][0]; 
    15                 $after = @$matches[2][0]; 
    16                 $format = @$matches[3][0]; 
    17                 if ( $format != '' ) { $value = date( stripslashes($format),strtotime(stripslashes($value)) ); } 
    18                 $value = ( $value == '' )?'':$before.$value.$after; 
    19                 $search = @$matches[0][0]; 
    20                 $template = str_replace( $search, $value, $template ); 
    21                 // secondary search for RSS output 
    22                 $rss_search = "{rss_$key}"; 
    23                 $charset = get_option('blog_charset'); 
    24                 //$value = htmlspecialchars( $value, ENT_QUOTES, $charset ); 
    25                 //$value = htmlentities( $value, ENT_XML1, $charset ); 
    26             //  if ( $key == 'description' ) { echo $value; } 
    27                 $value = xml_entities( $value, $charset ); 
    28                 $value = xml_entity_decode( $value, $charset ); 
    29                 $template = stripcslashes(str_replace($rss_search,$value,$template)); 
    30             } 
     9            if ( strpos( $template, "{".$key ) !== false ) { 
     10                if ($type != 'list') { 
     11                    if ( $key == 'link' && $value == '') { $value = ( get_option('mc_uri') != '' )?get_option('mc_uri'):get_bloginfo('url'); } 
     12                    if ( $key != 'guid') { $value = htmlentities($value); } 
     13                } 
     14                if ( strpos( $template, "{".$key." " ) !== false ) { // only do preg_match if appropriate 
     15                    preg_match_all('/{'.$key.'\b(?>\s+(?:before="([^"]*)"|after="([^"]*)"|format="([^"]*)")|[^\s]+|\s+){0,2}}/', $template, $matches, PREG_PATTERN_ORDER ); 
     16                    if ( $matches ) { 
     17                        $before = @$matches[1][0]; 
     18                        $after = @$matches[2][0]; 
     19                        $format = @$matches[3][0]; 
     20                        if ( $format != '' ) { $value = date( stripslashes($format),strtotime(stripslashes($value)) ); } 
     21                        $value = ( $value == '' )?'':$before.$value.$after; 
     22                        $search = @$matches[0][0]; 
     23                        $template = str_replace( $search, $value, $template ); 
     24                    } 
     25                } else { // don't do preg match (never required for RSS) 
     26                    $template = stripcslashes(str_replace( "{".$key."}", $value, $template )); 
     27                    // secondary search for RSS output 
     28                    $rss_search = "{rss_$key}"; 
     29                    if ( strpos( $template, $rss_search ) !== false ) { 
     30                        $charset = get_option('blog_charset'); 
     31                        //$value = htmlspecialchars( $value, ENT_QUOTES, $charset ); 
     32                        //$value = htmlentities( $value, ENT_XML1, $charset ); 
     33                        //  if ( $key == 'description' ) { echo $value; } 
     34                        $value = xml_entities( $value, $charset ); 
     35                        $value = xml_entity_decode( $value, $charset ); 
     36                        $template = stripcslashes(str_replace($rss_search,$value,$template)); 
     37                    }                    
     38                } 
     39            } // end {$key check 
    3140        }  
    3241    } 
     42//$new = microtime( true ); 
     43//$length = $new - $mtime; 
     44//echo $length . ' seconds<br />'; //DEBUG       
    3345    return stripslashes(trim($template)); 
    3446} 
  • my-calendar/trunk/my-calendar.php

    r605378 r610194  
    66Author: Joseph C Dolson 
    77Author URI: http://www.joedolson.com 
    8 Version: 2.0.7 
     8Version: 2.0.8 
    99*/ 
    1010/*  Copyright 2009-2012  Joe Dolson (email : joe@joedolson.com) 
     
    2525*/ 
    2626global $mc_version, $wpdb; 
    27 $mc_version = '2.0.7'; 
     27$mc_version = '2.0.8'; 
    2828 
    2929// Define the tables used in My Calendar 
  • my-calendar/trunk/readme.txt

    r604930 r610194  
    8989 
    9090== Changelog == 
     91 
     92= 2.0.8 = 
     93 
     94* Re-written (simplified) holiday exclusion mechanism. 
     95* Performance improvements to templating and event processing. 
     96* Bug fix: Import from Kieran's "Calendar" plug-in was broken. 
     97* Bug fix: 'nextmonth' class was attached to events in weekly view; not appropriate to view. 
     98* Bug fix: Deleting single instance deleted entire event series. 
     99* Added option: number of events per page in admin events list 
    91100 
    92101= 2.0.7 = 
Note: See TracChangeset for help on using the changeset viewer.