Location: PHPKode > projects > O - OpenSource GroupWare > osgw/admin/language_manager.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.admin.php");
$admin = new admin;

if(isset($_POST['edit_messages']))
{
	//echo $_POST['edit_language'];
	$O->redirect('/admin/edit_messages.php?lang='. $_POST['edit_language']);	
} elseif(isset($_POST['add_languages']))
{
	foreach($_POST['available_languages'] AS $value)
	{
		$sql = "UPDATE o_languages SET enabled='1' WHERE lg_id='$value'";
		$db->query($sql);	
	}
	$O->redirect('/config/upgrade_languages.php?al=TRUE');
} elseif(isset($_POST['delete_languages']))
{
	$sql = "SELECT enabled FROM o_languages WHERE enabled='1'";
	$db->query($sql);
	
	if($db->num_rows > count($_POST['installed_languages']))
	{
		
		foreach($_POST['installed_languages'] AS $value)
		{
			$sql = "UPDATE o_languages SET enabled='0' WHERE lg_id='$value'";
			$db->query($sql);	
			$db->query("DELETE FROM o_text WHERE language='$value'");
			
		}	
	} else {
		echo "Can't remove all languages";
	}
}

echo $layout->page_header;
echo $layout->service_header($text['service_name'] . ' - '. $text['language_manager'],$admin->nav_buttons());


	$db->query("SELECT lg_id FROM o_languages WHERE enabled = '1'");
	$count = $db->num_rows;
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table align="center">
<tr>
	<td class="input_header">Install/Remove Languages</td>
<td>

	<table style="width:350px">
		<tr><td colspan="2">Available Languages</td><td>Installed Languages</td></tr>
		<tr>
			<td><?php echo $setup->get_language_support(0)?></td>
			<td style="text-align:center">
		<input type="submit" name="add_languages" value="Add Language" class="button1">
		<br />
		<br />
		<?php
			if($count > 1)
			{

		?>
		<input type="submit" name="delete_languages" value="Delete Language" class="button1">
		<?php
			}
		?>
			</td>
			<td><?php echo $setup->get_language_support(1)?></td>
		</tr>
	</table>
</td>
</tr>
	

<tr>
<td class="input_header">Message Editor</td>
<td style="vertical-align:top">
	<?php
		$db->query( "SELECT * FROM o_languages WHERE enabled='1'");
		echo "<select name=\"edit_language\">\n";
		while($db->fetch_results())
		{
			echo "<option value=\"{$db->record['lg_id']}\">{$db->record['language']}</option>\n";
		}
		echo "</select>\n";
		
	?>
	
	<input type="submit" name="edit_messages" value="<?php echo $text['edit_messages']?>" class="button1">

</tr>
<tr>
	<td class="input_header">Language Update:</td>
	
</tr>
</table>
</form>
<br />

<?php
	echo $layout->create_footer();
?>
Return current item: O - OpenSource GroupWare