public function indexAction()
 {
     $this->view->searchForm = Editor_Forms_Search::getInstance();
     $request = $this->getRequest();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$this->view->searchForm->isValid($this->getRequest()->getPost())) {
         return;
     }
     $userForSearch = $this->view->searchForm->getUserForSearch();
     $loggedUser = OpenSKOS_Db_Table_Users::requireFromIdentity();
     $this->view->disableSearchProfileChanging = $loggedUser->disableSearchProfileChanging;
     $searchOptions = $this->view->searchForm->getValues();
     $detailedSearchOptions = $userForSearch->getSearchOptions(true);
     // Change search profile if needed and allowed. Change concept schemes if needed.
     //!TODO Refactor. That code evolved little ugly.
     if ($loggedUser['id'] == $userForSearch['id']) {
         $profileId = $this->getRequest()->getParam('searchProfileId', '');
         if ($detailedSearchOptions['searchProfileId'] != $profileId || !isset($detailedSearchOptions['searchProfileId'])) {
             $this->_switchUserToSearchProfile($loggedUser, $profileId);
             $detailedSearchOptions = $loggedUser->getSearchOptions();
             // Reset allowedConceptScheme
             if ($loggedUser->disableSearchProfileChanging) {
                 $searchOptions['allowedConceptScheme'] = array();
             }
         } elseif (!isset($searchOptions['conceptScheme']) || !isset($detailedSearchOptions['conceptScheme']) || $searchOptions['conceptScheme'] != $detailedSearchOptions['conceptScheme']) {
             if ($loggedUser->isAllowedToUseSearchProfile('custom')) {
                 // Change concept schemes selection
                 $detailedSearchOptions['searchProfileId'] = 'custom';
                 if (isset($searchOptions['conceptScheme'])) {
                     $detailedSearchOptions['conceptScheme'] = $searchOptions['conceptScheme'];
                 } else {
                     $detailedSearchOptions['conceptScheme'] = array();
                 }
                 $loggedUser->setSearchOptions($detailedSearchOptions);
             }
         }
     }
     // Select the concepts
     $apiClient = new Editor_Models_ApiClient();
     try {
         $conceptsRaw = $apiClient->searchConcepts(Editor_Forms_Search::mergeSearchOptions($searchOptions, $detailedSearchOptions));
     } catch (Exception $ex) {
         $this->getHelper('json')->sendJson(array('status' => 'error', 'message' => 'Bad query syntax.'));
     }
     $concepts = array();
     foreach ($conceptsRaw['data'] as $concept) {
         $concepts[] = $concept->toArray(array('uuid', 'uri', 'status', 'schemes', 'previewLabel', 'previewScopeNote'));
     }
     $this->getHelper('json')->sendJson(array('status' => 'ok', 'numFound' => $conceptsRaw['numFound'], 'concepts' => $concepts, 'conceptSchemeOptions' => $this->_getConceptSchemeOptions($searchOptions), 'profileOptions' => $this->_getProfilesSelectOptions()));
 }
 public function indexAction()
 {
     $user = OpenSKOS_Db_Table_Users::requireFromIdentity();
     $apiClient = new Editor_Models_ApiClient();
     $this->view->assign('conceptSchemes', $apiClient->getAllConceptSchemeUriTitlesMap());
     $this->view->assign('conceptSchemesId', $apiClient->getConceptSchemeMap('uri', 'uuid'));
     $this->view->assign('disableSearchProfileChanging', $user->disableSearchProfileChanging);
     $this->view->assign('exportForm', Editor_Forms_Export::getInstance());
     $this->view->assign('deleteForm', Editor_Forms_Delete::getInstance());
     $this->view->assign('changeStatusForm', Editor_Forms_ChangeStatus::getInstance());
     $this->view->assign('historyData', $user->getUserHistory());
     $this->view->assign('searchForm', Editor_Forms_Search::getInstance());
 }