{literal}
<script type="text/javascript">
	function populateField(value, key){
		var field = document.getElementById(key);
		field.value = value;
	}
</script>
{/literal}
<h2>{i18n}Existing permissions{/i18n}</h2>

<p class="descriptiveText">{i18n}Permissions are descriptors used to ascertain whether groups of users have access to certain functionality. The built-in permissions below facilitate the default functionality of the DMS and can't be changed. Plugin developers may choose to add additional permissions below that manage access to their plugins functionality.{/i18n}</p>

<form method="POST" action="{$smarty.server.PHP_SELF}">
<fieldset>
<legend>{i18n}Create a new permission{/i18n}</legend>
<input type="hidden" name="action" value="newPermission">



{foreach item=oWidget from=$add_fields}
  {$oWidget->render()}
{/foreach}

<div class="form_actions">
<input type="submit" name="submit" value="{i18n}Create{/i18n}">
</div>
</fieldset>

</form>


<table class="listing">
    <thead>
        <tr>
            <th>{i18n}Permission{/i18n}</th>
            <th>{i18n}Display Name{/i18n}</th>
            <th>{i18n}Delete{/i18n}</th>
        </tr>
    </thead>
    { foreach item=oPerm from=$permissions }
        <tr class="{cycle values="odd,even"}">
            <td>
            { $oPerm->getName() }
            </td>
            <td>
            { $oPerm->getHumanName() }
            </td>
          { if $oPerm->getBuiltIn() == true }
            <td>
            {i18n}Built-in{/i18n}
            </td>
            { else }
            <!-- <td>
                Edit
            </td> -->
            <td>
               <a
href="{addQS}action=deletePermission&id={$oPerm->getId()}{/addQS}"
class="ktAction ktDelete">{i18n}Delete Permission{/i18n}</a>
            </td>
          { /if }
        </tr>
    { /foreach }
</table>
{if $context->sNameVal != ''}
<script type="text/javascript">
	populateField("{$context->sNameVal}", "name");
</script>
{/if}
{if $context->sHumanNameVal != ''}
<script type="text/javascript">
	populateField("{$context->sHumanNameVal}", "human_name");
</script>
{/if}