phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: calendar/inc class.bocalendar.inc.php,1.87,1.88


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: calendar/inc class.bocalendar.inc.php,1.87,1.88 class.uicalendar.inc.php,1.93,1.94
Date: Wed, 26 Feb 2003 11:42:06 -0500

Update of /cvsroot/phpgroupware/calendar/inc
In directory subversions:/tmp/cvs-serv30669

Modified Files:
        class.bocalendar.inc.php class.uicalendar.inc.php 
Log Message:
some fixes for recuring events:
- they show up in the planner now
- you are able to delete single occurantses of recuring events
applied patch #774 from mishas: dayview sometimes not showing 1. event


Index: class.bocalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.bocalendar.inc.php,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -r1.87 -r1.88
*** class.bocalendar.inc.php    23 Nov 2002 20:48:41 -0000      1.87
--- class.bocalendar.inc.php    26 Feb 2003 16:42:04 -0000      1.88
***************
*** 462,465 ****
--- 462,468 ----
                                $this->so->add_entry($event);
                                $cd = 16;
+                               
+                               $this->so->cal->event = $temp_event;
+                               unset($temp_event);
                        }
                        else
***************
*** 467,472 ****
                                $cd = 60;
                        }
!                       $this->so->cal->event = $temp_event;
!                       unset($temp_event);
                        return $cd;
                }
--- 470,474 ----
                                $cd = 60;
                        }
! //                    }
                        return $cd;
                }
***************
*** 880,883 ****
--- 882,924 ----
                }
  
+               /*!
+               @function time2array
+               @abstract returns a date-array suitable for the start- or 
endtime of an event from a timestamp
+               @syntax time2array($time,$alarm=0)
+               @param $time the timestamp for the values of the array
+               @param $alarm (optional) alarm field of the array, defaults to 0
+               @author ralfbecker
+               */
+               function time2array($time,$alarm = 0)
+               {
+                       return array(
+                               'year'  => intval(date('Y',$time)),
+                               'month' => intval(date('m',$time)),
+                               'mday'  => intval(date('d',$time)),
+                               'hour'  => intval(date('H',$time)),
+                               'min'   => intval(date('i',$time)),
+                               'sec'   => intval(date('s',$time)),
+                               'alarm' => intval($alarm)
+                       );
+               }
+ 
+               /*!
+               @function set_recur_date
+               @abstract set the start- and enddates of a recuring event for a 
recur-date
+               @syntax set_recur_date(&$event,$date)
+               @param $event the event which fields to set (has to be the 
original event for start-/end-times)
+               @param $date  the recuring date in form 'Ymd', eg. 20030226
+               @author ralfbecker
+               */
+               function set_recur_date(&$event,$date)
+               {
+                       $org_start = $this->maketime($event['start']);
+                       $org_end   = $this->maketime($event['end']);
+                       $start = 
mktime($event['start']['hour'],$event['start']['min'],0,substr($date,4,2),substr($date,6,2),substr($date,0,4));
+                       $end   = $org_end + $start - $org_start;
+                       $event['start'] = $this->time2array($start);
+                       $event['end']   = $this->time2array($end);
+               }
+ 
                function fix_update_time(&$time_param)
                {
***************
*** 2202,2206 ****
                {
                        $already_moved = Array();
-                       $has_category  = Array(); // remove only multiple 
occurences of a category per event/day
                        for($v=$firstday;$v<=$lastday;$v++)
                        {
--- 2243,2246 ----
***************
*** 2209,2278 ****
                                        continue;
                                }
!                               while (list($g,$event) = 
each($this->cached_events[$v]))
                                {
!                                       $start = 
sprintf('%04d%02d%02d',$event['start']['year'],$event['start']['month'],$event['start']['mday']);
                                        
print_debug('EVENT',_debug_array($event,False));
                                        print_debug('start',$start);
                                        print_debug('v',$v);
  
!                                       if($start < $firstday)
!                                       {
!                                               $start = $firstday; // event 
continues into current month/year
!                                       }
! 
! //                                    if ($start != $v && 
$event['recur_type'] == MCAL_RECUR_NONE)                                        
            // this is an enddate-entry --> remove it
!                                       if ($start != $v)                       
                                // this is an enddate-entry --> remove it
!                                       {
!                                               
unset($this->cached_events[$v][$g]);
!                                               if($g != 
count($this->cached_events[$v]))
!                                               {
!                                                       if 
($has_category[$event['id']]['category'] != True)
!                                                       {
!                                                               continue; // we 
need at least one evidence for this category
!                                                       }
!                                                       for($h=$g + 
1;$h<$c_daily;$h++)
!                                                       {
!                                                               
$this->cached_events[$v][$h - 1] = $this->cached_events[$v][$h];
!                                                       }
!                                                       
unset($this->cached_events[$v][$h]);
!                                                       
$has_category[$event['id']]['category'] = True;
!                                               }
! 
! //                                            if ($start < $firstday && 
$event['recur_type'] == MCAL_RECUR_NONE)                              // start 
before period --> move it to the beginning
!                                               if ($start < $firstday)         
                // start before period --> move it to the beginning
!                                               {
!                                                       
if($already_moved[$event['id']] > 0)
!                                                       {
!                                                               continue;
!                                                       }
!                                                       $add_event = True;
!                                                       $c_events = 
count($this->cached_events[$firstday]);
!                                                       
for($i=0;$i<$c_events;$i++)
!                                                       {
!                                                               $add_event = 
($this->cached_events[$firstday][$i]['id'] == $event['id']?False:$add_event);
!                                                       }
!                                                       if($add_event)
!                                                       {
!                                                               
$this->cached_events[$firstday][] = $event;
!                                                               
$already_moved[$event['id']] = 1;
!                                                               
print_debug('Event moved');
!                                                       }
!                                                       else
!                                                       {
!                                                               
$already_moved[$event['id']] = 2;
!                                                               
print_debug('Event removed (not moved)');
!                                                       }
!                                               }
!                                               else
!                                               {
!                                                       print_debug('Event 
removed');
!                                               }
!                                       }
!                                       else
                                        {
!                                               print_debug('Event OK');
                                        }
                                }
-                               flush();
                        }
                }
