$f) $filter[$i] = self::parseFilter($f, $map); } else $filter[0] = isset($map[$filter[0]]) ? $map[$filter[0]] : $filter[0]; array_unshift($filter, $op); return( $filter ); } protected static function parseConcept($data, $map, $flip = false) { if (!is_array($data) || count($data) <= 0) return false; if ($flip === true) $map = array_flip($map); $new = array(); foreach ($data as $i => $v) if (array_key_exists($i, $map)) $new[$map[$i]] = $v; return $new; } protected static function parseOrder($data, $map) { $new = array(); if (!is_array($data)) $data = array($data); foreach ($data as $v) if (array_key_exists($v, $map)) $new[] = $map[$v]; return $new; } protected static function parsejustthese($data, $map, $flip = false) { if (!is_array($data) || count($data) <= 0) return false; if ($flip === true) $map = array_flip($map); $new = array(); foreach ($data as $v) if (array_key_exists($v, $map)) $new[] = $map[$v]; return $new; } protected static function parserCristeria($criteria, $map) { if (isset($criteria['filter'])) $criteria['filter'] = self::parseFilter($criteria['filter'], $map); if (isset($criteria['order'])) { $ord = self::parseOrder($criteria['order'], $map); if (count($ord) > 0) $criteria['order'] = $ord; else unset($criteria['order']); } return $criteria; } public static function futureEvent( $startTime , $rangeEnd ) { //Verifica data list( $y1 , $m1 , $d1) = explode( '-' , $rangeEnd ); $rangeEndMicrotime = gmmktime(0, 0, 0, $m1 , $d1, $y1); $nowMicrotime = gmmktime(0, 0, 0); if($rangeEndMicrotime < $nowMicrotime ) return false; if($rangeEndMicrotime === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento. { $sTime = new DateTime( '@'.(int)($startTime / 1000) , new DateTimeZone('UTC') ); $eventHour = (date_format( $sTime , 'H') * 3600) + (date_format( $sTime , 'i') * 60) + date_format( $sTime , 's'); $nowHour = (gmdate('H') * 3600) + (gmdate('i') * 60) + gmdate('s'); if( $eventHour < $nowHour ) return false; } return true; } /** * Resgata o organizador do evento * * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @sponsor Caixa Econômica Federal * @author Cristiano Corrêa Schmidt * @access public */ protected static function getOrganizer( &$schedulable ) { $f = Controller::find(array('concept' => 'participant') , false , array('deepness' => '1' , 'filter' => array('AND' , array('=', 'schedulable' , $schedulable ) , array('=', 'isOrganizer' , '1')))); return ( isset( $f[0] ) ) ? $f[0] : false; } public static function lg($print, $name = ''){ ob_start(); print "\n"; print $name . ": "; print_r( $print ); $output = ob_get_clean(); file_put_contents( "/tmp/prototype.log", $output , FILE_APPEND ); } } ?>