Ejemplo n.º 1
0
 public function switchAction()
 {
     $csrfForm = new Omeka_Form_SessionCsrf();
     if (!$this->getRequest()->isPost() || !$csrfForm->isValid($_POST)) {
         $this->_helper->flashMessenger(__('Invalid form submission.'), 'error');
         $this->_helper->redirector('browse');
         return;
     }
     $themeName = $this->_getParam(Theme::PUBLIC_THEME_OPTION);
     // Theme names should be alphanumeric(-ish) (prevent security flaws).
     if (preg_match('/[^a-z0-9\\-_]/i', $themeName)) {
         $this->_helper->flashMessenger(__('You have chosen an illegal theme name. Please select another theme.'), 'error');
         return;
     }
     $theme = Theme::getTheme($themeName);
     $minVer = $theme->omeka_minimum_version;
     if (!empty($minVer) && version_compare(OMEKA_VERSION, $theme->omeka_minimum_version, '<')) {
         $this->_helper->flashMessenger(__('This theme requires a newer version of Omeka (%s).', $minVer), 'error');
         $this->_helper->redirector('browse');
         return;
     }
     // Set the public theme option according to the form post.
     set_option(Theme::PUBLIC_THEME_OPTION, $themeName);
     if (!Theme::getOptions($themeName) && ($configForm = new Omeka_Form_ThemeConfiguration(array('themeName' => $themeName)))) {
         Theme::setOptions($themeName, $configForm->getValues());
     }
     $this->_helper->flashMessenger(__('The theme has been successfully changed.'), 'success');
     $this->_helper->redirector('browse');
 }
Ejemplo n.º 2
0
 public function index()
 {
     if ($this->mongo_db->user->find()->count() && !$this->input->get('ok')) {
         show_error('Kurulum zaten yapılmış!');
     }
     $this->load->library('form_validation');
     $this->load->library('user/auth');
     $data = array();
     $this->form_validation->set_rules('password', 'Şifre', 'trim|required|xss_clean');
     $this->form_validation->set_rules('confirm_password', 'Şifre tekrarı', 'trim|required|xss_clean|matches[password]');
     $this->form_validation->set_rules('email', 'E-posta', 'trim|required|xss_clean|valid_email');
     $this->form_validation->set_rules('name', 'İsim', 'trim|required|xss_clean');
     if ($this->form_validation->run()) {
         $data['name'] = set_value('name');
         $data['permissions'] = set_value('permissions');
         if ($this->auth->create(set_value('email'), set_value('password'), $data, TRUE)) {
             set_option('site_name', set_value('site_name'));
             set_option('site_email', set_value('site_email'));
             set_option('per_page', 10);
             set_option('per_page_admin', 20);
             set_option('debug', 0);
             $navigation = array('slug' => 'HEAD_MENU', 'title' => 'Üst Menü', 'items' => array(array('title' => 'Anasayfa', 'url' => '/', 'access_level' => '0', 'target' => ''), array('title' => 'İletişim', 'url' => '/contact', 'access_level' => '0', 'target' => '')));
             $this->mongo_db->navigation->insert($navigation);
             flash_message('success', 'Üye başarıyla eklendi.');
             redirect('install?ok=1');
         }
     }
     $this->load->view('index', $data);
 }
Ejemplo n.º 3
0
 public function testCanReachUpgradePageWithoutBeingLoggedIn()
 {
     set_option('omeka_version', '1.0');
     $this->db->query("TRUNCATE omeka_schema_migrations");
     $this->dispatch('/upgrade');
     $this->assertNotRedirectTo('/users/login');
 }
Ejemplo n.º 4
0
 public function hookConfig($args)
 {
     $post = $args['post'];
     foreach ($post as $key => $value) {
         set_option($key, $value);
     }
 }
