commit 2190aaa4c62d42707fa85a840e0b7a13fef10c44
Author: Filip Jani <jsem@filek.cz>
Date:   Tue Jun 11 15:15:13 2019 +0200

    Re #7607 vyhledávání pouze pro přihlášené, upravení menu

diff --git a/app/AdminModule/component/User/UserEditForm.php b/app/AdminModule/component/User/UserEditForm.php
index f32eb59..6475d4b 100644
--- a/app/AdminModule/component/User/UserEditForm.php
+++ b/app/AdminModule/component/User/UserEditForm.php
@@ -175,7 +175,7 @@ class UserEditForm extends Control
      */
     private function getRoles()
     {
-        return $this->roleRepository->findAll()->fetchPairs(RoleRepository::COLUMN_ID, RoleRepository::COLUMN_NAME);
+        return $this->roleRepository->getRolesForSelect();
     }
 }
 
diff --git a/app/AdminModule/component/User/UserGrid.php b/app/AdminModule/component/User/UserGrid.php
index 5b5ea64..b79028b 100644
--- a/app/AdminModule/component/User/UserGrid.php
+++ b/app/AdminModule/component/User/UserGrid.php
@@ -4,8 +4,13 @@
 namespace App\AdminModule\Components;
 
 
+use App\Model\Repository\BookRepository;
+use App\Model\Repository\RoleRepository;
 use App\Model\Repository\UserRepository;
+use App\Model\Repository\UserRoleRepository;
 use App\Utils\DataGrid\DataGrid;
+use Nette\Database\Table\ActiveRow;
+use Nette\Database\Table\Selection;
 use Ublaboo\DataGrid\Exception\DataGridException;
 
 class UserGrid extends DataGrid
@@ -14,10 +19,16 @@ class UserGrid extends DataGrid
      * @var UserRepository
      */
     private $userRepository;
+    /**
+     * @var RoleRepository
+     */
+    private $roleRepository;
 
-    public function __construct(UserRepository $userRepository)
+    public function __construct(UserRepository $userRepository,
+                                RoleRepository $roleRepository)
     {
         $this->userRepository = $userRepository;
+        $this->roleRepository = $roleRepository;
 
         parent::__construct();
     }
@@ -46,11 +57,32 @@ class UserGrid extends DataGrid
         $this->addColumnNumber(UserRepository::COLUMN_ID, 'ID')->setDefaultHide(TRUE);
         $this->addColumnText(UserRepository::COLUMN_USERNAME, 'Uživatel');
         $this->addColumnText(UserRepository::COLUMN_LOGIN, 'Login');
+        $this->addColumnText(RoleRepository::COLUMN_NAME, 'Role')
+            ->setRenderer(function (ActiveRow $activeRow)
+            {
+                try
+                {
+                    $userRoleRow = $activeRow->related(UserRoleRepository::TABLE_NAME)->fetch();
+                    $roleRow = $userRoleRow->ref(RoleRepository::TABLE_NAME);
+
+                    return $roleRow->{RoleRepository::COLUMN_NAME};
+
+                } catch (\Exception $ex)
+                {
+                    \Tracy\Debugger::log($ex->getMessage(), 'user-grid');
+                    return "not found";
+                }
+            });
         $this->addColumnText(UserRepository::COLUMN_EMAIL, 'Email');
 
         // Definice filtrů
         $this->addFilterText(UserRepository::COLUMN_USERNAME, 'Uživatel');
         $this->addFilterText(UserRepository::COLUMN_LOGIN, 'Login');
+        $this->addFilterSelect(RoleRepository::COLUMN_NAME, 'Role', ['' => 'all'] + $this->roleRepository->getRolesForSelect())
+            ->setCondition(function (Selection $selection, $value)
+            {
+                $selection->where(':role.role_id', $value);
+            });
         $this->addFilterText(UserRepository::COLUMN_EMAIL, 'Email');
 
         // Akce
diff --git a/app/AdminModule/presenters/BookPresenter.php b/app/AdminModule/presenters/BookPresenter.php
index b2c228c..f69c4cc 100644
--- a/app/AdminModule/presenters/BookPresenter.php
+++ b/app/AdminModule/presenters/BookPresenter.php
@@ -8,7 +8,7 @@ use App\AdminModule\Components\IBookGridFactory;
 use App\Enum\EFlashMessage;
 use App\Model\Repository\BookRepository;
 
