/** * Saves the admins current preferences to the database. * * @package Admin */ function updateAdminPreferences() { global $options, $context, $settings, $user_info; // This must exist! if (!isset($context['admin_preferences'])) { return false; } // This is what we'll be saving. $options['admin_preferences'] = serialize($context['admin_preferences']); require_once SUBSDIR . '/Themes.subs.php'; // Just check we haven't ended up with something theme exclusive somehow. removeThemeOptions('custom', 'all', 'admin_preferences'); updateThemeOptions(array(1, $user_info['id'], 'admin_preferences', $options['admin_preferences'])); // Make sure we invalidate any cache. cache_put_data('theme_settings-' . $settings['theme_id'] . ':' . $user_info['id'], null, 0); }
/** * Make any theme changes that are sent with the profile. * * @param int $memID * @param int $id_theme */ function makeThemeChanges($memID, $id_theme) { global $modSettings, $context, $user_info; $db = database(); $reservedVars = array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'); // Can't change reserved vars. if (isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0 || isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0) { fatal_lang_error('no_access', false); } // Don't allow any overriding of custom fields with default or non-default options. $request = $db->query('', ' SELECT col_name FROM {db_prefix}custom_fields WHERE active = {int:is_active}', array('is_active' => 1)); $custom_fields = array(); while ($row = $db->fetch_assoc($request)) { $custom_fields[] = $row['col_name']; } $db->free_result($request); // These are the theme changes... $themeSetArray = array(); if (isset($_POST['options']) && is_array($_POST['options'])) { foreach ($_POST['options'] as $opt => $val) { if (in_array($opt, $custom_fields)) { continue; } // These need to be controlled. if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { $val = max(0, min($val, 50)); } elseif ($opt == 'allow_no_censored') { continue; } $themeSetArray[] = array($id_theme, $memID, $opt, is_array($val) ? implode(',', $val) : $val); } } $erase_options = array(); if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { foreach ($_POST['default_options'] as $opt => $val) { if (in_array($opt, $custom_fields)) { continue; } // These need to be controlled. if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { $val = max(0, min($val, 50)); } elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { continue; } $themeSetArray[] = array(1, $memID, $opt, is_array($val) ? implode(',', $val) : $val); $erase_options[] = $opt; } } // If themeSetArray isn't still empty, send it to the database. if (empty($context['password_auth_failed'])) { require_once SUBSDIR . '/Themes.subs.php'; if (!empty($themeSetArray)) { updateThemeOptions($themeSetArray); } if (!empty($erase_options)) { removeThemeOptions('custom', $memID, $erase_options); } $themes = explode(',', $modSettings['knownThemes']); foreach ($themes as $t) { cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); } } }
/** * Reorders the front page blocks in response to a D&D ajax request */ public function action_userblockorder() { global $context, $txt, $user_info, $settings, $modSettings; // Should not happen, but no guest processing if ($user_info['is_guest'] || $user_info['id'] == 0) { return; } // Start off with nothing $context['xml_data'] = array(); $errors = array(); $order = array(); // Chances are loadLanguage('SPortal'); // You have to be allowed to do this $validation_session = checkSession(); if (empty($validation_session)) { $block_tree = array(); // No questions that we are rearranging the blocks if (isset($_POST['order'], $_POST['received'], $_POST['moved'])) { $column_numbers = array('sp_left_div' => 1, 'sp_top_div' => 2, 'sp_bottom_div' => 3, 'sp_right_div' => 4, 'sp_header' => 5, 'sp_footer' => 6); // What block was drag and dropped? e.g. block_2,4 list($block_moved, ) = explode(',', $_POST['moved']); $block_moved = (int) str_replace('block_', '', $block_moved); // Where is it going $target_column = $column_numbers[$_POST['received']]; // The block ids arrive in 1-n view order ... block,column foreach ($_POST['block'] as $id) { list($block, $column) = explode(',', $id); // Update the moved blocks column if ($block == $block_moved) { $column = $target_column; } $block_tree[$column][] = $block; } } // Update the option so its remembered require_once SUBSDIR . '/Themes.subs.php'; updateThemeOptions(array($settings['theme_id'], $user_info['id'], 'sp_block_layout', serialize($block_tree))); if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { cache_put_data('theme_settings-' . $settings['theme_id'] . ':' . $user_info['id'], null, 60); } $order[] = array('value' => $txt['sp-blocks_success_arrange']); } else { $errors[] = array('value' => $txt['sp-blocks_fail_arrange']); } // Return the response $context['sub_template'] = 'generic_xml'; $context['xml_data'] = array('orders' => array('identifier' => 'order', 'children' => $order), 'errors' => array('identifier' => 'error', 'children' => $errors)); }
/** * Set a theme option via javascript. * * What it does: * - sets a theme option without outputting anything. * - can be used with javascript, via a dummy image... (which doesn't require * the page to reload.) * - requires someone who is logged in. * - accessed via ?action=jsoption;var=variable;val=value;session_var=sess_id. * - optionally contains &th=theme id * - does not log access to the Who's Online log. (in index.php..) */ public function action_jsoption() { global $settings, $user_info, $options, $modSettings; // Check the session id. checkSession('get'); // This good-for-nothing pixel is being used to keep the session alive. if (empty($_GET['var']) || !isset($_GET['val'])) { redirectexit($settings['images_url'] . '/blank.png'); } // Sorry, guests can't go any further than this.. if ($user_info['is_guest'] || $user_info['id'] == 0) { obExit(false); } $reservedVars = array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url', 'name'); // Can't change reserved vars. if (in_array(strtolower($_GET['var']), $reservedVars)) { redirectexit($settings['images_url'] . '/blank.png'); } // Use a specific theme? if (isset($_GET['th']) || isset($_GET['id'])) { // Invalidate the current themes cache too. if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { cache_put_data('theme_settings-' . $settings['theme_id'] . ':' . $user_info['id'], null, 60); } $settings['theme_id'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; } // If this is the admin preferences the passed value will just be an element of it. if ($_GET['var'] == 'admin_preferences') { $options['admin_preferences'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array(); // New thingy... if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; } // Change the value to be something nice, $_GET['val'] = serialize($options['admin_preferences']); } elseif ($_GET['var'] == 'minmax_preferences') { $options['minmax_preferences'] = !empty($options['minmax_preferences']) ? unserialize($options['minmax_preferences']) : array(); // New value for them if (isset($_GET['minmax_key']) && strlen($_GET['minmax_key']) < 10) { $options['minmax_preferences'][$_GET['minmax_key']] = $_GET['val']; } // Change the value to be something nice, $_GET['val'] = serialize($options['minmax_preferences']); } // Update the option. require_once SUBSDIR . '/Themes.subs.php'; updateThemeOptions(array($settings['theme_id'], $user_info['id'], $_GET['var'], is_array($_GET['val']) ? implode(',', $_GET['val']) : $_GET['val'])); if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { cache_put_data('theme_settings-' . $settings['theme_id'] . ':' . $user_info['id'], null, 60); } // Don't output anything... redirectexit($settings['images_url'] . '/blank.png'); }
/** * The credits section in admin panel. * * What it does: * - Determines the current level of support functions from the server, such as * current level of caching engine or graphics librayrs installed. * - Accessed by ?action=admin;area=credits */ public function action_credits() { global $forum_version, $txt, $scripturl, $context, $user_info, $modSettings; // We need a little help from our friends require_once SUBSDIR . '/Membergroups.subs.php'; require_once SUBSDIR . '/Who.subs.php'; require_once SUBSDIR . '/Admin.subs.php'; // You have to be able to do at least one of the below to see this page. isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments')); // Find all of this forum's administrators... if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups')) { // Add a 'more'-link if there are more than 32. $context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>'; } // Load credits. $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['support_credits_title'], 'help' => '', 'description' => ''); loadLanguage('Who'); $context += prepareCreditsData(); // This makes it easier to get the latest news with your time format. $context['time_format'] = urlencode($user_info['time_format']); $context['forum_version'] = $forum_version; // Get a list of current server versions. $checkFor = array('gd', 'imagick', 'db_server', 'mmcache', 'eaccelerator', 'zend', 'apc', 'memcache', 'xcache', 'opcache', 'php', 'server'); $context['current_versions'] = getServerVersions($checkFor); $context['can_admin'] = allowedTo('admin_forum'); $context['sub_template'] = 'credits'; $context['page_title'] = $txt['support_credits_title']; // Load in the admin quick tasks $context['quick_admin_tasks'] = getQuickAdminTasks(); $index = 'new_in_' . str_replace(array('ElkArte ', '.'), array('', '_'), FORUM_VERSION); if (isset($txt[$index])) { $context['latest_updates'] = replaceBasicActionUrl($txt[$index]); require_once SUBSDIR . '/Themes.subs.php'; updateThemeOptions(array(1, $user_info['id'], 'dismissed_' . $index, 1)); } }