Ejemplo n.º 5
0
 public function testAccessPermissions()
 {
     set_option('display_system_info', true);
     $this->currentuser->role = 'admin';
     $this->dispatch('system-info');
     $this->assertNotController('system-info');
 }
 public function setUp()
 {
     parent::setUp();
     // All tests are done with local paths to simplify them (no http layer).
     if ($this->_allowLocalPaths) {
         $settings = (object) array('local_folders' => (object) array('allow' => '1', 'check_realpath' => '0', 'base_path' => TEST_FILES_DIR));
         Zend_Registry::set('oai_pmh_static_repository', $settings);
     } else {
         $settings = (object) array('local_folders' => (object) array('allow' => '0', 'check_realpath' => '0', 'base_path' => '/var/path/to/the/folder'));
         Zend_Registry::set('oai_pmh_static_repository', $settings);
     }
     defined('TEST_FILES_WEB') or define('TEST_FILES_WEB', WEB_ROOT . DIRECTORY_SEPARATOR . basename(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'suite' . DIRECTORY_SEPARATOR . '_files');
     $pluginHelper = new Omeka_Test_Helper_Plugin();
     // ArchiveDocument is a required plugin.
     $path = PLUGIN_DIR . DIRECTORY_SEPARATOR . 'ArchiveDocument' . DIRECTORY_SEPARATOR . 'ArchiveDocumentPlugin.php';
     $this->assertTrue(is_file($path) && filesize($path), __('This plugin requires ArchiveDocument.'));
     $pluginHelper->setUp('ArchiveDocument');
     $pluginHelper->setUp(self::PLUGIN_NAME);
     // OcrElementSet is an optional plugin, but required for some tests.
     try {
         $pluginHelper->setUp('OcrElementSet');
     } catch (Omeka_Plugin_Loader_Exception $e) {
     }
     // Allow extensions "xml" and "json".
     $whiteList = get_option(Omeka_Validate_File_Extension::WHITELIST_OPTION) . ',xml,json';
     set_option(Omeka_Validate_File_Extension::WHITELIST_OPTION, $whiteList);
     // Allow media types for "xml" and "json".
     $whiteList = get_option(Omeka_Validate_File_MimeType::WHITELIST_OPTION) . ',application/xml,text/xml,application/json';
     set_option(Omeka_Validate_File_MimeType::WHITELIST_OPTION, $whiteList);
 }
 public function uninstall()
 {
     $db = get_db();
     $db->query("DROP TABLE IF EXISTS `{$db->MapfigStudio}`");
     set_option('mapfig_studio_api_key', '');
     set_option('mapfig_studio_url', '');
 }
 /**
  * If 'Display private items' is not checked, do not display private
  * collections for exclusion.
  */
 public function testDisplayPrivateCollectionsNotChecked()
 {
     set_option('solr_search_display_private_items', '0');
     $this->dispatch('solr-search/collections');
     $this->assertXpathContentContains("//dd[@id='solrexclude-element']/label", "public collection");
     $this->assertNotXpathContentContains("//dd[@id='solrexclude-element']/label", "private collection");
 }
Ejemplo n.º 9
0
 /**
  * Standard modular run function for setting features from the setup wizard.
  */
 function set_fields()
 {
     if (!addon_installed('banners')) {
         return;
     }
     $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
     if (post_param_integer('have_default_banners_donation', 0) == 0) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => 'donate'));
         if (!is_null($test)) {
             require_code('banners2');
             delete_banner('donate');
             foreach (array_keys($usergroups) as $id) {
                 $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'donate', 'zone_name' => 'site', 'group_id' => $id), false, true);
             }
         }
     }
     if (post_param_integer('have_default_banners_advertising', 0) == 0) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => 'advertise_here'));
         if (!is_null($test)) {
             require_code('banners2');
             delete_banner('advertise_here');
             foreach (array_keys($usergroups) as $id) {
                 $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'advertise', 'zone_name' => 'site', 'group_id' => $id), false, true);
             }
         }
     }
     $test = $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)');
     if ($test == 0) {
         set_option('is_on_banners', '0');
     }
 }
Ejemplo n.º 10
0
 /**
  * Standard modular run function for setting features from the setup wizard.
  */
 function set_fields()
 {
     if (!addon_installed('stats')) {
         return;
     }
     set_option('stats_store_time', post_param('stats_store_time'));
 }
 public function testUpdatedOptions()
 {
     set_option('neatlinetime', serialize(array('item_title' => 1, 'item_date' => 2, 'item_description' => 3)));
     $this->assertEquals(neatlinetime_get_option('item_title'), 1);
     $this->assertEquals(neatlinetime_get_option('item_date'), 2);
     $this->assertEquals(neatlinetime_get_option('item_description'), 3);
 }
 public function setUp()
 {
     parent::setUp();
     $pluginHelper = new Omeka_Test_Helper_Plugin();
     $pluginHelper->setUp(self::PLUGIN_NAME);
     define('TEST_FILES_DIR', ARCHIVE_REPERTORY_DIR . '/tests/suite/_files');
     // Add constraints if derivatives have been added in the config file.
     $fileDerivatives = Zend_Registry::get('bootstrap')->getResource('Config')->fileDerivatives;
     if (!empty($fileDerivatives) && !empty($fileDerivatives->paths)) {
         foreach ($fileDerivatives->paths->toArray() as $type => $path) {
             set_option($type . '_constraint', 1);
         }
     }
     // Prepare config and set a test temporary storage in registry.
     $config = new Omeka_Test_Resource_Config();
     $configIni = $config->init();
     if (isset($configIni->paths->imagemagick)) {
         $this->convertDir = $configIni->paths->imagemagick;
     } else {
         $this->convertDir = dirname(`which convert`);
     }
     $storage = Zend_Registry::get('storage');
     $adapter = $storage->getAdapter();
     $adapterOptions = $adapter->getOptions();
     $this->_storagePath = $adapterOptions['localDir'];
     // Set default strategy for the creation of derivative files.
     $this->strategy = new Omeka_File_Derivative_Strategy_ExternalImageMagick();
     $this->strategy->setOptions(array('path_to_convert' => $this->convertDir));
     $this->creator = new Omeka_File_Derivative_Creator();
     $this->creator->setStrategy($this->strategy);
     Zend_Registry::set('file_derivative_creator', $this->creator);
     // Create one item on which attach files.
     $this->item = insert_item(array('public' => true));
     set_option('disable_default_file_validation', 1);
 }