--- 2249,2268 ----
                                        continue;
                                }
!                               $cached = $this->cached_events[$v];
!                               $this->cached_events[$v] = array();
!                               while (list($g,$event) = each($cached))
                                {
!                                       $end = 
date('Ymd',$this->maketime($event['end']));
                                        
print_debug('EVENT',_debug_array($event,False));
                                        print_debug('start',$start);
                                        print_debug('v',$v);
  
!                                       if 
(!isset($already_moved[$event['id']]) || $event['recur_type'] && $v > $end)
                                        {
!                                               $this->cached_events[$v][] = 
$event;
!                                               $already_moved[$event['id']] = 
1;
!                                               print_debug('Event moved');
                                        }
                                }
                        }
                }

Index: class.uicalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.uicalendar.inc.php,v
retrieving revision 1.93
retrieving revision 1.94
diff -C2 -r1.93 -r1.94
*** class.uicalendar.inc.php    13 Feb 2003 22:58:09 -0000      1.93
--- class.uicalendar.inc.php    26 Feb 2003 16:42:04 -0000      1.94
***************
*** 1029,1032 ****
--- 1029,1033 ----
                                                'action_confirm_button' => 
"onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this 
single occurence ?\\n\\nThis will delete\\nthis entry for all users.")."')\"",
                                                'action_extra_field'    => 
'<input type="hidden" name="delete_type" value="single">'
+                                                       . '<input type="hidden" 
name="date" 
value="'.sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day).'">'
                                        );
                                        $p->set_var($var);
