diff --git a/admin/albums.php b/admin/albums.php index afcc8b82d..8583e55fc 100644 --- a/admin/albums.php +++ b/admin/albums.php @@ -183,6 +183,8 @@ foreach ($allAlbum as $album) $the_place['cat'] = $album; } +$is_forbidden = array_fill_keys(@explode(',', $user['forbidden_categories']), 1); + //Make an ordered tree function cmpCat($a, $b) { @@ -195,50 +197,10 @@ function cmpCat($a, $b) function assocToOrderedTree($assocT) { + global $nb_photos_in, $nb_sub_photos; + $orderedTree = array(); - $query = ' -SELECT - category_id, - COUNT(*) AS nb_photos - FROM '.IMAGE_CATEGORY_TABLE.' - GROUP BY category_id -;'; - - $nb_photos_in = query2array($query, 'category_id', 'nb_photos'); - - $query = ' -SELECT - id, - uppercats - FROM '.CATEGORIES_TABLE.' -;'; - $all_categories = query2array($query, 'id', 'uppercats'); - $subcats_of = array(); - - foreach ($all_categories as $id => $uppercats) - { - foreach (array_slice(explode(',', $uppercats), 0, -1) as $uppercat_id) - { - @$subcats_of[$uppercat_id][] = $id; - } - } - - $nb_sub_photos = array(); - foreach ($subcats_of as $cat_id => $subcat_ids) - { - $nb_photos = 0; - foreach ($subcat_ids as $id) - { - if (isset($nb_photos_in[$id])) - { - $nb_photos+= $nb_photos_in[$id]; - } - } - - $nb_sub_photos[$cat_id] = $nb_photos; - } - foreach($assocT as $cat) { $orderedCat = array(); @@ -248,7 +210,7 @@ SELECT $orderedCat['id'] = $cat['cat']['id']; $orderedCat['nb_images'] = isset($nb_photos_in[$cat['cat']['id']]) ? $nb_photos_in[$cat['cat']['id']] : 0; $orderedCat['last_updates'] = $cat['cat']['lastmodified']; - $orderedCat['has_not_access'] = !cat_admin_access($cat['cat']['id']); + $orderedCat['has_not_access'] = isset($is_forbidden[$cat['cat']['id']]); $orderedCat['nb_sub_photos'] = isset($nb_sub_photos[$cat['cat']['id']]) ? $nb_sub_photos[$cat['cat']['id']] : 0; if (isset($cat['children'])) { @@ -262,6 +224,49 @@ SELECT return $orderedTree; } +$query = ' +SELECT + category_id, + COUNT(*) AS nb_photos + FROM '.IMAGE_CATEGORY_TABLE.' + GROUP BY category_id +;'; + +$nb_photos_in = query2array($query, 'category_id', 'nb_photos'); + +$query = ' +SELECT + id, + uppercats + FROM '.CATEGORIES_TABLE.' +;'; +$all_categories = query2array($query, 'id', 'uppercats'); + +$subcats_of = array(); + +foreach ($all_categories as $id => $uppercats) +{ + foreach (array_slice(explode(',', $uppercats), 0, -1) as $uppercat_id) + { + @$subcats_of[$uppercat_id][] = $id; + } +} + +$nb_sub_photos = array(); +foreach ($subcats_of as $cat_id => $subcat_ids) +{ + $nb_photos = 0; + foreach ($subcat_ids as $id) + { + if (isset($nb_photos_in[$id])) + { + $nb_photos+= $nb_photos_in[$id]; + } + } + + $nb_sub_photos[$cat_id] = $nb_photos; +} + $template->assign( array( 'album_data' => assocToOrderedTree($associatedTree), diff --git a/admin/themes/default/js/albums.js b/admin/themes/default/js/albums.js index 3383c6b88..a244774b7 100644 --- a/admin/themes/default/js/albums.js +++ b/admin/themes/default/js/albums.js @@ -33,18 +33,6 @@ $(document).ready(() => { +''; action_order = ''; - action_small = - "
" - +"" - +""+ str_add_album +"" - +""+ str_edit_album +"" - +""+ str_add_photo +"" - +""+ str_visit_gallery +"" - +""+ str_sort_order +"" - +""+ str_delete_album +"" - +"" - +"
"; - cont = li.find('.jqtree-element'); cont.addClass('move-cat-container'); cont.attr('id', 'cat-'+node.id) @@ -53,7 +41,6 @@ $(document).ready(() => { cont.append(actions); cont.find('.move-cat-action .move-cat-see').after(action_order); - cont.find('.move-cat-action').before(action_small); cont.find(".toggle-cat-option").on("click", function () { $(".cat-option").hide(); $(this).find(".cat-option").toggle(); @@ -71,7 +58,6 @@ $(document).ready(() => { .replace(/%id%/g, node.id))); } else { cont.find('.move-cat-order').addClass("notClickable"); - cont.find('#catOptionsSmall .icon-sort-name-up').hide(); cont.append($(toggler_cont .replace(/%content%/g, toggler_close) @@ -131,25 +117,9 @@ $(document).ready(() => { if (node.has_not_access) { cont.find(".move-cat-see").addClass("notClickable"); - cont.find('#catOptionsSmall .icon-eye').hide(); } } - /* Hide album options and on click on the screen */ - - $(document).mouseup(function (e) { - e.stopPropagation(); - let option_is_clicked = false - $("#catOptionsSmall a").each(function () { - if (!($(this).has(e.target).length === 0)) { - option_is_clicked = true; - } - }) - if (!option_is_clicked) { - $(".jqtree-element").find("#catOptionsSmall").hide(); - } - }); - var url_split = window.location.href.split("cat_move"); var catToOpen = url_split[url_split.length-1].split("-")[1]; @@ -313,10 +283,6 @@ $(document).ready(() => { openAddAlbumPopIn($(this).data("aid")); $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); }) - $(".move-cat-add-small").on("click", function () { - openAddAlbumPopIn($(this).data("aid")); - $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); - }) $(".CloseAddAlbum").on("click", function () { closeAddAlbumPopIn(); }); @@ -392,16 +358,9 @@ $(document).ready(() => { openAddAlbumPopIn($(this).data("aid")); $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); }); - $(".move-cat-add-small").unbind("click").on("click", function () { - openAddAlbumPopIn($(this).data("aid")); - $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); - }); $(".move-cat-delete").on("click", function () { triggerDeleteAlbum($(this).data("id")); }); - $(".move-cat-delete-small").on("click", function () { - triggerDeleteAlbum($(this).data("id")); - }); $(".move-cat-title-container").unbind("click").on("click", function () { openRenameAlbumPopIn($(this).find(".move-cat-title").attr("title")); $(".RenameAlbumSubmit").data("cat_id", $(this).attr('data-id')); @@ -437,9 +396,6 @@ $(document).ready(() => { $(".move-cat-delete").on("click", function () { triggerDeleteAlbum($(this).data("id")); }); - $(".move-cat-delete-small").on("click", function () { - triggerDeleteAlbum($(this).data("id")); - }); /*---------------- Checkboxes @@ -577,16 +533,9 @@ function openDeleteAlbumPopIn(cat_to_delete) { openAddAlbumPopIn($(this).data("aid")); $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); }); - $(".move-cat-add-small").on("click", function () { - openAddAlbumPopIn($(this).data("aid")); - $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); - }); $(".move-cat-delete").on("click", function () { triggerDeleteAlbum($(this).data("id")); }); - $(".move-cat-delete-small").on("click", function () { - triggerDeleteAlbum($(this).data("id")); - }); $(".move-cat-title-container").unbind("click").on("click", function () { openRenameAlbumPopIn($(this).find(".move-cat-title").attr("title")); $(".RenameAlbumSubmit").data("cat_id", $(this).attr('data-id')); @@ -741,16 +690,9 @@ function applyMove(event) { openAddAlbumPopIn($(this).data("aid")); $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); }); - $(".move-cat-add-small").unbind("click").on("click", function () { - openAddAlbumPopIn($(this).data("aid")); - $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); - }); $(".move-cat-delete").on("click", function () { triggerDeleteAlbum($(this).data("id")); }); - $(".move-cat-delete-small").on("click", function () { - triggerDeleteAlbum($(this).data("id")); - }); $(".move-cat-title-container").on("click", function () { openRenameAlbumPopIn($(this).find(".move-cat-title").attr("title")); $(".RenameAlbumSubmit").data("cat_id", $(this).attr('data-id')); @@ -768,16 +710,9 @@ function applyMove(event) { openAddAlbumPopIn($(this).data("aid")); $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); }); - $(".move-cat-add-small").unbind("click").on("click", function () { - openAddAlbumPopIn($(this).data("aid")); - $(".AddAlbumSubmit").data("a-parent", $(this).data("aid")); - }); $(".move-cat-delete").on("click", function () { triggerDeleteAlbum($(this).data("id")); }); - $(".move-cat-delete-small").on("click", function () { - triggerDeleteAlbum($(this).data("id")); - }); $(".move-cat-title-container").on("click", function () { openRenameAlbumPopIn($(this).find(".move-cat-title").attr("title")); $(".RenameAlbumSubmit").data("cat_id", $(this).attr('data-id')); @@ -855,7 +790,7 @@ function changeRank(node, rank) { }) } -function makePrivateHierarchy (node) { +function makePrivateHierarchy(node) { node.status = 'private'; node.children.forEach(node => { makePrivateHierarchy(node); diff --git a/admin/themes/default/template/albums.tpl b/admin/themes/default/template/albums.tpl index 44ac7be16..6536b70fe 100644 --- a/admin/themes/default/template/albums.tpl +++ b/admin/themes/default/template/albums.tpl @@ -523,28 +523,10 @@ input[name="position"] { .dragging .move-cat-container .move-cat-toogler, .dragging .move-cat-container .move-cat-action-cont a, -.dragging .move-cat-container .move-cat-title-container, -.dragging .move-cat-action-small { +.dragging .move-cat-container .move-cat-title-container{ pointer-events: all; } -.move-cat-action-small { - display: none; - position: relative; - right: 10px; - font-weight: bold; - cursor: pointer; - transform: scale(1.2); - padding: 20px 10px; -} - -#catOptionsSmall .dropdown-option { - font-size: 10px; - font-weight: bold; -} -#catOptionsSmall .dropdown-option::before{ - margin: 0 6px 0 -2px; -} .last-update { display: none; @@ -575,23 +557,25 @@ input[name="position"] { display: none; } - .move-cat-action { - display: none; + ul.jqtree-tree ul.jqtree_common { + margin-left: 20px !important; } - .move-cat-action-small { - display: flex; - } - - .move-cat-title-container { - max-width: 80%; - } -} - -@media (max-width: 850px) { .move-cat-title-container { max-width: 60%; } } +@media (max-width: 1100px) { + .move-cat-title-container { + max-width: 50%; + } +} + +@media (max-width: 850px) { + .move-cat-title-container { + max-width: 40%; + } +} + \ No newline at end of file