示例#1
0
 /**
  * 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')));
 }
示例#2
0
 /**
  * Start work
  *
  * return void
  */
 public function startWorkAction()
 {
     $work_id = $this->request->variable('work_id', 0);
     //Check the request
     if (!$this->is_valid($work_id) || !check_form_key('working')) {
         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 work
     $work = $this->workService->getWork($work_id);
     $user_skills = $this->userSkillService->getCurrentUserSkills();
     //Check condition
     if (!$work->canUserWork($user_skills)) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     $now = time();
     $this->container->get('consim.core.entity.action')->setUserId($consim_user->getUserId())->setLocationId($consim_user->getLocationId())->setStartTime($now)->setEndTime($now + $work->getDuration())->setWorkId($work->getId())->setResult('')->insert();
     redirect($this->helper->route('consim_core_index'));
 }