diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php
index 5cc23fe905..edbe8f630b 100755
--- a/calendar/inc/class.bocalendar.inc.php
+++ b/calendar/inc/class.bocalendar.inc.php
@@ -121,7 +121,7 @@
{
$this->grants = $GLOBALS['phpgw']->acl->get_grants('calendar');
- if($this->debug) { echo "Read Use_Session : (".$session.") Event: start='$start', v='$v' ";
+ echo ' remove it
@@ -1904,7 +2074,7 @@
$already_moved[$event['id']] = 1;
if($this->debug)
{
- echo "moved
\n"; }
+ if($this->debug) { echo ''."\n"; }
if($session)
{
@@ -131,8 +131,8 @@
if($this->debug)
{
- echo "BO Filter : (".$this->filter.")
\n";
- echo "Owner : ".$this->owner."
\n";
+ echo ''."\n";
+ echo ''."\n";
}
$owner = (isset($GLOBALS['owner'])?$GLOBALS['owner']:'');
@@ -244,8 +244,8 @@
if($this->debug)
{
- echo "BO Filter : (".$this->filter.")
\n";
- echo "Owner : ".$this->owner."
\n";
+ echo ''."\n";
+ echo ''."\n";
}
}
@@ -358,7 +358,7 @@
$event = $this->so->read_entry($id);
if(!isset($event['participants'][$this->owner]) && $this->user_is_a_member($event,$this->owner))
{
- $this->add_attribute('participants','U',intval($this->owner));
+ $this->so->add_attribute('participants','U',intval($this->owner));
$this->so->add_entry($event);
$event = $this->get_cached_event();
}
@@ -437,7 +437,7 @@
if($this->debug)
{
- echo "ID : ".$l_cal['id']."
\n";
+ echo ''."\n";
}
if(isset($GLOBALS['HTTP_GET_VARS']['readsess']))
@@ -460,12 +460,7 @@
}
else
{
- if(!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD))
- {
- ExecMethod('calendar.uicalendar.index');
- $GLOBALS['phpgw']->common->phpgw_exit();
- }
- elseif($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT))
+ if((!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) || ($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT)))
{
ExecMethod('calendar.uicalendar.index');
$GLOBALS['phpgw']->common->phpgw_exit();
@@ -615,7 +610,6 @@
);
}
- $event_ids = Array();
if($event['id'])
{
$event_ids[] = $event['id'];
@@ -626,8 +620,10 @@
}
$overlapping_events = $this->overlap(
- $this->maketime($event['start']) - $this->datetime->tz_offset,
- $this->maketime($event['end']) - $this->datetime->tz_offset,
+// $this->maketime($event['start']) - $this->datetime->tz_offset,
+// $this->maketime($event['end']) - $this->datetime->tz_offset,
+ $this->maketime($event['start']),
+ $this->maketime($event['end']),
$event['participants'],
$event['owner'],
$event_ids
@@ -791,85 +787,207 @@
return $error;
}
- function overlap($starttime,$endtime,$participants,$owner=0,$id=0)
+ function overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False)
{
- $retval = Array();
- $ok = False;
+// $retval = Array();
+// $ok = False;
/* This needs some attention.. by commenting this chunk of code it will fix bug #444265 */
- if($starttime == $endtime && $GLOBALS['phpgw']->common->show_date($starttime,'Hi') == 0)
+
+ if($restore_cache)
{
- $endtime = mktime(23,59,59,$GLOBALS['phpgw']->common->show_date($starttime,'m'),$GLOBALS['phpgw']->common->show_date($starttime,'d') + 1,$GLOBALS['phpgw']->common->show_date($starttime,'Y')) - $this->datetime->tz_offset;
+ $temp_cache_events = $this->cached_events;
}
- $sql = 'AND ((('.$starttime.' <= phpgw_cal.datetime) AND ('.$endtime.' >= phpgw_cal.datetime) AND ('.$endtime.' <= phpgw_cal.edatetime)) '
- . 'OR (('.$starttime.' >= phpgw_cal.datetime) AND ('.$starttime.' < phpgw_cal.edatetime) AND ('.$endtime.' >= phpgw_cal.edatetime)) '
- . 'OR (('.$starttime.' <= phpgw_cal.datetime) AND ('.$endtime.' >= phpgw_cal.edatetime)) '
- . 'OR (('.$starttime.' >= phpgw_cal.datetime) AND ('.$endtime.' <= phpgw_cal.edatetime))) ';
-
- if(count($participants) > 0)
+// $temp_start = intval($GLOBALS['phpgw']->common->show_date($starttime,'Ymd'));
+// $temp_start_time = intval($GLOBALS['phpgw']->common->show_date($starttime,'Hi'));
+// $temp_end = intval($GLOBALS['phpgw']->common->show_date($endtime,'Ymd'));
+// $temp_end_time = intval($GLOBALS['phpgw']->common->show_date($endtime,'Hi'));
+ $temp_start = intval(date('Ymd',$starttime));
+ $temp_start_time = intval(date('Hi',$starttime));
+ $temp_end = intval(date('Ymd',$endtime));
+ $temp_end_time = intval(date('Hi',$endtime));
+ if($this->debug)
{
- $p_g = '';
- if(count($participants))
+ echo ''."\n";
+ echo ''."\n";
+ }
+
+ $users = Array();
+ if(count($participants))
+ {
+ while(list($user,$status) = each($participants))
{
- $users = Array();
- while(list($user,$status) = each($participants))
- {
- $users[] = $user;
- }
- if($users)
- {
- $p_g .= 'phpgw_cal_user.cal_login IN ('.implode(',',$users).')';
- }
+ $users[] = $user;
}
- if($p_g)
- {
- $sql .= ' AND (' . $p_g . ')';
- }
- }
-
- if(count($id) >= 1)
- {
- @reset($id);
- $sql .= ' AND phpgw_cal.cal_id NOT IN ('.(count($id)==1?$id[0]:implode(',',$id)).')';
- }
-
- $sql .= ' ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
-
- $events = $this->so->get_event_ids(False,$sql);
- if($events == False)
- {
- return false;
- }
-
- $db2 = $GLOBALS['phpgw']->db;
-
- for($i=0;$i
\n";
+ }
+ if(!$found)
+ {
+ if($this->debug)
+ {
+ echo ''."\n";
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ $retval = False;
+ }
+
+ if($restore_cache)
+ {
+ $this->cached_events = $temp_cache_events;
+ }
+
+ return $retval;
+
+// if($starttime == $endtime && $GLOBALS['phpgw']->common->show_date($starttime,'Hi') == 0)
+// {
+// $endtime = mktime(23,59,59,$GLOBALS['phpgw']->common->show_date($starttime,'m'),$GLOBALS['phpgw']->common->show_date($starttime,'d') + 1,$GLOBALS['phpgw']->common->show_date($starttime,'Y')) - $this->datetime->tz_offset;
+// }
+//
+// - $sql = 'AND ((('.$starttime.' <= phpgw_cal.datetime) AND ('.$endtime.' >= phpgw_cal.datetime) AND ('.$endtime.' <= phpgw_cal.edatetime)) '
+// . 'OR (('.$starttime.' >= phpgw_cal.datetime) AND ('.$starttime.' < phpgw_cal.edatetime) AND ('.$endtime.' >= phpgw_cal.edatetime)) '
+// - . 'OR (('.$starttime.' <= phpgw_cal.datetime) AND ('.$endtime.' >= phpgw_cal.edatetime)) '
+// - . 'OR (('.$starttime.' >= phpgw_cal.datetime) AND ('.$endtime.' <= phpgw_cal.edatetime))) ';
+//
+// if(count($participants) > 0)
+// {
+// $p_g = '';
+// if(count($participants))
+// {
+// $users = Array();
+// while(list($user,$status) = each($participants))
+// {
+// $users[] = $user;
+// }
+// if($users)
+// {
+// $p_g .= 'phpgw_cal_user.cal_login IN ('.implode(',',$users).')';
+// }
+// }
+// if($p_g)
+// {
+// $sql .= ' AND (' . $p_g . ')';
+// }
+// }
+//
+// if(count($id) >= 1)
+// {
+// @reset($id);
+// $sql .= ' AND phpgw_cal.cal_id NOT IN ('.(count($id)==1?$id[0]:implode(',',$id)).')';
+// }
+//
+// $sql .= ' ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
+//
+// $events = $this->so->get_event_ids(False,$sql);
+// if($events == False)
+// {
+// return false;
+// }
+//
+// $db2 = $GLOBALS['phpgw']->db;
+//
+// for($i=0;$i
\n";
+ echo ''."\n";
}
for($i=0;$i
\n";
+ echo ''."\n";
}
$inserted = True;
break;
@@ -1104,6 +1227,10 @@
{
$this->cached_events[$date][$j] = $this->cached_events[$date][$j-1];
}
+ if($this->debug)
+ {
+ echo ''."\n";
+ }
$inserted = True;
$this->cached_events[$date][$i] = $event;
break;
@@ -1112,6 +1239,10 @@
}
if(!$inserted)
{
+ if($this->debug)
+ {
+ echo ''."\n";
+ }
$this->cached_events[$date][] = $event;
}
}
@@ -1125,6 +1256,10 @@
$search_date_day = date('d',$datetime);
$search_date_dow = date('w',$datetime);
$search_beg_day = mktime(0,0,0,$search_date_month,$search_date_day,$search_date_year);
+ if($this->debug)
+ {
+ echo ''."\n";
+ }
$repeated = $this->repeating_events;
$r_events = count($repeated);
for ($i=0;$i<$r_events;$i++)
@@ -1142,7 +1277,13 @@
}
$end_recur_date = date('Ymd',$event_recur_time);
$full_event_date = date('Ymd',$event_beg_day);
-
+
+ if($this->debug)
+ {
+ echo ''."\n";
+ echo ''."\n";
+ }
+
// only repeat after the beginning, and if there is an rpt_end before the end date
if (($search_date_full > $end_recur_date) || ($search_date_full < $full_event_date))
{
@@ -1161,7 +1302,15 @@
switch($type)
{
case MCAL_RECUR_DAILY:
- if (floor(($search_beg_day - $event_beg_day)/86400) % $freq)
+ if($this->debug)
+ {
+ echo ''."\n";
+ }
+ if ($freq == 1 && $rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0 && $search_date_full <= $end_recur_date)
+ {
+ $this->sort_event($rep_events,$search_date_full);
+ }
+ elseif (floor(($search_beg_day - $event_beg_day)/86400) % $freq)
{
continue;
}
@@ -1260,7 +1409,10 @@
{
unset($owner_id);
$owner_id = $this->g_owner;
- echo ''."\n";
+ if($this->debug)
+ {
+ echo ''."\n";
+ }
}
if(!$eyear && !$emonth && !$eday)
@@ -1294,8 +1446,8 @@
if($this->debug)
{
- echo "Start Date : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n";
- echo "End Date : ".sprintf("%04d%02d%02d",$eyear,$emonth,$eday)."
\n";
+ echo ''."\n";
+ echo ''."\n";
}
if($owner_id)
@@ -1314,8 +1466,8 @@
if($this->debug)
{
- echo "events cached : $c_cached_ids : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n";
- echo "repeating events cached : $c_cached_ids_repeating : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n";
+ echo ''."\n";
+ echo ''."\n";
}
$this->cached_events = Array();
@@ -1325,7 +1477,6 @@
return;
}
- $this->cached_events = Array();
if($c_cached_ids)
{
for($i=0;$i<$c_cached_ids;$i++)
@@ -1348,13 +1499,13 @@
}
if($this->debug)
{
- echo "Date: ".$j." Count : ".$c_evt_day."
\n";
+ echo ''."\n";
}
if($this->cached_events[$j][$c_evt_day]['id'] != $event['id'])
{
if($this->debug)
{
- echo "Adding Event for Date: ".$j."
\n";
+ echo ''."\n";
}
$this->cached_events[$j][] = $event;
}
@@ -1369,11 +1520,30 @@
for($i=0;$i<$c_cached_ids_repeating;$i++)
{
$this->repeating_events[$i] = $this->so->read_entry($cached_event_ids_repeating[$i]);
+ if($this->debug)
+ {
+ echo ''."\n";
+ }
}
- $edate -= $this->datetime->tz_offset;
- for($date=mktime(0,0,0,$smonth,$sday,$syear) - $this->datetime->tz_offset;$date<$edate;$date += 86400)
+// $edate -= $this->datetime->tz_offset;
+// for($date=mktime(0,0,0,$smonth,$sday,$syear) - $this->datetime->tz_offset;$date<=$edate;$date += 86400)
+ for($date=mktime(0,0,0,$smonth,$sday,$syear);$date<=$edate;$date += 86400)
{
+ if($this->debug)
+ {
+// $search_date = $GLOBALS['phpgw']->common->show_date($date,'Ymd');
+ $search_date = date('Ymd',$date);
+ echo ''."\n";
+ }
$this->check_repeating_events($date);
+ if($this->debug)
+ {
+ echo ''."\n";
+ for($i=0;$i
\n";
- echo "userid = ".$userid."
\n";
+ echo ''."\n";
+ echo ''."\n";
}
if(!is_object($send))
{
@@ -1704,7 +1874,7 @@
if($this->debug)
{
- echo "Email being sent to: ".$to."
\n";
+ echo ''."\n";
}
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $part_prefs['common']['tz_offset'];
@@ -1810,7 +1980,7 @@
{
if($this->debug)
{
- echo "Modifying event for user ".$old_userid."
\n";
+ echo ''."\n";
}
$this->modified[intval($old_userid)] = $new_status;
}
@@ -1818,7 +1988,7 @@
{
if($this->debug)
{
- echo "Deleting user ".$old_userid." from the event
\n";
+ echo ''."\n";
}
$this->deleted[intval($old_userid)] = $old_status;
}
@@ -1830,7 +2000,7 @@
{
if($this->debug)
{
- echo "Adding event for user ".$new_userid."
\n";
+ echo ''."\n";
}
$this->added[$new_userid] = 'U';
$new_event['participants'][$new_userid] = 'U';
@@ -1869,7 +2039,7 @@
if($this->debug)
{
echo "
"; print_r($event); echo "