Location: PHPKode > projects > O - OpenSource GroupWare > osgw/users/themes.php
<?php
/**************************************************************************
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   @Authors:	Ryan Thompson(hide@address.com)
***************************************************************************/

include("./data.php");
$service['add_header'] = TRUE;
include("../config.inc.php");
include($here. "/class.preferences.php");
$prefs = new preferences;


if(isset($_POST['save_scheme']))
{
	if(isset($_POST['link']))
	{
		$sql = "SELECT scheme_id FROM o_schemes LEFT JOIN o_themes ON o_themes.scheme_link=o_schemes.scheme_id WHERE
				o_themes.theme_id='{$_POST['theme']}'";
		$db->query($sql);
		$db->fetch_results();
		$scheme = $db->record['scheme_id'];
	} else {
		$scheme = $_POST['scheme'];
	}
	
			
$sql = "UPDATE o_preferences SET value='$scheme' WHERE user_id='". $user->user_id ."'
	AND service='gl' AND preference='scheme'";
$db->query($sql);

$sql = "UPDATE o_preferences SET value='$_POST[theme]' WHERE user_id='". $user->user_id ."'
	AND service='gl' AND preference='theme'";
$db->query($sql);

$O->redirect('/users/themes.php');
}
echo $layout->page_header;
echo $layout->service_header($text['service_name'], $prefs->nav_buttons(), $text['themes']);

?>
<br />
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">

<table style="width:450px" align="center"  cellpadding="0" cellspacing="0">
<tr>
<td class="input_header">Theme: </td>
<td>

<?php
$sql = "SELECT o_themes.* FROM o_themes LEFT JOIN o_preferences ON o_preferences.value=o_themes.theme_id
	WHERE o_preferences.user_id='". $user->user_id ."' AND o_preferences.preference='theme'
	AND o_preferences.service='gl'";
$db->query($sql);
?>
<select name="theme">
<?php

$db->fetch_results();
echo "<option value=\"". $db->record['theme_id'] ."\">". $db->record['name'] ."</option>";
echo "<option value=\"\">------------------</option>";

$sql = "SELECT theme_id, name FROM o_themes";
$db->query($sql);
while($db->fetch_results())
{
	echo "<option value=\"". $db->record['theme_id'] ."\">". $db->record['name'] ."</option>";
}
?>

</select>

</td>
<td><?php echo $text['link_theme']?><input type="checkbox" name="link" value="TRUE" checked="checked"></td>
</tr>
<tr>
	<td class="input_header">Scheme: </td>
	<td>
<?php

$sql = "SELECT o_schemes.* FROM o_schemes LEFT JOIN o_preferences ON o_preferences.value=o_schemes.scheme_id
	WHERE o_preferences.user_id='". $user->user_id ."' AND o_preferences.preference='scheme'
	AND o_preferences.service='gl'";
$db->query($sql);
$db->fetch_results();

$scheme = $db->record['scheme'];
echo"\n<select name=\"scheme\">\n";
	echo "<option value=\"". $db->record['scheme_id'] ."\">". $db->record['name'] ."</option>";
	echo "<option value=\"\">------------------</option>";
$sql = "SELECT scheme_id, name FROM o_schemes";
$db->query($sql);

while($db->fetch_results())
{
	echo "<option value=\"". $db->record['scheme_id'] ."\">". $db->record['name'] ."</option>";
}

echo "</select>\n";

?>
</td></tr>

<tr>
<td>
<input type="submit" name="save_scheme" class="button1" value="Save Scheme">
</td></tr>
</table>
</form>
<br />
<?php echo $layout->create_footer()?>
Return current item: O - OpenSource GroupWare