***************
*** 1094,1102 ****
                function edit($params='')
                {
!                       if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
!                       {
!                          $this->no_edit();
!                       }
!                       
                        if($this->debug)
                        {
--- 1095,1104 ----
                function edit($params='')
                {
! //            No event loaded, so what to check?
! //                    if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
! //                    {
! //                       $this->no_edit();
! //                    }
! 
                        if($this->debug)
                        {
***************
*** 1141,1150 ****
                                {
                                        $event['id'] = 0;
!                                       $event['start']['month'] = 
$this->bo->month;
!                                       $event['start']['mday'] = 
$this->bo->day;
!                                       $event['start']['year'] = 
$this->bo->year;
!                                       $event['end']['month'] = 
$this->bo->month;
!                                       $event['end']['mday'] = $this->bo->day;
!                                       $event['end']['year'] = $this->bo->year;
                                        $event['recur_type'] = MCAL_RECUR_NONE;
                                        $event['recur_interval'] = 0;
--- 1143,1147 ----
                                {
                                        $event['id'] = 0;
!                                       
$this->bo->set_recur_date($event,$GLOBALS['HTTP_POST_VARS']['date']);
                                        $event['recur_type'] = MCAL_RECUR_NONE;
                                        $event['recur_interval'] = 0;
***************
*** 1153,1156 ****
--- 1150,1154 ----
                                        $event['recur_enddate']['mday'] = 0;
                                        $event['recur_enddate']['year'] = 0;
+                                       $event['recur_execption'] = array();
                                }
                                $this->edit_form(
***************
*** 1428,1437 ****
                                if($deleted_type && $delete_type == 'single')
                                {
                                        $cd = $this->bo->delete_single(
                                                Array(
                                                        'id'    => 
intval($cal_id),
!                                                       'year'  => 
$this->bo->year,
!                                                       'month' => 
$this->bo->month,
!                                                       'day'   => 
$this->bo->day
                                                )
                                        );
--- 1426,1436 ----
                                if($deleted_type && $delete_type == 'single')
                                {
+                                       $date = 
$GLOBALS['HTTP_POST_VARS']['date'];
                                        $cd = $this->bo->delete_single(
                                                Array(
                                                        'id'    => 
intval($cal_id),
!                                                       'year'  => 
substr($date,0,4),
!                                                       'month' => 
substr($date,4,2),
!                                                       'day'   => 
substr($date,6,2)
                                                )
                                        );
***************
*** 1823,1827 ****
                 * planner_update_row - update a row of the planner view
                 *
!                * parameters are: 
                 *   - index (e.g. user id, category id, ...) of the row
                 *   - name/title of the row (e.g. user name, category name)
--- 1822,1826 ----
                 * planner_update_row - update a row of the planner view
                 *
!                * parameters are:
                 *   - index (e.g. user id, category id, ...) of the row
                 *   - name/title of the row (e.g. user name, category name)
***************
*** 1835,1843 ****
                        $intervals_per_day = 
$this->bo->prefs['calendar']['planner_intervals_per_day'];
                        $is_private        = 
!$this->bo->check_perms(PHPGW_ACL_READ,$event);
! 
                        $view = $this->planner_html->link('/index.php',
                                array(
                                        'menuaction' => 
'calendar.uicalendar.view',
!                                       'cal_id' => $event['id']
                                )
                        );
--- 1834,1843 ----
                        $intervals_per_day = 
$this->bo->prefs['calendar']['planner_intervals_per_day'];
                        $is_private        = 
!$this->bo->check_perms(PHPGW_ACL_READ,$event);
!                       
                        $view = $this->planner_html->link('/index.php',
                                array(
                                        'menuaction' => 
'calendar.uicalendar.view',
!                                       'cal_id' => $event['id'],
!                                       'date' => 
date('Ymd',$this->bo->maketime($event['start']))
                                )
                        );
***************
*** 1870,1880 ****
                        } while ($akt_cell > $start_cell);
  
                        if ($akt_cell < $start_cell)
                        {
!                               $row[$event['id'].'_1'] = '&nbsp;';
!                               $row['.'.$event['id'].'_1'] = 
'colspan="'.($start_cell-$akt_cell).'"';
                        }
!                       $opt = &$row['.'.$event['id'].'_2'];
!                       $cel = &$row[$event['id'].'_2'];
  
                        // if possible, display information about event within 
cells representing it
--- 1870,1881 ----
                        } while ($akt_cell > $start_cell);
  
+                       $id = 
$event['id'].'-'.date('Ymd',$this->bo->maketime($event['start']));
                        if ($akt_cell < $start_cell)
                        {
!                               $row[$id.'_1'] = '&nbsp;';
!                               $row['.'.$id.'_1'] = 
'colspan="'.($start_cell-$akt_cell).'"';
                        }
!                       $opt = &$row['.'.$id.'_2'];
!                       $cel = &$row[$id.'_2'];
  
                        // if possible, display information about event within 
cells representing it
***************
*** 1956,1959 ****
--- 1957,1964 ----
                                $cel .= 
$this->planner_html->image('calendar','mini-calendar-bar.gif','','border="0"');
                        }
+                       if ($event['recur_type'])
+                       {
+                               $cel .= 
$this->planner_html->image('calendar','recur.gif','','border="0"');
+                       }
                        $cel .= 
$this->planner_html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"');
                        $cel .= '</a>';
***************
*** 2007,2011 ****
                        {
                                $days_between = 
$GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']);
- 
                                $end_cell = $intervals_per_day * $days_between 
+ $interval[$event['end']['hour']];
                                if ($end_cell == $start_cell && $end_cell < 
$last_cell)
--- 2012,2015 ----
***************
*** 2018,2022 ****
                                $end_cell = $last_cell;
                        }
- 
                        // get the categories associated with event
                        //
--- 2022,2025 ----
***************
*** 2157,2162 ****
                                // process all events on day $v
                                //
!                               while (list($nul,$event) = @each($daily))
                                {
                                        $this->planner_process_event($event);
                                }
--- 2160,2169 ----
                                // process all events on day $v
                                //
!                               while (list(,$event) = @each($daily))
                                {
+                                       if ($event['recur_type'])       // 
calculate start- + end-datetime for recuring events
+                                       {
+                                               
$this->bo->set_recur_date($event,$v);
+                                       }
                                        $this->planner_process_event($event);
                                }
***************
*** 3720,3724 ****
                                        {
                                                print_debug('IND before',$ind);
!                                               if($ind <= 
date('H',$last_endtime-1))   // -1 to allow events to end on a full hour, 
without blocking the next hour-slot
                                                {
                                                        $ind = $last_ind;
--- 3727,3731 ----
                                        {
                                                print_debug('IND before',$ind);
!                                               if($ind <= 
date('H',$last_endtime-1) && $last_ind)      // -1 to allow events to end on a 
full hour, without blocking the next hour-slot
                                                {
                                                        $ind = $last_ind;
***************
*** 4380,4384 ****
                                        'action_url_button'     => 
$this->page('delete','&cal_id='.$event['id']),
                                        'action_text_button'    => 
lang('Delete'),
!                                       'action_confirm_button' => 
"onClick=\"return confirm('".lang("Are you sure\\nyou want to \\ndelete this 
entry?\\n\\nThis will delete\\nthis entry for all users.")."')\"",
                                        'action_extra_field'    => ''
                                );
--- 4387,4391 ----
                                        'action_url_button'     => 
$this->page('delete','&cal_id='.$event['id']),
                                        'action_text_button'    => 
lang('Delete'),
!                                       'action_confirm_button' => 
"onClick=\"return confirm('".lang("Are you sure\\nyou want to \\ndelete this 
entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"",
                                        'action_extra_field'    => ''
                                );





reply via email to

[Prev in Thread] Current Thread [Next in Thread]