function eventMyAttendanceJson($siteSlug, $eventSlug, Request $request, Application $app)
 {
     if (!$this->build($siteSlug, $request, $app)) {
         $app->abort(404, "Site does not exist.");
     }
     $repo = new \repositories\EventRepository();
     $this->parameters['event'] = $repo->loadBySlug($this->parameters['site'], $eventSlug);
     if (!$this->parameters['event']) {
         $app->abort(404, "Event does not exist.");
     }
     $uaer = new UserAtEventRepository();
     $userAtEvent = $uaer->loadByUserAndEventOrInstanciate($app['currentUser'], $this->parameters['event']);
     $data = array();
     if ($request->request->get('CSFRToken') == $app['websession']->getCSFRToken() && !$this->parameters['event']->isInPast()) {
         if ($request->request->get('privacy') == 'public') {
             $userAtEvent->setIsPlanPublic(true);
         } else {
             if ($request->request->get('privacy') == 'private') {
                 $userAtEvent->setIsPlanPublic(false);
             }
         }
         if ($request->request->get('attending') == 'no') {
             $userAtEvent->setIsPlanAttending(false);
             $userAtEvent->setIsPlanMaybeAttending(false);
         } else {
             if ($request->request->get('attending') == 'maybe') {
                 $userAtEvent->setIsPlanAttending(false);
                 $userAtEvent->setIsPlanMaybeAttending(true);
             } else {
                 if ($request->request->get('attending') == 'yes') {
                     $userAtEvent->setIsPlanAttending(true);
                     $userAtEvent->setIsPlanMaybeAttending(false);
                 }
             }
         }
         $uaer->save($userAtEvent);
     }
     $data['attending'] = $userAtEvent->getIsPlanAttending() ? 'yes' : ($userAtEvent->getIsPlanMaybeAttending() ? 'maybe' : 'no');
     $data['privacy'] = $userAtEvent->getIsPlanPublic() ? 'public' : 'private';
     $data['inPast'] = $this->parameters['event']->isInPast() ? 1 : 0;
     $data['CSFRToken'] = $app['websession']->getCSFRToken();
     $response = new Response(json_encode($data));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
 protected function actionThingsToDoAfterGetUser(Application $app, UserAccountModel $user)
 {
     // events
     $uaerepo = new UserAtEventRepository();
     $eventsAdded = false;
     foreach ($this->parameters['afterGetUserAddEvents'] as $event) {
         if ($event->getIsAllowedForAfterGetUser()) {
             $uae = $uaerepo->loadByUserAndEventOrInstanciate($user, $event);
             if (!$uae->getIsPlanAttending() && !$uae->getIsPlanMaybeAttending()) {
                 $uae->setIsPlanMaybeAttending(true);
                 $uaerepo->save($uae);
                 $eventsAdded = true;
             }
         }
     }
     if ($eventsAdded) {
         $app['flashmessages']->addMessage("Check out your personal calendar for events you are interested in!");
         // TODO add link
     }
     // areas
     $uwarepo = new UserWatchesAreaRepository();
     foreach ($this->parameters['afterGetUserAddAreas'] as $area) {
         if ($area->getIsAllowedForAfterGetUser()) {
             $uwarepo->startUserWatchingArea($user, $area);
         }
     }
     // reset
     $app['websession']->setArray("afterGetUserAddEvents", array());
     $app['websession']->setArray("afterGetUserAddAreas", array());
 }