[5341] | 1 | <?php |
---|
| 2 | |
---|
[5437] | 3 | class Helpers { |
---|
[5341] | 4 | |
---|
| 5 | public static function futureEvent( $startTime , $rangeEnd ) |
---|
[5636] | 6 | { |
---|
[5615] | 7 | //Verifica data |
---|
| 8 | $range = new DateTime( '@'.(int)($rangeEnd / 1000) , new DateTimeZone('UTC') ); |
---|
| 9 | list( $y1 , $m1 , $d1) = explode( '-' , $range->format('y-m-d')); |
---|
[5341] | 10 | |
---|
| 11 | $rangeEndMicrotime = gmmktime(0, 0, 0, $m1 , $d1, $y1); |
---|
| 12 | $nowMicrotime = gmmktime(0, 0, 0); |
---|
| 13 | |
---|
| 14 | if($rangeEndMicrotime < $nowMicrotime ) |
---|
| 15 | return false; |
---|
| 16 | |
---|
| 17 | if($rangeEndMicrotime === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento. |
---|
| 18 | { |
---|
| 19 | $sTime = new DateTime( '@'.(int)($startTime / 1000) , new DateTimeZone('UTC') ); |
---|
| 20 | $eventHour = (date_format( $sTime , 'H') * 3600) + (date_format( $sTime , 'i') * 60) + date_format( $sTime , 's'); |
---|
| 21 | $nowHour = (gmdate('H') * 3600) + (gmdate('i') * 60) + gmdate('s'); |
---|
| 22 | |
---|
| 23 | if( $eventHour < $nowHour ) |
---|
| 24 | return false; |
---|
| 25 | } |
---|
| 26 | 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 | $f = Controller::find(array('concept' => 'participant') , false , array('deepness' => '1' , 'filter' => array('AND' , array('=', 'schedulable' , $schedulable ) , array('=', 'isOrganizer' , '1')))); |
---|
| 40 | return ( isset( $f[0] ) ) ? $f[0] : false; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | public static function lg($print, $name = ''){ |
---|
| 44 | ob_start(); |
---|
| 45 | print "\n"; |
---|
| 46 | print $name . ": "; |
---|
| 47 | print_r( $print ); |
---|
| 48 | $output = ob_get_clean(); |
---|
| 49 | file_put_contents( "/tmp/prototype.log", $output , FILE_APPEND ); |
---|
| 50 | |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | ?> |
---|