|
@@ -63,10 +63,6 @@ function ModifyFeatureSettings()
|
|
|
|
|
|
call_integration_hook('integrate_modify_features', array(&$subActions));
|
|
|
|
|
|
- // If karma is disabled don't show the setting page.
|
|
|
- if (!in_array('k', $context['admin_features']))
|
|
|
- unset($subActions['karma']);
|
|
|
-
|
|
|
loadGeneralSettingParameters($subActions, 'basic');
|
|
|
|
|
|
// Load up all the tabs...
|
|
@@ -128,148 +124,6 @@ function ModifyModSettings()
|
|
|
$subActions[$_REQUEST['sa']]();
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * This is an overall control panel enabling/disabling lots of SMF's key feature components.
|
|
|
- *
|
|
|
- * @param $return_config
|
|
|
- */
|
|
|
-function ModifyCoreFeatures($return_config = false)
|
|
|
-{
|
|
|
- global $txt, $scripturl, $context, $settings, $sc, $modSettings;
|
|
|
-
|
|
|
- /* This is an array of all the features that can be enabled/disabled - each option can have the following:
|
|
|
- title - Text title of this item (If standard string does not exist).
|
|
|
- desc - Description of this feature (If standard string does not exist).
|
|
|
- settings - Array of settings to change (For each name => value) on enable - reverse is done for disable. If > 1 will not change value if set.
|
|
|
- setting_callback- Function that returns an array of settings to save - takes one parameter which is value for this feature.
|
|
|
- save_callback - Function called on save, takes state as parameter.
|
|
|
- */
|
|
|
- $core_features = array(
|
|
|
- // k = karma.
|
|
|
- 'k' => array(
|
|
|
- 'url' => 'action=admin;area=featuresettings;sa=karma',
|
|
|
- 'settings' => array(
|
|
|
- 'karmaMode' => 2,
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
-
|
|
|
- // Anyone who would like to add a core feature?
|
|
|
- call_integration_hook('integrate_core_features', array(&$core_features));
|
|
|
-
|
|
|
- // Are we getting info for the help section.
|
|
|
- if ($return_config)
|
|
|
- {
|
|
|
- $return_data = array();
|
|
|
- foreach ($core_features as $id => $data)
|
|
|
- $return_data[] = array('switch', isset($data['title']) ? $data['title'] : $txt['core_settings_item_' . $id]);
|
|
|
- return $return_data;
|
|
|
- }
|
|
|
-
|
|
|
- loadGeneralSettingParameters();
|
|
|
-
|
|
|
- // Are we saving?
|
|
|
- if (isset($_POST['save']))
|
|
|
- {
|
|
|
- checkSession();
|
|
|
-
|
|
|
- if (isset($_GET['xml']))
|
|
|
- {
|
|
|
- $tokenValidation = validateToken('admin-core', 'post', false);
|
|
|
-
|
|
|
- if (empty($tokenValidation))
|
|
|
- return 'token_verify_fail';
|
|
|
- }
|
|
|
- else
|
|
|
- validateToken('admin-core');
|
|
|
-
|
|
|
- $setting_changes = array('admin_features' => array());
|
|
|
-
|
|
|
- // Cycle each feature and change things as required!
|
|
|
- foreach ($core_features as $id => $feature)
|
|
|
- {
|
|
|
- // Enabled?
|
|
|
- if (!empty($_POST['feature_' . $id]))
|
|
|
- $setting_changes['admin_features'][] = $id;
|
|
|
-
|
|
|
- // Setting values to change?
|
|
|
- if (isset($feature['settings']))
|
|
|
- {
|
|
|
- foreach ($feature['settings'] as $key => $value)
|
|
|
- {
|
|
|
- if (empty($_POST['feature_' . $id]) || (!empty($_POST['feature_' . $id]) && ($value < 2 || empty($modSettings[$key]))))
|
|
|
- $setting_changes[$key] = !empty($_POST['feature_' . $id]) ? $value : !$value;
|
|
|
- }
|
|
|
- }
|
|
|
- // Is there a call back for settings?
|
|
|
- if (isset($feature['setting_callback']))
|
|
|
- {
|
|
|
- $returned_settings = $feature['setting_callback'](!empty($_POST['feature_' . $id]));
|
|
|
- if (!empty($returned_settings))
|
|
|
- $setting_changes = array_merge($setting_changes, $returned_settings);
|
|
|
- }
|
|
|
-
|
|
|
- // Standard save callback?
|
|
|
- if (isset($feature['on_save']))
|
|
|
- $feature['on_save']();
|
|
|
- }
|
|
|
-
|
|
|
- // Make sure this one setting is a string!
|
|
|
- $setting_changes['admin_features'] = implode(',', $setting_changes['admin_features']);
|
|
|
-
|
|
|
- // Make any setting changes!
|
|
|
- updateSettings($setting_changes);
|
|
|
-
|
|
|
- // This is needed to let menus appear if cache > 2
|
|
|
- clean_cache('data');
|
|
|
-
|
|
|
- // Any post save things?
|
|
|
- foreach ($core_features as $id => $feature)
|
|
|
- {
|
|
|
- // Standard save callback?
|
|
|
- if (isset($feature['save_callback']))
|
|
|
- $feature['save_callback'](!empty($_POST['feature_' . $id]));
|
|
|
- }
|
|
|
-
|
|
|
- if (!isset($_REQUEST['xml']))
|
|
|
- redirectexit('action=admin;area=corefeatures;' . $context['session_var'] . '=' . $context['session_id']);
|
|
|
- }
|
|
|
-
|
|
|
- // Put them in context.
|
|
|
- $context['features'] = array();
|
|
|
- foreach ($core_features as $id => $feature)
|
|
|
- $context['features'][$id] = array(
|
|
|
- 'title' => isset($feature['title']) ? $feature['title'] : $txt['core_settings_item_' . $id],
|
|
|
- 'desc' => isset($feature['desc']) ? $feature['desc'] : $txt['core_settings_item_' . $id . '_desc'],
|
|
|
- 'enabled' => in_array($id, $context['admin_features']),
|
|
|
- 'state' => in_array($id, $context['admin_features']) ? 'on' : 'off',
|
|
|
- 'url' => !empty($feature['url']) ? $scripturl . '?' . $feature['url'] . ';' . $context['session_var'] . '=' . $context['session_id'] : '',
|
|
|
- 'image' => (file_exists($settings['theme_dir'] . '/images/admin/feature_' . $id . '.png') ? $settings['images_url'] : $settings['default_images_url']) . '/admin/feature_' . $id . '.png',
|
|
|
- );
|
|
|
-
|
|
|
- // Are they a new user?
|
|
|
- $context['is_new_install'] = !isset($modSettings['admin_features']);
|
|
|
- $context['force_disable_tabs'] = $context['is_new_install'];
|
|
|
- // Don't show them this twice!
|
|
|
- if ($context['is_new_install'])
|
|
|
- updateSettings(array('admin_features' => ''));
|
|
|
-
|
|
|
- // sub_template is already generic_xml and the token is created somewhere else
|
|
|
- if (isset($_REQUEST['xml']))
|
|
|
- return;
|
|
|
-
|
|
|
- $context['sub_template'] = 'core_features';
|
|
|
- $context['page_title'] = $txt['core_settings_title'];
|
|
|
- $context[$context['admin_menu_name']]['tab_data'] = array(
|
|
|
- 'title' => $txt['core_settings_title'],
|
|
|
- 'help' => '',
|
|
|
- 'description' => $txt['core_settings_desc'],
|
|
|
- );
|
|
|
-
|
|
|
- // We love our tokens.
|
|
|
- createToken('admin-core');
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Config array for chaning the basic forum settings
|
|
|
* Accessed from ?action=admin;area=featuresettings;sa=basic;
|
|
@@ -426,22 +280,27 @@ function ModifyLayoutSettings($return_config = false)
|
|
|
*/
|
|
|
function ModifyKarmaSettings($return_config = false)
|
|
|
{
|
|
|
- global $txt, $scripturl, $context, $settings, $sc;
|
|
|
+ global $txt, $scripturl, $context, $settings, $modSettings;
|
|
|
|
|
|
- $config_vars = array(
|
|
|
- // Karma - On or off?
|
|
|
+ if (empty($modSettings['karmaMode']))
|
|
|
+ $config_vars = array(
|
|
|
array('select', 'karmaMode', explode('|', $txt['karma_options'])),
|
|
|
- '',
|
|
|
- // Who can do it.... and who is restricted by time limits?
|
|
|
- array('int', 'karmaMinPosts', 6, 'postinput' => strtolower($txt['posts'])),
|
|
|
- array('float', 'karmaWaitTime', 6, 'postinput' => $txt['hours']),
|
|
|
- array('check', 'karmaTimeRestrictAdmins'),
|
|
|
- '',
|
|
|
- // What does it look like? [smite]?
|
|
|
- array('text', 'karmaLabel'),
|
|
|
- array('text', 'karmaApplaudLabel'),
|
|
|
- array('text', 'karmaSmiteLabel'),
|
|
|
- );
|
|
|
+ );
|
|
|
+ else
|
|
|
+ $config_vars = array(
|
|
|
+ // Karma - On or off?
|
|
|
+ array('select', 'karmaMode', explode('|', $txt['karma_options'])),
|
|
|
+ '',
|
|
|
+ // Who can do it.... and who is restricted by time limits?
|
|
|
+ array('int', 'karmaMinPosts', 6, 'postinput' => strtolower($txt['posts'])),
|
|
|
+ array('float', 'karmaWaitTime', 6, 'postinput' => $txt['hours']),
|
|
|
+ array('check', 'karmaTimeRestrictAdmins'),
|
|
|
+ '',
|
|
|
+ // What does it look like? [smite]?
|
|
|
+ array('text', 'karmaLabel'),
|
|
|
+ array('text', 'karmaApplaudLabel'),
|
|
|
+ array('text', 'karmaSmiteLabel'),
|
|
|
+ );
|
|
|
|
|
|
call_integration_hook('integrate_karma_settings', array(&$config_vars));
|
|
|
|