/**
  * Initiated all important variable
  * and check if it a consim-user
  *
  * @access protected
  */
 protected function init()
 {
     //Check if user in consim
     if ($this->user->data['consim_register'] == 0) {
         //go to register page
         redirect($this->helper->route('consim_core_register'));
         return null;
     }
     // Add language file
     $this->user->add_lang_ext('consim/core', 'consim_common');
     $this->add_navlinks();
     //Check all finished Actions
     $this->actionService->finishedActions();
     //Get the ConSim-User
     $consim_user = $this->userService->getCurrentUser();
     // get User Skill and add to template
     $user_skills = $this->userSkillService->getCurrentUserSkills();
     //User Skill to Template
     $this->widgetService->userSkillWidget($this->userSkillService->sortSkillsByCategory($user_skills));
     // Get inventory and add to template
     $inventory = $this->inventoryService->getCurrentInventory();
     $this->widgetService->inventoryWidget($inventory);
     //Get Cash Assets and add to template
     $cashAssets = $this->assetService->getCurrentCashAsset();
     $this->widgetService->cashAssetsWidget($cashAssets);
     //Is User active?
     if ($consim_user->getActive()) {
         //get current action
         $action = $this->actionService->getCurrentAction();
         //Is User traveling?
         if ($action->getRouteId() > 0) {
             $this->widgetService->travelWidget($action);
         }
         // is user working?
         if ($action->getWorkId() > 0) {
             $this->widgetService->workWidget($action);
         }
     }
     //Get User-Location
     $user_location = $this->locationService->getCurrentLocation();
     //Experience to Template
     $this->widgetService->experienceWidget($consim_user);
     //Location to Template
     $this->widgetService->locationWidget($user_location);
     //Set Weather to Template
     try {
         $this->weatherService->loadWeatherFromProvinceID($user_location->getProvinceID())->setWeatherWidget();
     } catch (base $e) {
         $this->template->assign_var('OWM_ERROR', $this->user->lang($e->getMessage()));
     }
     // Set output vars for display in the template
     $this->template->assign_vars(array('TIME' => date("d.m.Y - H:i:s", time()), 'GO_TO_INFORMATION' => $this->helper->route('consim_core_activity'), 'U_OVERVIEW' => $this->helper->route('consim_core_index'), 'U_ACTIONLIST' => $this->helper->route('consim_core_action_list'), 'U_ASSET' => $this->helper->route('consim_core_asset')));
 }
Beispiel #2
0
 /**
  * End work
  *
  * @return void
  */
 public function endWorkAction()
 {
     $action_id = $this->request->variable('action_id', 0);
     //Check the request
     if (!$this->is_valid($action_id) || !check_form_key('working_end')) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     //Load ConsimUser
     $consim_user = $this->userService->getCurrentUser();
     //Check, if user active
     if (!$consim_user->getActive()) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     $action = $this->actionService->getCurrentAction();
     if ($action->getStatus() != 2) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     $action->userDone();
     redirect($this->helper->route('consim_core_work', array('action_id' => $action->getId())));
 }