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