Overview

Namespaces

  • Budovy
  • Kdyby
    • BootstrapFormRenderer
      • DI
      • Latte
  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • Nextras
    • Datagrid
  • None
  • PHP
  • Tester
    • CodeCoverage
    • Runner
      • Output
  • Vodacek
    • Forms
      • Controls
  • WebLoader
    • Filter
    • Nette

Classes

  • AuthorizeScheduledTaskFactory
  • AuthorizeScheduledTaskPresenter
  • BasePresenter
  • BreakdownFactory
  • BreakdownPresenter
  • BreakdownRepository
  • BreakdownStatisticFactory
  • BreakdownStatisticPresenter
  • ContactBindingFactory
  • ContactbindingPresenter
  • ContactBindingRepository
  • ContactFactory
  • ContactPresenter
  • ContactRepository
  • DocumentFactory
  • DocumentPresenter
  • DocumentRepository
  • DocumentsDatagrid
  • DocumenttypeFactory
  • DocumenttypePresenter
  • DocumenttypeRepository
  • DownloadPresenter
  • EmailPresenter
  • ErrorPresenter
  • HomepagePresenter
  • OperationFactory
  • OperationPresenter
  • OperationRepository
  • PeriodicTaskFactory
  • PeriodicTaskPresenter
  • PeriodicTaskRealizationFactory
  • PeriodicTaskRealizationPresenter
  • PeriodicTaskRealizationRepository
  • PeriodicTaskRepository
  • PeriodicTaskStatisticFactory
  • PeriodicTaskStatisticPresenter
  • PlaceFactory
  • PlacePresenter
  • PlaceRepository
  • PriorityFactory
  • PriorityPresenter
  • PriorityRepository
  • Repository
  • RoleRepository
  • RouterFactory
  • ScheduledTaskFactory
  • ScheduledTaskPresenter
  • ScheduledTaskRealizationFactory
  • ScheduledTaskRealizationPresenter
  • ScheduledTaskRealizationRepository
  • ScheduledTaskRepository
  • ScheduledTaskStatisticFactory
  • ScheduledTaskStatisticPresenter
  • SignPresenter
  • UnitFactory
  • UnitPresenter
  • UnitRepository
  • UserFactory
  • UserManager
  • UserPresenter
  • UserRepository
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace Budovy;
 3: 
 4: class UserPresenter extends BasePresenter {
 5:     /** @var Budovy\UserRepository @inject */
 6:     public $userRepository;
 7: 
 8:     /** @var UserFactory @inject */
 9:     public $userFactory;
10: 
11:     protected function createComponentGrid() {
12:         $session = $this->getSession()->getSection('history');
13:         $session->secuser = (string)$this->getHttpRequest()->getUrl();
14: 
15:         return $this->userFactory->createDataGrid();
16:     }
17: 
18:     public function actionEdit($id) {
19:         $item = $this->userRepository->findById($id);
20: 
21:         if ($id > 0 && $item === false) {
22:             $this->redirect('default');
23:         }
24: 
25:         if ($id > 0) {
26:             $this['editForm']->setDefaults($item);
27:         }
28: 
29:         $this->template->id = $id;
30:     }
31: 
32:     protected function createComponentEditForm() {
33:         $session = $this->getSession()->getSection('history');
34: 
35:         if (isset($session->secuser)) {
36:             $backlink = $session->secuser;
37:         } else {
38:             $backlink = $this->link('default');
39:         }
40: 
41:         $form = $this->userFactory->createEditForm($backlink);
42:         $form->onSuccess[] = $this->editFormSubmitted;
43: 
44:         return $form;
45:     }
46: 
47:     public function editFormSubmitted($form) {
48:         $fdata = $form->getValues();
49: 
50:         $id = $this->getParameter('id');
51:         $password = $fdata->password;
52: 
53:         unset($fdata->password);
54: 
55:         try {
56:             if ($id > 0) {
57:                 $this->userRepository->updateById($id, $fdata);
58: 
59:                 $this->flashMessage("Záznam byl upraven.", "success");
60:             } else {
61:                 $data = $this->userRepository->insertData($fdata);
62: 
63:                 $id = $data->id;
64: 
65:                 $this->flashMessage("Záznam byl vložen.", "success");
66:             }
67: 
68:             if (strlen($password) > 0) {
69:                 $this->userRepository->setPassword($id, $password);
70:             }
71:         } catch (\PDOException $e) {
72:             $this->flashMessage("Záznam nelze uložit. Login je již obsazen.", "error");
73:             $this->redirect('this');
74:         }
75: 
76:         $session = $this->getSession()->getSection('history');
77: 
78:         if (isset($session->secuser)) {
79:             $backlink = $session->secuser;
80:         } else {
81:             $backlink = $this->link('default');
82:         }
83: 
84:         $this->redirectUrl($backlink);
85:     }
86: 
87:     public function handleDelete($id) {
88:         try {
89:             $this->userRepository->deleteById($id);
90:             $this->flashMessage("Záznam byl smazán.", "success");
91:         } catch (\PDOException $e) {
92:             $this->flashMessage("Záznam nelze smazat!", "error");
93:         }
94: 
95:         $this->redirect('this');
96:     }
97: }
API documentation generated by ApiGen 2.8.0