source: trunk/admin/themes/default/template/cat_perm.tpl @ 28532

Last change on this file since 28532 was 28532, checked in by mistic100, 10 years ago

feature 3077 : improve cache invalidation

  • add "lastmodified" automatic field for categories, groups, users, tags and images tables
  • provide a "server key" to the client cache manager
  • Property svn:eol-style set to LF
File size: 7.4 KB
Line 
1{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'}
2
3{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'}
4{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.default.css"}
5
6{footer_script}
7(function(){
8{* <!-- GROUPS --> *}
9var groupsCache = new LocalStorageCache({
10  key: 'groupsAdminList',
11  serverKey: '{$CACHE_KEYS.groups}',
12  serverId: '{$CACHE_KEYS._hash}',
13
14  loader: function(callback) {
15    jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.groups.getList&per_page=99999', function(data) {
16      callback(data.result.groups);
17    });
18  }
19});
20
21jQuery('[data-selectize=groups]').selectize({
22  valueField: 'id',
23  labelField: 'name',
24  searchField: ['name'],
25  plugins: ['remove_button']
26});
27
28groupsCache.get(function(groups) {
29  jQuery('[data-selectize=groups]').each(function() {
30    this.selectize.load(function(callback) {
31      callback(groups);
32    });
33
34    jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, id) {
35      this.selectize.addItem(id);
36    }, this));
37  });
38});
39
40{* <!-- USERS --> *}
41var usersCache = new LocalStorageCache({
42  key: 'usersAdminList',
43  serverKey: '{$CACHE_KEYS.users}',
44  serverId: '{$CACHE_KEYS._hash}',
45
46  loader: function(callback) {
47    var users = [];
48   
49    // recursive loader
50    (function load(page){
51      jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.users.getList&display=username&per_page=99999&page='+ page, function(data) {
52        users = users.concat(data.result.users);
53       
54        if (data.result.paging.count == data.result.paging.per_page) {
55          load(++page);
56        }
57        else {
58          callback(users);
59        }
60      });
61    }(0));
62  }
63});
64
65jQuery('[data-selectize=users]').selectize({
66  valueField: 'id',
67  labelField: 'username',
68  searchField: ['username'],
69  plugins: ['remove_button']
70});
71
72usersCache.get(function(users) {
73  jQuery('[data-selectize=users]').each(function() {
74    this.selectize.load(function(callback) {
75      callback(users);
76    });
77
78    jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, id) {
79      this.selectize.addItem(id);
80    }, this));
81  });
82});
83
84{* <!-- TOGGLES --> *}
85function checkStatusOptions() {
86  if (jQuery("input[name=status]:checked").val() == "private") {
87    jQuery("#privateOptions, #applytoSubAction").show();
88  }
89  else {
90    jQuery("#privateOptions, #applytoSubAction").hide();
91  }
92}
93
94checkStatusOptions();
95jQuery("#selectStatus").change(function() {
96  checkStatusOptions();
97});
98
99{if isset($nb_users_granted_indirect) && $nb_users_granted_indirect>0}
100  jQuery(".toggle-indirectPermissions").click(function(e){
101    jQuery(".toggle-indirectPermissions").toggle();
102    jQuery("#indirectPermissionsDetails").toggle();
103    e.preventDefault();
104  });
105{/if}
106}());
107{/footer_script}
108
109<div class="titrePage">
110  <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> &#8250; {'Edit album'|@translate} {$TABSHEET_TITLE}</h2>
111</div>
112
113<form action="{$F_ACTION}" method="post" id="categoryPermissions">
114
115<fieldset>
116  <legend>{'Access type'|@translate}</legend>
117
118  <p id="selectStatus">
119    <label><input type="radio" name="status" value="public" {if not $private}checked="checked"{/if}> <strong>{'public'|@translate}</strong> : <em>{'any visitor can see this album'|@translate}</em></label>
120    <br>
121    <label><input type="radio" name="status" value="private" {if $private}checked="checked"{/if}> <strong>{'private'|@translate}</strong> : <em>{'visitors need to login and have the appropriate permissions to see this album'|@translate}</em></label>
122  </p>
123</fieldset>
124
125<fieldset id="privateOptions">
126  <legend>{'Groups and users'|@translate}</legend>
127
128  <p>
129{if count($groups) > 0}
130    <strong>{'Permission granted for groups'|@translate}</strong>
131    <br>
132    <select data-selectize="groups" data-value="{$groups_selected|@json_encode|escape:html}"
133        name="groups[]" multiple style="width:600px;" ></select>
134{else}
135    {'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list" class="externalLink">{'Group management'|@translate}</a>
136{/if}
137  </p>
138
139  <p>
140    <strong>{'Permission granted for users'|@translate}</strong>
141    <br>
142    <select data-selectize="users" data-value="{$users_selected|@json_encode|escape:html}"
143        name="users[]" multiple style="width:600px;" ></select>
144  </p>
145
146{if isset($nb_users_granted_indirect) && $nb_users_granted_indirect>0}
147  <p>
148    {'%u users have automatic permission because they belong to a granted group.'|@translate:$nb_users_granted_indirect}
149    <a href="#" class="toggle-indirectPermissions" style="display:none">{'hide details'|@translate}</a>
150    <a href="#" class="toggle-indirectPermissions">{'show details'|@translate}</a>
151
152    <ul id="indirectPermissionsDetails" style="display:none">
153  {foreach from=$user_granted_indirect_groups item=group_details}
154      <li><strong>{$group_details.group_name}</strong> : {$group_details.group_users}</li>
155  {/foreach}
156    </ul>
157  </p>
158{/if}
159
160{*
161  <h4>{'Groups'|@translate}</h4>
162
163  <fieldset>
164    <legend>{'Permission granted'|@translate}</legend>
165    <ul>
166      {foreach from=$group_granted_ids item=id}
167      <li><label><input type="checkbox" name="deny_groups[]" value="{$id}"> {$all_groups[$id]}</label></li>
168      {/foreach}
169    </ul>
170    <input class="submit" type="submit" name="deny_groups_submit" value="{'Deny selected groups'|@translate}">
171  </fieldset>
172
173  <fieldset>
174    <legend>{'Permission denied'|@translate}</legend>
175    <ul>
176      {foreach from=$group_denied_ids item=id}
177      <li><label><input type="checkbox" name="grant_groups[]" value="{$id}"> {$all_groups[$id]}</label></li>
178      {/foreach}
179    </ul>
180    <input class="submit" type="submit" name="grant_groups_submit" value="{'Grant selected groups'|@translate}">
181    <label><input type="checkbox" name="apply_on_sub">{'Apply to sub-albums'|@translate}</label>
182  </fieldset>
183
184  <h4>{'Users'|@translate}</h4>
185
186  <fieldset>
187    <legend>{'Permission granted'|@translate}</legend>
188    <ul>
189      {foreach from=$user_granted_direct_ids item=id}
190      <li><label><input type="checkbox" name="deny_users[]" value="{$id}"> {$all_users[$id]}</label></li>
191      {/foreach}
192    </ul>
193    <input class="submit" type="submit" name="deny_users_submit" value="{'Deny selected users'|@translate}">
194  </fieldset>
195
196  <fieldset>
197    <legend>{'Permission granted thanks to a group'|@translate}</legend>
198    {if isset($user_granted_indirects) }
199    <ul>
200      {foreach from=$user_granted_indirects item=user_group}
201      <li>{$user_group.USER} ({$user_group.GROUP})</li>
202      {/foreach}
203    </ul>
204    {/if}
205  </fieldset>
206
207  <fieldset>
208    <legend>{'Permission denied'|@translate}</legend>
209    <ul>
210      {foreach from=$user_denied_ids item=id}
211      <li><label><input type="checkbox" name="grant_users[]" value="{$id}"> {$all_users[$id]}</label></li>
212      {/foreach}
213    </ul>
214    <input class="submit" type="submit" name="grant_users_submit" value="{'Grant selected users'|@translate}">
215    <label><input type="checkbox" name="apply_on_sub">{'Apply to sub-albums'|@translate}</label>
216  </fieldset>
217*}
218</fieldset>
219
220  <p style="margin:12px;text-align:left;">
221    <input class="submit" type="submit" value="{'Save Settings'|@translate}" name="submit">
222    <label id="applytoSubAction" style="display:none;">
223      <input type="checkbox" name="apply_on_sub" {if $INHERIT}checked="checked"{/if}>
224      {'Apply to sub-albums'|@translate}
225    </label>
226  </p>
227
228<input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
229</form>
Note: See TracBrowser for help on using the repository browser.