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