1 | {combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'} |
---|
2 | {combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} |
---|
3 | |
---|
4 | {combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} |
---|
5 | |
---|
6 | {literal} |
---|
7 | <style> |
---|
8 | form fieldset p {text-align:left;margin:0 0 1.5em 0;line-height:20px;} |
---|
9 | .permissionActions {text-align:center;height:20px} |
---|
10 | .permissionActions a:hover {border:none} |
---|
11 | .permissionActions img {margin-bottom:-2px} |
---|
12 | .rowSelected {background-color:#C2F5C2 !important} |
---|
13 | #community_nb_photos, #community_storage {width:400px; display:inline-block; margin-right:10px;} |
---|
14 | </style> |
---|
15 | {/literal} |
---|
16 | |
---|
17 | {footer_script}{literal} |
---|
18 | |
---|
19 | $(document).ready(function() { |
---|
20 | $("select[name=who]").change(function () { |
---|
21 | $("[name^=who_]").hide(); |
---|
22 | $("[name=who_"+$(this).prop("value")+"]").show(); |
---|
23 | checkWhoOptions(); |
---|
24 | }); |
---|
25 | |
---|
26 | function checkWhoOptions() { |
---|
27 | if ('any_visitor' == $("select[name=who] option:selected").val()) { |
---|
28 | $("#userAlbumOption").attr("disabled", true); |
---|
29 | $("#userAlbumInfo").hide(); |
---|
30 | |
---|
31 | if (-1 == $("select[name=category] option:selected").val()) { |
---|
32 | $("select[name=category]").val("0"); |
---|
33 | checkWhereOptions(); |
---|
34 | } |
---|
35 | } |
---|
36 | else { |
---|
37 | $("#userAlbumOption").attr("disabled", false); |
---|
38 | $("#userAlbumInfo").show(); |
---|
39 | } |
---|
40 | } |
---|
41 | checkWhoOptions(); |
---|
42 | |
---|
43 | function checkWhereOptions() { |
---|
44 | var recursive = $("input[name=recursive]"); |
---|
45 | var create = $("input[name=create_subcategories]"); |
---|
46 | |
---|
47 | if ($("select[name=category] option:selected").val() == 0) { |
---|
48 | $(recursive).attr("disabled", true); |
---|
49 | $(recursive).attr('checked', true); |
---|
50 | } |
---|
51 | else if ($("select[name=category] option:selected").val() == -1) { |
---|
52 | /* user upload only */ |
---|
53 | $(recursive).attr("disabled", true).attr('checked', false); |
---|
54 | $(create).attr("disabled", true).attr('checked', false); |
---|
55 | } |
---|
56 | else { |
---|
57 | $(recursive).removeAttr("disabled"); |
---|
58 | } |
---|
59 | |
---|
60 | if (!$(recursive).is(':checked')) { |
---|
61 | $(create).attr('checked', false); |
---|
62 | $(create).attr("disabled", true); |
---|
63 | } |
---|
64 | else { |
---|
65 | $(create).removeAttr("disabled"); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | checkWhereOptions(); |
---|
70 | |
---|
71 | $("select[name=category]").change(function() { |
---|
72 | checkWhereOptions(); |
---|
73 | }); |
---|
74 | |
---|
75 | $("input[name=recursive]").change(function() { |
---|
76 | checkWhereOptions(); |
---|
77 | }); |
---|
78 | |
---|
79 | $("#displayForm").click(function() { |
---|
80 | $("[name=add_permission]").show(); |
---|
81 | $(this).hide(); |
---|
82 | return false; |
---|
83 | }); |
---|
84 | |
---|
85 | /* ∞ */ |
---|
86 | /** |
---|
87 | * find the key from a value in the startStopValues array |
---|
88 | */ |
---|
89 | function getSliderKeyFromValue(value, values) { |
---|
90 | for (var key in values) { |
---|
91 | if (values[key] == value) { |
---|
92 | return key; |
---|
93 | } |
---|
94 | } |
---|
95 | return 0; |
---|
96 | } |
---|
97 | |
---|
98 | var nbPhotosValues = [5,10,20,50,100,500,1000,5000,-1]; |
---|
99 | |
---|
100 | function getNbPhotosInfoFromIdx(idx) { |
---|
101 | if (idx == nbPhotosValues.length - 1) { |
---|
102 | return "{/literal}{'no limit'|@translate}{literal}"; |
---|
103 | } |
---|
104 | |
---|
105 | return sprintf( |
---|
106 | "{/literal}{'up to %d photos (for each user)'|@translate}{literal}", |
---|
107 | nbPhotosValues[idx] |
---|
108 | ); |
---|
109 | } |
---|
110 | |
---|
111 | /* init nb_photos info span */ |
---|
112 | var nbPhotos_init = getSliderKeyFromValue(jQuery('input[name=nb_photos]').val(), nbPhotosValues); |
---|
113 | |
---|
114 | jQuery("#community_nb_photos_info").html(getNbPhotosInfoFromIdx(nbPhotos_init)); |
---|
115 | |
---|
116 | jQuery("#community_nb_photos").slider({ |
---|
117 | range: "min", |
---|
118 | min: 0, |
---|
119 | max: nbPhotosValues.length - 1, |
---|
120 | value: nbPhotos_init, |
---|
121 | slide: function( event, ui ) { |
---|
122 | jQuery("#community_nb_photos_info").html(getNbPhotosInfoFromIdx(ui.value)); |
---|
123 | }, |
---|
124 | stop: function( event, ui ) { |
---|
125 | jQuery("input[name=nb_photos]").val(nbPhotosValues[ui.value]); |
---|
126 | } |
---|
127 | }); |
---|
128 | |
---|
129 | var storageValues = [10,50,100,200,500,1000,5000,-1]; |
---|
130 | |
---|
131 | function getStorageInfoFromIdx(idx) { |
---|
132 | if (idx == storageValues.length - 1) { |
---|
133 | return "{/literal}{'no limit'|@translate}{literal}"; |
---|
134 | } |
---|
135 | |
---|
136 | return sprintf( |
---|
137 | "{/literal}{'up to %dMB (for each user)'|@translate}{literal}", |
---|
138 | storageValues[idx] |
---|
139 | ); |
---|
140 | } |
---|
141 | |
---|
142 | /* init storage info span */ |
---|
143 | var storage_init = getSliderKeyFromValue(jQuery('input[name=storage]').val(), storageValues); |
---|
144 | |
---|
145 | jQuery("#community_storage_info").html(getStorageInfoFromIdx(storage_init)); |
---|
146 | |
---|
147 | jQuery("#community_storage").slider({ |
---|
148 | range: "min", |
---|
149 | min: 0, |
---|
150 | max: storageValues.length - 1, |
---|
151 | value: storage_init, |
---|
152 | slide: function( event, ui ) { |
---|
153 | jQuery("#community_storage_info").html(getStorageInfoFromIdx(ui.value)); |
---|
154 | }, |
---|
155 | stop: function( event, ui ) { |
---|
156 | jQuery("input[name=storage]").val(storageValues[ui.value]); |
---|
157 | } |
---|
158 | }); |
---|
159 | |
---|
160 | }); |
---|
161 | {/literal}{/footer_script} |
---|
162 | |
---|
163 | |
---|
164 | <div class="titrePage"> |
---|
165 | <h2>{'Upload Permissions'|@translate} - {'Community'|@translate}</h2> |
---|
166 | </div> |
---|
167 | |
---|
168 | {if not isset($edit)} |
---|
169 | <a id="displayForm" href="#">{'Add a permission'|@translate}</a> |
---|
170 | {/if} |
---|
171 | |
---|
172 | <form method="post" name="add_permission" action="{$F_ADD_ACTION}" class="properties" {if not isset($edit)}style="display:none"{/if}> |
---|
173 | <fieldset> |
---|
174 | <legend>{if isset($edit)}{'Edit a permission'|@translate}{else}{'Add a permission'|@translate}{/if}</legend> |
---|
175 | |
---|
176 | <p> |
---|
177 | <strong>{'Who?'|@translate}</strong> |
---|
178 | <br> |
---|
179 | <select name="who"> |
---|
180 | {html_options options=$who_options selected=$who_options_selected} |
---|
181 | </select> |
---|
182 | |
---|
183 | <select name="who_user" {if not isset($user_options_selected)}style="display:none"{/if}> |
---|
184 | {html_options options=$user_options selected=$user_options_selected} |
---|
185 | </select> |
---|
186 | |
---|
187 | <select name="who_group" {if not isset($group_options_selected)}style="display:none"{/if}> |
---|
188 | {html_options options=$group_options selected=$group_options_selected} |
---|
189 | </select> |
---|
190 | </p> |
---|
191 | |
---|
192 | <p> |
---|
193 | <strong>{'Where?'|@translate}</strong> {if $community_conf.user_albums}<em id="userAlbumInfo">{'(in addition to user album)'|@translate}</em>{/if} |
---|
194 | <br> |
---|
195 | <select class="categoryDropDown" name="category"> |
---|
196 | {if $community_conf.user_albums} |
---|
197 | <option value="-1"{if $user_album_selected} selected="selected"{/if} id="userAlbumOption">{'User album only'|@translate}</option> |
---|
198 | {/if} |
---|
199 | <option value="0"{if $whole_gallery_selected} selected="selected"{/if}>{'The whole gallery'|@translate}</option> |
---|
200 | <option disabled="disabled">------------</option> |
---|
201 | {html_options options=$category_options selected=$category_options_selected} |
---|
202 | </select> |
---|
203 | <br> |
---|
204 | <label><input type="checkbox" name="recursive" {if $recursive}checked="checked"{/if}> {'Apply to sub-albums'|@translate}</label> |
---|
205 | <br> |
---|
206 | <label><input type="checkbox" name="create_subcategories" {if $create_subcategories}checked="checked"{/if}> {'ability to create sub-albums'|@translate}</label> |
---|
207 | </p> |
---|
208 | |
---|
209 | <p> |
---|
210 | <strong>{'Which level of trust?'|@translate}</strong> |
---|
211 | <br><label><input type="radio" name="moderated" value="true" {if $moderated}checked="checked"{/if}> <em>{'low trust'|@translate}</em> : {'uploaded photos must be validated by an administrator'|@translate}</label> |
---|
212 | <br><label><input type="radio" name="moderated" value="false" {if not $moderated}checked="checked"{/if}> <em>{'high trust'|@translate}</em> : {'uploaded photos are directly displayed in the gallery'|@translate}</label> |
---|
213 | </p> |
---|
214 | |
---|
215 | <p style="margin-bottom:0"> |
---|
216 | <strong>{'How many photos?'|@translate}</strong> |
---|
217 | </p> |
---|
218 | <div id="community_nb_photos"></div> |
---|
219 | <span id="community_nb_photos_info">{'no limit'|@translate}</span> |
---|
220 | <input type="hidden" name="nb_photos" value="{$nb_photos}"> |
---|
221 | |
---|
222 | <p style="margin-top:1.5em;margin-bottom:0;"> |
---|
223 | <strong>{'How much disk space?'|@translate}</strong> |
---|
224 | </p> |
---|
225 | <div id="community_storage"></div> |
---|
226 | <span id="community_storage_info">{'no limit'|@translate}</span> |
---|
227 | <input type="hidden" name="storage" value="{$storage}"> |
---|
228 | |
---|
229 | {if isset($edit)} |
---|
230 | <input type="hidden" name="edit" value="{$edit}"> |
---|
231 | {/if} |
---|
232 | |
---|
233 | <p style="margin-top:1.5em;"> |
---|
234 | <input class="submit" type="submit" name="submit_add" value="{if isset($edit)}{'Submit'|@translate}{else}{'Add'|@translate}{/if}"/> |
---|
235 | <a href="{$F_ADD_ACTION}">{'Cancel'|@translate}</a> |
---|
236 | </p> |
---|
237 | </fieldset> |
---|
238 | </form> |
---|
239 | |
---|
240 | <table class="table2" style="margin:15px auto;"> |
---|
241 | <tr class="throw"> |
---|
242 | <th>{'Who?'|@translate}</th> |
---|
243 | <th>{'Where?'|@translate}</th> |
---|
244 | <th>{'Options'|@translate}</th> |
---|
245 | <th>{'Actions'|@translate}</th> |
---|
246 | </tr> |
---|
247 | {if not empty($permissions)} |
---|
248 | {foreach from=$permissions item=permission name=permission_loop} |
---|
249 | <tr class="{if $smarty.foreach.permission_loop.index is odd}row1{else}row2{/if}{if $permission.HIGHLIGHT} rowSelected{/if}"> |
---|
250 | <td>{$permission.WHO}</td> |
---|
251 | <td>{$permission.WHERE}</td> |
---|
252 | <td> |
---|
253 | <span title="{$permission.TRUST_TOOLTIP}">{$permission.TRUST}</span>{if $permission.RECURSIVE}, |
---|
254 | <span title="{$permission.RECURSIVE_TOOLTIP}">{'sub-albums'|@translate}</span>{/if}{if $permission.NB_PHOTOS}, |
---|
255 | <span title="{$permission.NB_PHOTOS_TOOLTIP}">{'%d photos'|@translate|sprintf:$permission.NB_PHOTOS}</span>{/if}{if $permission.STORAGE}, |
---|
256 | <span title="{$permission.STORAGE_TOOLTIP}">{$permission.STORAGE}MB</span>{/if} |
---|
257 | {if $permission.CREATE_SUBCATEGORIES} |
---|
258 | , {'sub-albums creation'|@translate} |
---|
259 | {/if} |
---|
260 | </td> |
---|
261 | <td class="permissionActions"> |
---|
262 | <a href="{$permission.U_EDIT}"> |
---|
263 | <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/edit_s.png" alt="{'edit'|@translate}" title="{'edit'|@translate}" /> |
---|
264 | </a> |
---|
265 | <a href="{$permission.U_DELETE}" onclick="return confirm( document.getElementById('btn_delete').title + '\n\n' + '{'Are you sure?'|@translate|@escape:'javascript'}');"> |
---|
266 | <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/delete.png" id="btn_delete" alt="{'delete'|@translate}" title="{'Delete permission'|@translate}" /> |
---|
267 | </a> |
---|
268 | </td> |
---|
269 | </tr> |
---|
270 | {/foreach} |
---|
271 | {/if} |
---|
272 | </table> |
---|