phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] calendar/inc class.bocalendar.inc.php,1.99


From: skwashd
Subject: [Phpgroupware-cvs] calendar/inc class.bocalendar.inc.php,1.99
Date: Sun, 4 Dec 2005 10:24:00 +0100

Update of calendar/inc

Modified Files:
     Branch: MAIN
            class.bocalendar.inc.php lines: +84 -16

Log Message:
fix for bug #3852

====================================================
Index: calendar/inc/class.bocalendar.inc.php
diff -u calendar/inc/class.bocalendar.inc.php:1.98 
calendar/inc/class.bocalendar.inc.php:1.99
--- calendar/inc/class.bocalendar.inc.php:1.98  Fri Nov 18 11:40:45 2005
+++ calendar/inc/class.bocalendar.inc.php       Sun Dec  4 09:24:34 2005
@@ -726,12 +726,13 @@

                                if(!isset($l_categories))
                                {
-                                       $l_categories = 0;
+                                       $l_categories = array();
+                                       $l_categories[] = 0;
                                }

-                               $is_public = ($l_cal['private'] == 
'public'?1:0);
+                               $is_public = ($l_cal['private'] == 'public' ? 1 
: 0);
                                $this->so->event_init();
-                               if(count($l_categories) >= 2)
+                               if ( is_array($l_categories) && 
count($l_categories) >= 2)
                                {
                                        
$this->so->set_category(implode(',',$l_categories));
                                }
@@ -829,7 +830,7 @@
                                {
                                        $minparts = $this->owner;
                                }
-                               
if(address@hidden($event['participants'][$l_cal['owner']]))
+                               
if(!isset($event['participants'][$l_cal['owner']]))
                                {
                                        
$this->so->add_attribute('owner',$minparts);
                                }
@@ -1156,7 +1157,7 @@

                function 
overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False)
                {
-//                     $retval = array();
+                       $retval = array();
 //                     $ok = False;

 /* This needs some attention.. by commenting this chunk of code it will fix 
bug #444265 */
@@ -1176,8 +1177,8 @@
                        $temp_end_time = intval(date('Hi',$endtime));
                        if($this->debug)
                        {
-                               echo '<!-- Temp_Start: '.$temp_start.' 
-->'."\n";
-                               echo '<!-- Temp_End: '.$temp_end.' -->'."\n";
+                               echo "<!-- Temp_Start: {$temp_start} (epoch 
{$starttime}) -->\n"
+                                       . "<!-- Temp_End: {$temp_end} (epoch 
{$endtime}) -->\n";
                        }

                        $users = array();
@@ -1195,10 +1196,10 @@

                        $possible_conflicts = $this->store_to_cache(
                                array(
-                                       'smonth'        => 
substr(strval($temp_start),4,2),
+                                       'smonth'=> 
substr(strval($temp_start),4,2),
                                        'sday'  => 
substr(strval($temp_start),6,2),
                                        'syear' => 
substr(strval($temp_start),0,4),
-                                       'emonth'        => 
substr(strval($temp_end),4,2),
+                                       'emonth'=> 
substr(strval($temp_end),4,2),
                                        'eday'  => 
substr(strval($temp_end),6,2),
                                        'eyear' => 
substr(strval($temp_end),0,4),
                                        'owner' => $users
@@ -1211,7 +1212,12 @@
                                echo '<!-- Possible Conflicts 
('.$temp_start.'): '.count($possible_conflicts[$temp_start]).' '.count($id).' 
-->'."\n";
                        }

-                       if($possible_conflicts[$temp_start] || 
$possible_conflicts[$temp_end])
+                       if ( !is_array($possible_conflicts) )
+                       {
+                               $possible_conflicts = array();
+                       }
+
+                       if( isset($possible_conflicts[$temp_start]) || 
isset($possible_conflicts[$temp_end]) )
                        {
                                if($temp_start == $temp_end)
                                {
@@ -1220,7 +1226,7 @@
                                                echo '<!-- Temp_Start == 
Temp_End -->'."\n";
                                        }
                                        
@reset($possible_conflicts[$temp_start]);
-                                       while(list($key,$event) = 
each($possible_conflicts[$temp_start]))
+                                       foreach ( 
$possible_conflicts[$temp_start] as $key => $event )
                                        {
                                                $found = False;
                                                if($id)
@@ -1277,10 +1283,72 @@
                                                }
                                        }
                                }
-                       }
-                       else
-                       {
-                               $retval = False;
+                               else
+                               {
+                                       foreach ( $possible_conflicts as 
$event_list )
+                                       {
+                                               if ( is_array($event_list) )
+                                               {
+                                                       foreach ($event_list as 
$event)
+                                                       {
+                                                               $found = False;
+                                                               if ( 
is_array($id) )
+                                                               {
+                                                                       foreach 
( $id as $key => $event_id)
+                                                                       {
+                                                                               
if($this->debug)
+                                                                               
{
+                                                                               
        echo '<!-- $id['.$key.'] = '.$id[$key].' = '.$event_id.' -->'."\n";
+                                                                               
        echo '<!-- '.$event['id'].' == '.$event_id.' -->'."\n";
+                                                                               
}
+                                                                               
if($event['id'] == $event_id)
+                                                                               
{
+                                                                               
        $found = True;
+                                                                               
}
+                                                                       }
+                                                               }
+                                                               if($this->debug)
+                                                               {
+                                                                       echo 
"<!-- Item found: $found -->\n";
+                                                               }
+                                                               if(!$found)
+                                                               {
+                                                                       
if($this->debug)
+                                                                       {
+                                                                               
echo "'<!-- \nChecking event id #{$event['id']}\n";
+                                                                       }
+                                                                       
$temp_event_start = mktime($event['start']['hour'], $event['start']['min'], 1, 
$event['start']['month'], $event['start']['day'], $event['start']['year']);
+                                                                       
$temp_event_end = mktime($event['end']['hour'], $event['end']['min']-1, 59, 
$event['end']['month'], $event['end']['day'], $event['end']['year']);
+                                                                       if ( 
$this->debug)
+                                                                       {
+                                                                               
echo "Temp Event Start (epoch) = $temp_event_start\n"
+                                                                               
        . "Temp Event End (epoch) = $temp_event_end\n";
+                                                                       }
+
+                                                                       if ( ( 
($starttime >= $temp_event_start && $starttime <= $temp_event_end )
+                                                                               
|| ($endtime <= $temp_event_end && $endtime >= $temp_event_start ) )
+                                                                               
&& !$this->participants_not_rejected($participants,$event) )
+                                                                       {
+                                                                               
if($this->debug)
+                                                                               
{
+                                                                               
        echo ' Conflicts';
+                                                                               
}
+                                                                               
$retval[] = $event['id'];
+                                                                       }
+                                                                       
if($this->debug)
+                                                                       {
+
+                                                                               
echo " -->\n";
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               if ( $this->debug )
+                               {
+                                       echo "<!-- \nretval = " . 
var_export($retval,true) . "-->\n";
+                               }
                        }

                        if($restore_cache)






reply via email to

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