/**
  * @param int $block_id
  * @return array
  */
 public function save($block_id)
 {
     $content = $this->request->variable('content', '', true);
     $cblocks = $this->_get_custom_blocks();
     $sql_data = array('block_id' => $block_id, 'block_content' => $content, 'bbcode_bitfield' => '', 'bbcode_options' => 7, 'bbcode_uid' => '');
     generate_text_for_storage($sql_data['block_content'], $sql_data['bbcode_uid'], $sql_data['bbcode_bitfield'], $sql_data['bbcode_options'], true, true, true);
     $sql = !isset($cblocks[$block_id]) ? 'INSERT INTO ' . $this->cblocks_table . ' ' . $this->db->sql_build_array('INSERT', $sql_data) : 'UPDATE ' . $this->cblocks_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_data) . ' WHERE block_id = ' . (int) $block_id;
     $this->db->sql_query($sql);
     $this->cache->destroy('pt_cblocks');
     return array('id' => $block_id, 'content' => $this->_get_content($sql_data), 'callback' => 'previewCustomBlock');
 }
Example #2
0
 public function add(array &$forum_data, $forum_perm_from = 0)
 {
     $forum_data += array('parent_id' => $this->config['sitemaker_parent_forum_id']);
     $errors = admin::save($forum_data);
     if (!sizeof($errors)) {
         $forum_data['forum_id'] = (int) $forum_data['forum_id'];
         // Copy permissions?
         if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id']) {
             copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], false, false);
             phpbb_cache_moderators($this->db, $this->cache, $this->auth);
         }
         $this->auth->acl_clear_prefetch();
         $this->cache->destroy('sql', FORUMS_TABLE);
     }
     return $errors;
 }
Example #3
0
 /**
  * Remove modules cache file
  *
  * @param string	$module_class	Class of the module (acp, ucp, mcp etc...)
  */
 public function remove_cache_file($module_class)
 {
     // Sanitise for future path use, it's escaped as appropriate for queries
     $cache_class = str_replace(array('.', '/', '\\'), '', basename($module_class));
     $this->cache->destroy('_modules_' . $cache_class);
     $this->cache->destroy('sql', $this->modules_table);
 }
Example #4
0
    /**
     * Deactivate styles
     */
    protected function action_deactivate()
    {
        // Get list of styles to deactivate
        $ids = $this->request_vars('id', 0, true);
        // Check for default style
        foreach ($ids as $id) {
            if ($id == $this->default_style) {
                trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING);
            }
        }
        // Reset default style for users who use selected styles
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET user_style = 0
			WHERE user_style IN (' . implode(', ', $ids) . ')';
        $this->db->sql_query($sql);
        // Deactivate styles
        $sql = 'UPDATE ' . STYLES_TABLE . '
			SET style_active = 0
			WHERE style_id IN (' . implode(', ', $ids) . ')';
        $this->db->sql_query($sql);
        // Purge cache
        $this->cache->destroy('sql', STYLES_TABLE);
        // Show styles list
        $this->frontend();
    }
 public function add(&$forum_data, $forum_perm_from = 0)
 {
     $forum_data += array('parent_id' => $this->config['sitemaker_parent_forum_id'], 'forum_type' => FORUM_POST, 'type_action' => '', 'forum_status' => ITEM_UNLOCKED, 'forum_parents' => '', 'forum_name' => '', 'forum_link' => '', 'forum_link_track' => false, 'forum_desc' => '', 'forum_desc_uid' => '', 'forum_desc_options' => 7, 'forum_desc_bitfield' => '', 'forum_rules' => '', 'forum_rules_uid' => '', 'forum_rules_options' => 7, 'forum_rules_bitfield' => '', 'forum_rules_link' => '', 'forum_image' => '', 'forum_style' => 0, 'display_subforum_list' => false, 'display_on_index' => false, 'forum_topics_per_page' => 0, 'enable_indexing' => true, 'enable_icons' => false, 'enable_prune' => false, 'enable_post_review' => true, 'enable_quick_reply' => false, 'prune_days' => 7, 'prune_viewed' => 7, 'prune_freq' => 1, 'prune_old_polls' => false, 'prune_announce' => false, 'prune_sticky' => false, 'show_active' => false, 'forum_password' => '', 'forum_password_confirm' => '', 'forum_password_unset' => false);
     $errors = $this->forum->update_forum_data($forum_data);
     if (!sizeof($errors)) {
         $forum_data['forum_id'] = (int) $forum_data['forum_id'];
         // Copy permissions?
         if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id']) {
             copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], false, false);
             phpbb_cache_moderators($this->db, $this->cache, $this->auth);
         }
         $this->auth->acl_clear_prefetch();
         $this->cache->destroy('sql', FORUMS_TABLE);
     }
     return $errors;
 }
 /**
  * Delete a question
  * @param integer $question_id
  */
 public function acp_delete_question($question_id)
 {
     $tables = array($this->table_sortables_questions, $this->table_sortables_answers);
     foreach ($tables as $table) {
         $sql = "DELETE FROM {$table}\n\t\t\t\tWHERE question_id = " . (int) $question_id;
         $this->db->sql_query($sql);
     }
     $this->cache->destroy('sql', $tables);
 }
