Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,15 @@

// Register permissions
rex_perm::register('bloecks[]');
rex_perm::register('bloecks[settings]');
rex_perm::register('bloecks[copy]');
rex_perm::register('bloecks[order]');

// Backend functionality
if (rex::isBackend() && PHP_SAPI !== 'cli') {
// Only run session-dependent code when not in CLI context
rex_extension::register('PACKAGES_INCLUDED', static function () {
$addon = rex_addon::get('bloecks');

// Clear clipboard on login/logout and session start for security
Backend::clearClipboardOnSessionStart();
Backend::init();

// Register wrapper for slice_columns-style drag & drop only if enabled
if ($addon->getConfig('enable_drag_drop', false)) {
rex_extension::register('SLICE_SHOW', Wrapper::addDragDropWrapper(...), rex_extension::EARLY);
rex_extension::register('SLICE_MENU', Wrapper::addDragHandle(...));
// error_log("BLOECKS DEBUG: Drag & Drop extension points registered");
}
// error_log("BLOECKS DEBUG: Drag & Drop disabled, no wrapper extension points registered");
});
}
5 changes: 5 additions & 0 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ bloecks_disabled = Deaktiviert
bloecks_drag_move = Slice verschieben
bloecks_drag_handle = Verschieben

# Permissions
perm_general_bloecks[] = Vollzugriff auf alle blÖcks-Features
perm_general_bloecks[copy] = Slices kopieren und einfügen
perm_general_bloecks[order] = Slices per Drag & Drop sortieren

# Copy/Cut/Paste functionality
bloecks_copy_slice = Slice kopieren
bloecks_cut_slice = Slice ausschneiden
Expand Down
5 changes: 5 additions & 0 deletions lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ bloecks_disabled = Disabled
bloecks_drag_move = Move slice
bloecks_drag_handle = Move

# Permissions
perm_general_bloecks[] = Full access to all blÖcks features
perm_general_bloecks[copy] = Copy and paste slices
perm_general_bloecks[order] = Reorder slices via drag & drop

# Copy/Cut/Paste functionality
bloecks_copy_slice = Copy slice
bloecks_cut_slice = Cut slice
Expand Down
5 changes: 5 additions & 0 deletions lang/es_es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ bloecks_disabled = Deshabilitado
bloecks_drag_move = Mover slice
bloecks_drag_handle = Mover

# Permissions
perm_general_bloecks[] = Acceso completo a todas las funciones de blÖcks
perm_general_bloecks[copy] = Copiar y pegar slices
perm_general_bloecks[order] = Reordenar slices mediante arrastrar y soltar

# Copy/Cut/Paste functionality
bloecks_copy_slice = Copiar slice
bloecks_cut_slice = Cortar slice
Expand Down
22 changes: 22 additions & 0 deletions lang/fi_fi.lang
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ bloecks_csv_notice = Pilkuilla erotettu lista ID:istä
bloecks_no_permission = Ei käyttöoikeutta
bloecks_feat_copy = Kopioi, leikkaa ja liitä slicejä
bloecks_feat_order = Järjestä slicejä uudelleen vetämällä ja pudottamalla
bloecks_intro = Kevyt työkalu slicejen kopiointiin/liittämiseen, leikkaamiseen ja vetämiseen/pudottamiseen.
bloecks_enabled = Käytössä
bloecks_disabled = Ei käytössä
bloecks_drag_move = Siirrä slice
bloecks_drag_handle = Siirrä