Ejemplo n.º 13
0
 /**
  * Hook to plugin configuration form submission.
  *
  * Sets options submitted by the configuration form.
  */
 public function hookConfig($args)
 {
     foreach (array_keys($this->_options) as $option) {
         if (isset($args['post'][$option])) {
             set_option($option, $args['post'][$option]);
         }
     }
 }
Ejemplo n.º 14
0
 public function hookConfig()
 {
     set_option('ef_displayOnMobile', (bool) (int) $_POST['ef_displayOnMobile']);
     set_option('ef_notify', (bool) (int) $_POST['ef_notify']);
     set_option('ef_isCalendar', (bool) (int) $_POST['ef_isCalendar']);
     set_option('ef_cookieExpiration', (int) $_POST['ef_cookieExpiration']);
     set_option('ef_rssfeed', $_POST['ef_rssfeed']);
 }
 /**
  * Tests whether geolocation_get_center correctly returns the default latitude, longitude, and zoom level
  */
 public function testGeolocationGetCenter()
 {
     $this->_checkValidCenter();
     set_option('geolocation_default_latitude', '4');
     set_option('geolocation_default_longitude', '5');
     set_option('geolocation_default_zoom', '6');
     $this->_checkValidCenter();
 }
Ejemplo n.º 16
0
 public function hookConfig()
 {
     set_option('ajs_items', (bool) (int) $_POST['ajs_items']);
     set_option('ajs_collections', (bool) (int) $_POST['ajs_collections']);
     set_option('ajs_showHighlights', (bool) (int) $_POST['ajs_showHighlights']);
     set_option('ajs_displayOnMobile', (bool) (int) $_POST['ajs_displayOnMobile']);
     //set_option('ajs_simplePages', (bool)(int)$_POST['ajs_simplePages']);
 }
