Example #1
0
 /**
  * Display board announcements
  *
  * @return null
  * @access public
  */
 public function display_board_announcements()
 {
     // Do not continue if announcement has been disabled
     if (!$this->config['board_announcements_enable']) {
         return;
     }
     // Get board announcement data from the cache
     $board_announcement_data = $this->cache->get('_board_announcement_data');
     if ($board_announcement_data === false) {
         // Get board announcement data from the config_text object
         $board_announcement_data = $this->config_text->get_array(array('announcement_text', 'announcement_uid', 'announcement_bitfield', 'announcement_options', 'announcement_bgcolor', 'announcement_timestamp'));
         // Cache board announcement data
         $this->cache->put('_board_announcement_data', $board_announcement_data);
     }
     // Get announcement cookie if one exists
     $cookie = $this->request->variable($this->config['cookie_name'] . '_baid', '', true, \phpbb\request\request_interface::COOKIE);
     // Do not continue if announcement has been dismissed
     if (!$this->user->data['board_announcements_status'] || $cookie == $board_announcement_data['announcement_timestamp']) {
         return;
     }
     // Prepare board announcement message for display
     $announcement_message = generate_text_for_display($board_announcement_data['announcement_text'], $board_announcement_data['announcement_uid'], $board_announcement_data['announcement_bitfield'], $board_announcement_data['announcement_options']);
     // Add board announcements language file
     $this->user->add_lang_ext('phpbb/boardannouncements', 'boardannouncements');
     // Output board announcement to the template
     $this->template->assign_vars(array('S_BOARD_ANNOUNCEMENT' => true, 'S_BOARD_ANNOUNCEMENT_DISMISS' => (bool) $this->config['board_announcements_dismiss'], 'BOARD_ANNOUNCEMENT' => $announcement_message, 'BOARD_ANNOUNCEMENT_BGCOLOR' => $board_announcement_data['announcement_bgcolor'], 'U_BOARD_ANNOUNCEMENT_CLOSE' => $this->controller_helper->route('phpbb_boardannouncements_controller', array('hash' => generate_link_hash('close_boardannouncement')))));
 }
Example #2
0
 /**
  * Remove an existing config_text setting.
  *
  * @param string $config_name The name of the config_text setting you would
  * 	like to remove
  * @return null
  */
 public function remove($config_name)
 {
     if (is_null($this->config_text->get($config_name))) {
         return;
     }
     $this->config_text->delete($config_name);
 }
 /**
  * @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));
 }
Example #4
0
 /**
  * Set a cookie to keep an announcement closed
  *
  * @return bool True
  * @access protected
  */
 protected function set_board_announcement_cookie()
 {
     // Get board announcement data from the DB text object
     $announcement_timestamp = $this->config_text->get('announcement_timestamp');
     // Store the announcement timestamp/id in a cookie with a 1 year expiration
     $this->user->set_cookie('baid', $announcement_timestamp, strtotime('+1 year'));
     return true;
 }
Example #5
0
 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')));
 }
