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 UserRepository extends Repository {
  5:     /**
  6:      * Vraci data v poli ID => nazev
  7:      *
  8:      * @return array
  9:      */
 10:     function getPairData() {
 11:         return $this->getTable()->select('id, CONCAT(firstname, \' \', lastname) AS name')->order('name ASC')->fetchPairs('id', 'name');
 12:     }
 13: 
 14:     /**
 15:      * Vrati selection pro datagrid
 16:      *
 17:      * @param array $filter
 18:      * @param array $order
 19:      * @param int $page
 20:      * @param int $limit
 21:      * @return \Nette\Database\Table\Selection
 22:      */
 23:     function getGridSelection($filter, $order, $page, $limit) {
 24:         $selection = $this->getTable()->select('user.*, role.name AS role');
 25: 
 26:         if (isset($order[0]))
 27:             $selection->order(implode(' ', $order));
 28: 
 29:         $selection->page($page, $limit);
 30: 
 31:         return $this->addGridFilter($selection, $filter);
 32:     }
 33: 
 34:     /**
 35:      * Vrati pocet zaznamu pro datagrid
 36:      *
 37:      * @param array $filter
 38:      * @return int
 39:      */
 40:     function getGridCount($filter) {
 41:         $selection = $this->getTable()->select('COUNT(*) AS cnt');
 42: 
 43:         $result = $this->addGridFilter($selection, $filter)->fetch();
 44: 
 45:         return $result->cnt;
 46:     }
 47: 
 48:     /**
 49:      * Omezi selection na zaklade filtru pro datagrid
 50:      *
 51:      * @param Selection $selection
 52:      * @param Array $filter
 53:      * @return \Nette\Database\Table\Selection
 54:      */
 55:     private function addGridFilter(\Nette\Database\Table\Selection $selection, $filter) {
 56:         $filters = array();
 57: 
 58:         foreach ($filter as $k => $v) {
 59:             if ($k == 'role')
 60:                 $filters['user.role=?'] = $v;
 61:             else
 62:                 $filters[$k . ' LIKE ?'] = "%$v%";
 63:         }
 64: 
 65:         return $selection->where($filters);
 66:     }
 67: 
 68:     /**
 69:      * Vraci zaznam dle uzivatelskeho jmeno
 70:      *
 71:      * @param string $username Uzivatelske jmeno
 72:      * @return mixed
 73:      */
 74:     public function findByName($username) {
 75:         return $this->getTable()->where('username', $username)->fetch();
 76:     }
 77: 
 78:     /**
 79:      * Nastavuje heslo pro kontakt
 80:      *
 81:      * @param int $id ID kontaktu
 82:      * @param string $password Nove heslo
 83:      */
 84:     public function setPassword($id, $password) {
 85:         $this->getTable()->where(array('id' => $id))->update(array(
 86:             'password' => UserManager::calculateHash($password)
 87:         ));
 88:     }
 89: 
 90:     /**
 91:      * Ziska povolene emaily pro prijem upozorneni
 92:      *
 93:      * @return \Nette\Database\Table\Selection
 94:      */
 95:     public function getEnabledEmails() {
 96:         return $this->getTable()
 97:             ->select('email')
 98:             ->where('receiveemail=1');
 99:     }
100: }
API documentation generated by ApiGen 2.8.0