Example #7
0
    /**
     * {@inheritdoc}
     */
    public function purge_notifications($notification_type_id)
    {
        $sql = 'DELETE FROM ' . $this->notifications_table . '
			WHERE notification_type_id = ' . (int) $notification_type_id;
        $this->db->sql_query($sql);
        $sql = 'DELETE FROM ' . $this->notification_types_table . '
			WHERE notification_type_id = ' . (int) $notification_type_id;
        $this->db->sql_query($sql);
        $this->cache->destroy('notification_type_ids');
    }
Example #8
0
 /**
  * Run auto groups check against users for a given condition/type
  * Called in the ACP when adding/editing or via the Resync button
  *
  * @param int     $autogroups_rule_id      The id of the auto group rule
  *
  * @return null
  * @access public
  */
 public function sync_autogroups($autogroups_rule_id)
 {
     // Purge cached rules table queries
     $this->cache->destroy('sql', $this->autogroups_rules_table);
     // Get the auto group type name used by the specified auto group rule
     $autogroups_type_name = $this->get_autogroups_type_name(0, $autogroups_rule_id);
     // If auto group type exists, run it
     if ($autogroups_type_name !== false) {
         $this->check_condition($autogroups_type_name, array('action' => 'sync'));
     }
 }
Example #9
0
 public function forumlist_display_rating($event)
 {
     $forum_rows = $event['forum_rows'];
     $this->helper->get_max_forum_thanks();
     $forum_thanks_rating = array();
     foreach ($forum_rows as $row) {
         $forum_thanks_rating[] = $row['forum_id'];
     }
     $this->cache->put('_forum_thanks_rating', $forum_thanks_rating);
     $this->helper->get_thanks_forum_number();
     $this->cache->destroy('_forum_thanks_rating');
 }
Example #10
0
    /**
     * Increments an integer config value directly in the database.
     *
     * Using this method instead of setting the new value directly avoids race
     * conditions and unlike set_atomic it cannot fail.
     *
     * @param string $key       The configuration option's name
     * @param int    $increment Amount to increment by
     * @param bool   $use_cache Whether this variable should be cached or if it
     *                          changes too frequently to be efficiently cached.
     */
    function increment($key, $increment, $use_cache = true)
    {
        if (!isset($this->config[$key])) {
            $this->set($key, '0', $use_cache);
        }
        $sql_update = $this->db->cast_expr_to_string($this->db->cast_expr_to_bigint('config_value') . ' + ' . (int) $increment);
        $this->db->sql_query('UPDATE ' . $this->table . '
			SET config_value = ' . $sql_update . "\n\t\t\tWHERE config_name = '" . $this->db->sql_escape($key) . "'");
        if ($use_cache) {
            $this->cache->destroy('config');
        }
        $this->config[$key] += $increment;
    }
 /**
  * Performs add|edit|del|clean|prune actions
  */
 public function mchat_action($action, $sql_ary = null, $message_id = 0, $log_username = '')
 {
     switch ($action) {
         // User adds a message
         case 'add':
             $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
             $this->mchat_add_user_session();
             break;
             // User edits a message
         // User edits a message
         case 'edit':
             $sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE message_id = ' . (int) $message_id;
             $this->mchat_add_user_session();
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($log_username));
             break;
             // User deletes a message
         // User deletes a message
         case 'del':
             $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id = ' . (int) $message_id;
             $this->mchat_add_user_session();
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($log_username));
             $this->cache->destroy('sql', $this->mchat_table);
             break;
             // Founder purges all messages
         // Founder purges all messages
         case 'clean':
             $sql = 'TRUNCATE TABLE ' . $this->mchat_table;
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
             $this->cache->destroy('sql', $this->mchat_table);
             break;
             // User triggers messages to be pruned
         // User triggers messages to be pruned
         case 'prune':
             $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id < ' . (int) $message_id;
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
             $this->cache->destroy('sql', $this->mchat_table);
             break;
         default:
             return;
     }
     $result = $this->db->sql_query($sql);
     if ($result !== false) {
         switch ($action) {
             case 'add':
                 if ($this->db->sql_nextid() == 1) {
                     $this->cache->destroy('sql', $this->mchat_table);
                 }
                 break;
         }
     }
 }
