Overview

Namespaces

  • App
    • Components
    • Interfaces
    • Lib
      • Files
      • Forms
        • Controls
      • Html
      • Repair
      • Statics
    • Model
    • Modules
      • BaseModule
        • Presenters
      • PartnersModule
        • Presenters
      • ProductModule
        • Presenters
      • SaleModule
        • Model
        • Presenters
      • SettingsModule
        • Model
        • Presenters
      • StoreModule
        • Model
        • Presenters
    • Presenters
    • Router
  • PHP

Classes

  • DateTime
  • SplFileInfo

Interfaces

  • ArrayAccess
  • Countable
  • Exception
  • Iterator
  • Traversable
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Download
 1: <?php
 2: 
 3: /**
 4:  * Project sberp
 5:  *
 6:  * @file SecurePresenter 
 7:  * @author Jaromír Polášek
 8:  * @version 0.7.1.FORM
 9:  * Encoding UTF-8
10:  */
11: 
12: namespace App\Presenters;
13: 
14: use Nette\Security\IUserStorage,
15:     App\Model\Action,
16:     App\Lib\Statics\Cons;
17: 
18: /**
19:  * Presenter pro zabezpečený přístup. 
20:  * Kontroluje přihlášení, zpřístupňuje Action
21:  */
22: class SecurePresenter extends BasePresenter {
23: 
24:     /** @var string $userName Jméno aktuálně přihlášeného uživatele */
25:     protected $userName = 'Unknown';
26: 
27:     /** @var App\Model\Action $action Služba Akce */
28:     protected $action;
29: 
30:     /**
31:      * Získání závislosti Action
32:      * @param \App\Model\Action $action
33:      */
34:     public function injectAction(Action $action) {
35:     $this->action = $action;
36:     }
37: 
38:     /**
39:      * Před zavoláním render je nutbé službě Action předat paramery
40:      */
41:     protected function beforeRender() {
42:     //$this->action->params = $this->params;
43:     $this->template->action = $this->action;
44:     parent::beforeRender();
45:     }
46: 
47:     /**
48:      * Startup. Kontrola autentizace uživatele
49:      */
50:     protected function startup() {
51:     parent::startup();
52:     if (!$this->user->isLoggedIn()) {
53:         ($this->user->logoutReason === IUserStorage::INACTIVITY) ?
54:                 $this->flashMessage('Byly jste odhlášeni pro neaktivitu. Prosím přihlašte se znovu.') : NULL;
55:         $this->redirect(':Base:Sign:in', array('backlink' => $this->storeRequest()));
56:     } else {
57:         $this->action->params = $this->params;
58: 
59:         $this->template->table = ($sub = $this->subrequest()) ?
60:             str_replace('default', 'add', $sub) : NULL;
61:     }
62:     }
63: 
64:     /**
65:      * Generuje link pro subrequest
66:      * @return string
67:      */
68:     protected function subrequest() {
69:     return ($this->action->child !== NULL) ?
70:         $this->link(\App\Router\RouterFactory::getRouteString($this->action->child), array('source' => $this->action->child[Cons::COLUMN_ID],
71:             'backlink' => $this->storeRequest())) : NULL;
72:     }
73: 
74: }
75: 
sberp API API documentation generated by ApiGen