From 208cf9a32f8510296a95ff4630c8f4741d70d416 Mon Sep 17 00:00:00 2001 From: nicod_ <nicod@lerebooteux.fr> Date: Thu, 16 Jan 2025 03:32:38 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Gestion=20des=20r=C3=B4les=20dans=20un?= =?UTF-8?q?=20tableau=20de=20la=20config=20des=20types=20de=20blocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formulaires/exporter_blocktypes.php | 12 ++++++------ inc/blocks.php | 22 +++++++++------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/formulaires/exporter_blocktypes.php b/formulaires/exporter_blocktypes.php index da5284e..ae23c92 100644 --- a/formulaires/exporter_blocktypes.php +++ b/formulaires/exporter_blocktypes.php @@ -44,7 +44,7 @@ function formulaires_exporter_blocktypes_traiter() { $blocks = sql_allfetsel('*', 'spip_blocktypes'); foreach ($blocks as $block) { - $block['enfants'] = array_column(sql_allfetsel( + $block['enfant'] = array_column(sql_allfetsel( 'b.identifiant', 'spip_blocktypes_liens bl join spip_blocktypes b on(b.id_blocktype = bl.id_objet)', [ @@ -54,7 +54,7 @@ function formulaires_exporter_blocktypes_traiter() { ] ), 'identifiant'); - $block['parents'] = array_column(sql_allfetsel( + $block['parent'] = array_column(sql_allfetsel( 'b.identifiant', 'spip_blocktypes_liens bl join spip_blocktypes b on(b.id_blocktype = bl.id_objet)', [ @@ -71,11 +71,11 @@ function formulaires_exporter_blocktypes_traiter() { if ($block['objets']) { $data['objets'] = $block['objets']; } - if ($block['enfants']) { - $data['enfants'] = $block['enfants']; + if ($block['enfant']) { + $data['roles']['enfant'] = $block['enfant']; } - if ($block['parents']) { - $data['parents'] = $block['parents']; + if ($block['parent']) { + $data['roles']['parent'] = $block['parent']; } if ($saisies = blocks_deserialize($block['saisies'])) { diff --git a/inc/blocks.php b/inc/blocks.php index 081804b..05680d2 100644 --- a/inc/blocks.php +++ b/inc/blocks.php @@ -32,7 +32,6 @@ function blocks_deserialize($data): ?array { return is_array($retour) ? $retour : null; } - /** * Chercher tous les types de blocs existant * On cherche des fichiers blocks/*.yaml dans le PATH @@ -308,18 +307,15 @@ function bloctypes_trouver_parents($blocktype): array { * @return array */ function _bloctypes_trouver_role(string $blocktype, string $role): array { - // TODO : à réécrire !!! - - // include_spip('action/editer_liens'); - // if ( - // $id_blocktype - // && $role - // && ($blocktypes_parents = objet_trouver_liens(['blocktype' => $id_blocktype], ['blocktype' => '*'], ['role' => $role])) - // ) { - // return array_column($blocktypes_parents, 'id_objet'); - // } - - return []; + $blocktypes_roles = []; + if ( + $blocktype + && ($blocktypes = blocktypes_lister_types()) + ) { + $blocktypes_roles = $blocktypes[$blocktype]['roles'][$role] ?? []; + } + + return $blocktypes_roles; } /** -- GitLab