# Permissions
perm_general_bloecks[] = Täysi pääsy kaikkiin blÖcks-ominaisuuksiin
perm_general_bloecks[copy] = Kopioi ja liitä slicejä
perm_general_bloecks[order] = Järjestä slicejä vetämällä ja pudottamalla = blÖcks
bloecks_overview = Yleiskatsaus
bloecks_settings = Asetukset
bloecks_docs = Dokumentaatio
bloecks_enable_copy_paste = Ota käyttöön Kopioi & Liitä
bloecks_enable_drag_drop = Ota käyttöön Vedä & Pudota
bloecks_active = aktiivinen
bloecks_templates_exclude = Jätä pois mallien ID:t
bloecks_modules_exclude = Jätä pois moduulien ID:t
bloecks_csv_notice = Pilkuilla erotettu lista ID:istä
bloecks_no_permission = Ei käyttöoikeutta
bloecks_feat_copy = Kopioi, leikkaa ja liitä slicejä
bloecks_feat_order = Järjestä slicejä uudelleen vetämällä ja pudottamalla
bloecks_intro = Kevyt työkalu slicejen kopiointiin/liittämiseen, leikkaamiseen ja vetämiseen & pudottamiseen.
bloecks_enabled = Käytössä
bloecks_disabled = Pois käytöstä
Expand Down
5 changes: 5 additions & 0 deletions lang/fr_fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ bloecks_disabled = Désactivé
bloecks_drag_move = Déplacer la slice
bloecks_drag_handle = Déplacer

# Permissions
perm_general_bloecks[] = Accès complet à toutes les fonctionnalités blÖcks
perm_general_bloecks[copy] = Copier et coller des slices
perm_general_bloecks[order] = Réorganiser les slices par glisser-déposer

# Copy/Cut/Paste functionality
bloecks_copy_slice = Copier la slice
bloecks_cut_slice = Couper la slice
Expand Down
5 changes: 5 additions & 0 deletions lang/it_it.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ bloecks_disabled = Disabilitato
bloecks_drag_move = Sposta slice
bloecks_drag_handle = Sposta

# Permissions
perm_general_bloecks[] = Accesso completo a tutte le funzionalità blÖcks
perm_general_bloecks[copy] = Copia e incolla slice
perm_general_bloecks[order] = Riordina slice tramite trascinamento

# Copy/Cut/Paste functionality
bloecks_copy_slice = Copia slice
bloecks_cut_slice = Taglia slice
Expand Down
5 changes: 5 additions & 0 deletions lang/pl_pl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ bloecks_disabled = Wyłączony
bloecks_drag_move = Przesuń slice
bloecks_drag_handle = Przesuń

# Permissions
perm_general_bloecks[] = Pełny dostęp do wszystkich funkcji blÖcks
perm_general_bloecks[copy] = Kopiuj i wklej slices
perm_general_bloecks[order] = Zmieniaj kolejność slices przeciągając i upuszczając

# Copy/Cut/Paste functionality
bloecks_copy_slice = Kopiuj slice
bloecks_cut_slice = Wytnij slice
Expand Down
21 changes: 13 additions & 8 deletions lang/sv_se.lang
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@ bloecks_navigation = blÖcks
bloecks_overview = Översikt
bloecks_settings = Inställningar
bloecks_docs = Dokumentation
bloecks_enable_copy_paste = Aktivera Kopiera & Klistra in
bloecks_enable_drag_drop = Aktivera Dra & Släpp
bloecks_enable_copy_paste = Aktivera kopiera och klistra in
bloecks_enable_drag_drop = Aktivera dra och släpp
bloecks_active = aktiv
bloecks_templates_exclude = Uteslut mall-ID:n
bloecks_modules_exclude = Uteslut modul-ID:n
bloecks_templates_exclude = Exkludera mall-ID:n
bloecks_modules_exclude = Exkludera modul-ID:n
bloecks_csv_notice = Kommaseparerad lista med ID:n
bloecks_no_permission = Ingen behörighet
bloecks_feat_copy = Kopiera, klipp ut och klistra in slices
bloecks_feat_order = Ordna om slices via dra & släpp
bloecks_intro = Lättviktsverktyg för kopiera/klistra in, klipp ut och dra & släpp av slices.
bloecks_feat_copy = Kopiera, klipp ut och klistra in avsnitt
bloecks_feat_order = Ordna om avsnitt via dra och släpp
bloecks_intro = Lätt verktyg för kopiera/klistra in, klipp ut och dra och släpp av avsnitt.
bloecks_enabled = Aktiverad
bloecks_disabled = Inaktiverad
bloecks_drag_move = Flytta slice
bloecks_drag_move = Flytta avsnitt
bloecks_drag_handle = Flytta

