Exemple #1
0
 /**
  * Return location of current user
  *
  * @return Location
  */
 public function getCurrentLocation()
 {
     if (null === $this->currentLocation) {
         $this->currentLocation = $this->getLocation($this->userService->getCurrentUser()->getLocationId());
     }
     return $this->currentLocation;
 }
 /**
  * Return the inventory of current user
  *
  * @return \consim\core\entity\InventoryItem[]
  */
 public function getCurrentInventory()
 {
     if (null === $this->currentInventory) {
         $this->currentInventory = $this->getInventory($this->userService->getCurrentUser()->getUserId());
     }
     return $this->currentInventory;
 }
 /**
  * Return the skills of current user
  *
  * @return \consim\core\entity\UserSkill[]|null
  */
 public function getCurrentUserSkills()
 {
     if (null === $this->currentUserSkills) {
         $this->currentUserSkills = $this->getUserSkills($this->userService->getCurrentUser()->getUserId());
     }
     return $this->currentUserSkills;
 }
 /**
  * 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')));
 }
Exemple #5
0
    /**
     * Get cash asset of current user
     *
     * @return \consim\core\entity\UserAsset[]
     */
    public function getCurrentBondAsset()
    {
        if (null != $this->currentBondAsset) {
            return $this->currentBondAsset;
        }
        $user = $this->userService->getCurrentUser();
        $bondAssets = array();
        $sql = 'SELECT ua.id, ua.user_id, ua.asset_id, a.type_id, at.name as type_name, a.name, a.short_name, ua.value,
				a.exchange_rate_value, a.exchange_rate_comma, a.nominal_value
			FROM ' . $this->container->getParameter('tables.consim.users_assets') . ' ua
			LEFT JOIN ' . $this->container->getParameter('tables.consim.assets') . ' a ON a.id = ua.asset_id 
			LEFT JOIN ' . $this->container->getParameter('tables.consim.asset_types') . ' at ON at.id = a.type_id
			WHERE ua.user_id = ' . $user->getUserId() . ' AND a.type_id = ' . self::BOND_TYPE;
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $bondAssets[] = $this->container->get('consim.core.entity.user_asset')->import($row);
        }
        $this->db->sql_freeresult($result);
        $this->currentBondAsset = $bondAssets;
        return $bondAssets;
    }
Exemple #6
0
    /**
     * Get current action from user
     *
     * @param int $user_id User ID
     * @return Action
     * @access public
     */
    public function getCurrentActionFromUser($user_id)
    {
        if (null !== $this->currentAction && $this->userService->getCurrentUser()->getUserId() == $user_id) {
            return $this->currentAction;
        }
        $sql = 'SELECT a.id, a.user_id, a.location_id, a.starttime, a.endtime, a.route_id, a.work_id, a.result, a.successful_trials, a.status
			FROM ' . $this->consim_action_table . ' a
			WHERE user_id = ' . (int) $user_id . ' AND status = ' . Action::active . ' OR status = ' . Action::mustConfirm;
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        return $this->container->get('consim.core.entity.action')->import($row);
    }
 /**
  * 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())));
 }