1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace App\Presenters;
13:
14: use Nette\Security\IUserStorage,
15: App\Model\Action,
16: App\Lib\Statics\Cons;
17:
18: 19: 20: 21:
22: class SecurePresenter extends BasePresenter {
23:
24:
25: protected $userName = 'Unknown';
26:
27:
28: protected $action;
29:
30: 31: 32: 33:
34: public function injectAction(Action $action) {
35: $this->action = $action;
36: }
37:
38: 39: 40:
41: protected function beforeRender() {
42:
43: $this->template->action = $this->action;
44: parent::beforeRender();
45: }
46:
47: 48: 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: 66: 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: