Ignore:
Timestamp:
05/12/11 11:52:50 (13 years ago)
Author:
afernandes
Message:

Ticket #1416 - Disponibilizado módulo de recursos para a comunidade

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/Resources/inc/class.boresources.inc.php

    r3524 r4362  
    267267                        } 
    268268 
    269                         /*$this->so = CreateObject('resources.soresources', 
     269                        $this->so = CreateObject('calendar.socalendar', 
    270270                                Array( 
    271271                                        'owner'         => $this->owner, 
     
    274274                                        'g_owner'       => $this->g_owner 
    275275                                ) 
    276                         );*/ 
     276                        ); 
    277277                        $this->rpt_day = array( // need to be after creation of soresources 
    278278                                MCAL_M_SUNDAY    => 'Sunday', 
     
    589589 
    590590                        $event = $this->so->read_entry($id); 
    591                                 echo $event; 
     591                                //echo $event; 
    592592                         
    593593                         
    594594                        return False; 
     595                } 
     596                 
     597                 
     598        function read_entry2($id,$ignore_acl=False) 
     599                { 
     600                         
     601                         
     602                                $event = $this->so->read_entry($id); 
     603                                if(!isset($event['participants'][$this->owner]) && $this->user_is_a_member($event,$this->owner)) 
     604                                { 
     605                                        $this->so->add_attribute('participants','U',(int)$this->owner); 
     606                                        $this->so->add_entry($event); 
     607                                        $event = $this->get_cached_event(); 
     608                                } 
     609                                return $this->xmlrpc ? $this->xmlrpc_prepare($event) : $event; 
     610                         
    595611                } 
    596612 
     
    774790 
    775791                         
     792                         
    776793                        $send_to_ui = True; 
    777794                        //if ((!is_array($l_start) || !is_array($l_end)) && !isset($_GET['readsess']))  // xmlrpc call 
     
    799816                                        foreach($params['participants'] as $user => $data) 
    800817                                        { 
     818                                                 
    801819                                                $l_participants[] = $user.$data['status']; 
    802820                                        } 
     
    12041222                                } 
    12051223 
     1224                                 
    12061225                                $overlapping_events = $this->overlap( 
    12071226                                        $this->maketime($event['start']), 
     
    14711490                } 
    14721491 
    1473                 function overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False) 
     1492        function overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False,$location='n/a') 
    14741493                { 
    14751494//                      $retval = Array(); 
     
    14781497/* This needs some attention.. by commenting this chunk of code it will fix bug #444265 */ 
    14791498 
     1499                        //        foreach($id as $c=>$v) 
     1500                  //   echo "<p>El 565vector con indice $c tiene el valor $v </p>"; 
     1501                 
     1502                         
     1503                         
    14801504                        if($restore_cache) 
    14811505                        { 
     
    14881512//                      $temp_end_time = (int)$GLOBALS['phpgw']->common->show_date($endtime,'Hi'); 
    14891513                        $temp_start = (int)(date('Ymd',$starttime)); 
     1514 
    14901515                        $temp_start_time = (int)(date('Hi',$starttime)); 
    14911516                        $temp_end = (int)(date('Ymd',$endtime)); 
    14921517                        $temp_end_time = (int)(date('Hi',$endtime)); 
     1518                //      echo "<br>inicio".$temp_start_time." <br> fin ".$temp_end_time."<br>   ".(int)(date('Hi a',$endtime))."<br>"; 
     1519                //      echo "<br>inicio".$temp_start." <br> fin ".$temp_end."<br>   ".(int)(date('Hi a',$endtime))."<br>"; 
     1520                         
    14931521                        if($this->debug) 
    14941522                        { 
     
    15091537                                $users[] = $this->owner; 
    15101538                        } 
     1539 
    15111540 
    15121541                        $possible_conflicts = $this->store_to_cache( 
     
    15181547                                        'eday'  => substr(strval($temp_end),6,2), 
    15191548                                        'eyear' => substr(strval($temp_end),0,4), 
    1520                                         'owner' => $users 
     1549                                        'owner' => $users, 
     1550                                        'location'      => $location 
    15211551                                ) 
    15221552                        ); 
     
    15271557                                echo '<!-- Possible Conflicts ('.$temp_start.'): '.count($possible_conflicts[$temp_start]).' '.count($id).' -->'."\n"; 
    15281558                        } 
    1529  
     1559//echo "aaa".$possible_conflicts[$temp_start]; 
     1560//echo "bbbb".$possible_conflicts[$temp_end]; 
    15301561                        if($possible_conflicts[$temp_start] || $possible_conflicts[$temp_end]) 
    15311562                        { 
     
    15691600                                                        $temp_event_end = sprintf("%d%02d",$event['end']['hour'],$event['end']['min']); 
    15701601//                                                      if((($temp_start_time <= $temp_event_start) && ($temp_end_time >= $temp_event_start) && ($temp_end_time <= $temp_event_end)) || 
     1602 
     1603 
     1604                        /*}*/ 
     1605 
     1606 
     1607 
    15711608                                                        if(($temp_start_time <= $temp_event_start && 
    1572                                                                 $temp_end_time > $temp_event_start && 
    1573                                                                 $temp_end_time <= $temp_event_end || 
    1574                                                                 $temp_start_time >= $temp_event_start && 
    1575                                                                 $temp_start_time < $temp_event_end && 
    1576                                                                 $temp_end_time >= $temp_event_end || 
    1577                                                                 $temp_start_time <= $temp_event_start && 
    1578                                                                 $temp_end_time >= $temp_event_end || 
    1579                                                                 $temp_start_time >= $temp_event_start && 
    1580                                                                 $temp_end_time <= $temp_event_end) && 
    1581                                                                 $this->participants_not_rejected($participants,$event)) 
     1609                                                                $temp_end_time >= $temp_event_start && 
     1610                                                                $temp_end_time <= $temp_event_end) || 
     1611                                                                ($temp_start_time <= $temp_event_start && 
     1612                                                                $temp_end_time >= $temp_event_start && 
     1613                                                                $temp_end_time >= $temp_event_end)|| 
     1614                                                                ($temp_start_time <= $temp_event_start && 
     1615                                                                $temp_end_time >= $temp_event_end) ||            
     1616 
     1617                                                                ($temp_start_time >= $temp_event_start && 
     1618                                                                $temp_start_time <= $temp_event_end && 
     1619                                                                $temp_end_time >= $temp_event_end) || 
     1620                                                                 
     1621                                                                ($temp_start_time >= $temp_event_start && 
     1622                                                                $temp_end_time <= $temp_event_end))  
    15821623                                                        { 
    15831624                                                                if($this->debug) 
     
    15851626                                                                        echo ' Conflicts'; 
    15861627                                                                } 
    1587                                                                 $retval[] = $event['id']; 
     1628                                                                $retval[] = $event; 
    15881629                                                        } 
    15891630                                                        if($this->debug) 
     
    15971638                        else 
    15981639                        { 
    1599                                 $retval = False; 
     1640                                $retval1 = False; 
     1641                                $retval = Array(); 
    16001642                        } 
    16011643 
     
    20222064                        } 
    20232065                        $repeated = $this->repeating_events; 
     2066 
     2067//echo $repeated."repeat<br>" ; 
    20242068                        $r_events = count($repeated); 
     2069//echo $r_events."  ".$this->repeating_event[1]. "repeat23<br>" ; 
    20252070                        for ($i=0;$i<$r_events;$i++) 
    20262071                        { 
    20272072                                $rep_events = $this->repeating_events[$i]; 
     2073 
    20282074                                $id = $rep_events['id']; 
     2075//echo $id; 
    20292076                                $event_beg_day = mktime(0,0,0,$rep_events['start']['month'],$rep_events['start']['mday'],$rep_events['start']['year']); 
    20302077                                if($rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0) 
     
    21602207                                return False; 
    21612208                        } 
    2162                         if (isset($params['start']) && ($datearr = $GLOBALS['server']->iso86012date($params['start']))) 
     2209$location=$params['location']; 
     2210 
     2211        //echo "location".$location;             
     2212        if (isset($params['start']) && ($datearr = $GLOBALS['server']->iso86012date($params['start']))) 
    21632213                        { 
    21642214                                $syear = $datearr['year']; 
     
    22192269                                //Se $emonth nao tem valor, recebe o valor de $smonth (que recebe $params['smonth']) e soma 1. 
    22202270                                //O valor $params['emonth'] indica o mes final para a pesquisa de eventos, e passou a ser 
    2221                                 //informado na a impressao de eventos mensais. Mudancas feitas em class.uiresources.inc.php,  
     2271                                //informado na a impressao de eventos mensais. Mudancas feitas em class.uicalendar.inc.php,  
    22222272                                //function display_month_print(); 
    22232273                                if(!$emonth) 
     
    22362286                                $edate = mktime(23,59,59,$emonth,$eday,$eyear); 
    22372287                        } 
    2238                         //echo "<p>boresources::store_to_cache(".print_r($params,True).") syear=$syear, smonth=$smonth, sday=$sday, eyear=$eyear, emonth=$emonth, eday=$eday, xmlrpc='$param[xmlrpc]'</p>\n"; 
     2288                        //echo "<p>bocalendar::store_to_cache(".print_r($params,True).") syear=$syear, smonth=$smonth, sday=$sday, eyear=$eyear, emonth=$emonth, eday=$eday, xmlrpc='$param[xmlrpc]'</p>\n"; 
    22392289                        if($this->debug) 
    22402290                        { 
     
    22482298                        if($owner_id) 
    22492299                        { 
    2250                                 $cached_event_ids = "";//$this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id); 
    2251                                 $cached_event_ids_repeating = "";//$this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id); 
     2300 
     2301                                $cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id,$location); 
     2302                                $cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id,$location); 
    22522303                        } 
    22532304                        else 
    22542305                        { 
    2255                                 $cached_event_ids = "";//$this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday); 
    2256                                 $cached_event_ids_repeating = "";//$this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday); 
     2306 
     2307                                $cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday,0,$location); 
     2308                                $cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,0,$location); 
    22572309                        } 
    22582310 
    22592311                        $c_cached_ids = count($cached_event_ids); 
    22602312                        $c_cached_ids_repeating = count($cached_event_ids_repeating); 
    2261  
     2313//echo "totaless".$c_cached_ids." -  ".$c_cached_ids_repeating; 
    22622314                        if($this->debug) 
    22632315                        { 
     
    22742326 
    22752327                        $cache_start = (int)(sprintf("%04d%02d%02d",$syear,$smonth,$sday)); 
     2328 
    22762329                        $cached_event=$this->get_cached_event(); 
     2330 
    22772331                        if($c_cached_ids) 
    22782332                        { 
     2333 
    22792334                                for($i=0;$i<$c_cached_ids;$i++) 
    22802335                                { 
    2281                                         $event = "";//$this->so->read_entry($cached_event_ids[$i]); 
     2336                                        $event = $this->so->read_entry($cached_event_ids[$i]); 
     2337 
     2338//echo "<br>antrrrrroooo".$event['start']."  a ".$event['end']." b ".$event['id']; 
    22822339                                        if ($event['recur_type']) 
    22832340                                        { 
     
    22872344                                        $enddate = (int)(date('Ymd',$this->maketime($event['end']))); 
    22882345                                        $this->cached_events[$startdate][] = $event; 
     2346//echo "ver".$event['recur_type'].$startdate." ---".$enddate."<br>antrrrrroooo";; 
    22892347                                        if($startdate != $enddate) 
    22902348                                        { 
     
    22942352                                                for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=(int)(date('Ymd',mktime(0,0,0,$start['month'],$start['mday'] + $k,$start['year'])))) 
    22952353                                                { 
     2354 
     2355 
    22962356                                                        $c_evt_day = count($this->cached_events[$j]) - 1; 
     2357//echo "<br>aaaa".$c_evt_day."<br>antrrrrroooo"; ; 
    22972358                                                        if($c_evt_day < 0) 
    22982359                                                        { 
     
    23102371                                                                } 
    23112372                                                                $this->cached_events[$j][] = $event; 
     2373//echo "<br>llll:".$event."<br>antrrrrroooo";; 
    23122374                                                        } 
    23132375                                                        if ($j >= $cache_start && (@$params['no_doubles'] || @$this->xmlrpc)) 
     
    23232385                        if($c_cached_ids_repeating) 
    23242386                        { 
     2387//echo "repeaiting".$c_cached_ids_repeating; 
     2388 
    23252389                                for($i=0;$i<$c_cached_ids_repeating;$i++) 
    23262390                                { 
    2327                                         $this->repeating_events[$i] = "";//$this->so->read_entry($cached_event_ids_repeating[$i]); 
     2391                                        $this->repeating_events[$i] = $this->so->read_entry($cached_event_ids_repeating[$i]); 
     2392//echo "abc".$this->repeating_events[$i]."<br>"; 
    23282393                                        if($this->debug) 
    23292394                                        { 
     
    23392404                                        } 
    23402405                                        $this->check_repeating_events($date); 
     2406 
     2407 
    23412408                                        if($this->debug) 
    23422409                                        { 
     
    23492416                                } 
    23502417                        } 
     2418 
     2419//echo "countt".count($this->cached_events); 
    23512420                        $retval = Array(); 
    23522421                        for($j=date('Ymd',mktime(0,0,0,$smonth,$sday,$syear)),$k=0;$j<=date('Ymd',mktime(0,0,0,$emonth,$eday,$eyear));$k++,$j=date('Ymd',mktime(0,0,0,$smonth,$sday + $k,$syear))) 
    23532422                        { 
     2423//echo "vueltaaaa".$j."<br>"; 
    23542424                                if(is_array($this->cached_events[$j])) 
    23552425                                { 
     
    23592429                                                { 
    23602430                                                        $retval[] = $this->xmlrpc_prepare($event); 
     2431//echo "cachhhhhheeeeeqqq2222".$this->xmlrpc_prepare($event)."<br>"; 
    23612432                                                } 
    23622433                                        } 
     
    23642435                                        { 
    23652436                                                $retval[$j] = $this->cached_events[$j]; 
    2366                                         } 
    2367                                 } 
     2437                                                //foreach($this->cached_events[$j][0] as $c=>$v) 
     2438                                                //echo "<p>El vector con indice $c tiene el valor $v </p>"; 
     2439//echo "cachhhhhheeeeeqqq".$this->cached_events[$j][0]['public']."<br>"; 
     2440                                        } 
     2441                                } 
     2442 
     2443 
    23682444                        } 
    23692445                        //echo "store_to_cache(".print_r($params,True).")=<pre>".print_r($retval,True)."</pre>\n"; 
    2370                         //$this->so->cal->event = $cached_event; 
     2446                        $this->so->cal->event = $cached_event; 
    23712447                        return $retval; 
    23722448                } 
Note: See TracChangeset for help on using the changeset viewer.