dao = $dao; } /** * Store the data into the $_SESSION PHP variable */ public function save() { $_SESSION['SessionData'] = $this; } /** * Retrieve the SessionData object from the $_SESSION PHP variable. Create a * new one if it is necessary. * @param \RAP\DAO $dao * @return \RAP\SessionData the SessionData object */ public static function get(DAO $dao) { if (!isset($_SESSION['SessionData'])) { $session = new SessionData($dao); $session->save(); } return $_SESSION['SessionData']; } public function setCallbackURL(CallbackHandler $callbackHandler, $callbackURL) { $this->callbackURL = $callbackHandler->filterCallbackURL($callbackURL); $this->callbackTitle = $callbackHandler->getCallbackTitle($callbackURL); $this->callbackLogo = $callbackHandler->getCallbackLogo($callbackURL); $this->save(); } public function getCallbackURL() { return $this->callbackURL; } public function getCallbackTitle() { return $this->callbackTitle; } public function getCallbackLogo() { return $this->callbackLogo; } /** * Perform a user search and store the results inside the session. This is * used for achieving the user selection using the dropdown menu in the join * request modal. * @param string $searchText */ public function searchUser($searchText) { $users = $this->dao->searchUser($searchText); $this->userSearchResults = []; foreach ($users as $user) { // this search shouldn't contains the user itself if ($user->id !== $this->user->id) { $searchResult = UserSearchResult::buildFromUser($user); array_push($this->userSearchResults, $searchResult); } } $this->save(); } /** * Update the user data model stored into the session after the primary * identity has changed, in order to avoid reading again the user data from * the database. * @param int $identityId */ public function updatePrimaryIdentity($identityId) { foreach ($this->user->identities as $identity) { $identity->primary = ($identity->id === $identityId); } } }