<?php

require_once('include/admin.inc.php');

auth_redirect(); // Require logged in user to access this page.

$type = get_typeByID( $_GET['edit'] )
	or mtdie("Invalid type number!");

$metas = get_allMetaTypes();

adminhead('Types');
adminmenu('manage-types.php');

?>

<h2>Edit Type Information</h2>

<form action="manage-types.php" method="post" name="post" id="post">
<?php nonce_field('save-type-'.$type->id); ?>
<input type="hidden" name="action" value="edit_type" />
<input type="hidden" name="type_id" value="<?php echo $type->id; ?>" />

<div id="poststuff">

	<table class="editform" width="100%" cellspacing="2" cellpadding="5">
	<tr>
	<th scope="row" width="33%">Name</th>
	<td width="66%"><input name="name" type="text" id="name" value="<?php echo htmlentities($type->name); ?>" /></td>
	</tr>
	<tr>
	<th scope="row" width="33%">Description</th>
	<td width="66%"><input name="description" type="text" id="description" value="<?php echo htmlentities($type->description); ?>" /></td>
	</tr>
	<th scope="row" width="33%">Metatypes</th>
	<td width="66%">
	<?php
		foreach($metas as $s) {
			echo '<input id="c-' . $s->id . '" type="checkbox" name="meta[' . $s->id . ']"' . ( _objectInArrayWithIdExists( $s->id, $type->meta ) ? ' checked="checked"' : '') . '/> <label for="c-' . $s->id . '">' . $s->name . '</label><br/>';
		}
	?></td>
	</tr>
	</table>

	<p class="submit"><input type="submit" value="Save &raquo;" name="submit" /></p>

</div>

</form>

<?php adminfooter(); ?>
