[6351] | 1 | <?php |
---|
| 2 | |
---|
[6357] | 3 | use prototype\api\Config as Config; |
---|
| 4 | |
---|
[6351] | 5 | class CalendarLastResource extends Resource{ |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | /** |
---|
| 9 | * Busca os eventos contidos nas agendas assinas do usuário |
---|
| 10 | * |
---|
| 11 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 12 | * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
| 13 | * @sponsor Caixa EconÃŽmica Federal |
---|
| 14 | * @author Adriano Coutinho da Silva |
---|
| 15 | * @return Lista dos ultimos 10 eventos do usuário |
---|
| 16 | * @access public |
---|
| 17 | **/ |
---|
| 18 | function GET($request){ |
---|
| 19 | $this->secured(); |
---|
| 20 | |
---|
| 21 | $calendar = Controller::find( array( 'concept' => 'calendarSignature' ), array('calendar'), array( 'filter' => array( '=', 'user', Config::me("uidNumber") ) ) ); |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | if($calendar){ |
---|
| 27 | $calendars = array(); |
---|
| 28 | $timezones = array(); |
---|
| 29 | |
---|
| 30 | foreach($calendar as $key => $value) |
---|
| 31 | array_push($calendars, $value['calendar']); |
---|
| 32 | |
---|
| 33 | $calendarTimezone = Controller::find( array( 'concept' => 'calendar' ), array('id', 'timezone'), array( 'filter' => array( 'IN', 'id', $calendars ) ) ); |
---|
| 34 | |
---|
| 35 | foreach($calendarTimezone as $key => $value) |
---|
| 36 | $timezones[ $value['id'] ] = $value['timezone']; |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | $schedulables = Controller::find( array( 'concept' => 'schedulable' ), false, |
---|
| 40 | array( 'filter' => array('AND', array('>=','rangeStart', (time() - 86400).'000'), array('<=','rangeEnd', (time() + 2592000).'000') ,array( 'IN', 'calendar', $calendars )), 'deepness' => 2, 'timezones' => $timezones) ); |
---|
| 41 | |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | $response = new Response($request); |
---|
| 45 | $response->code = Response::OK; |
---|
| 46 | $response->addHeader('Content-type', 'aplication/json'); |
---|
| 47 | |
---|
| 48 | $response->body = json_encode(( isset($schedulables) && $schedulables) ? $schedulables : array()); |
---|
| 49 | return $response; |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | ?> |
---|