protected function buildIdentity($userID) { $userData = $this->usersModel->get($userID); if (!$userData) { throw new \Nette\Security\AuthenticationException('Neexistují odpovídající data o uživateli.', self::FAILURE); } unset($userData->id); $membershipData = $this->membershipModel->query("SELECT `group`.* FROM membership JOIN `group` ON `group`.id = membership.group_id WHERE membership.user_id = " . $userID)->fetchAll(); $roles = array(); foreach ($membershipData as $record) { $roles[] = $record->role_name; } $settings = $this->usersModel->query("SELECT * FROM `user_setting` WHERE user_id = {$userID}")->fetch(); if (!$settings) { $this->usersModel->query("INSERT INTO `user_setting` (`user_id`) VALUES ({$userID})"); $settings = $this->usersModel->query("SELECT * FROM `user_setting` WHERE user_id = {$userID}")->fetch(); } $settings = $settings->toArray(); unset($settings["user_id"]); $userData["settings"] = $settings; return new \Nette\Security\Identity($userID, $roles, $userData); }
public function renderDefault() { $this->template->subjects = $this->model->query("SELECT count(*) as total FROM sch_subject")->fetch(); $this->template->groups = $this->model->query("SELECT count(*) as total FROM `sch_group`")->fetch(); $this->template->teachers = $this->model->query("SELECT count(*) as total FROM `sch_teacher`")->fetch(); $this->template->students = $this->model->query("SELECT count(*) as total FROM `sch_student`")->fetch(); $this->template->classes = $this->model->query("SELECT count(*) as total FROM `sch_class`")->fetch(); }
public function renderDefault() { $this->template->users = $this->model->query("SELECT count(*) as total FROM user")->fetch(); $this->template->groups = $this->model->query("SELECT count(*) as total FROM `group`")->fetch(); $this->template->files = $this->model->query("SELECT count(*) as total FROM `file`")->fetch(); }