<?php

$perms_groups = sfConfig::get('app_permissions_list', array());
ksort($perms_groups);

$credentials = $node->getCredentials();
if (empty($credentials)) {
    $current_perms = array();
} else {
    $current_perms = explode('|', $node->getCredentials());
}

?>

<table width="100%" border="0" cellpadding="2" cellspacing="0" class="none">
<tr>
	<td width="25"><?php echo radiobutton_tag('perms_type', Node::PERMS_ALLOWED_TO_ANYBODY, Node::PERMS_ALLOWED_TO_ANYBODY == $node->getPermsType(), array('id' => 'radio_perms_allow_to_anybody'));
?></td>
	<td><label for="radio_perms_allow_to_anybody"><?php echo __('Everybody can access this page', null, 'catalyz');
?></label></td>
</tr>
<tr>
	<td width="25"><?php echo radiobutton_tag('perms_type', Node::PERMS_INHERIT, Node::PERMS_INHERIT == $node->getPermsType(), array('id' => 'radio_perms_inherit'));
?></td>
	<td><label for="radio_perms_inherit"><?php echo __('Use same permissions as parent page', null, 'catalyz');
?></label></td>
</tr>
<?php if (count($perms_groups) > 0) {
    ?>
<tr valign="top">
	<td width="25"><?php echo radiobutton_tag('perms_type', Node::PERMS_RESTRICTED, Node::PERMS_RESTRICTED == $node->getPermsType(), array('id' => 'radio_perms_restricted'));
    ?></td>
	<td>
		<label for="radio_perms_restricted"><?php echo __('Restricted to the following groups:', null, 'catalyz');
    ?></label>
		<table border="0" cellpadding="2" cellspacing="0">
		<?php foreach($perms_groups as $perm_id => $perm_name) {
        ?>
		<tr>
			<td><?php echo checkbox_tag('perms_groups[' . $perm_id . ']', true, in_array($perm_id, $current_perms)
					, array('id' => 'permission'.$perm_id)
					);
        ?></td>
			<td><?php echo $perm_name;
        ?></td>
		</tr>
		<?php }
    ?>
		</table>

	</td>
</tr>
<?php }
?>
</table>