<h2><img src="{if $config->get("ui/morphEnabled") == '1'}{$rootUrl}/skins/kts_{$config->get("ui/morphTo")}/title_bullet.png{else}{$rootUrl}/resources/graphics/title_bullet.png{/if}"/>{i18n}Document permissions{/i18n}:<br />{$context->oDocument->getName()|sanitize}</h2>

<p class="descriptiveText">{i18n}This page shows the permissions that apply to
this specific document.  Where the folder view shows you information by role and group,
this page shows the actual groups (and, if they are assigned directly to a role, the users)
who have the different permissions. As a result, groups, users and roles with <strong>no</strong>
permissions are not shown.{/i18n}</p>

{if $edit}
{i18n}Manage security{/i18n}: <a href="{addQS}action=resolved_users&fDocumentId={$context->oDocument->getId()}{/addQS}">{i18n}View resolved permissions for user{/i18n}</a>
{/if}

{if ((empty($roles) && empty($groups) && empty($users)))}
<div class="ktInfoMessage"><span>{i18n}No roles or groups have been defined or have permissions.{/i18n}</span></div>
{else}

<table  class="kt_collection"cellspacing="0" cellpadding="0" border="0">
<thead>
<tr>
<th>{i18n}Role or Group{/i18n}</th>
{ foreach item=oPerm from=$permissions }
<th title="{$oPerm->getName()}" class="centered" style="white-space: normal !important;">{$oPerm->getHumanName()} {assign var=iPermId value=$oPerm->getId()}
{if ($workflow_controls.$iPermId)}<br /><span class="descriptiveText">(workflow controlled)</span>{/if}
{if ($conditions_control.$iPermId)}<br /><span class="descriptiveText">(condition affected)</span>{/if}
</th>
{ /foreach }
</tr>
</thead>
<tbody>

{ foreach item=oRole from=$roles }
<td><span class="descriptiveText">{i18n}Role{/i18n}:</span> {$oRole->getName()}</td>
  { assign var=iRoleId value=$oRole->getId() }
  { foreach item=oPerm from=$permissions }
    { assign var=iPermId value=$oPerm->getId() }
    { assign var=bHasPerm value=$aMapPermissionRole[$iPermId][$iRoleId] }

{ if $bHasPerm }
<td class="centered"><span class="ktAction ktInline ktAllowed">{i18n}Allowed{/i18n}</span></td>
{ else }
<td class="centered"><span class="ktAction ktInline ktDenied">{i18n}Denied{/i18n}</span></td>
{ /if }
  { /foreach }
</tr>
{ /foreach }


{ foreach item=oGroup from=$groups }
<td><span class="descriptiveText">{i18n}Group{/i18n}:</span> {$oGroup->getName()}</td>
  { assign var=iGroupId value=$oGroup->getId() }
  { foreach item=oPerm from=$permissions }
    { assign var=iPermId value=$oPerm->getId() }
    { assign var=bHasPerm value=$aMapPermissionGroup[$iPermId][$iGroupId] }

{ if $bHasPerm }
<td class="centered"><span class="ktAction ktInline ktAllowed">{i18n}Allowed{/i18n}</span></td>
{ else }
<td class="centered"><span class="ktAction ktInline ktDenied">{i18n}Denied{/i18n}</span></td>
{ /if }


  { /foreach }
</tr>
{ /foreach }


{ foreach item=oUser from=$users }
<td><span class="descriptiveText">{i18n}User: {/i18n}</span> {$oUser->getName()}</td>
  { assign var=iUserId value=$oUser->getId() }
  { foreach item=oPerm from=$permissions }
    { assign var=iPermId value=$oPerm->getId() }
    { assign var=bHasPerm value=$aMapPermissionUser[$iPermId][$iUserId] }

{ if $bHasPerm }
<td class="centered"><span class="ktAction ktInline ktAllowed">{i18n}Allowed{/i18n}</span></td>
{ else }
<td class="centered"><span class="ktAction ktInline ktDenied">{i18n}Denied{/i18n}</span></td>
{ /if }


  { /foreach }
</tr>
{ /foreach }

</tbody>
</table>
{ /if }

