Beispiel #1
0
function unadcalendar_find_calendar(Slim\Route $route)
{
    global $app, $info;
    $curso = $route->getParam('cs');
    $email = $route->getParam('em');
    $gcVersion = $info['google/calendar']['version'];
    $clientId = $info['unadcalendar']['client_id'];
    $rqCalendar = google_calendar_find($gcVersion, $clientId, $curso)->body();
    $rqCalendar = json_decode($rqCalendar);
    if ($rqCalendar->status) {
        //no existe problemas
        $calendarId = $rqCalendar->calendar->id;
        $rqEvents = google_calendar_get_events($gcVersion, $clientId, $calendarId)->body();
        $rqEvents = json_decode($rqEvents);
        if (!$rqEvents->status) {
            return;
        }
        $mpEvent = _unadcalendar_map_events($calendarId, $rqEvents->events, $email);
        if (is_null($mpEvent)) {
            //existe problemas con el calendario
            //no hay eventos, se elimina el calendario
            google_calendar_delete($gcVersion, $clientId, $calendarId);
            return;
        }
        $request['name'] = get_course_by_code(JSON_COUSER, $rqCalendar->calendar->summary);
        $request['code'] = $rqCalendar->calendar->summary;
        $request['status'] = true;
        $request['calendar_id'] = $calendarId;
        $request['events'] = $mpEvent;
        $app->response()->body(json_encode($request));
        $app->stop();
    }
}
Beispiel #2
0
 /**
  * Test sets param when exists
  */
 public function testSetRouteParamWhenExists()
 {
     // Prepare route
     $requestUri = '/hello/mr/anderson';
     $route = new \Slim\Route('/hello/:first/:last', 'fooCallable');
     // Parse route params
     $this->assertTrue($route->matches($requestUri));
     // Get param
     $this->assertEquals('anderson', $route->getParam('last'));
     // Set param
     $route->setParam('last', 'smith');
     // Get new param
     $this->assertEquals('smith', $route->getParam('last'));
 }
Beispiel #3
0
function google_calendar_valid_client(Slim\Route $route)
{
    global $app;
    $clientId = $route->getParam('clientId');
    $data = Spyc::YAMLLoad(dirname(__FILE__) . "/client/{$clientId}.yaml");
    if (!isset($data['key']) || !isset($data['key_api']) || !isset($data['key_client'])) {
        $request = array('status' => false, 'message' => 'Denied ClientID o Params not found');
        $app->response()->body(json_encode($request));
        $app->response()->status(302);
        $app->stop();
    }
}