Example #6
0
 /**
  * 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));
     }
 }
Example #7
0
 public function test_delete_array_get_remaining()
 {
     $this->config_text->delete_array(array('foo', 'bar'));
     $this->assertNull($this->config_text->get('bar'));
     $this->assertNull($this->config_text->get('foo'));
     $this->assertSame('string-de-ding', $this->config_text->get('meh'));
 }
Example #8
0
 /**
  * {inheritDoc}
  */
 public function render(\phpbb\template\template $template)
 {
     $l_admin_info = $this->config_text->get('contact_admin_info');
     if ($l_admin_info) {
         $contact_admin_data = $this->config_text->get_array(array('contact_admin_info', 'contact_admin_info_uid', 'contact_admin_info_bitfield', 'contact_admin_info_flags'));
         $l_admin_info = generate_text_for_display($contact_admin_data['contact_admin_info'], $contact_admin_data['contact_admin_info_uid'], $contact_admin_data['contact_admin_info_bitfield'], $contact_admin_data['contact_admin_info_flags']);
     }
     $template->assign_vars(array('S_CONTACT_ADMIN' => true, 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], 'S_IS_REGISTERED' => $this->user->data['is_registered'], 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=contactadmin'), 'CONTACT_INFO' => $l_admin_info, 'MESSAGE' => $this->body, 'SUBJECT' => $this->subject, 'NAME' => $this->sender_name, 'EMAIL' => $this->sender_address));
     parent::render($template);
 }
Example #9
0
 public function core_posting_modify_template_vars($event)
 {
     $page_data = $event['page_data'];
     $post_data = $event['post_data'];
     $mode = $event['mode'];
     $submit = $event['submit'];
     $preview = $event['preview'];
     $load = $event['load'];
     $save = $event['save'];
     $refresh = $event['refresh'];
     $forum_id = $event['forum_id'];
     if ($mode == 'post' && !$submit && !$preview && !$load && !$save && !$refresh && empty($post_data['post_text']) && empty($post_data['post_subject']) && $this->config_text->get('marttiphpbb_postingtemplate_forum[' . $forum_id . ']')) {
         $page_data['MESSAGE'] = $this->config_text->get('marttiphpbb_postingtemplate_forum[' . $forum_id . ']');
     }
     $event['page_data'] = $page_data;
 }
Example #10
0
 /**
  * Add some stats from piwik on the index
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function add_on_index($event)
 {
     //Is it activated?
     if (!empty($this->config['piwik_stats_index_active']) == false) {
         return;
     }
     // Get piwikstats data from the config_text object
     $config_text = $this->config_text->get_array(array('piwik_token', 'piwik_time_index', 'piwik_cache_index'));
     //Get the data from Cache
     $data = false;
     // $this->cache->get('piwik_stats_index');
     //No Data in the Cache
     if ($data === false) {
         //url to piwik
         $url = $this->config['piwik_url'] . '/index.php?module=API&method=VisitsSummary.get' . '&idSite=' . $this->config['piwik_site_id'] . '&apiModule=VisitsSummary&apiAction=get' . '&period=range&date=last' . $config_text['piwik_time_index'] . '&token_auth=' . $config_text['piwik_token'] . '&format=php';
         //get the data from piwik
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $data = curl_exec($ch);
         curl_close($ch);
         //Is it a correct url?
         if ($data === false) {
             return;
         }
         //$this->cache->put('piwik_stats_index', $data, $config_text['piwik_cache_index']);
     }
     //unserialize the data
     $data = @unserialize($data);
     //Is there serialized data or get we an error from piwik?
     if ($data === false || isset($data['result']) && $data['result'] === 'error') {
         return;
     }
     // Add piwikstats language file
     $this->user->add_lang_ext('tacitus89/piwikstats', 'piwikstats');
     // Output piwikstats to the template
     $this->template->assign_vars(array('S_PIWIK_STATS_INDEX_ACTIVATE' => !empty($this->config['piwik_stats_index_active']) ? true : false, 'S_PIWIK_STATS_PAGE_ACTIVATE' => !empty($this->config['piwik_stats_page_active']) ? true : false, 'PIWIK_STATS_URL' => $this->helper->route('tacitus89_piwikstats_main_controller'), 'PIWIK_VISITORS' => number_format($data['nb_visits'], 0, ',', '.'), 'PIWIK_ACTIONS' => number_format($data['nb_actions'], 0, ',', '.'), 'PIWIK_AVG_TIME_ON_SITE' => gmdate("H:i:s", $data['avg_time_on_site']), 'PIWIK_ACTIONS_PER_VISIT' => round($data['nb_actions_per_visit'], 2), 'PIWIK_TIME' => $config_text['piwik_time_index']));
 }
Example #11
0
 public function edit_subject($event)
 {
     $mode = $event['mode'];
     $post_data = $event['post_data'];
     $topic_first_post_id = isset($event['post_data']['topic_first_post_id']) ? $event['post_data']['topic_first_post_id'] : 0;
     $post_id = isset($event['post_data']['post_id']) ? $event['post_data']['post_id'] : 0;
     $forums = explode(',', $this->config['sub_prfx_forums']);
     if (in_array($event['forum_id'], $forums) && ($mode == 'post' || $mode == 'edit') && ($post_id == $topic_first_post_id || !$topic_first_post_id)) {
         if ($mode == 'edit') {
             $subject_data = $event['post_data']['post_subject'];
             $subject_data = explode(']', $subject_data);
             $subject = array_pop($subject_data);
             $subject_prfixes = array_diff($subject_data, array($subject));
             foreach ($subject_prfixes as $key => $pfx) {
                 $subject_prfixes[$key] = str_replace('[', '', $pfx);
             }
         }
         $options = $options_second = array(0 => $this->user->lang['SELECT']);
         $options = array_merge($options, explode(',', (string) $this->config_text->get('sub_prfx')));
         $options_second = array_merge($options_second, explode(',', (string) $this->config_text->get('sub_prfx_second')));
         $key = isset($subject_prfixes[0]) ? array_search($subject_prfixes[0], $options) : 0;
         $second_key = isset($subject_prfixes[1]) ? array_search($subject_prfixes[1], $options_second) : 0;
         $prefix = $this->request->variable('subprfx', $key);
         $subprfx_second = $this->request->variable('subprfx_second', $second_key);
         $select = '';
         if ($options[1]) {
             foreach ($options as $key => $value) {
                 $select .= '<option value="' . $key . '"' . ($key == $prefix ? ' selected="selected"' : '') . '>' . $value . '</option>';
             }
         }
         $select_second = '';
         if ($options_second[1]) {
             foreach ($options_second as $key => $value) {
                 $select_second .= '<option value="' . $key . '"' . ($key == $subprfx_second ? ' selected="selected"' : '') . '>' . $value . '</option>';
             }
         }
         $this->template->assign_vars(array('S_SELECT' => $select, 'S_SELECT_SECOND' => $select_second));
     }
 }
 public function test_is_valid_tag()
 {
     global $table_prefix;
     $this->assertTrue($this->tags_manager->is_valid_tag("tag"));
     // clean tags must be trimed (note the trailing space)
     $this->assertFalse($this->tags_manager->is_valid_tag("tag ", true));
     $this->assertFalse($this->tags_manager->is_valid_tag("ta"), 'tag is too short');
     $this->assertFalse($this->tags_manager->is_valid_tag("abcdefghijabcdefghijabcdefghija", true), 'tag is too long');
     // will be cleaned and thereby trimmed to 30 chars
     $this->assertTrue($this->tags_manager->is_valid_tag("abcdefghijabcdefghijabcdefghija", false));
     // enable blacklist and whitelist
     global $table_prefix;
     $config = new \phpbb\config\config(array(prefixes::CONFIG . '_allowed_tags_regex' => '/^[a-z]{3,30}$/i', prefixes::CONFIG . '_whitelist_enabled' => true, prefixes::CONFIG . '_blacklist_enabled' => true));
     $this->config_text->set_array(array(prefixes::CONFIG . '_blacklist' => json_encode(array("blacktag", "blackwhitetag")), prefixes::CONFIG . '_whitelist' => json_encode(array("whitetag", "blackwhitetag"))));
     $db_helper = new \robertheim\topictags\service\db_helper($this->db);
     $this->tags_manager = new tags_manager($this->db, $config, $this->config_text, $this->auth, $db_helper, $table_prefix);
     $this->assertFalse($this->tags_manager->is_valid_tag("blacktag", true), 'tag is on blacklist');
     $this->assertFalse($this->tags_manager->is_valid_tag("notwhitetag", true), 'tag is not on whitelist');
     $this->assertTrue($this->tags_manager->is_valid_tag("whitetag", true), 'tag is not blacklisted and on whitelist');
     $this->assertFalse($this->tags_manager->is_valid_tag("blackwhitetag", true), 'blacklist must be given priority');
     $this->config_text->delete_array(array(prefixes::CONFIG . '_blacklist', prefixes::CONFIG . '_whitelist'));
 }
Example #13
0
 public function posts_merging($event)
 {
     $mode = $event['mode'];
     $subject = $event['subject'];
     $username = $event['username'];
     $topic_type = $event['topic_type'];
     $poll = $event['poll'];
     $data = $event['data'];
     $update_message = $event['update_message'];
     $update_search_index = $event['update_search_index'];
     $current_time = time();
     $do_not_merge_with_previous = $this->request->variable('posts_merging_option', false);
     if (!$do_not_merge_with_previous && !$this->helper->post_needs_approval($data) && in_array($mode, array('reply', 'quote')) && $this->merge_interval && !$this->helper->excluded_from_merge($data)) {
         $merge_post_data = $this->helper->get_last_post_data($data);
         // Do not merge if there's no last post data, the post is locked or allowed merge period has left
         if (!$merge_post_data || $merge_post_data['post_edit_locked'] || $current_time - (int) $merge_post_data['topic_last_post_time'] > $this->merge_interval || !$this->user->data['is_registered']) {
             return;
         }
         // Also, don't let user to violate attachments limit by posts merging
         // In this case, also don't merge posts and return
         // Exceptions are administrators and forum moderators
         $num_old_attachments = $this->helper->count_post_attachments((int) $merge_post_data['post_id']);
         $num_new_attachments = sizeof($data['attachment_data']);
         $total_attachments_count = $num_old_attachments + $num_new_attachments;
         if ($total_attachments_count > $this->config['max_attachments'] && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_', (int) $data['forum_id'])) {
             return;
         }
         $data['post_id'] = (int) $merge_post_data['post_id'];
         $merge_post_data['post_attachment'] = $total_attachments_count ? 1 : 0;
         // Decode old message and addon
         $merge_post_data['post_text'] = $this->helper->prepare_text_for_merge($merge_post_data);
         $data['message'] = $this->helper->prepare_text_for_merge($data);
         // Handle inline attachments BBCode in old message
         if ($num_new_attachments) {
             $merge_post_data['post_text'] = preg_replace('#\\[attachment=([0-9]+)\\](.*?)\\[\\/attachment\\]#e', "'[attachment='.(\\1 + {$num_new_attachments}).']\\2[/attachment]'", $merge_post_data['post_text']);
         }
         // Prepare message separator
         $separator = (string) $this->config_text->get('posts_merging_separator_text');
         $this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging');
         // Calculate the time interval
         $interval = $this->helper->get_time_interval($current_time, $merge_post_data['post_time']);
         $time = array();
         $time[] = $interval->h ? $this->user->lang('D_HOURS', $interval->h) : null;
         $time[] = $interval->i ? $this->user->lang('D_MINUTES', $interval->i) : null;
         $time[] = $interval->s ? $this->user->lang('D_SECONDS', $interval->s) : null;
         // Allow using language variables like {L_LANG_VAR}
         $separator = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($matches) {
             return $this->user->lang($matches[1]);
         }, $separator);
         // Eval linefeeds and generate the separator, time interval included
         $separator = sprintf(str_replace('\\n', "\n", $separator), implode(' ', $time));
         // Merge subject
         if (!empty($subject) && $subject != $merge_post_data['post_subject'] && $merge_post_data['post_id'] != $merge_post_data['topic_first_post_id']) {
             $separator .= sprintf($this->user->lang['MERGE_SUBJECT'], $subject);
         }
         // Merge posts
         $merge_post_data['post_text'] = $merge_post_data['post_text'] . $separator . $data['message'];
         // Make sure the message is safe
         $this->type_cast_helper->recursive_set_var($merge_post_data['post_text'], '', true);
         //Prepare post for submit
         $options = '';
         $warn_msg = generate_text_for_storage($merge_post_data['post_text'], $merge_post_data['bbcode_uid'], $merge_post_data['bbcode_bitfield'], $options, $merge_post_data['enable_bbcode'], $merge_post_data['enable_magic_url'], $merge_post_data['enable_smilies']);
         // If $warn_msg is not empty, the merged message does not conform some restrictions
         // In this case we simply don't merge and return back to the function submit_post()
         if (!empty($warn_msg)) {
             return;
         }
         // If this is the first merging for current post, save original post time within the post_created field
         // Update post time with the current time and submit post to the database
         $merge_post_data['post_created'] = $merge_post_data['post_created'] ?: $merge_post_data['post_time'];
         $merge_post_data['post_time'] = $data['post_time'] = $current_time;
         $this->helper->submit_post_to_database($merge_post_data);
         // Submit attachments
         $this->helper->submit_attachments($data);
         // Update read tracking
         $this->helper->update_read_tracking($data);
         // If a username was supplied or the poster is a guest, we will use the supplied username.
         // Doing it this way we can use "...post by guest-username..." in notifications when
         // "guest-username" is supplied or ommit the username if it is not.
         $username = $username !== '' || !$this->user->data['is_registered'] ? $username : $this->user->data['username'];
         // Send Notifications
         // Despite the post_id is the same and users who've been already notified
         // won't be notified again about the same post_id, we send notifications
         // for new users possibly subscribed to it
         $notification_data = array_merge($data, array('topic_title' => isset($data['topic_title']) ? $data['topic_title'] : $subject, 'post_username' => $username, 'poster_id' => (int) $data['poster_id'], 'post_text' => $data['message'], 'post_time' => $merge_post_data['post_time'], 'post_subject' => $subject));
         $this->notification_manager->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post'), $notification_data);
         // Update search index
         $this->helper->update_search_index($merge_post_data);
         //Generate redirection URL and redirecting
         $params = $add_anchor = '';
         $params .= '&amp;t=' . $data['topic_id'];
         $params .= '&amp;p=' . $data['post_id'];
         $add_anchor = '#p' . $data['post_id'];
         $url = "{$this->phpbb_root_path}viewtopic.{$this->php_ext}";
         $url = append_sid($url, 'f=' . (int) $data['forum_id'] . $params) . $add_anchor;
         /**
          * Modify the data for post submitting
          *
          * @event rxu.postsmerging.posts_merging_end
          * @var	string	mode				Variable containing posting mode value
          * @var	string	subject				Variable containing post subject value
          * @var	string	username			Variable containing post author name
          * @var	int		topic_type			Variable containing topic type value
          * @var	array	poll				Array with the poll data for the post
          * @var	array	data				Array with the data for the post
          * @var	bool	update_message		Flag indicating if the post will be updated
          * @var	bool	update_search_index	Flag indicating if the search index will be updated
          * @var	string	url					The "Return to topic" URL
          * @since 2.0.0
          */
         $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'update_message', 'update_search_index', 'url');
         extract($this->phpbb_dispatcher->trigger_event('rxu.postsmerging.posts_merging_end', compact($vars)));
         redirect($url);
     }
 }
