Overview

Namespaces

  • None
  • PHP

Classes

  • BasePresenter
  • CekarnaPresenter
  • ErrorPresenter
  • Model
  • NavstevaPresenter
  • PacientPresenter
  • SignPresenter

Functions

  • callback
  • dump
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Tento soubor je součástí projektu ErNISTo z předmetu A6N33LI Lékařská informatika
 4:  * v 1. ročníku magisterského studia oboru Biomedicínského inženýrství     
 5:  */
 6: 
 7: use Nette\Application\UI,
 8:     Nette\Security as NS;
 9: /**
10:  * Presenter, který zajišťije přihlášení a odhlášení uživatele. Založen na sandboxu dodávaném v Nette frameworku 
11:  */
12: class SignPresenter extends Nette\Application\UI\Presenter 
13: {
14:     /** @persistent */
15:     public $backlink = '';
16: 
17:         /**
18:      * Továrnička pro tvorbu přihlašovacího formuláře 
19:      * @return Nette\Application\UI\Form
20:      */
21:     protected function createComponentSignInForm()
22:     {
23:         $form = new UI\Form;
24:         $form->addText('username', 'Přihlašovací jméno',30)
25:             ->setRequired('Vyplňte přihlašovací jméno');
26: 
27:         $form->addPassword('password', 'Heslo',30)
28:             ->setRequired('Vyplňte heslo');
29: 
30:         $form->addCheckbox('remember', 'Zapamatovat si mě na tomto počítači');
31: 
32:         $form->addSubmit('send', 'Přihlásit');
33: 
34:         $form->onSuccess[] = callback($this, 'signInFormSubmitted');
35:         return $form;
36:     }
37: 
38: 
39:         /**
40:          * Zpracuje hodnoty z formuláře a pokusí se přihlásit uživatele
41:          * @param   Nette\Application\UI\Form     odeslaný formulář
42:          * @return  void
43:          */
44:     public function signInFormSubmitted($form)
45:     {
46:         try {
47:             $values = $form->getValues();
48:             if ($values->remember) {
49:                 $this->getUser()->setExpiration('+ 14 days', FALSE);
50:             } else {
51:                 $this->getUser()->setExpiration('+ 20 minutes', TRUE);
52:             }
53:             $this->getUser()->login($values->username, $values->password);
54:             $this->application->restoreRequest($this->backlink);
55:                         $this->redirect('Cekarna:view');
56: 
57:         } catch (NS\AuthenticationException $e) {
58:             $form->addError($e->getMessage());
59:         }
60:     }
61: 
62:         /**
63:          * Odhlásí uživatele a přesměruje ho na stránku přihlášení
64:          * @return  void
65:          */
66:     public function actionOut()
67:     {
68:         $this->getUser()->logout();
69:         $this->flashMessage('Byl jste odhlášen');
70:         $this->redirect('in');
71:     }
72: 
73: }
ErNISTo API documentation generated by ApiGen 2.6.1