document_permissions.smarty
4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
{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>
<table class="pretty" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead>
<tr>
<th>Role</th>
{ foreach item=oPerm from=$permissions }
<th title="{$oPerm->sName}">{$oPerm->sHumanName}</th>
{ /foreach }
</tr>
</thead>
<tbody>
{ foreach item=oRole from=$roles }
<td>{$oRole->getId()} / {$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="true">True</td>
{ else }
<td class="false">False</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>
<table class="pretty" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead>
<tr>
<th>Role</th>
{ foreach item=oPerm from=$permissions }
<th title="{$oPerm->sName}">{$oPerm->sHumanName}</th>
{ /foreach }
</tr>
</thead>
<tbody>
{ foreach item=oRole from=$roles }
<td>{$oRole->getId()} / {$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="true"><input type="checkbox" name="foo[{$iPermId}][role][]"
value="{$iRoleId}" checked="true"></td>
{ else }
<td class="false"><input type="checkbox" name="foo[{$iPermId}][role][]"
value="{$iRoleId}"></td>
{ /if }
{ /foreach }
</tr>
{ /foreach }
</tbody>
</table>
<input type="submit" name="submit" value="{i18n}Update{/i18n}">
</form>
</div>
{ /if }