-class BookPresenter extends BaseUserPresenter
+class BookPresenter extends BaseAdminPresenter
 {
     /**
      * @var IBookGridFactory
diff --git a/app/AdminModule/presenters/BookTypePresenter.php b/app/AdminModule/presenters/BookTypePresenter.php
index c5becbb..d09780f 100644
--- a/app/AdminModule/presenters/BookTypePresenter.php
+++ b/app/AdminModule/presenters/BookTypePresenter.php
@@ -9,7 +9,7 @@ use App\Enum\EFlashMessage;
 use App\Model\Repository\BookTypeRepository;
 use const Couchbase\ENCODER_FORMAT_IGBINARY;
 
-class BookTypePresenter extends BaseUserPresenter
+class BookTypePresenter extends BaseAdminPresenter
 {
 
     /**
diff --git a/app/AdminModule/presenters/MuseumPresenter.php b/app/AdminModule/presenters/MuseumPresenter.php
index a9f55e7..287079c 100644
--- a/app/AdminModule/presenters/MuseumPresenter.php
+++ b/app/AdminModule/presenters/MuseumPresenter.php
@@ -8,7 +8,7 @@ use App\AdminModule\Components\IMuseumGridFactory;
 use App\Enum\EFlashMessage;
 use App\Model\Repository\MuseumRepository;
 
-class MuseumPresenter extends BaseUserPresenter
+class MuseumPresenter extends BaseAdminPresenter
 {
     /**
      * @var IMuseumGridFactory
diff --git a/app/AdminModule/presenters/ObjectPresenter.php b/app/AdminModule/presenters/ObjectPresenter.php
index 38d9c19..ed97efc 100644
--- a/app/AdminModule/presenters/ObjectPresenter.php
+++ b/app/AdminModule/presenters/ObjectPresenter.php
@@ -8,7 +8,7 @@ use App\AdminModule\Components\IObjectTypeGridFactory;
 use App\Enum\EFlashMessage;
 use App\Model\Repository\ObjectTypeRepository;
 
-class ObjectPresenter extends BaseUserPresenter
+class ObjectPresenter extends BaseAdminPresenter
 {
     /** @var ObjectTypeRepository */
     private $objectTypeRepository;
diff --git a/app/AdminModule/presenters/OriginPresenter.php b/app/AdminModule/presenters/OriginPresenter.php
index 210a2b5..1b091f2 100644
--- a/app/AdminModule/presenters/OriginPresenter.php
+++ b/app/AdminModule/presenters/OriginPresenter.php
@@ -9,7 +9,7 @@ use App\AdminModule\Components\IOriginGridFactory;
 use App\Enum\EFlashMessage;
 use App\Model\Repository\OriginRepository;
 
-class OriginPresenter extends BaseUserPresenter
+class OriginPresenter extends BaseAdminPresenter
 {
     /**
      * @var IOriginGridFactory
diff --git a/app/AdminModule/presenters/SurfacePresenter.php b/app/AdminModule/presenters/SurfacePresenter.php
index 696ee79..f9ed5dc 100644
--- a/app/AdminModule/presenters/SurfacePresenter.php
+++ b/app/AdminModule/presenters/SurfacePresenter.php
@@ -8,7 +8,7 @@ use App\AdminModule\Components\ISurfaceTypeGridFactory;
 use App\Enum\EFlashMessage;
 use App\Model\Repository\SurfaceTypeRepository;
 
-class SurfacePresenter extends BaseUserPresenter
+class SurfacePresenter extends BaseAdminPresenter
 {
     /** @var ISurfaceTypeGridFactory */
     private $surfaceTypeGridFactory;
diff --git a/app/AdminModule/presenters/TransliterationPresenter.php b/app/AdminModule/presenters/TransliterationPresenter.php
index 60e2f96..3d1373e 100644
--- a/app/AdminModule/presenters/TransliterationPresenter.php
+++ b/app/AdminModule/presenters/TransliterationPresenter.php
@@ -12,7 +12,7 @@ use App\AdminModule\Components\ITransliterationNewFormFactory;
 use App\FrontModule\Components\IKeyboard;
 use App\Model\Repository\TransliterationRepository;
 
-class TransliterationPresenter extends BaseUserPresenter
+class TransliterationPresenter extends BaseAdminPresenter
 {
     /**
      * @var ITransliterationGridFactory
diff --git a/app/AdminModule/presenters/TransportPresenter.php b/app/AdminModule/presenters/TransportPresenter.php
index a950cc4..c4c031c 100644
--- a/app/AdminModule/presenters/TransportPresenter.php
+++ b/app/AdminModule/presenters/TransportPresenter.php
@@ -11,7 +11,7 @@ use App\Model\Repository\SurfaceTypeRepository;
 use App\Model\TransportModel;
 use App\Utils\TextParser;
 
-class TransportPresenter extends BaseUserPresenter
+class TransportPresenter extends BaseAdminPresenter
 {
     /** @var IImportFormFactory */
     private $importFormFactory;
diff --git a/app/FrontModule/component/Transliteration/TransliterationView.latte b/app/FrontModule/component/Transliteration/TransliterationView.latte
index 064dcf6..482a6c1 100644
--- a/app/FrontModule/component/Transliteration/TransliterationView.latte
+++ b/app/FrontModule/component/Transliteration/TransliterationView.latte
@@ -4,12 +4,15 @@
 <div>
 
     <div>
-        {if isset($transliteration->id_book) && !empty($transliteration->id_book)}
-            <a href="{$presenter->link(':Admin:Book:edit', ['id' => $transliteration->id_book])}">edit book</a>
-        {/if}
-        {if isset($transliteration->id) && !empty($transliteration->id)}
-            <a href="{$presenter->link(':Admin:Transliteration:edit#transliteration-info', ['id' => $transliteration->id])}">edit
-                transliteration info</a>
+        {if $user->isInRole(\App\Enum\EUserRole::ADMIN)}
+            {if isset($transliteration->id_book) && !empty($transliteration->id_book)}
+                <a href="{$presenter->link(':Admin:Book:edit', ['id' => $transliteration->id_book])}">edit book</a>
+            {/if}
+            |
+            {if isset($transliteration->id) && !empty($transliteration->id)}
+                <a href="{$presenter->link(':Admin:Transliteration:edit#transliteration-info', ['id' => $transliteration->id])}">edit
+                    transliteration info</a>
+            {/if}
         {/if}
     </div>
 
@@ -88,8 +91,10 @@
     </div>
 
 
-    {if isset($transliteration->id) && !empty($transliteration->id)}
-        <a href="{$presenter->link(':Admin:Transliteration:edit#transliteration-data', ['id' => $transliteration->id])}">edit</a>
+    {if $user->isInRole(\App\Enum\EUserRole::ADMIN)}
+        {if isset($transliteration->id) && !empty($transliteration->id)}
+            <a href="{$presenter->link(':Admin:Transliteration:edit#transliteration-data', ['id' => $transliteration->id])}">edit</a>
+        {/if}
     {/if}
 
     <div class="container-fluid">
diff --git a/app/FrontModule/presenters/TransliterationPresenter.php b/app/FrontModule/presenters/TransliterationPresenter.php
index 3f2f01b..7ede746 100644
--- a/app/FrontModule/presenters/TransliterationPresenter.php
+++ b/app/FrontModule/presenters/TransliterationPresenter.php
@@ -4,6 +4,7 @@ namespace App\FrontModule\Presenters;
 
 
 
+use App\AdminModule\Presenters\BaseUserPresenter;
 use App\FrontModule\Components\IKeyboard;
 use App\FrontModule\Components\ITransliterationSearchFormFactory;
 use App\FrontModule\Components\ITransliterationSearchResultListFactory;
@@ -13,9 +14,8 @@ use App\Model\Repository\LitReferenceRepository;
 use App\Model\Repository\RevHistoryRepository;
 use App\Model\Repository\TransliterationRepository;
 use App\Model\TransliterationSearchModel;
-use Nette\Application\UI\Presenter;
 
-class TransliterationPresenter extends Presenter
+class TransliterationPresenter extends BaseUserPresenter
 {
     /** @var ITransliterationSearchFormFactory */
     private $transliterationSearchFormFactory;
diff --git a/app/model/repository/RoleRepository.php b/app/model/repository/RoleRepository.php
index 93cc9db..9fa31ab 100644
--- a/app/model/repository/RoleRepository.php
+++ b/app/model/repository/RoleRepository.php
@@ -16,4 +16,14 @@ class RoleRepository extends Repository
     /** Sloupečky tabulky */
     const COLUMN_ID = 'id';
     const COLUMN_NAME = 'name';
+
+    /**
+     * Vrací role uživatele pro selectboxy
+     *
+     * @return array
+     */
+    public function getRolesForSelect()
+    {
+        return $this->findAll()->fetchPairs(RoleRepository::COLUMN_ID, RoleRepository::COLUMN_NAME);
+    }
 }
\ No newline at end of file
diff --git a/app/templates/@menu.latte b/app/templates/@menu.latte
index bffbc19..fd69e0b 100644
--- a/app/templates/@menu.latte
+++ b/app/templates/@menu.latte
@@ -1,27 +1,37 @@
 <nav class="navbar navbar-expand-lg navbar-dark bg-primary" style="background-color: #003366 !important;">
     <ul class="navbar-nav mr-auto">
-        <li class="nav-item">
-            <a n:class="nav-link, $presenter->isLinkCurrent(':Front:Transliteration:*') ? active" n:href=":Front:Transliteration:search">Search & edit texts</a>
-        </li>
+        {if $user->loggedIn && ($user->isInRole(\App\Enum\EUserRole::ADMIN) || $user->isInRole(\App\Enum\EUserRole::USER))}
+            <li class="nav-item">
+                <a n:class="nav-link, $presenter->isLinkCurrent(':Front:Transliteration:*') ? active" n:href=":Front:Transliteration:search">Search
+                    & edit texts</a>
+            </li>
+        {/if}
         <li class="nav-item">
             <a class="nav-link" href="/utf/sj.php">Search dictionary</a>
         </li>
-        <li class="nav-item">
-            <a n:class="nav-link, $presenter->isLinkCurrent(':Front:Catalogue:*') ? active" n:href=":Front:Catalogue:default">Text catalogue</a>
-        </li>
+        {if $user->loggedIn && ($user->isInRole(\App\Enum\EUserRole::ADMIN) || $user->isInRole(\App\Enum\EUserRole::USER))}
+            <li class="nav-item">
+                <a n:class="nav-link, $presenter->isLinkCurrent(':Front:Catalogue:*') ? active" n:href=":Front:Catalogue:default">Text
+                    catalogue</a>
+            </li>
+        {/if}
         <li class="nav-item">
             <a class="nav-link" href="/utf/signs.html">Catalogue of cuneiform signs</a>
         </li>
         <li class="nav-item">
-            <a n:class="nav-link, $presenter->isLinkCurrent(':Front:Contact:default') ? active" n:href=":Front:Contact:default">Contact & members</a>
-        </li>
-        <li class="nav-item">
-            <a n:class="nav-link, $presenter->isLinkCurrent(':Admin:Transliteration:new') ? active" n:href=":Admin:Transliteration:new">Input new text</a>
+            <a n:class="nav-link, $presenter->isLinkCurrent(':Front:Contact:default') ? active" n:href=":Front:Contact:default">Contact
+                & members</a>
         </li>
+        {if $user->loggedIn && $user->isInRole(\App\Enum\EUserRole::ADMIN)}
+            <li class="nav-item">
+                <a n:class="nav-link, $presenter->isLinkCurrent(':Admin:Transliteration:new') ? active" n:href=":Admin:Transliteration:new">Input
+                    new text</a>
+            </li>
+        {/if}
         <li class="nav-item">
             <a class="nav-link" href="/multidic">Dictionary</a>
         </li>
-        {if $user->loggedIn && ($user->isInRole(\App\Enum\EUserRole::ADMIN) || $user->isInRole(\App\Enum\EUserRole::USER))}
+        {if $user->loggedIn && $user->isInRole(\App\Enum\EUserRole::ADMIN)}
             <li class="nav-item">
                 <a n:class="nav-link, strpos($presenter->getRequest()->getPresenterName(), 'Admin') !== FALSE ? active" n:href=":Admin:Default:">Admin</a>
             </li>
diff --git a/old/html/multidic/app/webroot/classes/db.php b/old/html/multidic/app/webroot/classes/db.php
index ad088f2..035bf5f 100644
--- a/old/html/multidic/app/webroot/classes/db.php
+++ b/old/html/multidic/app/webroot/classes/db.php
@@ -10,10 +10,10 @@
 
 class DB_Sql
 {
-    var $Host = "Filek.cz";
-    var $Database = "aswi-dictionary";
-    var $User = "dbowner";
-    var $Password = "db486ex12";
+    var $Host = "localhost";
+    var $Database = "web_klinopis_dictionary";
+    var $User = "klinopis";
+    var $Password = "";
 
     /** @var mysqli_result */
     var $result = null;
diff --git a/old/html/utf/dbconfig.php b/old/html/utf/dbconfig.php
index 87a5937..50a52b3 100644
--- a/old/html/utf/dbconfig.php
+++ b/old/html/utf/dbconfig.php
@@ -2,5 +2,5 @@
 
 define('DB_HOST', 'localhost');
 define('DB_NAME', 'web_klinopis_klinopis');
-define('DB_USER', 'dbowner');
+define('DB_USER', 'klinopis');
 define('DB_PASSWORD', '');
\ No newline at end of file
