protected function startup()
{
parent::startup();
// Login check
if ($this->getName() != 'Admin:Sign') {
$role = $this->user->getRoles();
$roleCheck = $this->database->table("users_roles")->get($role[0]);
if ($roleCheck->admin_access == 0) {
$this->flashMessage($this->translator->translate('messages.sign.invalidLogin'), "error");
$this->redirect(':Admin:Sign:in');
}
if ($this->user->isLoggedIn()) {
} else {
if ($this->user->logoutReason === Nette\Security\IUserStorage::INACTIVITY) {
$this->flashMessage($this->translator->translate('messages.sign.youWereLoggedIn'), "note");
}
$this->redirect('Sign:in', array('backlink' => $this->storeRequest()));
}
}
if ($this->user->isLoggedIn()) {
$this->template->isLoggedIn = TRUE;
$this->template->member = $this->database->table("users")->get($this->user->getId());
}
// Set values from db
$this->template->settings = $this->database->table("settings")->fetchPairs("setkey", "setvalue");
$this->template->appDir = APP_DIR;
$this->template->signed = TRUE;
$this->template->langSelected = $this->translator->getLocale();
// Set language from cookie
if ($this->context->httpRequest->getCookie('language_admin') == '') {
$this->translator->setLocale($this->translator->getDefaultLocale());
} else {
$this->translator->setLocale($this->context->httpRequest->getCookie('language_admin'));
}
}