Example #12
0
File: page.php Project: R3gi/pages
    /**
     * Remove page link location data for a page
     * This method usually need not be called outside of this class
     *
     * @param int $page_id Page identifier
     * @return page_interface $this object for chaining calls
     * @throws \phpbb\pages\exception\out_of_bounds
     * @access protected
     */
    protected function remove_page_links($page_id)
    {
        // Throw an exception if page identifier is invalid
        if (!$this->page_id_exists($page_id)) {
            throw new \phpbb\pages\exception\out_of_bounds('page_id');
        }
        // Delete the page's links from the database
        $sql = 'DELETE FROM ' . $this->pages_pages_links_table . '
			WHERE page_id = ' . (int) $page_id;
        $this->db->sql_query($sql);
        // Destroy cached page links
        $this->cache->destroy('sql', $this->pages_pages_links_table);
        return $this;
    }
Example #13
0
    /**
     * {@inheritdoc}
     */
    public function submit_autogroups_options()
    {
        // Get data from the form
        $autogroups_default_exempt = $this->request->variable('group_ids', array(0));
        // Use a confirmation box routine before setting the data
        if (confirm_box(true)) {
            // Set selected groups to 1
            $sql = 'UPDATE ' . GROUPS_TABLE . '
				SET autogroup_default_exempt = 1
				WHERE ' . $this->db->sql_in_set('group_id', $autogroups_default_exempt, false, true);
            $this->db->sql_query($sql);
            // Set all other groups to 0
            $sql = 'UPDATE ' . GROUPS_TABLE . '
				SET autogroup_default_exempt = 0
				WHERE ' . $this->db->sql_in_set('group_id', $autogroups_default_exempt, true, true);
            $this->db->sql_query($sql);
            // Clear the cached group table data
            $this->cache->destroy('sql', GROUPS_TABLE);
        } else {
            confirm_box(false, $this->user->lang('CONFIRM_OPERATION'), build_hidden_fields(array('generalsubmit' => true, 'group_ids' => $autogroups_default_exempt)));
        }
    }
 public function clear_cached_queries()
 {
     define('SITEMAKER_FORUM_CHANGED', true);
     $this->cache->destroy('sql', array(FORUMS_TABLE, TOPICS_TABLE, POSTS_TABLE, USERS_TABLE));
 }
