コード例 #1
0
 /**
  * Allows to edit load balancing settings.
  *
  * This method handles the display, allows to edit, and saves the result
  * for the _balancingSettings form.
  */
 public function action_balancingSettings_display()
 {
     global $txt, $scripturl, $context;
     // Initialize the form
     $this->_initBalancingSettingsForm();
     // Initialize it with our settings
     $config_vars = $this->_balancingSettingsForm->settings();
     call_integration_hook('integrate_loadavg_settings');
     $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
     $context['settings_title'] = $txt['load_balancing_settings'];
     // Saving?
     if (isset($_GET['save'])) {
         // Stupidity is not allowed.
         foreach ($_POST as $key => $value) {
             if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable') {
                 continue;
             } elseif ($key == 'loadavg_auto_opt' && $value <= 1) {
                 $_POST['loadavg_auto_opt'] = '1.0';
             } elseif ($key == 'loadavg_forum' && $value < 10) {
                 $_POST['loadavg_forum'] = '10.0';
             } elseif ($value < 2) {
                 $_POST[$key] = '2.0';
             }
         }
         call_integration_hook('integrate_save_loadavg_settings');
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
     }
     createToken('admin-ssc');
     createToken('admin-dbsc');
     $this->_balancingSettingsForm->prepare_db($config_vars);
 }
コード例 #2
0
 /**
  * Adminstration page for topics: allows to display and set settings related to topics.
  *
  * Requires the admin_forum permission.
  * Accessed from ?action=admin;area=postsettings;sa=topics.
  * @uses Admin template, edit_topic_settings sub-template.
  */
 public function action_topicSettings_display()
 {
     global $context, $txt, $scripturl;
     // Initialize the form
     $this->_initTopicSettingsForm();
     // Retrieve the current config settings
     $config_vars = $this->_topicSettings->settings();
     // Setup the template.
     $context['sub_template'] = 'show_settings';
     // Are we saving them - are we??
     if (isset($_GET['save'])) {
         // Security checks
         checkSession();
         // Notify addons and integrations of the settings change.
         call_integration_hook('integrate_save_topic_settings');
         // Save the result!
         Settings_Form::save_db($config_vars);
         // We're done here, pal.
         redirectexit('action=admin;area=postsettings;sa=topics');
     }
     // Set up the template stuff nicely.
     $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=topics';
     $context['settings_title'] = $txt['manageposts_topic_settings'];
     // Prepare the settings
     Settings_Form::prepare_db($config_vars);
 }
コード例 #3
0
 /**
  * If you have a general mod setting to add stick it here.
  */
 public function action_addonSettings_display()
 {
     // Initialize the form
     $this->_initAddonSettingsForm();
     // Initialize settings
     $config_vars = $this->_addonSettings->settings();
     // Saving?
     if (isset($_GET['save'])) {
         checkSession();
         call_integration_hook('integrate_save_general_mod_settings');
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=addonsettings;sa=general');
     }
     Settings_Form::prepare_db($config_vars);
 }
