コード例 #1
0
 /**
  * Start travel
  *
  * @param $travel_id
  * @return void
  */
 public function startTravelAction($travel_id)
 {
     //Check the request
     if (!$this->is_valid($travel_id) || !check_link_hash($this->request->variable('hash', ''), 'travel_' . $travel_id)) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     //Load ConsimUser
     $consim_user = $this->userService->getCurrentUser();
     //Check, if user not active
     if ($consim_user->getActive()) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     //Get Infos about the Route
     $route = $this->routeService->findRoute($consim_user->getLocationId(), $travel_id);
     $now = time();
     $this->container->get('consim.core.entity.action')->setUserId($consim_user->getUserId())->setLocationId($consim_user->getLocationId())->setStartTime($now)->setEndTime($now + $route->getTime() / 10)->setRouteId($route->getId())->setResult('')->insert();
     //$consim_user->setLocation($travel_id);
     //$consim_user->save();
     //Reload the Consim Index
     redirect($this->helper->route('consim_core_index'));
 }
コード例 #2
0
ファイル: ActionController.php プロジェクト: Tacitus89/consim
 /**
  * Display travel action
  *
  * @param $action_id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showTravelAction($action_id)
 {
     $action = $this->actionService->getAction($action_id);
     //check if the user is owner of action
     if ($action->getUserId() != $this->userService->getCurrentUser()->getUserId() || $action->getRouteId() == 0) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     $now = time();
     $time = $action->getEndTime() - $now;
     $route = $this->routeService->getRoute($action->getRouteId());
     $location = $this->locationService->getLocationFromRoute($action->getLocationId(), $route);
     // Set output vars for display in the template
     $this->template->assign_vars(array('IS_TRAVELING' => TRUE, 'START_LOCATION_NAME' => $location['start']->getName(), 'START_LOCATION_IMAGE' => $location['start']->getImage(), 'START_LOCATION_TYPE' => $location['start']->getType(), 'START_LOCATION_PROVINCE' => $location['start']->getProvince(), 'START_LOCATION_COUNTRY' => $location['start']->getCountry(), 'START_TIME' => date("d.m.Y - H:i:s", $action->getStartTime()), 'END_LOCATION_NAME' => $location['end']->getName(), 'END_LOCATION_IMAGE' => $location['end']->getImage(), 'END_LOCATION_TYPE' => $location['end']->getType(), 'END_LOCATION_PROVINCE' => $location['end']->getProvince(), 'END_LOCATION_COUNTRY' => $location['end']->getCountry(), 'END_TIME' => date("d.m.Y - H:i:s", $action->getEndTime()), 'COUNTDOWN' => date("i:s", $time)));
     // Send all data to the template file
     return $this->helper->render('consim_traveling.html', $this->user->lang('CONSIM'));
 }