# Permissions
perm_general_bloecks[] = Full åtkomst till alla blÖcks-funktioner
perm_general_bloecks[copy] = Kopiera och klistra in avsnitt
perm_general_bloecks[order] = Ordna om avsnitt via dra och släpp

# Copy/Cut/Paste functionality
bloecks_copy_slice = Kopiera slice
bloecks_cut_slice = Klipp ut slice
Expand Down
29 changes: 21 additions & 8 deletions lib/bloecks_backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public static function init(): void
$copyPasteEnabled = (bool) $addon->getConfig('enable_copy_paste', false);
$dragDropEnabled = (bool) $addon->getConfig('enable_drag_drop', false);

// Only register extension points if features are enabled
if ($copyPasteEnabled) {
// Only register extension points if features are enabled AND user has permissions
if ($copyPasteEnabled &&
(rex::getUser()->hasPerm('bloecks[]') || rex::getUser()->hasPerm('bloecks[copy]'))) {
// Register slice menu extensions for copy/paste
rex_extension::register('STRUCTURE_CONTENT_SLICE_MENU', self::addButtons(...));

Expand All @@ -54,20 +55,32 @@ public static function init(): void
rex_extension::register('STRUCTURE_CONTENT_BEFORE_SLICES', self::process(...));
}

// Register drag & drop extension points if enabled AND user has permissions
if ($dragDropEnabled &&
(rex::getUser()->hasPerm('bloecks[]') || rex::getUser()->hasPerm('bloecks[order]'))) {
rex_extension::register('SLICE_SHOW', Wrapper::addDragDropWrapper(...), rex_extension::EARLY);
rex_extension::register('SLICE_MENU', Wrapper::addDragHandle(...));
}

// Load assets on content edit pages ONLY if features are enabled
if ('content' === rex_be_controller::getCurrentPagePart(1)) {
// Only load assets if at least one feature is enabled
if ($copyPasteEnabled || $dragDropEnabled) {
// Only load assets if at least one feature is enabled and user has permissions
$loadCopyPasteAssets = $copyPasteEnabled &&
(rex::getUser()->hasPerm('bloecks[]') || rex::getUser()->hasPerm('bloecks[copy]'));
$loadDragDropAssets = $dragDropEnabled &&
(rex::getUser()->hasPerm('bloecks[]') || rex::getUser()->hasPerm('bloecks[order]'));

if ($loadCopyPasteAssets || $loadDragDropAssets) {
// JS config for drag & drop ordering
rex_view::setJsProperty('bloecks', [
'token' => rex_csrf_token::factory('bloecks')->getValue(),
'perm_order' => rex::getUser()->hasPerm('bloecks[]') || rex::getUser()->hasPerm('bloecks[order]'),
'enable_copy_paste' => $copyPasteEnabled,
'enable_drag_drop' => $dragDropEnabled,
'enable_copy_paste' => $loadCopyPasteAssets,
'enable_drag_drop' => $loadDragDropAssets,
]);

// Load SortableJS for drag & drop only if drag & drop is enabled
if ($dragDropEnabled) {
// Load SortableJS for drag & drop only if drag & drop is enabled and user has permissions
if ($loadDragDropAssets) {
rex_view::addJsFile($addon->getAssetsUrl('js/sortable.min.js'));
}

Expand Down
2 changes: 1 addition & 1 deletion package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ supportpage: https://github.com/FriendsOfREDAXO/bloecks

page:
title: 'translate:bloecks_navigation'
perm: bloecks[]
perm: admin
pjax: false
icon: rex-icon fa-th-large
subPath: settings.php
Expand Down
2 changes: 1 addition & 1 deletion pages/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/** @var rex_addon $this */

if (!rex::getUser()->hasPerm('bloecks[settings]')) {
if (!rex::getUser()->isAdmin()) {
echo rex_view::error(rex_i18n::msg('bloecks_no_permission'));
return;
}
Expand Down