public function indexAction() { $form = new Admin_Form_Configuration(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); $form->populate($data); $result = $form->processPost($data, $data); switch ($result) { case Admin_Form_Configuration::RESULT_SAVE: if ($form->isValid($data)) { $config = new Zend_Config(array(), true); $form->updateModel($config); Application_Configuration::save($config); } else { break; } case Admin_Form_Configuration::RESULT_CANCEL: $this->_redirectTo('setup', null, 'index', 'admin'); break; default: break; } } else { $form->populateFromModel($this->getConfig()); } $this->_helper->viewRenderer->setNoRender(true); echo $form; }
/** * Returns instance of class. * @return Application_Configuration */ public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new Application_Configuration(); } return self::$_instance; }
/** * Get an instance of the view helper. * * @return Application_View_Helper_LanguageSelector */ public function languageSelector() { if (isset($this->view->languageSelectorDisabled) && $this->view->languageSelectorDisabled === true) { return null; } $returnParams = Zend_Controller_Action_HelperBroker::getStaticHelper('ReturnParams'); $currentLocale = new Zend_Locale(Zend_Registry::get('Zend_Translate')->getLocale()); $configHelper = new Application_Configuration(); // only show languages that are present in resources and activated in configuration $translations = Zend_Registry::get('Zend_Translate')->getList(); $supportedLang = $configHelper->getSupportedLanguages(); $translations = array_intersect($translations, $supportedLang); $result = array(); foreach ($translations as $translation) { if ($currentLocale->getLanguage() !== $translation) { $languageName = $currentLocale->getTranslation($translation, 'language', $translation); $languageUrl = $this->view->url(array_merge(array('action' => 'language', 'controller' => 'index', 'module' => 'home', 'language' => $translation), $returnParams->getReturnParameters()), null, true); array_push($result, array('name' => htmlspecialchars($languageName), 'url' => $languageUrl)); } } return $result; }
/** * Returns all associated Opus_File objects that are visible in OAI and accessible by user * @return array Accessible Opus_File objects * * TODO check embargo date * TODO merge access checks with code for deliver controller */ public function getAccessibleFiles() { $realm = Opus_Security_Realm::getInstance(); // admins sollen immer durchgelassen werden, nutzer nur wenn das doc im publizierten Zustand ist if (!$realm->skipSecurityChecks()) { // kein administrator // PUBLISHED Dokumente sind immer verfügbar (Zugriff auf Modul kann eingeschränkt sein) if ($this->_doc->getServerState() !== 'published') { // Dokument nicht published if (!$realm->checkDocument($this->_docId)) { // Dokument ist nicht verfügbar für aktuellen Nutzer $this->logErrorMessage('document id =' . $this->_docId . ' is not published and access is not allowed for current user'); throw new Oai_Model_Exception('access to requested document is forbidden'); } } if ($this->_doc->hasEmbargoPassed() === false) { if (!$realm->checkDocument($this->_docId)) { // Dokument ist nicht verfügbar für aktuellen Nutzer $this->logErrorMessage('document id =' . $this->_docId . ' is not embargoed and access is not allowed for current user'); throw new Oai_Model_Exception('access to requested document files is embargoed'); } } } $files = array(); $filesToCheck = $this->_doc->getFile(); /* @var $file Opus_File */ foreach ($filesToCheck as $file) { $filename = $this->_appConfig->getFilesPath() . $this->_docId . DIRECTORY_SEPARATOR . $file->getPathName(); if (is_readable($filename)) { array_push($files, $file); } else { $this->logErrorMessage("skip non-readable file {$filename}"); } } if (empty($files)) { $this->logErrorMessage('document with id ' . $this->_docId . ' does not have any associated files'); throw new Oai_Model_Exception('requested document does not have any associated readable files'); } $containerFiles = array(); /* @var $file Opus_File */ foreach ($files as $file) { if ($file->getVisibleInOai() && $realm->checkFile($file->getId())) { array_push($containerFiles, $file); } } if (empty($containerFiles)) { $this->logErrorMessage('document with id ' . $this->_docId . ' does not have associated files that are accessible'); throw new Oai_Model_Exception('access denied on all files that are associated to the requested document'); } return $containerFiles; }
/** * Zeigt an, ob eine neuere Version von OPUS verfügbar ist. * * TODO Behandlung von is_null($latestVersion) hängt vom Verhalten der Version Helpers ab (ueberarbeiten) */ public function updateAction() { $localVersion = Application_Configuration::getOpusVersion(); $latestVersion = $this->_helper->version(); $this->view->currentVersion = $localVersion; $this->view->latestVersion = null; if (is_null($latestVersion)) { $this->view->message = $this->view->translate('admin_info_version_error_getting_latest'); } elseif ($localVersion == $latestVersion) { $this->view->message = $this->view->translate('admin_info_version_current'); } else { $this->view->message = $this->view->translate('admin_info_version_outdated'); $this->view->latestVersion = $latestVersion; } }
public function testGetInstance() { $config = Application_Configuration::getInstance(); $this->assertNotNull($config); $this->assertInstanceOf('Application_Configuration', $config); $this->assertSame($config, Application_Configuration::getInstance()); }
public function testGetOpusInfo() { $data = Application_Configuration::getOpusInfo(); $config = Zend_Registry::get('Zend_Config'); $this->assertInternalType('array', $data); /* OPUSVIER-3542 Version not working the same way with git $this->assertArrayHasKey('admin_info_version', $data); $this->assertEquals($config->version, $data['admin_info_version']); */ }
protected function _initVersionInfo() { $this->bootstrap('View'); $view = $this->getResource('View'); $view->headMeta()->appendName('Opus-Version', Application_Configuration::getOpusVersion()); }
/** * Switches the language for Zend_Translate and redirects back. * * @return void */ public function languageAction() { $module = null; $controller = null; $action = null; $language = null; $params = array(); foreach ($this->getRequest()->getParams() as $param => $value) { switch ($param) { case 'rmodule': $module = $value; break; case 'rcontroller': $controller = $value; break; case 'raction': $action = $value; break; case 'rrmodule': $params['rmodule'] = $value; break; case 'rrcontroller': $params['rcontroller'] = $value; break; case 'rraction': $params['raction'] = $value; break; case 'language': $language = $value; break; default: $params[$param] = $value; } } $appConfig = new Application_Configuration(); if ($appConfig->isLanguageSelectionEnabled() && !is_null($language) && Zend_Registry::get('Zend_Translate')->isAvailable($language)) { $sessiondata = new Zend_Session_Namespace(); $sessiondata->language = $language; } $this->_redirectTo($action, '', $controller, $module, $params); }
/** * Updates configuration with values from form elements. */ public function updateModel($config) { foreach ($this->_options as $name => $option) { $value = $this->getElement($name)->getValue(); // TODO move into Admin_Model_Option? if (is_array($value)) { $value = implode(',', $value); } Application_Configuration::setValueInConfig($config, $option->getKey(), $value); } }