function onConstruct() { if ($this->session->has("auth")) { //Retrieve its value $auth = $this->session->get("auth"); $this->organisation_id = $auth['organisation_id']; } $organisation = Organisation::findFirstById($this->organisation_id); $widget_name = str_replace('PRIME\\Themes\\' . ucwords($organisation->theme) . '\\Widgets\\', '', $this->router->getNamespaceName()) . "/" . $this->router->getControllerName(); $widget_name = strtolower(str_replace('_', ' ', $widget_name)); $this->widget_name = $widget_name; $this->theme = $organisation->theme; $this->view_dir = '../app/themes/' . $auth['theme'] . '/widgets/' . str_replace('PRIME\\Themes\\' . ucwords($organisation->theme) . '\\Widgets\\', '', $this->router->getNamespaceName()) . '/'; }
/** * Register authenticated user into session data * * @param Users $user */ private function _registerSession($user) { $organisation = Organisation::findFirstById($user->organisation_id); $database = OrgDatabase::findFirstByorganisation_id($user->organisation_id); $this->session->set('auth', array('email' => $user->email, 'image_path' => $user->image_path, 'role' => $user->role, 'full_name' => $user->full_name, 'organisation_id' => $user->organisation_id, 'theme' => $organisation->theme, 'db_name' => $database->db_name, 'organisation_name' => $organisation->name)); }