/** * 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('cd' => array('url' => 'action=admin;area=managecalendar', 'settings' => array('cal_enabled' => 1)), 'cp' => array('url' => 'action=admin;area=featuresettings;sa=profile', 'save_callback' => create_function('$value', ' global $smcFunc; if (!$value) { $smcFunc[\'db_query\'](\'\', \' UPDATE {db_prefix}custom_fields SET active = 0\'); } '), 'setting_callback' => create_function('$value', ' if (!$value) return array( \'disabled_profile_fields\' => \'\', \'registration_fields\' => \'\', \'displayFields\' => \'\', ); else return array(); ')), 'dr' => array('url' => 'action=admin;area=managedrafts', 'settings' => array('drafts_enabled' => 1, 'drafts_post_enabled' => 2, 'drafts_pm_enabled' => 2, 'drafts_autosave_enabled' => 2, 'drafts_show_saved_enabled' => 2), 'setting_callback' => create_function('$value', ' global $smcFunc, $sourcedir; // Set the correct disabled value for the scheduled task. $smcFunc[\'db_query\'](\'\', \' UPDATE {db_prefix}scheduled_tasks SET disabled = {int:disabled} WHERE task = {string:task}\', array( \'disabled\' => $value ? 0 : 1, \'task\' => \'remove_old_drafts\', ) ); ')), 'ih' => array('url' => 'action=admin;area=modsettings;sa=hooks', 'settings' => array('handlinghooks_enabled' => 1)), 'k' => array('url' => 'action=admin;area=featuresettings;sa=karma', 'settings' => array('karmaMode' => 2)), 'ml' => array('url' => 'action=admin;area=logs;sa=modlog', 'settings' => array('modlog_enabled' => 1)), 'pm' => array('url' => 'action=admin;area=permissions;sa=postmod', 'setting_callback' => create_function('$value', ' global $sourcedir; // Cant use warning post moderation if disabled! if (!$value) { require_once($sourcedir . \'/PostModeration.php\'); approveAllData(); return array(\'warning_moderate\' => 0); } else return array(); ')), 'ps' => array('url' => 'action=admin;area=paidsubscribe', 'settings' => array('paid_enabled' => 1), 'setting_callback' => create_function('$value', ' global $smcFunc, $sourcedir; // Set the correct disabled value for scheduled task. $smcFunc[\'db_query\'](\'\', \' UPDATE {db_prefix}scheduled_tasks SET disabled = {int:disabled} WHERE task = {string:task}\', array( \'disabled\' => $value ? 0 : 1, \'task\' => \'paid_subscriptions\', ) ); // Should we calculate next trigger? if ($value) { require_once($sourcedir . \'/ScheduledTasks.php\'); CalculateNextTrigger(\'paid_subscriptions\'); } ')), 'rg' => array('url' => 'action=admin;area=reports'), 'w' => array('url' => 'action=admin;area=securitysettings;sa=moderation', 'setting_callback' => create_function('$value', ' global $modSettings; list ($modSettings[\'warning_enable\'], $modSettings[\'user_limit\'], $modSettings[\'warning_decrement\']) = explode(\',\', $modSettings[\'warning_settings\']); $warning_settings = ($value ? 1 : 0) . \',\' . $modSettings[\'user_limit\'] . \',\' . $modSettings[\'warning_decrement\']; if (!$value) { $returnSettings = array( \'warning_watch\' => 0, \'warning_moderate\' => 0, \'warning_mute\' => 0, ); } elseif (empty($modSettings[\'warning_enable\']) && $value) { $returnSettings = array( \'warning_watch\' => 10, \'warning_moderate\' => 35, \'warning_mute\' => 60, ); } else $returnSettings = array(); $returnSettings[\'warning_settings\'] = $warning_settings; return $returnSettings; ')), 'sp' => array('url' => 'action=admin;area=sengines', 'settings' => array('spider_mode' => 1), 'setting_callback' => create_function('$value', ' // Turn off the spider group if disabling. if (!$value) return array(\'spider_group\' => 0, \'show_spider_online\' => 0); '), 'on_save' => create_function('', ' global $sourcedir, $modSettings; require_once($sourcedir . \'/ManageSearchEngines.php\'); recacheSpiderNames(); '))); // 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']; // We love our tokens. createToken('admin-core'); }
/** * Base admin callback function */ public function ModifyWordpressBridgeSettings() { global $txt, $context, $sourcedir; require_once $sourcedir . '/ManageSettings.php'; $context['page_title'] = $txt['wordpress bridge']; $subActions = array('bridge' => 'ModifyBridgeSettings', 'roles' => 'ManageRoles'); loadGeneralSettingParameters($subActions, 'bridge'); loadTemplate('WordpressBridge'); // Load up all the tabs... $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['wordpress bridge'], 'description' => '', 'tabs' => array('bridge' => array('description' => $txt['wordpress settings desc']), 'roles' => array('description' => $txt['wordpress roles desc']))); $this->{$subActions}[$_REQUEST['sa']](); }
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). image - Custom image to show next to feature. 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('cd' => array('url' => 'action=admin;area=managecalendar', 'settings' => array('cal_enabled' => 1)), 'cp' => array('url' => 'action=admin;area=featuresettings;sa=profile', 'save_callback' => create_function('$value', ' global $smcFunc; if (!$value) { $smcFunc[\'db_query\'](\'\', \' UPDATE {db_prefix}custom_fields SET active = 0\'); } '), 'setting_callback' => create_function('$value', ' if (!$value) return array( \'disabled_profile_fields\' => \'\', \'registration_fields\' => \'\', \'displayFields\' => \'\', ); else return array(); ')), 'k' => array('url' => 'action=admin;area=featuresettings;sa=karma', 'settings' => array('karmaMode' => 2)), 'ml' => array('url' => 'action=admin;area=logs;sa=modlog', 'settings' => array('modlog_enabled' => 1)), 'pm' => array('url' => 'action=admin;area=permissions;sa=postmod', 'setting_callback' => create_function('$value', ' global $sourcedir; // Cant use warning post moderation if disabled! if (!$value) { require_once($sourcedir . \'/PostModeration.php\'); approveAllData(); return array(\'warning_moderate\' => 0); } else return array(); ')), 'ps' => array('url' => 'action=admin;area=paidsubscribe', 'settings' => array('paid_enabled' => 1)), 'rg' => array('url' => 'action=admin;area=reports'), 'w' => array('url' => 'action=admin;area=securitysettings;sa=moderation', 'setting_callback' => create_function('$value', ' global $modSettings; list ($modSettings[\'warning_enable\'], $modSettings[\'user_limit\'], $modSettings[\'warning_decrement\']) = explode(\',\', $modSettings[\'warning_settings\']); $warning_settings = ($value ? 1 : 0) . \',\' . $modSettings[\'user_limit\'] . \',\' . $modSettings[\'warning_decrement\']; if (!$value) { $returnSettings = array( \'warning_watch\' => 0, \'warning_moderate\' => 0, \'warning_mute\' => 0, ); } elseif (empty($modSettings[\'warning_enable\']) && $value) { $returnSettings = array( \'warning_watch\' => 10, \'warning_moderate\' => 35, \'warning_mute\' => 60, ); } else $returnSettings = array(); $returnSettings[\'warning_settings\'] = $warning_settings; return $returnSettings; ')), 'sp' => array('url' => 'action=admin;area=sengines', 'settings' => array('spider_mode' => 1), 'setting_callback' => create_function('$value', ' // Turn off the spider group if disabling. if (!$value) return array(\'spider_group\' => 0, \'show_spider_online\' => 0); '), 'on_save' => create_function('', ' global $sourcedir, $modSettings; require_once($sourcedir . \'/ManageSearchEngines.php\'); recacheSpiderNames(); '))); // 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(); $setting_changes = array('admin_features' => array()); // Are we using the javascript stuff or radios to submit? $post_var_prefix = empty($_POST['js_worked']) ? 'feature_plain_' : 'feature_'; // Cycle each feature and change things as required! foreach ($core_features as $id => $feature) { // Enabled? if (!empty($_POST[$post_var_prefix . $id])) { $setting_changes['admin_features'][] = $id; } // Setting values to change? if (isset($feature['settings'])) { foreach ($feature['settings'] as $key => $value) { if (empty($_POST[$post_var_prefix . $id]) || !empty($_POST[$post_var_prefix . $id]) && ($value < 2 || empty($modSettings[$key]))) { $setting_changes[$key] = !empty($_POST[$post_var_prefix . $id]) ? $value : !$value; } } } // Is there a call back for settings? if (isset($feature['setting_callback'])) { $returned_settings = $feature['setting_callback'](!empty($_POST[$post_var_prefix . $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); // Any post save things? foreach ($core_features as $id => $feature) { // Standard save callback? if (isset($feature['save_callback'])) { $feature['save_callback'](!empty($_POST[$post_var_prefix . $id])); } } 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']), 'url' => !empty($feature['url']) ? $scripturl . '?' . $feature['url'] . ';' . $context['session_var'] . '=' . $context['session_id'] : ''); } // 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' => '')); } $context['sub_template'] = 'core_features'; $context['page_title'] = $txt['core_settings_title']; }
/** * Directs the admin to the proper page of settings for SimpleSEF * * @global array $txt * @global array $context * @global string $sourcedir */ public static function ModifySimpleSEFSettings() { global $txt, $context, $sourcedir, $backend_subdir; require_once $sourcedir . '/' . $backend_subdir . '/ManageSettings.php'; $context['page_title'] = $txt['simplesef']; $subActions = array('basic' => array('SimpleSEF', 'ModifyBasicSettings'), 'advanced' => array('SimpleSEF', 'ModifyAdvancedSettings'), 'alias' => array('SimpleSEF', 'ModifyAliasSettings')); loadGeneralSettingParameters($subActions, 'basic'); // Load up all the tabs... $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['simplesef'], 'description' => $txt['simplesef_desc'], 'tabs' => array('basic' => array(), 'advanced' => array(), 'alias' => array('description' => $txt['simplesef_alias_desc']))); call_user_func($subActions[$_REQUEST['sa']]); }