Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/PortalSources/PortalSettings.php

All the function calls and display in this file were derived
from the SMF ModSettings.php file and re-used in this
file to allow Portal Settings to look and work like the 
Edit Features and Options page from SMF.
LSP does not claim any ownership of code that is re-used from
any SMF file(s).
LSP: Lunabyte Systems Portal
Open-Source Project Inspired by Zef Hemel (hide@address.com)
Software Version:             LSP 2.0 "Enigma 2"
Software by:                  Lunabyte Systems (http://www.lunabyte.net)
Copyright 2002-2005 by:       Lunabyte Systems (http://www.lunabyte.net)
Support, News, Updates at:    http://www.lunabyte.net
This program is free software; you may redistribute it and/or modify it 
under the terms of the provided license as published by Lunabyte Systems.

This program is distributed in the hope that it is and will be useful,                  
but WITHOUT ANY WARRANTIES; without even any implied warranty of           

See the "LSP_license.txt" file for details of the LSP license.
The latest version can always be found at http://www.lunabyte.net.

if (!defined('ENIGMA'))
	die('<b>Access Violation</b><br />Direct Access to this location is not allowed.');

function PortalSettings()
	global $txt, $db_prefix, $modSettings, $config_vars, $moduledir, $blockdir;
	// load the regular modsettings language file AND the Enigma language file

	// Load all the pages for the portal home page selection
	$pagearray = getPagelist();
	// add the news option to the array
	$pagearray[] = array('usenews', $txt['usesitenews']);
	// add all the current modules to the array
	$pagearray = array_merge($pagearray, LoadstartModules());

	// Load all the boards for the news default board selection.
	$forumBoards = getBoardlist();

	/* Adding options to this list isn't hard.  The basic format for a checkbox is:
		array('check', 'nameInModSettingsAndSQL'),

	   And for a text box:
		array('text', 'nameInModSettingsAndSQL')
	   (NOTE: You have to add an entry for this at the bottom!)

	   In these cases, it will look for $txt['nameInModSettingsAndSQL'] as the description,
	   and $helptxt['nameInModSettingsAndSQL'] as the help popup description.

	Here's a quick explanation of how to add a new item:

	 * A text input box.  For textual values.
	ie.	array('text', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
			&$txt['OptionalDescriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),

	 * A text input box.  For numerical values.
	ie.	array('int', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
			&$txt['OptionalDescriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),

	 * A text input box.  For floating point values.
	ie.	array('float', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
			&$txt['OptionalDescriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),

	 * A check box.  Either one or zero. (boolean)
	ie.	array('check', 'nameInModSettingsAndSQL', null, &$txt['descriptionOfTheOption'],

	 * A selection box.  Used for the selection of something from a list.
	ie.	array('select', 'nameInModSettingsAndSQL', array('valueForSQL' => &$txt['displayedValue']),
			&$txt['descriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),
	Note that just saying array('first', 'second') will put 0 in the SQL for 'first'.

	 * A password input box. Used for passwords, no less!
	ie.	array('password', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
			&$txt['descriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),

	For each option:
		type (see above), variable name, size/possible values, description, helptext.
	OR	make type 'rule' for an empty string for a horizontal rule.
	OR	make type 'heading' with a string for a titled section. */

	$config_vars = array(
	// Start Enigma settings
		array('heading', &$txt['labelportal']),
			array('check', 'enableblocks'),
			array('check', 'showsubmissions'),
			array('check', 'enablesitemenus'),
			array('check', 'enablemodules'),
			array('check', 'enablesitenews'),
			array('text', 'NewsTitle'),
			array('int', 'maxnewsitems'),
			array('int', 'maxNPdisplay', '3'),
			// The default board to post in... kinda alone...
			array('select', 'news_defaultboard', $forumBoards), 
			array('check', 'enablearticles'),
			array('int', 'featuredarticles'),
			array('check', 'use_portal_home_page'),
			array('select', 'portal_home_page', $pagearray),
		array('heading', &$txt['blocksettings']),
			array('int', 'headlineslimit', '3'),
		array('heading', &$txt['compatibility']),
			array('check', 'parse_query_string'),
			array('check', 'old_ops'),

	// set an array to use for auto loading settings files
	$autoLoad = array();

	// Enigma -- Get ModSettings for Modules from the Main ModuleSettings file if the file exists
	if ($modSettings['enablemodules'] && file_exists($moduledir . '/ModuleSettings.php'))
		include_once $moduledir . '/ModuleSettings.php';
		// if autoload directory exists, set it to check
		if (is_dir($moduledir . '/ModuleSettings'))
			$autoLoad[] = array($moduledir . '/ModuleSettings', 'modules', 'ModuleSettings');
	// set and autoload directory for blocks if it exists
	if ($modSettings['enableblocks'] && is_dir($blockdir . '/BlockSettings'))
			$autoLoad[] = array($blockdir . '/BlockSettings', 'blocks', 'BlockSettings');

	// now let's check for files
	if (sizeof($autoLoad) > 0)
		foreach ($autoLoad as $n => $load)
			if ($loadFiles = readDirectory($load[0], 'Settings_', '.php'))
				foreach ($loadFiles as $file)
				{	// include the file
					include_once($load[0] . '/' . $file);
					// is it setup properly?  check it the best we can and add it to the array if it is
					if (!empty($auto_config_vars) && is_array($auto_config_vars) && sizeof($auto_config_vars) > 0 && is_array($auto_config_vars[0]))
						$config_vars = array_merge($config_vars, $auto_config_vars);
						loadPLanguage($load[1] . '/' . $load[2] . '/' . str_replace('.php', '', $file));
					// it's not configured properly, so let's let someone know
						fatal_error('"' . $load[0] . '/' . $file . '" ' . $txt['bad_file']);

	return $config_vars;

function ModifyPortalSettings()
	global $sourcedir, $txt, $scripturl, $context, $settings, $sc;


	require_once($sourcedir . '/ModSettings.php');


	$config_vars = PortalSettings();

	$context['page_title'] = $txt['portalsettings'];
	$context['sub_template'] = 'rawdata';

	$context['raw_data'] = '
		<form action="' . $scripturl . '?op=modifyPortalSettings2" method="post" name="modsForm">
			<table width="100%" border="0" cellspacing="1" cellpadding="0" class="bordercolor" align="center">
					<table border="0" cellspacing="0" cellpadding="4" align="center" width="100%">
						<tr class="titlebg">
							<td colspan="2">
								<a href="' . $scripturl . '?action=helpadmin;help=10" onclick="return reqWin(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.gif" alt="' . $txt[119] . '" border="0" align="top" /></a>
								' . $txt['modSettings_title'] . '
							<td align="right" class="smalltext">
								<a href="javascript:document.modsForm.expand.value = \'all\'; document.modsForm.submit();">' . $txt['mods_cat_expand_all'] . '</a>
						</tr><tr class="windowbg">
							<td colspan="3" class="smalltext" style="padding: 2ex;">' . $txt['pagedesc'] . '</td>';

	// Show them!

	$context['raw_data'] .= '
							<td class="windowbg2" colspan="3" style="text-align: center;"><input type="submit" value="' . $txt[10] . '" /></td>
			<input type="hidden" name="sc" value="' . $sc . '" />
			<input type="hidden" name="expand" value="" />

function ModifyPortalSettings2()
	global $sourcedir, $scripturl, $db_prefix, $settings;

	// Verify the user is allowed to be here!

	require_once($sourcedir . '/ModSettings.php');

	$setArray = array();

	// All the checkbox values....
	$config_vars = PortalSettings();

	foreach ($config_vars as $var)
		if (!isset($var[1]) || !isset($_POST[$var[1]]))

		// Checkboxes!
		elseif ($var[0] == 'check')
			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
		// Select boxes!
		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
			$setArray[$var[1]] = $_POST[$var[1]];
		// Integers!
		elseif ($var[0] == 'int')
			$setArray[$var[1]] = (int) $_POST[$var[1]];
		// Floating point!
		elseif ($var[0] == 'float')
			$setArray[$var[1]] = (float) $_POST[$var[1]];
		// Text and passwords!
		elseif ($var[0] == 'text' || $var[0] == 'password')
			$setArray[$var[1]] = $_POST[$var[1]];



	// Expand something?
	if (isset($_POST['expand']) && $_POST['expand'] != '')
		redirectexit('op=modifyPortalSettings;expand=' . $_POST['expand'] . '#sect' . $_POST['expand']);

	// Back to administration.

Return current item: Enigma