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());
 }
 public function exportAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->_forward('index', 'index');
     }
     $user = $this->getCurrentUser();
     $export = new Editor_Models_Export();
     $export->set('userId', $user['id']);
     $export->set('format', $this->getRequest()->getPost('format'));
     $export->set('type', $this->getRequest()->getPost('type'));
     $export->set('maxDepth', $this->getRequest()->getPost('maxDepth'));
     // Currently this applies only for rtf export.
     $outputFileName = $this->getRequest()->getPost('fileName');
     if (empty($outputFileName)) {
         $export->set('outputFileName', uniqid());
     } else {
         $export->set('outputFileName', $outputFileName);
     }
     $fieldsToExport = $this->getRequest()->getPost('fieldsToExport');
     if (empty($fieldsToExport)) {
         $export->set('fieldsToExport', array());
     } else {
         $export->set('fieldsToExport', explode(',', $this->getRequest()->getPost('fieldsToExport')));
     }
     switch ($export->get('type')) {
         case 'concept':
             $export->set('conceptUuid', $this->getRequest()->getPost('additionalData'));
             // We have the uuid in additionalData.
             break;
         case 'search':
             $searchFormData = Zend_Json::decode($this->getRequest()->getPost('additionalData'), Zend_Json::TYPE_ARRAY);
             // We have the json encoded search form data in additionalData.
             $searchFormData = $this->_fixJsSerializedArrayData('conceptScheme', $searchFormData);
             $searchFormData = $this->_fixJsSerializedArrayData('allowedConceptScheme', $searchFormData);
             $userForSearch = OpenSKOS_Db_Table_Users::requireById($searchFormData['user']);
             $userSearchOptions = $userForSearch->getSearchOptions($user['id'] != $userForSearch['id']);
             $export->set('searchOptions', Editor_Forms_Search::mergeSearchOptions($searchFormData, $userSearchOptions));
             break;
     }
     if ($export->isTimeConsumingExport()) {
         $export->exportWithBackgroundJob();
         $this->_redirect($this->getRequest()->getPost('currentUrl'));
     } else {
         $fileContent = $export->exportToString();
         $fileDetails = $export->getExportFileDetails();
         $this->getHelper('file')->sendFileContent($fileDetails['fileName'], $fileContent, $fileDetails['mimeType']);
     }
 }
 private function _getProfilesSelectOptions()
 {
     $profilesOptions = array();
     $userOptions = $this->getCurrentUser()->getSearchOptions();
     $searchForm = Editor_Forms_Search::factory();
     $rawOptions = $searchForm->getElement('searchProfileId')->getAttrib('options');
     foreach ($rawOptions as $id => $name) {
         $profilesOptions[] = array('id' => $id, 'name' => $name, 'selected' => isset($userOptions['searchProfileId']) && $userOptions['searchProfileId'] == $id);
     }
     return $profilesOptions;
 }