コード例 #4
0
    /**
     * Allows to view and modify the mail settings.
     *
     * @uses show_settings sub template
     */
    public function action_mailSettings_display()
    {
        global $txt, $scripturl, $context, $txtBirthdayEmails;
        // Some important context stuff
        $context['page_title'] = $txt['mail_settings'];
        $context['sub_template'] = 'show_settings';
        // Initialize the form
        $this->_initMailSettingsForm();
        // Piece of redundant code, for the javascript
        $processedBirthdayEmails = array();
        foreach ($txtBirthdayEmails as $key => $value) {
            $index = substr($key, 0, strrpos($key, '_'));
            $element = substr($key, strrpos($key, '_') + 1);
            $processedBirthdayEmails[$index][$element] = $value;
        }
        $config_vars = $this->_mailSettings->settings();
        // Saving?
        if (isset($_GET['save'])) {
            // Make the SMTP password a little harder to see in a backup etc.
            if (!empty($_POST['smtp_password'][1])) {
                $_POST['smtp_password'][0] = base64_encode($_POST['smtp_password'][0]);
                $_POST['smtp_password'][1] = base64_encode($_POST['smtp_password'][1]);
            }
            checkSession();
            // We don't want to save the subject and body previews.
            unset($config_vars['birthday_subject'], $config_vars['birthday_body']);
            call_integration_hook('integrate_save_mail_settings');
            // You can not send more per page load than you can per minute
            if (!empty($_POST['mail_batch_size'])) {
                $_POST['mail_batch_size'] = min((int) $_POST['mail_batch_size'], (int) $_POST['mail_period_limit']);
            }
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=mailqueue;sa=settings');
        }
        $context['post_url'] = $scripturl . '?action=admin;area=mailqueue;save;sa=settings';
        $context['settings_title'] = $txt['mailqueue_settings'];
        // Prepare the config form
        Settings_Form::prepare_db($config_vars);
        // Build a litte JS so the birthday mail can be seen
        $javascript = '
			var bDay = {';
        $i = 0;
        foreach ($processedBirthdayEmails as $index => $email) {
            $is_last = ++$i == count($processedBirthdayEmails);
            $javascript .= '
				' . $index . ': {
				subject: ' . JavaScriptEscape($email['subject']) . ',
				body: ' . JavaScriptEscape(nl2br($email['body'])) . '
			}' . (!$is_last ? ',' : '');
        }
        addInlineJavascript($javascript . '
		};
		function fetch_birthday_preview()
		{
			var index = document.getElementById(\'birthday_email\').value;

			document.getElementById(\'birthday_subject\').innerHTML = bDay[index].subject;
			document.getElementById(\'birthday_body\').innerHTML = bDay[index].body;
		}', true);
    }
コード例 #5
0
    /**
     * Modify any setting related to drafts.
     *
     * - Requires the admin_forum permission.
     * - Accessed from ?action=admin;area=managedrafts
     *
     * @uses Admin template, edit_topic_settings sub-template.
     */
    public function action_draftSettings_display()
    {
        global $context, $txt, $scripturl;
        isAllowedTo('admin_forum');
        loadLanguage('Drafts');
        // Initialize the form
        $this->_initDraftSettingsForm();
        $config_vars = $this->_draftSettings->settings();
        // Setup the template.
        $context['page_title'] = $txt['managedrafts_settings'];
        $context['sub_template'] = 'show_settings';
        $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['drafts'], 'help' => '', 'description' => $txt['managedrafts_settings_description']);
        // Saving them ?
        if (isset($_GET['save'])) {
            checkSession();
            call_integration_hook('integrate_save_drafts_settings');
            // Protect them from themselves.
            $_POST['drafts_autosave_frequency'] = $_POST['drafts_autosave_frequency'] < 30 ? 30 : $_POST['drafts_autosave_frequency'];
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=managedrafts');
        }
        // Some javascript to enable / disable the frequency input box
        addInlineJavascript('
			var autosave = document.getElementById(\'drafts_autosave_enabled\');

			createEventListener(autosave);
			autosave.addEventListener(\'change\', toggle);
			toggle();

			function toggle()
			{
				var select_elem = document.getElementById(\'drafts_autosave_frequency\');

				select_elem.disabled = !autosave.checked;
			}', true);
        // Final settings...
        $context['post_url'] = $scripturl . '?action=admin;area=managedrafts;save';
        $context['settings_title'] = $txt['managedrafts_settings'];
        // Prepare the settings...
        Settings_Form::prepare_db($config_vars);
    }
コード例 #6
0
    /**
     * Set general news and newsletter settings and permissions.
     *
     * What it does:
     * - Called by ?action=admin;area=news;sa=settings.
     * - Requires the forum_admin permission.
     *
     * @uses ManageNews template, news_settings sub-template.
     */
    public function action_newsSettings_display()
    {
        global $context, $txt, $scripturl;
        // Initialize the form
        $this->_initNewsSettingsForm();
        $config_vars = $this->_newsSettings->settings();
        // Add some javascript at the bottom...
        addInlineJavascript('
			document.getElementById("xmlnews_maxlen").disabled = !document.getElementById("xmlnews_enable").checked;
			document.getElementById("xmlnews_limit").disabled = !document.getElementById("xmlnews_enable").checked;', true);
        $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings'];
        $context['sub_template'] = 'show_settings';
        // Wrap it all up nice and warm...
        $context['post_url'] = $scripturl . '?action=admin;area=news;save;sa=settings';
        $context['permissions_excluded'] = array(-1);
        // Saving the settings?
        if (isset($_GET['save'])) {
            checkSession();
            call_integration_hook('integrate_save_news_settings');
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=news;sa=settings');
        }
        // We need this for the in-line permissions
        createToken('admin-mp');
        Settings_Form::prepare_db($config_vars);
    }
コード例 #7
0
 /**
  * Editing personal messages settings
  *
  * - Accessed with ?action=admin;area=featuresettings;sa=pmsettings
  */
 public function action_pmsettings()
 {
     global $txt, $scripturl, $context;
     // Initialize the form
     $this->_initPMSettingsForm();
     // Retrieve the current config settings
     $config_vars = $this->_PMSettings->settings();
     require_once SUBSDIR . '/PersonalMessage.subs.php';
     loadLanguage('ManageMembers');
     $context['pm_limits'] = loadPMLimits();
     // Saving?
     if (isset($_GET['save'])) {
         checkSession();
         require_once SUBSDIR . '/Membergroups.subs.php';
         foreach ($context['pm_limits'] as $group_id => $group) {
             if (isset($_POST['group'][$group_id]) && $_POST['group'][$group_id] != $group['max_messages']) {
                 updateMembergroupProperties(array('current_group' => $group_id, 'max_messages' => $_POST['group'][$group_id]));
             }
         }
         call_integration_hook('integrate_save_pmsettings_settings');
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=featuresettings;sa=pmsettings');
     }
     $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=pmsettings';
     $context['settings_title'] = $txt['personal_messages'];
     // We need this for the in-line permissions
     createToken('admin-mp');
     Settings_Form::prepare_db($config_vars);
 }
コード例 #8
0
 /**
  * Edit some general settings related to the search function.
  *
  * - Called by ?action=admin;area=managesearch;sa=settings.
  * - Requires the admin_forum permission.
  *
  * @uses ManageSearch template, 'modify_settings' sub-template.
  */
 public function action_searchSettings_display()
 {
     global $txt, $context, $scripturl, $modSettings;
     // Initialize the form
     $this->_initSearchSettingsForm();
     $config_vars = $this->_searchSettings->settings();
     // Perhaps the search method wants to add some settings?
     require_once SUBSDIR . '/Search.subs.php';
     $searchAPI = findSearchAPI();
     if (is_callable(array($searchAPI, 'searchSettings'))) {
         call_user_func_array($searchAPI->searchSettings, array(&$config_vars));
     }
     $context['page_title'] = $txt['search_settings_title'];
     $context['sub_template'] = 'show_settings';
     $context['search_engines'] = array();
     if (!empty($modSettings['additional_search_engines'])) {
         $context['search_engines'] = unserialize($modSettings['additional_search_engines']);
     }
     for ($count = 0; $count < 3; $count++) {
         $context['search_engines'][] = array('name' => '', 'url' => '', 'separator' => '');
     }
     // A form was submitted.
     if (isset($_REQUEST['save'])) {
         checkSession();
         call_integration_hook('integrate_save_search_settings');
         if (empty($_POST['search_results_per_page'])) {
             $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages'];
         }
         $new_engines = array();
         foreach ($_POST['engine_name'] as $id => $searchengine) {
             // If no url, forget it
             if (!empty($_POST['engine_url'][$id])) {
                 $new_engines[] = array('name' => trim(Util::htmlspecialchars($searchengine, ENT_COMPAT)), 'url' => trim(Util::htmlspecialchars($_POST['engine_url'][$id], ENT_COMPAT)), 'separator' => trim(Util::htmlspecialchars(!empty($_POST['engine_separator'][$id]) ? $_POST['engine_separator'][$id] : '+', ENT_COMPAT)));
             }
         }
         updateSettings(array('additional_search_engines' => !empty($new_engines) ? serialize($new_engines) : ''));
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']);
     }
     // Prep the template!
     $context['post_url'] = $scripturl . '?action=admin;area=managesearch;save;sa=settings';
     $context['settings_title'] = $txt['search_settings_title'];
     // We need this for the in-line permissions
     createToken('admin-mp');
     Settings_Form::prepare_db($config_vars);
 }
コード例 #9
0
    /**
     * All the post by email settings, used to control how the feature works
     *
     * @uses Admin language
     */
    public function action_settings()
    {
        global $scripturl, $context, $txt, $modSettings;
        // Be nice, show them we did something
        if (isset($_GET['saved'])) {
            $context['settings_message'] = $txt['saved'];
        }
        // Templates and language
        loadLanguage('Admin');
        loadTemplate('Admin', 'admin');
        // Load any existing email => board values used for new topic creation
        $context['maillist_from_to_board'] = array();
        $data = !empty($modSettings['maillist_receiving_address']) ? unserialize($modSettings['maillist_receiving_address']) : array();
        foreach ($data as $key => $addr) {
            $context['maillist_from_to_board'][$key] = array('id' => $key, 'emailfrom' => $addr[0], 'boardto' => $addr[1]);
        }
        // Initialize the maillist settings form
        $this->_initMaillistSettingsForm();
        // Retrieve the config settings
        $config_vars = $this->_maillistSettings->settings();
        // Saving settings?
        if (isset($_GET['save'])) {
            checkSession();
            call_integration_hook('integrate_save_maillist_settings');
            $email_error = false;
            $board_error = false;
            $maillist_receiving_address = array();
            // Basic checking of the email addresses
            require_once SUBSDIR . '/DataValidator.class.php';
            if (!Data_Validator::is_valid($_POST, array('maillist_sitename_address' => 'valid_email'), array('maillist_sitename_address' => 'trim'))) {
                $email_error = $_POST['maillist_sitename_address'];
            }
            if (!Data_Validator::is_valid($_POST, array('maillist_sitename_help' => 'valid_email'), array('maillist_sitename_help' => 'trim'))) {
                $email_error = $_POST['maillist_sitename_help'];
            }
            if (!Data_Validator::is_valid($_POST, array('maillist_mail_from' => 'valid_email'), array('maillist_mail_from' => 'trim'))) {
                $email_error = $_POST['maillist_mail_from'];
            }
            // Inbound email set up then we need to check for both valid email and valid board
            if (!$email_error && !empty($_POST['emailfrom'])) {
                // Get the board ids for a quick check
                $boards = maillist_board_list();
                // Check the receiving emails and the board id as well
                $boardtocheck = !empty($_POST['boardto']) ? $_POST['boardto'] : array();
                $addresstocheck = !empty($_POST['emailfrom']) ? $_POST['emailfrom'] : array();
                foreach ($addresstocheck as $key => $checkme) {
                    // Valid email syntax
                    if (!Data_Validator::is_valid($addresstocheck, array($key => 'valid_email'), array($key => 'trim'))) {
                        $email_error = $checkme;
                        $context['error_type'] = 'notice';
                        continue;
                    }
                    // Valid board id?
                    if (!isset($boardtocheck[$key]) || !isset($boards[$key])) {
                        $board_error = $checkme;
                        $context['error_type'] = 'notice';
                        continue;
                    }
                    // Decipher as [0]emailaddress and [1]board id
                    $maillist_receiving_address[] = array($checkme, $boardtocheck[$key]);
                }
            }
            // Enable or disable the fake cron
            enable_maillist_imap_cron(!empty($_POST['maillist_imap_cron']));
            // Check and set any errors or give the go ahead to save
            if ($email_error) {
                $context['settings_message'] = sprintf($txt['email_not_valid'], $email_error);
            } elseif ($board_error) {
                $context['settings_message'] = sprintf($txt['board_not_valid'], $board_error);
            } else {
                // Clear the moderation count cache
                cache_put_data('num_menu_errors', null, 900);
                // Should be off if mail posting is on, we ignore it anyway but this at least updates the ACP
                if (!empty($_POST['maillist_enabled'])) {
                    updateSettings(array('disallow_sendBody' => ''));
                }
                updateSettings(array('maillist_receiving_address' => serialize($maillist_receiving_address)));
                Settings_Form::save_db($config_vars);
                writeLog();
                redirectexit('action=admin;area=maillist;sa=emailsettings;saved');
            }
        }
        // Javascript vars for the "add more" buttons in the receive_email callback
        $board_list = maillist_board_list();
        $script = '';
        $i = 0;
        // Create the board selection list
        foreach ($board_list as $board_id => $board_name) {
            $script .= $i++ . ': {id:' . $board_id . ', name:' . JavaScriptEscape($board_name) . '},';
        }
        addInlineJavascript('
		var sEmailParent = \'add_more_email_placeholder\',
			oEmailOptionsdt = {size: \'50\', name: \'emailfrom[]\', class: \'input_text\'},
			oEmailOptionsdd = {size: \'1\', type: \'select\', name: \'boardto[]\', class: \'input_select\'},
			oEmailSelectData = {' . $script . '};

			document.getElementById(\'add_more_board_div\').style.display = \'\';', true);
        $context['boards'] = $board_list;
        $context['settings_title'] = $txt['ml_emailsettings'];
        $context['page_title'] = $txt['ml_emailsettings'];
        $context['post_url'] = $scripturl . '?action=admin;area=maillist;sa=emailsettings;save';
        $context['sub_template'] = 'show_settings';
        Settings_Form::prepare_db($config_vars);
    }
コード例 #10
0
    /**
     * This is the admin settings page for search engines.
     */
    public function action_engineSettings_display()
    {
        global $context, $txt, $scripturl;
        // Initialize the form
        $this->_initEngineSettingsForm();
        $config_vars = $this->_engineSettings->settings();
        // Set up a message.
        $context['settings_message'] = sprintf($txt['spider_settings_desc'], $scripturl . '?action=admin;area=logs;sa=pruning;' . $context['session_var'] . '=' . $context['session_id']);
        require_once SUBSDIR . '/SearchEngines.subs.php';
        require_once SUBSDIR . '/Membergroups.subs.php';
        $groups = getBasicMembergroupData(array('globalmod', 'postgroups', 'protected', 'member'));
        foreach ($groups as $row) {
            $config_vars['spider_group'][2][$row['id']] = $row['name'];
        }
        // Make sure it's valid - note that regular members are given id_group = 1 which is reversed in Load.php - no admins here!
        if (isset($_POST['spider_group']) && !isset($config_vars['spider_group'][2][$_POST['spider_group']])) {
            $_POST['spider_group'] = 0;
        }
        // We'll want this for our easy save.
        require_once SUBSDIR . '/SettingsForm.class.php';
        // Setup the template.
        $context['page_title'] = $txt['settings'];
        $context['sub_template'] = 'show_settings';
        // Are we saving them - are we??
        if (isset($_GET['save'])) {
            // security checks
            checkSession();
            // notify the interested addons or integrations
            call_integration_hook('integrate_save_search_engine_settings');
            // save the results!
            Settings_Form::save_db($config_vars);
            // make sure to rebuild the cache with updated results
            recacheSpiderNames();
            // We're done with this.
            redirectexit('action=admin;area=sengines;sa=settings');
        }
        // Set up some details for the template.
        $context['post_url'] = $scripturl . '?action=admin;area=sengines;save;sa=settings';
        $context['settings_title'] = $txt['settings'];
        // Do some javascript.
        $javascript_function = '
			function disableFields()
			{
				disabledState = document.getElementById(\'spider_mode\').value == 0;';
        foreach ($config_vars as $variable) {
            if ($variable[1] != 'spider_mode') {
                $javascript_function .= '
				if (document.getElementById(\'' . $variable[1] . '\'))
					document.getElementById(\'' . $variable[1] . '\').disabled = disabledState;';
            }
        }
        $javascript_function .= '
			}
			disableFields();';
        addInlineJavascript($javascript_function, true);
        // Prepare the settings...
        Settings_Form::prepare_db($config_vars);
    }
コード例 #11
0
 /**
  * Displays and allows to modify smileys settings.
  * @uses show_settings sub template
  */
 public function action_smileySettings_display()
 {
     global $context, $scripturl;
     // initialize the form
     $this->_initSmileySettingsForm();
     $config_vars = $this->_smileySettings->settings();
     // For the basics of the settings.
     require_once SUBSDIR . '/SettingsForm.class.php';
     require_once SUBSDIR . '/Smileys.subs.php';
     $context['sub_template'] = 'show_settings';
     // Finish up the form...
     $context['post_url'] = $scripturl . '?action=admin;area=smileys;save;sa=settings';
     $context['permissions_excluded'] = array(-1);
     // Saving the settings?
     if (isset($_GET['save'])) {
         checkSession();
         $_POST['smiley_sets_default'] = empty($this->_smiley_context[$_POST['smiley_sets_default']]) ? 'default' : $_POST['smiley_sets_default'];
         // Make sure that the smileys are in the right order after enabling them.
         if (isset($_POST['smiley_enable'])) {
             sortSmileyTable();
         }
         call_integration_hook('integrate_save_smiley_settings');
         Settings_Form::save_db($config_vars);
         cache_put_data('parsing_smileys', null, 480);
         cache_put_data('posting_smileys', null, 480);
         redirectexit('action=admin;area=smileys;sa=settings');
     }
     // We need this for the in-line permissions
     createToken('admin-mp');
     Settings_Form::prepare_db($config_vars);
 }
コード例 #12
0
 /**
  * A screen to set some general settings for permissions.
  */
 public function action_permSettings_display()
 {
     global $context, $modSettings, $txt, $scripturl;
     require_once SUBSDIR . '/ManagePermissions.subs.php';
     // Initialize the form
     $this->_initPermSettingsForm();
     $config_vars = $this->_permSettings->settings();
     // Some items for the template
     $context['page_title'] = $txt['permission_settings_title'];
     $context['sub_template'] = 'show_settings';
     // Don't let guests have these permissions.
     $context['post_url'] = $scripturl . '?action=admin;area=permissions;save;sa=settings';
     $context['permissions_excluded'] = array(-1);
     // Saving the settings?
     if (isset($_GET['save'])) {
         checkSession('post');
         call_integration_hook('integrate_save_permission_settings');
         Settings_Form::save_db($config_vars);
         // Clear all deny permissions...if we want that.
         if (empty($modSettings['permission_enable_deny'])) {
             clearDenyPermissions();
         }
         // Make sure there are no postgroup based permissions left.
         if (empty($modSettings['permission_enable_postgroups'])) {
             clearPostgroupPermissions();
         }
         redirectexit('action=admin;area=permissions;sa=settings');
     }
     // We need this for the in-line permissions
     createToken('admin-mp');
     Settings_Form::prepare_db($config_vars);
 }
コード例 #13
0
 /**
  * Set some general membergroup settings and permissions.
  *
  * What it does:
  * - Called by ?action=admin;area=membergroups;sa=settings
  * - Requires the admin_forum permission (and manage_permissions for changing permissions)
  * - Redirects to itself.
  *
  * @uses membergroup_settings sub template of ManageMembergroups.
  */
 public function action_groupSettings_display()
 {
     global $context, $scripturl, $txt;
     $context['sub_template'] = 'show_settings';
     $context['page_title'] = $txt['membergroups_settings'];
     // Needed for the settings functions.
     require_once SUBSDIR . '/SettingsForm.class.php';
     // initialize the form
     $this->_initGroupSettingsForm();
     // Don't allow assignment of guests.
     $context['permissions_excluded'] = array(-1);
     $config_vars = $this->_groupSettings->settings();
     if (isset($_REQUEST['save'])) {
         checkSession();
         call_integration_hook('integrate_save_membergroup_settings');
         // Yeppers, saving this...
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=membergroups;sa=settings');
     }
     // Some simple context.
     $context['post_url'] = $scripturl . '?action=admin;area=membergroups;save;sa=settings';
     $context['settings_title'] = $txt['membergroups_settings'];
     // We need this for the in-line permissions
     createToken('admin-mp');
     Settings_Form::prepare_db($config_vars);
 }
コード例 #14
0
    /**
     * A screen to display and allow to set a few general board and category settings.
     *
     * @uses modify_general_settings sub-template.
     */
    public function action_boardSettings_display()
    {
        global $context, $txt, $scripturl;
        // Initialize the form
        $this->_initBoardSettingsForm();
        // Get all settings
        $config_vars = $this->_boardSettings->settings();
        // Add some javascript stuff for the recycle box.
        addInlineJavascript('
				document.getElementById("recycle_board").disabled = !document.getElementById("recycle_enable").checked;', true);
        // Don't let guests have these permissions.
        $context['post_url'] = $scripturl . '?action=admin;area=manageboards;save;sa=settings';
        $context['permissions_excluded'] = array(-1);
        // Get the needed template bits
        loadTemplate('ManageBoards');
        $context['page_title'] = $txt['boards_and_cats'] . ' - ' . $txt['settings'];
        $context['sub_template'] = 'show_settings';
        // Warn the admin against selecting the recycle topic without selecting a board.
        $context['force_form_onsubmit'] = 'if(document.getElementById(\'recycle_enable\').checked && document.getElementById(\'recycle_board\').value == 0) { return confirm(\'' . $txt['recycle_board_unselected_notice'] . '\');} return true;';
        // Doing a save?
        if (isset($_GET['save'])) {
            checkSession();
            call_integration_hook('integrate_save_board_settings');
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=manageboards;sa=settings');
        }
        // We need this for the in-line permissions
        createToken('admin-mp');
        // Prepare the settings...
        Settings_Form::prepare_db($config_vars);
    }
コード例 #15
0
 /**
  * Show and allow to modify calendar settings.
  *
  * - The method uses a Settings_Form to do the work.
  */
 public function action_calendarSettings_display()
 {
     global $context, $scripturl;
     // Initialize the form
     $this->_initCalendarSettingsForm();
     $config_vars = $this->_calendarSettings->settings();
     // Get the settings template fired up.
     require_once SUBSDIR . '/SettingsForm.class.php';
     // Get the final touches in place.
     $context['post_url'] = $scripturl . '?action=admin;area=managecalendar;save;sa=settings';
     // Saving the settings?
     if (isset($_GET['save'])) {
         checkSession();
         call_integration_hook('integrate_save_calendar_settings');
         Settings_Form::save_db($config_vars);
         // Update the stats in case.
         updateSettings(array('calendar_updated' => time()));
         redirectexit('action=admin;area=managecalendar;sa=settings');
     }
     // We need this for the in-line permissions
     createToken('admin-mp');
     // Prepare the settings...
     Settings_Form::prepare_db($config_vars);
 }
コード例 #16
0
 /**
  * Allow to edit the settings on the pruning screen.
  *
  * Uses the _pruningSettings form.
  */
 public function action_pruningSettings_display()
 {
     global $txt, $scripturl, $context, $modSettings;
     // Make sure we understand what's going on.
     loadLanguage('ManageSettings');
     $context['page_title'] = $txt['pruning_title'];
     $config_vars = $this->_pruningSettings->settings();
     call_integration_hook('integrate_prune_settings');
     // Saving?
     if (isset($_GET['save'])) {
         checkSession();
         $savevar = array(array('text', 'pruningOptions'));
         if (!empty($_POST['pruningOptions'])) {
             $vals = array();
             foreach ($config_vars as $index => $dummy) {
                 if (!is_array($dummy) || $index == 'pruningOptions') {
                     continue;
                 }
                 $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
             }
             $_POST['pruningOptions'] = implode(',', $vals);
         } else {
             $_POST['pruningOptions'] = '';
         }
         Settings_Form::save_db($savevar);
         redirectexit('action=admin;area=logs;sa=pruning');
     }
     $context['post_url'] = $scripturl . '?action=admin;area=logs;save;sa=pruning';
     $context['settings_title'] = $txt['pruning_title'];
     $context['sub_template'] = 'show_settings';
     // Get the actual values
     if (!empty($modSettings['pruningOptions'])) {
         @(list($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneBadbehaviorLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']));
     } else {
         $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneBadbehaviorLog'] = $modSettings['pruneSpiderHitLog'] = 0;
     }
     Settings_Form::prepare_db($config_vars);
 }
コード例 #17
0
 /**
  * Settings to control articles
  */
 public function action_sportal_admin_article_settings()
 {
     global $context, $scripturl, $txt;
     // These are very likely to come in handy! (i.e. without them we're doomed!)
     require_once ADMINDIR . '/ManagePermissions.controller.php';
     require_once ADMINDIR . '/ManageServer.controller.php';
     require_once SUBSDIR . '/SettingsForm.class.php';
     // Initialize the form
     $this->_initArticleSettingsForm();
     $config_vars = $this->_articleSettingsForm->settings();
     // Save away
     if (isset($_GET['save'])) {
         checkSession();
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=portalconfig;sa=articlesettings');
     }
     // Show the form
     $context['post_url'] = $scripturl . '?action=admin;area=portalconfig;sa=articlesettings;save';
     $context['settings_title'] = $txt['sp-adminArticleSettingsName'];
     $context['page_title'] = $txt['sp-adminArticleSettingsName'];
     $context['sub_template'] = 'show_settings';
     Settings_Form::prepare_db($config_vars);
 }
コード例 #18
0
 /**
  * This action handler method displays and allows to change avatar settings.
  *
  * - Called by index.php?action=admin;area=manageattachments;sa=avatars.
  *
  * @uses 'avatars' sub-template.
  */
 public function action_avatarSettings_display()
 {
     global $txt, $context, $scripturl;
     // Initialize the form
     $this->_initAvatarSettingsForm();
     $config_vars = $this->_avatarSettings->settings();
     // Saving avatar settings?
     if (isset($_GET['save'])) {
         checkSession();
         call_integration_hook('integrate_save_avatar_settings');
         // Disable if invalid values would result
         if (isset($_POST['custom_avatar_enabled']) && $_POST['custom_avatar_enabled'] == 1 && (empty($_POST['custom_avatar_dir']) || empty($_POST['custom_avatar_url']))) {
             $_POST['custom_avatar_enabled'] = 0;
         }
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=manageattachments;sa=avatars');
     }
     // Attempt to figure out if the admin is trying to break things.
     $context['settings_save_onclick'] = 'return document.getElementById(\'custom_avatar_enabled\').value == 1 && (document.getElementById(\'custom_avatar_dir\').value == \'\' || document.getElementById(\'custom_avatar_url\').value == \'\') ? confirm(\'' . $txt['custom_avatar_check_empty'] . '\') : true;';
     // We need this for the in-line permissions
     createToken('admin-mp');
     // Prepare the context.
     $context['post_url'] = $scripturl . '?action=admin;area=manageattachments;save;sa=avatars';
     Settings_Form::prepare_db($config_vars);
     // Add a layer for the javascript.
     Template_Layers::getInstance()->add('avatar_settings');
     $context['sub_template'] = 'show_settings';
 }
コード例 #19
0
    /**
     * Allows to show/change attachment settings.
     *
     * - This is the default sub-action of the 'Attachments and Avatars' center.
     * - Called by index.php?action=admin;area=manageattachments;sa=attachments.
     *
     * @uses 'attachments' sub template.
     */
    public function action_attachSettings_display()
    {
        global $modSettings, $scripturl, $context;
        // initialize the form
        $this->_initAttachSettingsForm();
        $config_vars = $this->_attachSettingsForm->settings();
        addInlineJavascript('
	var storing_type = document.getElementById(\'automanage_attachments\'),
		base_dir = document.getElementById(\'use_subdirectories_for_attachments\');

	createEventListener(storing_type)
	storing_type.addEventListener("change", toggleSubDir, false);
	createEventListener(base_dir)
	base_dir.addEventListener("change", toggleSubDir, false);
	toggleSubDir();', true);
        // These are very likely to come in handy! (i.e. without them we're doomed!)
        require_once SUBSDIR . '/SettingsForm.class.php';
        require_once SUBSDIR . '/Attachments.subs.php';
        // Saving settings?
        if (isset($_GET['save'])) {
            checkSession();
            if (isset($_POST['attachmentUploadDir'])) {
                if (!empty($_POST['attachmentUploadDir']) && $modSettings['attachmentUploadDir'] != $_POST['attachmentUploadDir']) {
                    rename($modSettings['attachmentUploadDir'], $_POST['attachmentUploadDir']);
                }
                $modSettings['attachmentUploadDir'] = array(1 => $_POST['attachmentUploadDir']);
                $_POST['attachmentUploadDir'] = serialize($modSettings['attachmentUploadDir']);
            }
            if (!empty($_POST['use_subdirectories_for_attachments'])) {
                if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) {
                    $_POST['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : BOARDDIR;
                }
                if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories'])) {
                    if (!is_array($modSettings['attachment_basedirectories'])) {
                        $modSettings['attachment_basedirectories'] = unserialize($modSettings['attachment_basedirectories']);
                    }
                } else {
                    $modSettings['attachment_basedirectories'] = array();
                }
                if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) {
                    $currentAttachmentUploadDir = $modSettings['currentAttachmentUploadDir'];
                    if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) {
                        if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) {
                            $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments'];
                        }
                    }
                    if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) {
                        $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['basedirectory_for_attachments'];
                        updateSettings(array('attachment_basedirectories' => serialize($modSettings['attachment_basedirectories']), 'currentAttachmentUploadDir' => $currentAttachmentUploadDir));
                        $_POST['use_subdirectories_for_attachments'] = 1;
                        $_POST['attachmentUploadDir'] = serialize($modSettings['attachmentUploadDir']);
                    }
                }
            }
            call_integration_hook('integrate_save_attachment_settings');
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=manageattachments;sa=attachments');
        }
        $context['post_url'] = $scripturl . '?action=admin;area=manageattachments;save;sa=attachments';
        Settings_Form::prepare_db($config_vars);
        $context['sub_template'] = 'show_settings';
    }
コード例 #20
0
 /**
  * Change the way bad behavior ... well behaves
  */
 public function action_bbSettings_display()
 {
     global $txt, $scripturl, $context, $modSettings, $boardurl;
     // Initialize the form
     $this->_initBBSettingsForm();
     // Our callback templates are here
     loadTemplate('BadBehavior');
     // Any errors to display?
     if ($context['invalid_badbehavior_httpbl_key']) {
         $context['settings_message'][] = $txt['badbehavior_httpbl_key_invalid'];
         $context['error_type'] = 'warning';
     }
     // Have we blocked anything in the last 7 days?
     if (!empty($modSettings['badbehavior_enabled'])) {
         $context['settings_message'][] = bb2_insert_stats(true) . '<a href="' . $boardurl . '/index.php?action=admin;area=logs;sa=badbehaviorlog;desc" /> [' . $txt['badbehavior_details'] . ']</a>';
     }
     // Current whitelist data
     $whitelist = array('badbehavior_ip_wl', 'badbehavior_useragent_wl', 'badbehavior_url_wl');
     foreach ($whitelist as $list) {
         $context[$list] = array();
         $context[$list . '_desc'] = array();
         if (!empty($modSettings[$list])) {
             $context[$list] = unserialize($modSettings[$list]);
         }
         if (!empty($modSettings[$list . '_desc'])) {
             $context[$list . '_desc'] = unserialize($modSettings[$list . '_desc']);
         }
     }
     $config_vars = $this->_bbSettings->settings();
     // Saving?
     if (isset($_GET['save'])) {
         checkSession();
         // Make sure Bad Behavior defaults are set if nothing was specified
         $_POST['badbehavior_httpbl_threat'] = empty($_POST['badbehavior_httpbl_threat']) ? 25 : $_POST['badbehavior_httpbl_threat'];
         $_POST['badbehavior_httpbl_maxage'] = empty($_POST['badbehavior_httpbl_maxage']) ? 30 : $_POST['badbehavior_httpbl_maxage'];
         $_POST['badbehavior_reverse_proxy_header'] = empty($_POST['badbehavior_reverse_proxy_header']) ? 'X-Forwarded-For' : $_POST['badbehavior_reverse_proxy_header'];
         // Build up the whitelist options
         foreach ($whitelist as $list) {
             $this_list = array();
             $this_desc = array();
             if (isset($_POST[$list])) {
                 // Clear blanks from the data field, only grab the comments that don't have blank data value
                 $this_list = array_map('trim', array_filter($_POST[$list]));
                 $this_desc = array_intersect_key($_POST[$list . '_desc'], $this_list);
             }
             updateSettings(array($list => serialize($this_list), $list . '_desc' => serialize($this_desc)));
         }
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=securitysettings;sa=badbehavior');
     }
     $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=badbehavior';
     // Javascript vars for the "add more xyz" buttons in the callback forms
     addJavascriptVar(array('sUrlParent' => '\'add_more_url_placeholder\'', 'oUrlOptionsdt' => '{name: \'badbehavior_url_wl_desc[]\', class: \'input_text\'}', 'oUrlOptionsdd' => '{name: \'badbehavior_url_wl[]\', class: \'input_text\'}', 'sUseragentParent' => '\'add_more_useragent_placeholder\'', 'oUseragentOptionsdt' => '{name: \'badbehavior_useragent_wl_desc[]\', class: \'input_text\'}', 'oUseragentOptionsdd' => '{name: \'badbehavior_useragent_wl[]\', class: \'input_text\'}', 'sIpParent' => '\'add_more_ip_placeholder\'', 'oIpOptionsdt' => '{name: \'badbehavior_ip_wl_desc[]\', class: \'input_text\'}', 'oIpOptionsdd' => '{name: \'badbehavior_ip_wl[]\', class: \'input_text\'}'));
     Settings_Form::prepare_db($config_vars);
 }
コード例 #21
0
    /**
     * Administration page in Posts and Topics > BBC.
     *
     * - This method handles displaying and changing which BBC tags are enabled on the forum.
     *
     * @uses Admin template, edit_bbc_settings sub-template.
     */
    public function action_bbcSettings_display()
    {
        global $context, $txt, $modSettings, $scripturl;
        // Initialize the form
        $this->_initBBCSettingsForm();
        $config_vars = $this->_bbcSettings->settings();
        // Make sure a nifty javascript will enable/disable checkboxes, according to BBC globally set or not.
        addInlineJavascript('
			toggleBBCDisabled(\'disabledBBC\', ' . (empty($modSettings['enableBBC']) ? 'true' : 'false') . ');', true);
        // We'll need this forprepare_db() and save_db()
        require_once SUBSDIR . '/SettingsForm.class.php';
        // Make sure we check the right tags!
        $modSettings['bbc_disabled_disabledBBC'] = empty($modSettings['disabledBBC']) ? array() : explode(',', $modSettings['disabledBBC']);
        // Save page
        if (isset($_GET['save'])) {
            checkSession();
            // Security: make a pass through all tags and fix them as necessary
            $bbcTags = array();
            foreach (parse_bbc(false) as $tag) {
                $bbcTags[] = $tag['tag'];
            }
            if (!isset($_POST['disabledBBC_enabledTags'])) {
                $_POST['disabledBBC_enabledTags'] = array();
            } elseif (!is_array($_POST['disabledBBC_enabledTags'])) {
                $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
            }
            // Work out what is actually disabled!
            $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
            // Notify addons and integrations
            call_integration_hook('integrate_save_bbc_settings', array($bbcTags));
            // Save the result
            Settings_Form::save_db($config_vars);
            // And we're out of here!
            redirectexit('action=admin;area=postsettings;sa=bbc');
        }
        // Make sure the template stuff is ready now...
        $context['sub_template'] = 'show_settings';
        $context['page_title'] = $txt['manageposts_bbc_settings_title'];
        $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=bbc';
        $context['settings_title'] = $txt['manageposts_bbc_settings_title'];
        Settings_Form::prepare_db($config_vars);
    }
コード例 #22
0
 /**
  * Modify any setting related to posts and posting.
  *
  * - Requires the admin_forum permission.
  * - Accessed from ?action=admin;area=postsettings;sa=posts.
  *
  * @uses Admin template, edit_post_settings sub-template.
  */
 public function action_postSettings_display()
 {
     global $context, $txt, $modSettings, $scripturl, $db_type;
     // Initialize the form
     $this->_initPostSettingsForm();
     $config_vars = $this->_postSettings->settings();
     // Setup the template.
     $context['page_title'] = $txt['manageposts_settings'];
     $context['sub_template'] = 'show_settings';
     // Are we saving them - are we??
     if (isset($_GET['save'])) {
         checkSession();
         // If we're changing the message length (and we are using MySQL) let's check the column is big enough.
         if (isset($_POST['max_messageLength']) && $_POST['max_messageLength'] != $modSettings['max_messageLength'] && $db_type == 'mysql') {
             require_once SUBSDIR . '/Maintenance.subs.php';
             $colData = getMessageTableColumns();
             foreach ($colData as $column) {
                 if ($column['name'] == 'body') {
                     $body_type = $column['type'];
                 }
             }
             if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') {
                 fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
             }
         }
         // If we're changing the post preview length let's check its valid
         if (!empty($_POST['preview_characters'])) {
             $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
         }
         call_integration_hook('integrate_save_post_settings');
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=postsettings;sa=posts');
     }
     // Final settings...
     $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=posts';
     $context['settings_title'] = $txt['manageposts_settings'];
     // Prepare the settings...
     Settings_Form::prepare_db($config_vars);
 }
コード例 #23
0
    /**
     * Set any setting related to paid subscriptions,
     *
     * - i.e. modify which payment methods are to be used.
     * - It requires the moderate_forum permission
     * - Accessed from ?action=admin;area=paidsubscribe;sa=settings.
     */
    public function action_paidSettings_display()
    {
        global $context, $txt, $scripturl;
        require_once SUBSDIR . '/PaidSubscriptions.subs.php';
        // Initialize the form
        $this->_init_paidSettingsForm();
        $config_vars = $this->_paidSettings->settings();
        // Now load all the other gateway settings.
        $gateways = loadPaymentGateways();
        foreach ($gateways as $gateway) {
            $gatewayClass = new $gateway['display_class']();
            $setting_data = $gatewayClass->getGatewaySettings();
            if (!empty($setting_data)) {
                $config_vars[] = array('title', $gatewayClass->title, 'text_label' => isset($txt['paidsubs_gateway_title_' . $gatewayClass->title]) ? $txt['paidsubs_gateway_title_' . $gatewayClass->title] : $gatewayClass->title);
                $config_vars = array_merge($config_vars, $setting_data);
            }
        }
        // Some important context stuff
        $context['page_title'] = $txt['settings'];
        $context['sub_template'] = 'show_settings';
        $context['settings_message'] = replaceBasicActionUrl($txt['paid_note']);
        $context[$context['admin_menu_name']]['current_subsection'] = 'settings';
        // Get the final touches in place.
        $context['post_url'] = $scripturl . '?action=admin;area=paidsubscribe;save;sa=settings';
        $context['settings_title'] = $txt['settings'];
        // We want javascript for our currency options.
        addInlineJavascript('
		toggleCurrencyOther();', true);
        // Saving the settings?
        if (isset($_GET['save'])) {
            checkSession();
            call_integration_hook('integrate_save_subscription_settings');
            // Check that the entered email addresses are valid
            if (!empty($_POST['paid_email_to'])) {
                require_once SUBSDIR . '/DataValidator.class.php';
                $validator = new Data_Validator();
                // Some cleaning and some rules
                $validator->sanitation_rules(array('paid_email_to' => 'trim'));
                $validator->validation_rules(array('paid_email_to' => 'valid_email'));
                $validator->input_processing(array('paid_email_to' => 'csv'));
                $validator->text_replacements(array('paid_email_to' => $txt['paid_email_to']));
                if ($validator->validate($_POST)) {
                    $_POST['paid_email_to'] = $validator->paid_email_to;
                } else {
                    // Thats not an email, lets set it back in the form to be fixed and let them know its wrong
                    $config_vars[1]['value'] = $_POST['paid_email_to'];
                    $context['error_type'] = 'minor';
                    $context['settings_message'] = array();
                    foreach ($validator->validation_errors() as $id => $error) {
                        $context['settings_message'][] = $error;
                    }
                }
            }
            // No errors, then save away
            if (empty($context['error_type'])) {
                // Sort out the currency stuff.
                if ($_POST['paid_currency'] != 'other') {
                    $_POST['paid_currency_code'] = $_POST['paid_currency'];
                    $_POST['paid_currency_symbol'] = $txt[$_POST['paid_currency'] . '_symbol'];
                }
                $_POST['paid_currency_code'] = trim($_POST['paid_currency_code']);
                unset($config_vars['dummy_currency']);
                Settings_Form::save_db($config_vars);
                redirectexit('action=admin;area=paidsubscribe;sa=settings');
            }
        }
        // Prepare the settings...
        Settings_Form::prepare_db($config_vars);
    }
コード例 #24
0
 /**
  * This function handles pwentropy settings
  *
  * - General pwentropy settings.
  * - Accessed by ?action=admin;area=regcenter;sa=pwentropy
  * - Requires the admin_forum permission.
  */
 public function action_pwentropySettings_display()
 {
     global $txt, $context, $scripturl;
     // Initialize the form
     $this->_init_pwentropySettingsForm();
     // Load the config vars
     $config_vars = $this->_pweSettings->settings();
     // Save if asked
     if (isset($_GET['save'])) {
         checkSession();
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=regcenter;sa=pwentropy');
     }
     // Show the template otherwise
     $context['sub_template'] = 'show_settings';
     $context['settings_title'] = $txt['pwentropy_name'];
     $context['page_title'] = $context['settings_title'] = $txt['pwentropy_settings'];
     $context['post_url'] = $scripturl . '?action=admin;area=regcenter;sa=pwentropy;save';
     $context[$context['admin_menu_name']]['tab_data']['tabs']['pwentropy']['description'] = $txt['pwentropy_desc'];
     Settings_Form::prepare_db($config_vars);
 }
コード例 #25
0
    /**
     * This function handles registration settings, and provides a few pretty stats too while it's at it.
     *
     * - General registration settings and Coppa compliance settings.
     * - Accessed by ?action=admin;area=regcenter;sa=settings.
     * - Requires the admin_forum permission.
     */
    public function action_registerSettings_display()
    {
        global $txt, $context, $scripturl, $modSettings;
        // Initialize the form
        $this->_init_registerSettingsForm();
        $config_vars = $this->_registerSettings->settings();
        // Setup the template
        $context['sub_template'] = 'show_settings';
        $context['page_title'] = $txt['registration_center'];
        if (isset($_GET['save'])) {
            checkSession();
            // Are there some contacts missing?
            if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) {
                fatal_lang_error('admin_setting_coppa_require_contact');
            }
            // Post needs to take into account line breaks.
            $_POST['coppaPost'] = str_replace("\n", '<br />', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']);
            call_integration_hook('integrate_save_registration_settings');
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=regcenter;sa=settings');
        }
        $context['post_url'] = $scripturl . '?action=admin;area=regcenter;save;sa=settings';
        $context['settings_title'] = $txt['settings'];
        // Define some javascript for COPPA.
        addInlineJavascript('
			function checkCoppa()
			{
				var coppaDisabled = document.getElementById(\'coppaAge\').value == 0;
				document.getElementById(\'coppaType\').disabled = coppaDisabled;

				var disableContacts = coppaDisabled || document.getElementById(\'coppaType\').options[document.getElementById(\'coppaType\').selectedIndex].value != 1;
				document.getElementById(\'coppaPost\').disabled = disableContacts;
				document.getElementById(\'coppaFax\').disabled = disableContacts;
				document.getElementById(\'coppaPhone\').disabled = disableContacts;
			}
			checkCoppa();', true);
        // Turn the postal address into something suitable for a textbox.
        $modSettings['coppaPost'] = !empty($modSettings['coppaPost']) ? preg_replace('~<br ?/?' . '>~', "\n", $modSettings['coppaPost']) : '';
        Settings_Form::prepare_db($config_vars);
    }