Ejemplo n.º 17
0
function active_theme()
{
    $theme = hm_post('theme');
    if (is_dir(BASEPATH . HM_THEME_DIR . '/' . $theme) and is_file(BASEPATH . HM_THEME_DIR . '/' . $theme . '/init.php')) {
        $args = array('section' => 'system_setting', 'key' => 'theme', 'value' => $theme);
        set_option($args);
    }
}
Ejemplo n.º 18
0
 public function indexAction()
 {
     //check cli path
     try {
         Omeka_Job_Process_Dispatcher::getPHPCliPath();
     } catch (RuntimeException $e) {
         $this->_helper->flashMessenger(__("The background.php.path in config.ini is not valid. The correct path must be set for the import to work."), 'error');
     }
     if (isset($_POST['submit'])) {
         set_option('omeka_api_import_override_element_set_data', $_POST['omeka_api_import_override_element_set_data']);
         if (!empty($_POST['api_url'])) {
             //do a quick check for whether the API is active
             $client = new Zend_Http_Client();
             $client->setUri($_POST['api_url'] . '/site');
             $response = json_decode($client->request()->getBody(), true);
             if (isset($response['message'])) {
                 $this->_helper->flashMessenger(__("The API at %s is not active", $_POST['api_url']), 'error');
             } else {
                 $import = new OmekaApiImport();
                 $import->endpoint_uri = $_POST['api_url'];
                 $import->status = 'starting';
                 $import->save();
                 $args = array('endpointUri' => $_POST['api_url'], 'key' => $_POST['key'], 'importId' => $import->id);
                 try {
                     Zend_Registry::get('bootstrap')->getResource('jobs')->sendLongRunning('ApiImport_ImportJob_Omeka', $args);
                 } catch (Exception $e) {
                     $import->status = 'error';
                     $import->save();
                     _log($e);
                 }
             }
         }
         if (isset($_POST['undo'])) {
             $urls = $this->_helper->db->getTable('OmekaApiImport')->getImportedEndpoints();
             foreach ($_POST['undo'] as $endpointIndex) {
                 $mapRecords = $this->_helper->db->getTable('OmekaApiImportRecordIdMap')->findBy(array('endpoint_uri' => $urls[$endpointIndex]));
                 foreach ($mapRecords as $record) {
                     $record->delete();
                 }
                 $imports = $this->_helper->db->getTable('OmekaApiImport')->findBy(array('endpoint_uri' => $urls[$endpointIndex]));
                 foreach ($imports as $import) {
                     $import->delete();
                 }
             }
         }
     }
     if (!isset($import)) {
         $imports = $this->_helper->db->getTable('OmekaApiImport')->findBy(array('sort_field' => 'id', 'sort_dir' => 'd'), 1);
         if (empty($imports)) {
             $import = null;
         } else {
             $import = $imports[0];
         }
     }
     $this->view->import = $import;
     $urls = $this->_helper->db->getTable('OmekaApiImport')->getImportedEndpoints();
     $this->view->urls = $urls;
 }
 public function hookConfig($args)
 {
     $post = $args['post'];
     set_option('honor_thy_contributors_page_path', $post['page_path']);
     set_option('honor_thy_contributors_page_title', $post['page_title']);
     set_option('honor_thy_contributors_pre_text', $post['pre_text']);
     set_option('honor_thy_contributors_post_text', $post['post_text']);
     set_option('honor_thy_contributors_element_id', $post['element_id']);
 }
Ejemplo n.º 20
0
/**
 * Update a config option that references something, reflecting a new reference.
 *
 * @param  ID_TEXT		The old setting
 * @param  ID_TEXT		The new setting
 * @param  ID_TEXT		The config option type - presumably a type that holds references (e.g. "forum")
 */
function update_config_option_reference($old_setting, $new_setting, $type)
{
    $options = $GLOBALS['SITE_DB']->query_select('config', array('the_name'), array('the_type' => $type));
    foreach ($options as $option) {
        if (get_option($option['the_name']) == $old_setting) {
            set_option($option['the_name'], $new_setting);
        }
    }
}
Ejemplo n.º 21
0
 public function testEmptyConstructorWithInvalidSettingsAllowedHtmlAttributesThatLackAssociatedAllowedHtmlElements()
 {
     $dirtyHtml = 'whatever';
     $cleanHtml = 'whatever';
     set_option('html_purifier_allowed_html_elements', '');
     set_option('html_purifier_allowed_html_attributes', 'a.href');
     $htmlPurifierFilter = new Omeka_Filter_HtmlPurifier();
     $this->assertEquals($cleanHtml, $htmlPurifierFilter->filter($dirtyHtml));
 }
