source: trunk/prototype/modules/calendar/interceptors/Helpers.php @ 5437

Revision 5437, 1.9 KB checked in by cristiano, 12 years ago (diff)

Ticket #2434 - Atualização modulo agenda e API

Line 
1<?php
2
3class Helpers {   
4
5    public static function futureEvent( $startTime , $rangeEnd )
6    {
7        //Verifica data   
8        list( $y1  , $m1 , $d1) = explode( '-' , $rangeEnd );
9               
10        $rangeEndMicrotime = gmmktime(0, 0, 0, $m1 , $d1, $y1);
11        $nowMicrotime =   gmmktime(0, 0, 0);
12       
13        if($rangeEndMicrotime < $nowMicrotime )
14            return false;
15       
16        if($rangeEndMicrotime  === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento.
17        {
18            $sTime = new DateTime( '@'.(int)($startTime / 1000) , new DateTimeZone('UTC') );           
19            $eventHour = (date_format( $sTime , 'H') * 3600) + (date_format( $sTime , 'i') * 60) + date_format( $sTime , 's');
20            $nowHour = (gmdate('H') * 3600) + (gmdate('i') * 60) + gmdate('s');
21           
22            if( $eventHour  <  $nowHour )
23                    return false;
24        }
25       return true;
26    }
27   
28    /**
29    * Resgata o organizador do evento
30    *
31    * @license    http://www.gnu.org/copyleft/gpl.html GPL
32    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
33    * @sponsor    Caixa Econômica Federal
34    * @author     Cristiano Corrêa Schmidt
35    * @access     public
36    */
37    protected static function getOrganizer( &$schedulable ) {
38         $f = Controller::find(array('concept' => 'participant') , false , array('deepness' => '1' , 'filter' => array('AND' , array('=', 'schedulable' , $schedulable ) , array('=', 'isOrganizer' , '1'))));
39         return ( isset( $f[0] ) ) ? $f[0] : false;
40    }
41   
42    public static function lg($print, $name = ''){
43        ob_start();
44        print "\n";
45        print $name . ": ";
46        print_r( $print );
47        $output = ob_get_clean();
48        file_put_contents( "/tmp/prototype.log", $output , FILE_APPEND );
49               
50    }
51
52}
53
54?>
Note: See TracBrowser for help on using the repository browser.