getUser(); $arg = array(); $categories = $this->createQuery() ->execute(); foreach($categories as $category){ if($user->hasCredential($category->getPermission())){ $arg[$category->getId()] = $category->getName(); } } return $arg; } public function getParents() { return $this->createQuery() ->where('parent_id IS NULL') ->orderBy('priority DESC') ->execute(); } /* * Lucene vyhledavani */ static public function getLuceneIndex() { ProjectConfiguration::registerZend(); if (file_exists($index = self::getLuceneIndexFile())) { return Zend_Search_Lucene::open($index); } else { return Zend_Search_Lucene::create($index); } } static public function getLuceneIndexFile() { return sfConfig::get('sf_data_dir').'/lucene/equipment.'.sfConfig::get('sf_environment').'.index'; } public function getForLuceneQuery($query) { $hits = $this->getLuceneIndex()->find($query); $pks = array(); foreach ($hits as $hit) { $pks[] = $hit->pk; } if (empty($pks)) { return array(); } $q = $this->createQuery('p') ->whereIn('p.id', $pks) ->limit(20); return $q->execute(); } public function findOneBySlugInVersion($slug) { $id = $this->createQuery() ->from('EquipmentVersion') ->where('slug = ?', $slug) ->fetchOne(); return $id ? $this->find($id['id']) : false; } }