Ejemplo n.º 22
0
 /**
  * Processes the configuration form.
  *
  * @param array Options set in the config form.
  * @return void
  */
 public function hookConfig($args)
 {
     $post = $args['post'];
     foreach ($this->_options as $optionKey => $optionValue) {
         if (isset($post[$optionKey])) {
             set_option($optionKey, $post[$optionKey]);
         }
     }
 }
 /**
  * When the number of results exceeds the page length, the maximum number
  * of results and the pagination should be displayed.
  */
 public function testPagination()
 {
     // Set public page length to 2.
     set_option('per_page_public', 2);
     $item1 = $this->_item(true, 'Item 1');
     $item2 = $this->_item(true, 'Item 2');
     $item3 = $this->_item(true, 'Item 3');
     $item4 = $this->_item(true, 'Item 4');
     $item5 = $this->_item(true, 'Item 5');
     $item6 = $this->_item(true, 'Item 6');
     // --------------------------------------------------------------------
     // Page 1.
     $this->dispatch('solr-search');
     // Should just list items 1-2.
     $this->assertXpath('//a[@href="' . record_url($item1) . '"]');
     $this->assertXpath('//a[@href="' . record_url($item2) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item3) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item4) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item5) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item6) . '"]');
     // Should link to page 2.
     $next = public_url('solr-search?page=2');
     $this->assertXpath('//a[@href="' . $next . '"]');
     $this->resetResponse();
     $this->resetRequest();
     // --------------------------------------------------------------------
     // Page 2.
     $_GET['page'] = '2';
     $this->dispatch('solr-search');
     // Should just list items 3-4.
     $this->assertNotXpath('//a[@href="' . record_url($item1) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item2) . '"]');
     $this->assertXpath('//a[@href="' . record_url($item3) . '"]');
     $this->assertXpath('//a[@href="' . record_url($item4) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item5) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item6) . '"]');
     // Should link to page 3.
     $next = public_url('solr-search?page=3');
     $this->assertXpath('//a[@href="' . $next . '"]');
     $this->resetResponse();
     $this->resetRequest();
     // --------------------------------------------------------------------
     // Page 3.
     $_GET['page'] = '3';
     $this->dispatch('solr-search');
     // Should just list items 5-6.
     $this->assertNotXpath('//a[@href="' . record_url($item1) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item2) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item3) . '"]');
     $this->assertNotXpath('//a[@href="' . record_url($item4) . '"]');
     $this->assertXpath('//a[@href="' . record_url($item5) . '"]');
     $this->assertXpath('//a[@href="' . record_url($item6) . '"]');
     // Should link back to page 2.
     $prev = public_url('solr-search?page=2');
     $this->assertXpath('//a[@href="' . $prev . '"]');
     // --------------------------------------------------------------------
 }
 /**
  * Apply options defined in the `solr.ini` file.
  */
 protected function _applyTestingOptions()
 {
     // Parse the config file.
     $this->config = new Zend_Config_Ini(SOLR_TEST_DIR . '/solr.ini');
     // Apply the testing values.
     set_option('solr_search_port', $this->config->port);
     set_option('solr_search_host', $this->config->server);
     set_option('solr_search_core', $this->config->core);
 }
Ejemplo n.º 25
0
function hm_theme_dong_setting()
{
    if (isset($_POST['save_theme_setting'])) {
        foreach ($_POST as $key => $value) {
            $args = array('section' => 'theme_dong', 'key' => $key, 'value' => $value);
            set_option($args);
        }
    }
    hm_include(BASEPATH . '/' . HM_THEME_DIR . '/dong/admincp/theme_setting.php');
}
 /**
  * Sets options that appear in both the form and $_options.
  *
  * @param array $newOptions array of $optionName => $optionValue.
  */
 private function _setOptions($newOptions)
 {
     $cnt = new ContributionPlugin();
     $options = $cnt->getOptions();
     foreach ($newOptions as $optionName => $optionValue) {
         if (in_array($optionName, $options)) {
             set_option($optionName, $optionValue);
         }
     }
 }
 /**
  * When hit highlighting is disabled, snippets should not be displayed.
  */
 public function testHighlightingDisabled()
 {
     // Disable highlighting.
     set_option('solr_search_hl', '0');
     // Search for "item".
     $_GET['q'] = 'item';
     $this->dispatch('solr-search');
     // Should not show highlights.
     $this->assertNotXpath('//li[@class="snippet"]');
 }
Ejemplo n.º 28
0
 /**
  * Saves plugin configuration page.
  *
  * @param array Options set in the config form.
  */
 public function hookConfig($args)
 {
     $post = $args['post'];
     $post['openlayerszoom_tiles_dir'] = realpath(trim($post['openlayerszoom_tiles_dir']));
     foreach ($this->_options as $optionKey => $optionValue) {
         if (isset($post[$optionKey])) {
             set_option($optionKey, $post[$optionKey]);
         }
     }
 }
 public function hookConfig($args)
 {
     $post = $args['post'];
     if (isset($post['elements'])) {
         set_option('facet_by_metadata_elements', json_encode($post['elements']));
     } else {
         set_option('facet_by_metadata_elements', json_encode(array()));
     }
     set_option('facet_by_metadata_heading', $post['facet_by_metadata_heading']);
 }
Ejemplo n.º 30
0
 /**
  * Install table, options and element set
  */
 public function hookInstall()
 {
     $db = $this->_db;
     $sql = "\n            CREATE TABLE IF NOT EXISTS `{$db->Rating}` (\n              `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n              `record_id` int(10) unsigned NOT NULL,\n              `rating` float(2,1) NOT NULL DEFAULT '0',\n              `user_id` int(11) DEFAULT NULL,\n              PRIMARY KEY (`id`)\n            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n        ";
     $db->query($sql);
     // Install and set basic options
     $this->_installOptions();
     set_option('ratings_rating_roles', serialize(array()));
     insert_element_set($this->_elementSet, $this->_elements);
 }