Location: PHPKode > projects > O - OpenSource GroupWare > osgw/users/language.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;
echo $layout->page_header;
echo $layout->service_header($text['service_name'], $prefs->nav_buttons(), $text['language']);

if(isset($_POST['change_language']))
{
	$sql = "UPDATE o_preferences SET value='{$_POST['language']}' WHERE user_id='{$user->user_id}'
		AND service='gl' AND preference='language'";
	$db->query($sql);
}

?>

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


<table style="width:325px" align="center" cellpadding="0" cellspacing="0">
<tr>
	<td class="input_header" width="150">Current Language:</td>
	<td align="right">
		<?php 
		//Using a JOIN Statement doesn't seem to work with Postgres so we have to run two queries.
		$language = $user->get_preference('gl','language'); 
		$sql = "SELECT * FROM o_languages WHERE lg_id='$language'";
		
		$db->query($sql);
		
		$db->fetch_results();
		echo $db->record['language'];
		
		?>
	
	</td>
</tr>
<tr>
	<td class="input_header" width="150">New Language:</td>
	<td align="right">
		<select name="language">
		<?php
			$sql = "SELECT lg_id, language FROM o_languages WHERE enabled='1'";
			$db->query($sql);
			while($db->fetch_results())
			{
				echo "<option value=\"{$db->record['lg_id']}\">{$db->record['language']}</option>";
				
			}
		?>
		</select>
	
	</td>
</tr>

<tr>
	<td width="150"><input type="submit" value="Change Language" name="change_language" class="button1"></td>
	<td align="left"><input type="submit" value="Cancel" name="cancel" class="button1"></td>
</tr>

</table>
</form>
<br />
<?php echo $layout->create_footer()?>
Return current item: O - OpenSource GroupWare