Example #15
0
    /**
     * Moves an item up/down
     *
     * @param	int		$teampage_id	teampage_id of the item to be moved
     * @param	int		$delta		number of steps:
     *								- positive = move up
     *								- negative = move down
     * @return	bool		True if the group was moved successfully
     */
    public function move_teampage($teampage_id, $delta)
    {
        $delta = (int) $delta;
        if (!$delta) {
            return false;
        }
        $move_up = $delta > 0 ? true : false;
        $data = $this->get_teampage_values($teampage_id);
        $current_value = (int) $data['teampage_position'];
        if ($current_value != self::GROUP_DISABLED) {
            $this->db->sql_transaction('begin');
            if (!$move_up && $data['teampage_parent'] == self::NO_PARENT) {
                // If we move items down, we need to grab the one sibling more,
                // so we do not ignore the children of the previous sibling.
                // We will remove the additional sibling later on.
                $delta = abs($delta) + 1;
            }
            $sql = 'SELECT teampage_id, teampage_position
				FROM ' . TEAMPAGE_TABLE . '
				WHERE teampage_parent = ' . (int) $data['teampage_parent'] . '
					AND teampage_position' . ($move_up ? ' < ' : ' > ') . $current_value . '
				ORDER BY teampage_position' . ($move_up ? ' DESC' : ' ASC');
            $result = $this->db->sql_query_limit($sql, $delta);
            $sibling_count = 0;
            $sibling_limit = $delta;
            // Reset the delta, as we recalculate the new real delta
            $delta = 0;
            while ($row = $this->db->sql_fetchrow($result)) {
                $sibling_count++;
                $delta = $current_value - $row['teampage_position'];
                // Remove the additional sibling we added previously
                // But only, if we included it, this is not be the case
                // when we reached the end of our list
                if (!$move_up && $data['teampage_parent'] == self::NO_PARENT && $sibling_count == $sibling_limit) {
                    $delta++;
                }
            }
            $this->db->sql_freeresult($result);
            if ($delta) {
                $sql = 'SELECT COUNT(teampage_id) as num_items
					FROM ' . TEAMPAGE_TABLE . '
					WHERE teampage_id = ' . (int) $teampage_id . '
						OR teampage_parent = ' . (int) $teampage_id;
                $result = $this->db->sql_query($sql);
                $num_items = (int) $this->db->sql_fetchfield('num_items');
                $this->db->sql_freeresult($result);
                // First we move all items between our current value and the target value up/down 1,
                // so we have a gap for our item to move.
                $sql = 'UPDATE ' . TEAMPAGE_TABLE . '
					SET teampage_position = teampage_position' . ($move_up ? ' + ' : ' - ') . $num_items . '
					WHERE teampage_position' . ($move_up ? ' >= ' : ' <= ') . ($current_value - $delta) . '
						AND teampage_position' . ($move_up ? ' < ' : ' > ') . $current_value . '
						AND NOT (teampage_id = ' . (int) $teampage_id . '
							OR teampage_parent = ' . (int) $teampage_id . ')';
                $this->db->sql_query($sql);
                $delta = !$move_up && $data['teampage_parent'] == self::NO_PARENT ? abs($delta) - ($num_items - 1) : abs($delta);
                // And now finally, when we moved some other items and built a gap,
                // we can move the desired item to it.
                $sql = 'UPDATE ' . TEAMPAGE_TABLE . '
					SET teampage_position = teampage_position ' . ($move_up ? ' - ' : ' + ') . $delta . '
					WHERE teampage_id = ' . (int) $teampage_id . '
						OR teampage_parent = ' . (int) $teampage_id;
                $this->db->sql_query($sql);
                $this->db->sql_transaction('commit');
                $this->cache->destroy('sql', TEAMPAGE_TABLE);
                return true;
            }
            $this->db->sql_transaction('commit');
        }
        $this->cache->destroy('sql', TEAMPAGE_TABLE);
        return false;
    }
    /**
     * The main cron task code.
     */
    public function cron_tidy_warnings($topic_ids = array())
    {
        $warning_list = $user_list = $unban_list = array();
        $current_time = time();
        $sql = 'SELECT * FROM ' . WARNINGS_TABLE . "\n\t\t\tWHERE warning_end < {$current_time} \n\t\t\tAND warning_end > 0 \n\t\t\tAND warning_status = 1";
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $warning_list[] = $row['warning_id'];
            $user_list[$row['user_id']] = isset($user_list[$row['user_id']]) ? ++$user_list[$row['user_id']] : 1;
        }
        $this->db->sql_freeresult($result);
        if (sizeof($warning_list)) {
            $this->db->sql_transaction('begin');
            $sql = 'UPDATE ' . WARNINGS_TABLE . ' SET warning_status = 0
				WHERE ' . $this->db->sql_in_set('warning_id', $warning_list);
            $this->db->sql_query($sql);
            foreach ($user_list as $user_id => $value) {
                $sql = 'UPDATE ' . USERS_TABLE . " SET user_warnings = user_warnings - {$value}\n\t\t\t\t\tWHERE user_id = {$user_id}";
                $this->db->sql_query($sql);
            }
            // Try to get storage engine type to detect if transactions are supported
            // to apply proper bans selection (MyISAM/InnoDB)
            $operator = '<';
            /* Comment out this part of code for now as get_table_status()
            			* as unavailable for \phpbb\db\driver\driver_interface
            			if (strpos($this->db->get_sql_layer(), 'mysql') !== false)
            			{
            				$table_status = $this->db->get_table_status(USERS_TABLE);
            				if (isset($table_status['Engine']))
            				{
            					$operator = ($table_status['Engine'] === 'MyISAM') ? '<' : '<=';
            				}
            			}
            			*/
            $sql = 'SELECT u.user_id, b.ban_id FROM ' . USERS_TABLE . ' u, ' . BANLIST_TABLE . " b\n\t\t\t\tWHERE u.user_ban_id = 1\n\t\t\t\t\tAND u.user_warnings {$operator} " . (int) $this->config['warnings_for_ban'] . '
					AND u.user_id = b.ban_userid';
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $unban_list[(int) $row['user_id']] = (int) $row['ban_id'];
            }
            $this->db->sql_freeresult($result);
            if (sizeof($unban_list)) {
                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_ban_id = 0
					WHERE ' . $this->db->sql_in_set('user_id', array_keys($unban_list));
                $this->db->sql_query($sql);
                $sql = 'SELECT u.username AS unban_info, u.user_id
					FROM ' . USERS_TABLE . ' u, ' . BANLIST_TABLE . ' b
					WHERE ' . $this->db->sql_in_set('b.ban_id', $unban_list) . '
						AND u.user_id = b.ban_userid';
                $result = $this->db->sql_query($sql);
                $l_unban_list = '';
                $user_ids_ary = array();
                while ($row = $this->db->sql_fetchrow($result)) {
                    $l_unban_list .= ($l_unban_list != '' ? ', ' : '') . $row['unban_info'];
                    $user_ids_ary[] = $row['user_id'];
                }
                $this->db->sql_freeresult($result);
                $sql = 'DELETE FROM ' . BANLIST_TABLE . '
					WHERE ' . $this->db->sql_in_set('ban_id', $unban_list);
                $this->db->sql_query($sql);
                // Add to moderator log, admin log and user notes
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_UNBAN_USER', false, $l_unban_list);
                $this->phpbb_log->add('mod', 0, 0, 'LOG_UNBAN_USER', false, $l_unban_list);
                foreach ($user_ids_ary as $user_id) {
                    $this->phpbb_log->add('user', $user_id, 0, 'LOG_UNBAN_USER', false, $l_unban_list);
                }
            }
            $this->db->sql_transaction('commit');
        }
        $this->cache->destroy('sql', array(WARNINGS_TABLE, BANLIST_TABLE));
        $this->config->set('warnings_last_gc', time(), true);
    }
 /**
  * Delete all blocks and routes for a specific style
  */
 public function delete_blocks_by_style($style_id)
 {
     $this->block_mapper->delete(array('style' => (int) $style_id));
     $this->route_mapper->delete(array('style' => (int) $style_id));
     $this->cache->destroy('sitemaker_block_routes');
 }
 public function clear_cache()
 {
     $this->cache->destroy('sitemaker_menus');
 }
Example #19
0
 /**
  * Clear blocks cache
  */
 public function clear_cache()
 {
     $this->cache->destroy('sitemaker_blocks');
     $this->cache->destroy('sitemaker_block_routes');
 }
 /**
  * Update topic_preview_theme setting in the styles table
  *
  * @param	int		$style_id	id of the board style
  * @param	string	$theme		name of the selected theme
  * @access	protected
  */
 protected function set_style_theme($style_id, $theme)
 {
     $sql = 'UPDATE ' . STYLES_TABLE . "\n\t\t\tSET topic_preview_theme = '" . $this->db->sql_escape($theme) . "'\n\t\t\tWHERE style_id = " . (int) $style_id;
     $this->db->sql_query($sql);
     $this->cache->destroy('sql', STYLES_TABLE);
 }
    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();
    }