1: <?php
2:
3: /**
4: * Project sberp
5: *
6: * @file Properties
7: * @author Jaromír Polášek
8: * @version 0.8.1.MODULES
9: * Encoding UTF-8
10: */
11:
12: namespace App\Modules\BaseModule\Presenters;
13:
14: use App\Modules\SettingsModule\Presenters\UsersPresenter;
15:
16: /**
17: * Presenter pro nastavení předvoleb uživatele
18: */
19: class PropertiesPresenter extends UsersPresenter {
20:
21: /**
22: * Default Render - předá parametr $user->id a přesměruje na renderShow()
23: * předává data do šablony
24: * @param integer $source Číslo akce
25: */
26: public function renderDefault($source) {
27: $this->source = $source;
28: $this->template->id = $this->id = $this->user->id;
29: $this->redirectDefault();
30: }
31:
32: /**
33: * Edit Render
34: * Upraví záznam v databázi
35: * @param integer $source Číslo akce
36: * @param integer $id Id požadovaného objeku
37: */
38: public function renderEdit($source, $id) {
39: if (strval($id) != $this->user->id) {
40: $this->redirect('edit', $this->source, $this->user->id);
41: }
42: parent::renderEdit($source, $id);
43: // $template = $this->template;
44: // $template->source = $this->source = $source;
45: // $template->id = $this->id = $id;
46: // $template->foot = $this->action->jidash;
47: // $form = $this['editForm'];
48: // if (!$form->isSubmitted()) {
49: // $row = $this->action->data;
50: // if (!$row) {
51: // $this->error('Záznam nenalezen');
52: // } else if ($row instanceof \Nette\Database\Table\ActiveRow) {
53: // $form['form']->setDefaults($row);
54: // }
55: // }
56: // $form->addProtection();
57: // $template->data = $form;
58:
59: }
60:
61: /**
62: * Show Render
63: * Zobrazí konkrétní záznam z databáze
64: * @param integer $source Číslo akce
65: * @param integer $id Id požadovaného objeku
66: */
67: public function renderShow($source, $id) {
68: if (strval($id) != $this->user->id) {
69: $this->redirect('show', $this->source, $this->user->id);
70: }
71: parent::renderShow($source, $id);
72: // $template = $this->template;
73: // $template->source = $this->source = $source;
74: // $template->id = $this->id = $id;
75: // $form = $this['showForm'];
76: // $form['cancel']->setDisabled(TRUE);
77: // if (!$form->isSubmitted()) {
78: // $row = $this->action->data;
79: // if (!$row) {
80: // $this->error('Záznam nenalezen');
81: // } else if ($row instanceof \Nette\Database\Table\ActiveRow) {
82: // $form['form']->setDefaults($row);
83: // }
84: // }
85: // $template->data = $form;
86: }
87:
88: /**
89: * Přesmětování na výchozí zobrazení
90: */
91: public function redirectDefault() {
92: $this->redirect('show', $this->source, $this->id);
93: }
94:
95: }
96: