Пример #1
0
 /**
  * @param Register $user
  */
 public function register(Register $user)
 {
     $this->headerData();
     $this->view->showView();
     if (!empty($user)) {
         $username = $user->getUsername();
         $password = $user->getPassword();
         $firstName = $user->getFirstName();
         $lastName = $user->getLastName();
         $email = $user->getEmail();
         $gender = $user->getGender();
         $user = new UsersModel($username, $password);
         /**
          * Save only username and password in table users
          */
         $user->save();
         $userData = User::createInstance()->getOneByName($username);
         $id = $userData->getId();
         $userInfo = new User_infoModel($gender, $firstName, $lastName, $email, $id);
         /**
          * save UserInfoController in table user_info
          */
         $userInfo->save();
         if ($id != null) {
             $this->redirectControllers('user', 'index');
         }
     }
     $this->view->part('footer');
 }
Пример #2
0
 public function authenticate(array $credentials)
 {
     $user = $this->usersModel->findOneBy(['login' => $credentials[self::USERNAME], 'password' => $credentials[self::PASSWORD]]);
     if (!$user) {
         throw new \Nette\Security\AuthenticationException('Používateľ so zadaným UID neexistuje!');
     }
     $roles = array_keys($this->userRolesModel->findAll()->where('[user_id] = %i', $user->user_id)->fetchAssoc('role_id'));
     return new \Nette\Security\Identity($user->user_id, $roles, (array) $user);
 }
Пример #3
0
 /**
  *This method parses user submitted login info 
  *
  *@param array $data The user information submitted inthe form data
  *@return void
  */
 public function postIndex()
 {
     //prepare user info to send to the database
     $data = array('email' => Input::get('email'), 'password' => Input::get('password'));
     //check if use exists
     $user = UsersModel::checkUser($data);
     //check if user was found
     if ($user) {
         //check if the passwords do not match
         if ($user['password'] != md5($data['password'])) {
             //reload the form with error message
             $data['error'] = 'Invalid Password. Try again!';
             //load the form
             View::render('login/form', $data);
         }
         //password is correct - set user data in session
         Session::set('userInfo', $user);
         //check if this is admin user, //redirect to the appropriate user
         if ($user['user_type'] == 'admin') {
             Redirect::to($user['user_type']);
         }
         //else, redirect to the home controller
         Redirect::to('home');
     } else {
         //compose the error information
         $data['error'] = 'User not found!';
         //reload the form with the error message
         View::render('login/form', $data);
     }
 }
Пример #4
0
 public function editFormValidate(UserEditForm $form)
 {
     $values = $form->getValues();
     $user = $this->usersModel->find($this->template->user_id);
     if (isset($values->oldPassword) && $user->password == sha1($values->oldPassword)) {
         $form->addError('Staré heslo sa nezhoduje');
     }
 }
Пример #5
0
 /**
  * 
  * @param \Repository\User $user
  * @return type
  */
 public function save(\Models\UsersModel $user)
 {
     $query = 'INSERT INTO users(username, password )
             VALUE (?, ?)';
     $param = [$user->getUsername(), $user->getPassword()];
     $this->db->query($query, $param);
     return $this->db->row();
 }
Пример #6
0
 /**
  * @param \Nette\Application\UI\Presenter $presenter
  */
 protected function configure(\Nette\Application\UI\Presenter $presenter)
 {
     parent::configure($presenter);
     $this->setModel($this->usersModel->getAllUsers());
     $this->setPrimaryKey($this->usersModel->getPrimaryKeyName());
     $this->setRememberState(TRUE);
     $this->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER);
     $this->addColumnText('name', 'Meno')->setSortable()->setFilterText();
     $this->addColumnText('surname', 'Priezvisko')->setSortable()->setFilterText();
     $this->addColumnText('personal_id', 'Rodné číslo')->setSortable()->setFilterText();
     $this->addColumnEmail('email', 'Email')->setSortable()->setFilterText();
     $this->addColumnText('address', 'Adresa')->setSortable()->setFilterText();
     $this->addColumnDate('employed_from', 'Zamestnaný od')->setSortable()->setFilterText();
     $this->addColumnDate('employed_to', 'Zamestnaný do')->setSortable()->setFilterText();
     $this->addColumnText('role_name', 'Rola')->setSortable()->setFilterText();
     $this->addActionHref('edit', '')->setIcon('pencil')->getElementPrototype()->setTitle('Upraviť');
     $this->addActionHref('delete', '', 'delete!')->setIcon('trash icon-white')->setConfirm('Naozaj chcete odstrániť záznam?')->setElementPrototype(Html::el('a')->addClass('btn btn-danger btn-mini')->setTitle('Zmazať'));
 }
Пример #7
0
 /**
  * @param RegistrationForm
  */
 public function registrationFormValidate(RegistrationForm $form)
 {
     $values = $form->getValues();
     foreach ($this->usersModel->getUsersLogin() as $user) {
         if ($user->login == $values->login) {
             $form->addError('Tento login je uz použitý');
         }
     }
 }
 /**
  *This method loads the admin  homepage 
  *
  *@param null
  *@return void
  */
 public function getIndex()
 {
     // get a list of all  users fromt he database
     $users = UsersModel::all();
     $data['users'] = $users->result();
     $online = LogModel::where('online = ?', true)->count();
     $data['online'] = $online->num_rows();
     //get the ending date today
     View::render('admin/home', $data);
 }
 /**
  *This method parses user submitted signup info 
  *
  *@param array $data The post submited form data
  *@return void
  */
 public function postIndex()
 {
     //prepare the user information for sending to the database
     $data = array('email' => Input::get('email'), 'password' => md5(Input::get('password')), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'user_type' => 'user');
     //call model to insert records into the database
     $userCreated = UsersModel::save($data);
     //check if user was created
     if ($userCreated->lastInsertId()) {
         //redirect user to the login page
         Redirect::to('login');
     }
 }
Пример #10
0
 /**
  * @param int $car_id
  */
 public function actionEditDriver($car_id)
 {
     $driver = $this->carsModel->getDriverData($car_id);
     $car = $this->usersModel->getDriversEdit($car_id);
     if (!$car) {
         $this->error();
     }
     //		dump($car);die();
     $this->template->car = $car_id;
     $form = $this['driverForm'];
     $form->addSelect('user_id', 'Zmeniť šoféra na')->setRequired();
     $form['user_id']->setItems($car);
     if ($driver) {
         $form->setDefaults($this->usersModel->getDriverEdit($car_id));
     }
     $form->addSubmit('ok', 'Upraviť');
     $form->onSuccess[] = $this->driverFormEdit;
 }
 /**
  *This method update a users physical address information into the database.
  *@param int $user_id The id of the user to update password
  *@return void
  */
 public function updateAddress($user_id)
 {
     $update = UsersModel::saveById(array('id' => $user_id, 'country' => Input::get('country'), 'state' => Input::get('state'), 'city' => Input::get('city'), 'zip' => Input::get('zip')));
     if ($update->updateSuccess()) {
         Redirect::to(array('home'));
     }
 }
 /**
  *This method loads the login form 
  *
  *@param null
  *@return void
  */
 public function getLogout()
 {
     LogModel::where('id = ?', Session::get('log_id'))->save(array('online' => false));
     UsersModel::where('id = ?', Session::get('userInfo')['id'])->save(array('online' => false));
     //destry all session data
     Session::flush();
     //load the login form
     View::render('login/form');
 }