document_permissions.smarty 4.13 KB
{capture assign=sCSS}{literal}

td.true { background-color: #aaffaa; text-align: centre }
td.false { background-color: #ffaaaa; text-align: centre }
.edit { display: none; }
.view { display: block; }

.tablebutton {
    margin: 0em;
    margin-right: 1em;
    border: 1px solid #cccccc;
}
.activebutton {
    background-color: #eeeeff;
}
.inactivebutton {
    background-color: #ffeeee;
}

{/literal}{/capture}
{$context->oPage->requireCSSStandalone($sCSS)}
{$context->oPage->requireJSResource('thirdpartyjs/MochiKit/Base.js')}
{$context->oPage->requireJSResource('thirdpartyjs/MochiKit/Iter.js')}
{$context->oPage->requireJSResource('thirdpartyjs/MochiKit/DOM.js')}

<h2>{i18n}Document permissions{/i18n}</h2>

{ if $edit }
<div style="text-align: right">
<span class="tablebutton activebutton">
<a href="javascript:MochiKit.DOM.showElement('view'); MochiKit.DOM.hideElement('edit');">{i18n}View{/i18n}</a>
</span>
<span class="tablebutton inactivebutton">
<a href="javascript:MochiKit.DOM.showElement('edit'); MochiKit.DOM.hideElement('view');">{i18n}Edit{/i18n}</a>
</span>
</div>
{ /if }
<div class="view" id="view">
<table class="pretty" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead>
<tr>
<th>Group</th>
{ foreach item=oPerm from=$permissions }
<th title="{$oPerm->sName}">{$oPerm->sHumanName}</th>
{ /foreach }
</tr>
</thead>
<tbody>
{ foreach item=oGroup from=$groups }
<td>{$oGroup->getID()} / {$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="true">{i18n}True{/i18n}</td>
{ else }
<td class="false">{i18n}False{/i18n}</td>
{ /if }
  { /foreach }
</tr>
{ /foreach }
</tbody>
</table>

<div style="text-align: center; padding-top: 2px">
<span style="border: 1px solid #cccccc; background-color: #ffeeee;
padding: 2px; padding-right: 1em; padding-left: 1em">
{ if $inherited }
{i18n}Inherited from{/i18n}: {$inherited}
{* [<a
href="{$smarty.server.PHP_SELF}?action=copyPermissions&fDocumentID={$iDocumentID}">{i18n}Copy{/i18n}</a>]
*}
{ else }
[<a
href="{$smarty.server.PHP_SELF}?action=inheritPermissions&fDocumentID={$iDocumentID}">{i18n}Use
parent's permissions{/i18n}</a>]
{ /if }
</span>
</div>
</div>

{ if $edit }
<div class="edit" id="edit">
<form method="POST">
<input type="hidden" name="action" value="update">
<input type="hidden" name="fDocumentID" value="{$iDocumentID}">
<table class="pretty" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead>
<tr>
<th>Group</th>
{ foreach item=oPerm from=$permissions }
<th title="{$oPerm->sName}">{$oPerm->sHumanName}</th>
{ /foreach }
</tr>
</thead>
<tbody>
{ foreach item=oGroup from=$groups }
<td>{$oGroup->getID()} / {$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="true"><input type="checkbox" name="foo[{$iPermID}][group][]"
value="{$iGroupID}" checked="true"></td>
{ else }
<td class="false"><input type="checkbox" name="foo[{$iPermID}][group][]"
value="{$iGroupID}"></td>
{ /if }
  { /foreach }
</tr>
{ /foreach }
</tbody>
</table>

<input type="submit" name="submit" value="{i18n}Update{/i18n}">
</form>
</div>
{ /if }

<h2>{i18n}User permissions{/i18n}</h2>

<div>
<table class="pretty" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead>
<tr>
<th>{i18n}User{/i18n}</th>
{ foreach item=oPerm from=$permissions }
<th title="{$oPerm->sName}">{$oPerm->sHumanName}</th>
{ /foreach }
</tr>
</thead>
<tbody>
{ foreach item=oUser from=$users }
<td>{$oUser->getID()} / {$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="true">{i18n}True{/i18n}</td>
{ else }
<td class="false">{i18n}False{/i18n}</td>
{ /if }
  { /foreach }
</tr>
{ /foreach }
</tbody>
</table>
</div>