Example #14
0
 /**
  * Get piwikstats data from the config_text object
  *
  * @return array
  * @access private
  */
 private function getConfigText()
 {
     // Get piwikstats data from the config_text object
     return $this->config_text->get_array(array('piwik_token', 'piwik_cache_page', 'piwik_time_page'));
 }
 /**
  * Gets all tags from the whitelist
  */
 public function get_whitelist_tags()
 {
     return json_decode($this->config_text->get(prefixes::CONFIG . '_whitelist'), true);
 }
 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');
 }
Example #17
0
 /**
  * Save the resume data to the database
  */
 protected function save_resume_data()
 {
     $this->config_text->set('reparser_resume', serialize($this->resume_data));
 }
    public function main($id, $mode)
    {
        global $cache, $config, $db, $phpbb_log, $request, $template, $user, $phpbb_root_path, $phpEx, $phpbb_container;
        $this->cache = $cache;
        $this->config = $config;
        $this->config_text = $phpbb_container->get('config_text');
        $this->db = $db;
        $this->log = $phpbb_log;
        $this->request = $request;
        $this->template = $template;
        $this->user = $user;
        $this->phpbb_root_path = $phpbb_root_path;
        $this->php_ext = $phpEx;
        // Add the posting lang file needed by BBCodes
        $this->user->add_lang(array('posting'));
        // Add the board announcements ACP lang file
        $this->user->add_lang_ext('phpbb/boardannouncements', 'boardannouncements_acp');
        // Load a template from adm/style for our ACP page
        $this->tpl_name = 'board_announcements';
        // Set the page title for our ACP page
        $this->page_title = 'ACP_BOARD_ANNOUNCEMENTS_SETTINGS';
        // Define the name of the form for use as a form key
        $form_name = 'acp_board_announcements';
        add_form_key($form_name);
        // Set an empty error string
        $error = '';
        // Include files needed for displaying BBCodes
        if (!function_exists('display_custom_bbcodes')) {
            include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
        }
        // Get all board announcement data from the config_text table in the database
        $data = $this->config_text->get_array(array('announcement_text', 'announcement_uid', 'announcement_bitfield', 'announcement_options', 'announcement_bgcolor'));
        // If form is submitted or previewed
        if ($this->request->is_set_post('submit') || $this->request->is_set_post('preview')) {
            // Test if form key is valid
            if (!check_form_key($form_name)) {
                $error = $this->user->lang('FORM_INVALID');
            }
            // Get new announcement text and bgcolor values from the form
            $data['announcement_text'] = $this->request->variable('board_announcements_text', '', true);
            $data['announcement_bgcolor'] = $this->request->variable('board_announcements_bgcolor', '', true);
            // Get config options from the form
            $enable_announcements = $this->request->variable('board_announcements_enable', false);
            $allow_guests = $this->request->variable('board_announcements_guests', false);
            $dismiss_announcements = $this->request->variable('board_announcements_dismiss', false);
            // Prepare announcement text for storage
            generate_text_for_storage($data['announcement_text'], $data['announcement_uid'], $data['announcement_bitfield'], $data['announcement_options'], !$this->request->variable('disable_bbcode', false), !$this->request->variable('disable_magic_url', false), !$this->request->variable('disable_smilies', false));
            // Store the announcement text and settings if submitted with no errors
            if (empty($error) && $this->request->is_set_post('submit')) {
                // Store the config enable/disable state
                $this->config->set('board_announcements_enable', $enable_announcements);
                $this->config->set('board_announcements_guests', $allow_guests);
                $this->config->set('board_announcements_dismiss', $dismiss_announcements);
                // Store the announcement settings to the config_table in the database
                $this->config_text->set_array(array('announcement_text' => $data['announcement_text'], 'announcement_uid' => $data['announcement_uid'], 'announcement_bitfield' => $data['announcement_bitfield'], 'announcement_options' => $data['announcement_options'], 'announcement_bgcolor' => $data['announcement_bgcolor'], 'announcement_timestamp' => time()));
                // Set the board_announcements_status for all normal users
                // to 1 when an announcement is created, or 0 when announcement is empty
                $announcement_status = !empty($data['announcement_text']) ? 1 : 0;
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET board_announcements_status = ' . $announcement_status . '
					WHERE user_type <> ' . USER_IGNORE;
                $this->db->sql_query($sql);
                // Set the board_announcement status for guests if they are allowed
                // We do this separately for guests to make sure it is always set to
                // the correct value every time.
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET board_announcements_status = ' . ($allow_guests && $announcement_status ? 1 : 0) . '
					WHERE user_id = ' . ANONYMOUS;
                $this->db->sql_query($sql);
                // Log the announcement update
                $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'BOARD_ANNOUNCEMENTS_UPDATED_LOG');
                // Destroy any cached board announcement data
                $this->cache->destroy('_board_announcement_data');
                // Output message to user for the announcement update
                trigger_error($this->user->lang('BOARD_ANNOUNCEMENTS_UPDATED') . adm_back_link($this->u_action));
            }
        }
        // Prepare a fresh announcement preview
        $announcement_text_preview = '';
        if ($this->request->is_set_post('preview')) {
            $announcement_text_preview = generate_text_for_display($data['announcement_text'], $data['announcement_uid'], $data['announcement_bitfield'], $data['announcement_options']);
        }
        // prepare the announcement text for editing inside the textbox
        $announcement_text_edit = generate_text_for_edit($data['announcement_text'], $data['announcement_uid'], $data['announcement_options']);
        // Output data to the template
        $this->template->assign_vars(array('ERRORS' => $error, 'BOARD_ANNOUNCEMENTS_ENABLED' => isset($enable_announcements) ? $enable_announcements : $this->config['board_announcements_enable'], 'BOARD_ANNOUNCEMENTS_GUESTS' => isset($allow_guests) ? $allow_guests : $this->config['board_announcements_guests'], 'BOARD_ANNOUNCEMENTS_DISMISS' => isset($dismiss_announcements) ? $dismiss_announcements : $this->config['board_announcements_dismiss'], 'BOARD_ANNOUNCEMENTS_TEXT' => $announcement_text_edit['text'], 'BOARD_ANNOUNCEMENTS_PREVIEW' => $announcement_text_preview, 'BOARD_ANNOUNCEMENTS_BGCOLOR' => $data['announcement_bgcolor'], 'S_BBCODE_DISABLE_CHECKED' => !$announcement_text_edit['allow_bbcode'], 'S_SMILIES_DISABLE_CHECKED' => !$announcement_text_edit['allow_smilies'], 'S_MAGIC_URL_DISABLE_CHECKED' => !$announcement_text_edit['allow_urls'], 'BBCODE_STATUS' => $this->user->lang('BBCODE_IS_ON', '<a href="' . append_sid("{$this->phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'SMILIES_STATUS' => $this->user->lang('SMILIES_ARE_ON'), 'IMG_STATUS' => $this->user->lang('IMAGES_ARE_ON'), 'FLASH_STATUS' => $this->user->lang('FLASH_IS_ON'), 'URL_STATUS' => $this->user->lang('URL_IS_ON'), 'S_BBCODE_ALLOWED' => true, 'S_SMILIES_ALLOWED' => true, 'S_BBCODE_IMG' => true, 'S_BBCODE_FLASH' => true, 'S_LINKS_ALLOWED' => true, 'S_BOARD_ANNOUNCEMENTS' => true, 'U_ACTION' => $this->u_action));
        // Build custom bbcodes array
        display_custom_bbcodes();
    }
 private function get_settings()
 {
     $settings = $this->config_text->get('sfs_settings');
     $settings = unserialize($settings);
     return $settings;
 }
Example #20
0
 /**
  * {@inheritdoc}
  */
 protected function save_record(array $record)
 {
     $this->config_text->set('contact_admin_info', $record['text']);
 }