/** * Update an existing config_text setting. * * @param string $config_name The name of the config_text setting you would * like to update * @param mixed $config_value The value of the config_text setting * @return null * @throws \phpbb\db\migration\exception */ public function update($config_name, $config_value) { if (is_null($this->config_text->get($config_name))) { throw new \phpbb\db\migration\exception('CONFIG_NOT_EXIST', $config_name); } $this->config_text->set($config_name, $config_value); }
/** * @param string $list_name whitelist or blacklist * @param string $u_action phpbb acp-u_action */ private function manage_list($u_action, $list_name) { $list_name_upper = strtoupper($list_name); // Define the name of the form for use as a form key $form_name = 'topictags'; add_form_key($form_name); $errors = array(); if ($this->request->is_set_post('submit')) { if (!check_form_key($form_name)) { trigger_error('FORM_INVALID'); } $this->config->set(prefixes::CONFIG . '_' . $list_name . '_enabled', $this->request->variable(prefixes::CONFIG . '_' . $list_name . '_enabled', 0)); $list = rawurldecode(base64_decode($this->request->variable(prefixes::CONFIG . '_' . $list_name, ''))); if (!empty($list)) { $list = json_decode($list, true); $tags = array(); for ($i = 0, $size = sizeof($list); $i < $size; $i++) { $tags[] = $list[$i]['text']; } $list = json_encode($tags); } // store the list $this->config_text->set(prefixes::CONFIG . '_' . $list_name, $list); trigger_error($this->user->lang('TOPICTAGS_' . $list_name_upper . '_SAVED') . adm_back_link($u_action)); } // display $list = $this->config_text->get(prefixes::CONFIG . '_' . $list_name); $list = base64_encode(rawurlencode($list)); $this->template->assign_vars(array('TOPICTAGS_VERSION' => $this->user->lang('TOPICTAGS_INSTALLED', $this->config[prefixes::CONFIG . '_version']), 'TOPICTAGS_' . $list_name_upper . '_ENABLED' => $this->config[prefixes::CONFIG . '_' . $list_name . '_enabled'], 'TOPICTAGS_' . $list_name_upper => $list, 'S_RH_TOPICTAGS_INCLUDE_NG_TAGS_INPUT' => true, 'S_RH_TOPICTAGS_INCLUDE_CSS' => true, 'TOPICTAGS_CONVERT_SPACE_TO_MINUS' => $this->config[prefixes::CONFIG . '_convert_space_to_minus'] ? 'true' : 'false', 'S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => implode('<br />', $errors), 'U_ACTION' => $u_action)); }
public function test_update_resume_data() { $resume_data = array('test_reparser' => array('range-min' => 0, 'range-max' => 100, 'range-size' => 50)); $this->config_text->set('reparser_resume', serialize($resume_data)); $this->reparser_manager->update_resume_data('another_reparser', 5, 20, 10, false); $this->assert_array_content_equals($resume_data, unserialize($this->config_text->get('reparser_resume'))); $this->reparser_manager->update_resume_data('test_reparser', 0, 50, 50); $resume_data = array('test_reparser' => array('range-min' => 0, 'range-max' => 50, 'range-size' => 50), 'another_reparser' => array('range-min' => 5, 'range-max' => 20, 'range-size' => 10)); $this->assert_array_content_equals($resume_data, unserialize($this->config_text->get('reparser_resume'))); }
/** * Updates the resume data in the database * * @param string $name Name of the reparser to which the resume data belongs * @param int $min Lowest record ID * @param int $current Current record ID * @param int $size Number of records to process at a time * @param bool $update_db True if the resume data should be written to the database, false if not. (default: true) */ public function update_resume_data($name, $min, $current, $size, $update_db = true) { // Prevent overwriting the old, stored array if ($this->resume_data === null) { $this->get_resume_data(''); } $this->resume_data[$name] = array('range-min' => $min, 'range-max' => $current, 'range-size' => $size); if ($update_db) { $this->config_text->set('reparser_resume', serialize($this->resume_data)); } }
public function core_acp_manage_forums_update_data_after($event) { $forum_data = $event['forum_data']; $forum_id = $forum_data['forum_id']; $postingtemplate = utf8_normalize_nfc($this->request->variable('forum_postingtemplate', '', true)); if ($postingtemplate) { $this->config_text->set('marttiphpbb_postingtemplate_forum[' . $forum_id . ']', $postingtemplate); } else { $this->config_text->delete('marttiphpbb_postingtemplate_forum[' . $forum_id . ']'); } }
/** * Save the resume data to the database */ protected function save_resume_data() { $this->config_text->set('reparser_resume', serialize($this->resume_data)); }
public function test_set_get_long_string() { $expected = str_repeat('ABC', 10000); $this->config_text->set('long', $expected); $this->assertSame($expected, $this->config_text->get('long')); }
function main($id, $mode) { global $config, $request, $template, $user, $phpbb_container; $this->config = $config; $this->request = $request; $this->template = $template; $this->user = $user; $this->log = $phpbb_container->get('log'); $this->config_text = $phpbb_container->get('config_text'); // Add the piwikstats ACP lang file $user->add_lang_ext('tacitus89/piwikstats', 'piwikstats_acp'); // Create a form key for preventing CSRF attacks add_form_key('piwikstats_config'); // Create an array to collect errors that will be output to the user $errors = array(); // Is the form being submitted to us? if ($this->request->is_set_post('submit')) { // Test if the submitted form is valid if (!check_form_key('piwikstats_config')) { $errors[] = $this->user->lang('FORM_INVALID'); } $cacheTime = $this->request->variable('piwik_cache_page', 0); $cacheTimeIndex = $this->request->variable('piwik_cache_index', 0); if ($cacheTime > 2592000 || $cacheTimeIndex > 2592000) { $errors[] = $this->user->lang('ACP_PIWIK_CACHE_TOO_HIGH'); } // If no errors, process the form data if (empty($errors)) { // Set the options $this->config->set('piwik_ext_active', $this->request->variable('piwik_ext_active', 0)); $this->config->set('piwik_url', rtrim($this->request->variable('piwik_url', '', true), '/')); $this->config->set('piwik_site_id', $this->request->variable('piwik_site_id', 0)); $this->config->set('piwik_accept_donottrack', $this->request->variable('piwik_accept_donottrack', 0)); $this->config->set('piwik_use_user_id', $this->request->variable('piwik_use_user_id', 0)); $this->config->set('piwik_set_title', $this->request->variable('piwik_set_title', 0)); $this->config->set('piwik_track_visitortype', $this->request->variable('piwik_track_visitortype', 0)); $this->config->set('piwik_search', $this->request->variable('piwik_search', 0)); $this->config_text->set('piwik_token', $this->request->variable('piwik_token', '', true)); //Set stats_page $this->config->set('piwik_stats_page_active', $this->request->variable('piwik_stats_page_active', 0)); $this->config_text->set('piwik_time_page', $this->request->variable('piwik_time_page', 0)); $this->config_text->set('piwik_cache_page', $cacheTime); //Set stats_index $this->config->set('piwik_stats_index_active', $this->request->variable('piwik_stats_index_active', 0)); $this->config_text->set('piwik_time_index', $this->request->variable('piwik_time_index', 0)); $this->config_text->set('piwik_cache_index', $cacheTimeIndex); // Add option settings change action to the admin log $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PIWIKSTATS_SETTINGS_LOG'); // Option settings have been updated // Confirm this to the user and provide link back to previous page trigger_error($this->user->lang('ACP_PIWIKSTATS_SETTINGS_SAVED') . adm_back_link($this->u_action)); } } // Get piwikstats data from the config_text object $config_text = $this->config_text->get_array(array('piwik_token', 'piwik_cache_page', 'piwik_time_page', 'piwik_cache_index', 'piwik_time_index')); // Set output vars for display in the template $this->template->assign_vars(array('S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'U_ACTION' => $this->u_action, 'S_PIWIK_EXT_ACTIVE' => $this->config['piwik_ext_active'] ? true : false, 'PIWIK_URL' => $this->config['piwik_url'], 'PIWIK_SITE_ID' => $this->config['piwik_site_id'], 'S_PIWIK_ACCEPT_DONOTTRACK' => $this->config['piwik_accept_donottrack'] ? true : false, 'S_PIWIK_USER_ID' => $this->config['piwik_use_user_id'] ? true : false, 'S_PIWIK_SET_TITLE' => $this->config['piwik_set_title'] ? true : false, 'S_PIWIK_TRACK_VISITORTYPE' => $this->config['piwik_track_visitortype'] ? true : false, 'S_PIWIK_SEARCH' => $this->config['piwik_search'] ? true : false, 'PIWIK_TOKEN' => $config_text['piwik_token'], 'S_PIWIK_STATS_PAGE_ACTIVE' => $this->config['piwik_stats_page_active'] ? true : false, 'PIWIK_TIME_PAGE' => $config_text['piwik_time_page'], 'PIWIK_CACHE_PAGE' => $config_text['piwik_cache_page'], 'S_PIWIK_STATS_INDEX_ACTIVE' => $this->config['piwik_stats_index_active'] ? true : false, 'PIWIK_TIME_INDEX' => $config_text['piwik_time_index'], 'PIWIK_CACHE_INDEX' => $config_text['piwik_cache_index'])); // Load a template from adm/style for our ACP page $this->tpl_name = 'acp_piwikstats'; // Set the page title for our ACP page $this->page_title = $user->lang('ACP_PIWIK_INDEX'); }
/** * {@inheritdoc} */ protected function save_record(array $record) { $this->config_text->set('contact_admin_info', $record['text']); }