/** * get the current active character for this user * -> EITHER - the current active one for the current user * -> OR - get the first active one * @return null|CharacterModel */ public function getActiveCharacter() { $activeCharacter = null; $controller = new Controller\Controller(); $currentActiveCharacter = $controller->getCharacter(); if (!is_null($currentActiveCharacter) && $currentActiveCharacter->getUser()->_id === $this->id) { $activeCharacter =& $currentActiveCharacter; } else { // set "first" found as active for this user if ($activeCharacters = $this->getActiveCharacters()) { $activeCharacter = $activeCharacters[0]; } } return $activeCharacter; }
/** * update session data for active character * @param int $systemId */ protected function updateCharacterSessionLocation($systemId) { $controller = new Controller(); $f3 = $this->getF3(); $systemId = (int) $systemId; if (($activeCharacter = $controller->getCharacter()) && $activeCharacter->_id === $this->characterId->_id) { $prevSystemId = (int) $f3->get(User::SESSION_KEY_CHARACTER_PREV_SYSTEM_ID); if ($prevSystemId === 0) { $f3->set(User::SESSION_KEY_CHARACTER_PREV_SYSTEM_ID, $systemId); } else { $f3->set(User::SESSION_KEY_CHARACTER_PREV_SYSTEM_ID, (int) $this->systemId); } } }